MCPcopy
hub / github.com/coredns/coredns / TestPrefetch

Function TestPrefetch

plugin/cache/prefetch_test.go:18–203  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestPrefetch(t *testing.T) {
19 tests := []struct {
20 qname string
21 ttl int
22 prefetch int
23 verifications []verification
24 }{
25 {
26 qname: "hits.reset.example.org.",
27 ttl: 80,
28 prefetch: 1,
29 verifications: []verification{
30 {
31 after: 0 * time.Second,
32 answer: "hits.reset.example.org. 80 IN A 127.0.0.1",
33 fetch: true, // Initial fetch
34 },
35 {
36 after: 73 * time.Second,
37 answer: "hits.reset.example.org. 7 IN A 127.0.0.1",
38 fetch: true, // Triggers prefetch with 7 TTL (10% of 80 = 8 TTL threshold)
39 },
40 {
41 after: 80 * time.Second,
42 answer: "hits.reset.example.org. 73 IN A 127.0.0.2",
43 },
44 },
45 },
46 {
47 qname: "short.ttl.example.org.",
48 ttl: 5,
49 prefetch: 1,
50 verifications: []verification{
51 {
52 after: 0 * time.Second,
53 answer: "short.ttl.example.org. 5 IN A 127.0.0.1",
54 fetch: true,
55 },
56 {
57 after: 1 * time.Second,
58 answer: "short.ttl.example.org. 4 IN A 127.0.0.1",
59 },
60 {
61 after: 4 * time.Second,
62 answer: "short.ttl.example.org. 1 IN A 127.0.0.1",
63 fetch: true,
64 },
65 {
66 after: 5 * time.Second,
67 answer: "short.ttl.example.org. 4 IN A 127.0.0.2",
68 },
69 },
70 },
71 {
72 qname: "no.prefetch.example.org.",
73 ttl: 30,
74 prefetch: 0,
75 verifications: []verification{

Callers

nothing calls this directly

Calls 11

NewRecorderFunction · 0.92
AFunction · 0.92
prefetchHandlerFunction · 0.85
NewFunction · 0.70
FatalMethod · 0.65
RunMethod · 0.65
ServeDNSMethod · 0.65
FatalfMethod · 0.65
ErrorfMethod · 0.65
StringMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…