| 75 | } |
| 76 | |
| 77 | func TestEndpointsDisabled(t *testing.T) { |
| 78 | ctx := context.Background() |
| 79 | k := kubernetesWithFakeClient(ctx, "10.0.0.0/30", false, "headless") |
| 80 | k.opts.initEndpointsCache = false |
| 81 | |
| 82 | go k.APIConn.Run() |
| 83 | defer k.APIConn.Stop() |
| 84 | for !k.APIConn.HasSynced() { |
| 85 | time.Sleep(time.Millisecond) |
| 86 | } |
| 87 | |
| 88 | rw := &dnstest.Recorder{ResponseWriter: &test.ResponseWriter{}} |
| 89 | m := new(dns.Msg) |
| 90 | m.SetQuestion("svc2.testns.svc.cluster.local.", dns.TypeA) |
| 91 | k.ServeDNS(ctx, rw, m) |
| 92 | if rw.Msg.Rcode != dns.RcodeNameError { |
| 93 | t.Errorf("Expected NXDOMAIN, got %v", dns.RcodeToString[rw.Msg.Rcode]) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | func TestEndpointsEnabled(t *testing.T) { |
| 98 | ctx := context.Background() |