| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | package kubernetes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2018-04-22 08:34:35 +01:00
										 |  |  | 	"context" | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 	"testing" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-09 21:56:09 +01:00
										 |  |  | 	"github.com/coredns/coredns/plugin/kubernetes/object" | 
					
						
							| 
									
										
										
										
											2017-09-21 15:15:47 +01:00
										 |  |  | 	"github.com/coredns/coredns/plugin/pkg/dnstest" | 
					
						
							| 
									
										
										
										
											2017-09-14 09:36:06 +01:00
										 |  |  | 	"github.com/coredns/coredns/plugin/test" | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/miekg/dns" | 
					
						
							| 
									
										
										
										
											2018-01-03 19:11:28 +08:00
										 |  |  | 	api "k8s.io/api/core/v1" | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 	meta "k8s.io/apimachinery/pkg/apis/meta/v1" | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type APIConnReverseTest struct{} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-06 13:55:15 -04:00
										 |  |  | func (APIConnReverseTest) HasSynced() bool                             { return true } | 
					
						
							|  |  |  | func (APIConnReverseTest) Run()                                        {} | 
					
						
							|  |  |  | func (APIConnReverseTest) Stop() error                                 { return nil } | 
					
						
							|  |  |  | func (APIConnReverseTest) PodIndex(string) []*object.Pod               { return nil } | 
					
						
							|  |  |  | func (APIConnReverseTest) EpIndex(string) []*object.Endpoints          { return nil } | 
					
						
							|  |  |  | func (APIConnReverseTest) EndpointsList() []*object.Endpoints          { return nil } | 
					
						
							|  |  |  | func (APIConnReverseTest) ServiceList() []*object.Service              { return nil } | 
					
						
							|  |  |  | func (APIConnReverseTest) SvcExtIndexReverse(string) []*object.Service { return nil } | 
					
						
							|  |  |  | func (APIConnReverseTest) Modified(bool) int64                         { return 0 } | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | func (APIConnReverseTest) SvcIndex(svc string) []*object.Service { | 
					
						
							|  |  |  | 	if svc != "svc1.testns" { | 
					
						
							| 
									
										
										
										
											2018-02-28 10:53:12 -05:00
										 |  |  | 		return nil | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | 	svcs := []*object.Service{ | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2020-12-21 05:30:24 -05:00
										 |  |  | 			Name:       "svc1", | 
					
						
							|  |  |  | 			Namespace:  "testns", | 
					
						
							|  |  |  | 			ClusterIPs: []string{"192.168.1.100"}, | 
					
						
							|  |  |  | 			Ports:      []api.ServicePort{{Name: "http", Protocol: "tcp", Port: 80}}, | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2018-02-28 10:53:12 -05:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | 	return svcs | 
					
						
							| 
									
										
										
										
											2018-02-28 10:53:12 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | func (APIConnReverseTest) SvcIndexReverse(ip string) []*object.Service { | 
					
						
							| 
									
										
										
										
											2017-11-10 11:59:21 -05:00
										 |  |  | 	if ip != "192.168.1.100" { | 
					
						
							|  |  |  | 		return nil | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | 	svcs := []*object.Service{ | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2020-12-21 05:30:24 -05:00
										 |  |  | 			Name:       "svc1", | 
					
						
							|  |  |  | 			Namespace:  "testns", | 
					
						
							|  |  |  | 			ClusterIPs: []string{"192.168.1.100"}, | 
					
						
							|  |  |  | 			Ports:      []api.ServicePort{{Name: "http", Protocol: "tcp", Port: 80}}, | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | 	return svcs | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-11 21:59:50 +01:00
										 |  |  | func (APIConnReverseTest) EpIndexReverse(ip string) []*object.Endpoints { | 
					
						
							| 
									
										
										
										
											2020-10-30 08:14:30 -04:00
										 |  |  | 	ep1s1 := object.Endpoints{ | 
					
						
							| 
									
										
										
										
											2020-02-21 01:24:02 -05:00
										 |  |  | 		Subsets: []object.EndpointSubset{ | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				Addresses: []object.EndpointAddress{ | 
					
						
							| 
									
										
										
										
											2025-03-18 21:42:43 +02:00
										 |  |  | 					{IP: "10.0.0.100", Hostname: "ep1a"}, | 
					
						
							|  |  |  | 					{IP: "10.0.0.99", Hostname: "double-ep"}, // this endpoint is used by two services | 
					
						
							| 
									
										
										
										
											2020-10-30 08:14:30 -04:00
										 |  |  | 				}, | 
					
						
							|  |  |  | 				Ports: []object.EndpointPort{ | 
					
						
							|  |  |  | 					{Port: 80, Protocol: "tcp", Name: "http"}, | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		Name:      "svc1-slice1", | 
					
						
							|  |  |  | 		Namespace: "testns", | 
					
						
							|  |  |  | 		Index:     object.EndpointsKey("svc1", "testns"), | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	ep1s2 := object.Endpoints{ | 
					
						
							|  |  |  | 		Subsets: []object.EndpointSubset{ | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				Addresses: []object.EndpointAddress{ | 
					
						
							| 
									
										
										
										
											2020-02-21 01:24:02 -05:00
										 |  |  | 					{IP: "1234:abcd::1", Hostname: "ep1b"}, | 
					
						
							|  |  |  | 					{IP: "fd00:77:30::a", Hostname: "ip6svc1ex"}, | 
					
						
							|  |  |  | 					{IP: "fd00:77:30::2:9ba6", Hostname: "ip6svc1in"}, | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				Ports: []object.EndpointPort{ | 
					
						
							|  |  |  | 					{Port: 80, Protocol: "tcp", Name: "http"}, | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2020-10-30 08:14:30 -04:00
										 |  |  | 		Name:      "svc1-slice2", | 
					
						
							| 
									
										
										
										
											2020-02-21 01:24:02 -05:00
										 |  |  | 		Namespace: "testns", | 
					
						
							| 
									
										
										
										
											2020-10-30 08:14:30 -04:00
										 |  |  | 		Index:     object.EndpointsKey("svc1", "testns"), | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	ep1s3 := object.Endpoints{ | 
					
						
							|  |  |  | 		Subsets: []object.EndpointSubset{ | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				Addresses: []object.EndpointAddress{ | 
					
						
							| 
									
										
										
										
											2025-03-18 21:42:43 +02:00
										 |  |  | 					{IP: "10.0.0.100", Hostname: "ep1a"}, // duplicate endpointslice address | 
					
						
							| 
									
										
										
										
											2020-10-30 08:14:30 -04:00
										 |  |  | 				}, | 
					
						
							|  |  |  | 				Ports: []object.EndpointPort{ | 
					
						
							|  |  |  | 					{Port: 80, Protocol: "tcp", Name: "http"}, | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		Name:      "svc1-ccccc", | 
					
						
							|  |  |  | 		Namespace: "testns", | 
					
						
							|  |  |  | 		Index:     object.EndpointsKey("svc1", "testns"), | 
					
						
							| 
									
										
										
										
											2020-02-21 01:24:02 -05:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	ep2 := object.Endpoints{ | 
					
						
							|  |  |  | 		Subsets: []object.EndpointSubset{ | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				Addresses: []object.EndpointAddress{ | 
					
						
							| 
									
										
										
										
											2025-03-18 21:42:43 +02:00
										 |  |  | 					{IP: "10.0.0.99", Hostname: "double-ep"}, // this endpoint is used by two services | 
					
						
							| 
									
										
										
										
											2020-02-21 01:24:02 -05:00
										 |  |  | 				}, | 
					
						
							|  |  |  | 				Ports: []object.EndpointPort{ | 
					
						
							|  |  |  | 					{Port: 80, Protocol: "tcp", Name: "http"}, | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2020-10-30 08:14:30 -04:00
										 |  |  | 		Name:      "svc2-slice1", | 
					
						
							| 
									
										
										
										
											2020-02-21 01:24:02 -05:00
										 |  |  | 		Namespace: "testns", | 
					
						
							| 
									
										
										
										
											2020-10-30 08:14:30 -04:00
										 |  |  | 		Index:     object.EndpointsKey("svc2", "testns"), | 
					
						
							| 
									
										
										
										
											2020-02-21 01:24:02 -05:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-11-16 16:24:49 -05:00
										 |  |  | 	switch ip { | 
					
						
							|  |  |  | 	case "1234:abcd::1": | 
					
						
							| 
									
										
										
										
											2020-02-21 01:24:02 -05:00
										 |  |  | 		fallthrough | 
					
						
							| 
									
										
										
										
											2018-01-23 10:58:36 -05:00
										 |  |  | 	case "fd00:77:30::a": | 
					
						
							| 
									
										
										
										
											2020-02-21 01:24:02 -05:00
										 |  |  | 		fallthrough | 
					
						
							| 
									
										
										
										
											2018-01-23 10:58:36 -05:00
										 |  |  | 	case "fd00:77:30::2:9ba6": | 
					
						
							| 
									
										
										
										
											2020-10-30 08:14:30 -04:00
										 |  |  | 		return []*object.Endpoints{&ep1s2} | 
					
						
							|  |  |  | 	case "10.0.0.100": // two EndpointSlices for a Service contain this IP (EndpointSlice skew) | 
					
						
							|  |  |  | 		return []*object.Endpoints{&ep1s1, &ep1s3} | 
					
						
							|  |  |  | 	case "10.0.0.99": // two different Services select this IP | 
					
						
							|  |  |  | 		return []*object.Endpoints{&ep1s1, &ep2} | 
					
						
							| 
									
										
										
										
											2017-11-10 11:59:21 -05:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-02-21 01:24:02 -05:00
										 |  |  | 	return nil | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-30 11:10:41 -07:00
										 |  |  | func (APIConnReverseTest) GetNodeByName(ctx context.Context, name string) (*api.Node, error) { | 
					
						
							| 
									
										
										
										
											2017-09-29 15:58:50 -04:00
										 |  |  | 	return &api.Node{ | 
					
						
							|  |  |  | 		ObjectMeta: meta.ObjectMeta{ | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 			Name: "test.node.foo.bar", | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 	}, nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-29 21:27:25 -06:00
										 |  |  | func (APIConnReverseTest) GetNamespaceByName(name string) (*object.Namespace, error) { | 
					
						
							|  |  |  | 	return &object.Namespace{ | 
					
						
							|  |  |  | 		Name: name, | 
					
						
							| 
									
										
										
										
											2017-11-13 21:51:51 +00:00
										 |  |  | 	}, nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | func TestReverse(t *testing.T) { | 
					
						
							| 
									
										
										
										
											2018-01-23 10:58:36 -05:00
										 |  |  | 	k := New([]string{"cluster.local.", "0.10.in-addr.arpa.", "168.192.in-addr.arpa.", "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa.", "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa."}) | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 	k.APIConn = &APIConnReverseTest{} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tests := []test.Case{ | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			Qname: "100.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, | 
					
						
							|  |  |  | 			Rcode: dns.RcodeSuccess, | 
					
						
							|  |  |  | 			Answer: []dns.RR{ | 
					
						
							| 
									
										
										
										
											2017-11-15 15:04:17 +00:00
										 |  |  | 				test.PTR("100.0.0.10.in-addr.arpa.      5    IN      PTR       ep1a.svc1.testns.svc.cluster.local."), | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2017-11-10 11:59:21 -05:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			Qname: "100.1.168.192.in-addr.arpa.", Qtype: dns.TypePTR, | 
					
						
							|  |  |  | 			Rcode: dns.RcodeSuccess, | 
					
						
							|  |  |  | 			Answer: []dns.RR{ | 
					
						
							| 
									
										
										
										
											2017-11-15 15:04:17 +00:00
										 |  |  | 				test.PTR("100.1.168.192.in-addr.arpa.     5     IN      PTR       svc1.testns.svc.cluster.local."), | 
					
						
							| 
									
										
										
										
											2017-11-10 11:59:21 -05:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2017-11-16 16:24:49 -05:00
										 |  |  | 		{ // A PTR record query for an existing ipv6 endpoint should return a record | 
					
						
							|  |  |  | 			Qname: "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa.", Qtype: dns.TypePTR, | 
					
						
							|  |  |  | 			Rcode: dns.RcodeSuccess, | 
					
						
							|  |  |  | 			Answer: []dns.RR{ | 
					
						
							|  |  |  | 				test.PTR("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.c.b.a.4.3.2.1.ip6.arpa. 5 IN PTR ep1b.svc1.testns.svc.cluster.local."), | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2018-01-23 10:58:36 -05:00
										 |  |  | 		{ // A PTR record query for an existing ipv6 endpoint should return a record | 
					
						
							|  |  |  | 			Qname: "a.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa.", Qtype: dns.TypePTR, | 
					
						
							|  |  |  | 			Rcode: dns.RcodeSuccess, | 
					
						
							|  |  |  | 			Answer: []dns.RR{ | 
					
						
							|  |  |  | 				test.PTR("a.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa. 5 IN PTR ip6svc1ex.svc1.testns.svc.cluster.local."), | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		{ // A PTR record query for an existing ipv6 endpoint should return a record | 
					
						
							|  |  |  | 			Qname: "6.a.b.9.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa.", Qtype: dns.TypePTR, | 
					
						
							|  |  |  | 			Rcode: dns.RcodeSuccess, | 
					
						
							|  |  |  | 			Answer: []dns.RR{ | 
					
						
							|  |  |  | 				test.PTR("6.a.b.9.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.3.0.0.7.7.0.0.0.0.d.f.ip6.arpa. 5 IN PTR ip6svc1in.svc1.testns.svc.cluster.local."), | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			Qname: "101.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, | 
					
						
							| 
									
										
										
										
											2018-02-13 10:52:56 -05:00
										 |  |  | 			Rcode: dns.RcodeNameError, | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 			Ns: []dns.RR{ | 
					
						
							| 
									
										
										
										
											2019-01-10 10:49:53 -05:00
										 |  |  | 				test.SOA("0.10.in-addr.arpa.	5	IN	SOA	ns.dns.0.10.in-addr.arpa. hostmaster.0.10.in-addr.arpa. 1502782828 7200 1800 86400 5"), | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2017-08-17 18:42:14 +01:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			Qname: "example.org.cluster.local.", Qtype: dns.TypePTR, | 
					
						
							| 
									
										
										
										
											2018-02-28 10:53:12 -05:00
										 |  |  | 			Rcode: dns.RcodeNameError, | 
					
						
							|  |  |  | 			Ns: []dns.RR{ | 
					
						
							| 
									
										
										
										
											2019-01-10 10:49:53 -05:00
										 |  |  | 				test.SOA("cluster.local.       5     IN      SOA     ns.dns.cluster.local. hostmaster.cluster.local. 1502989566 7200 1800 86400 5"), | 
					
						
							| 
									
										
										
										
											2018-02-28 10:53:12 -05:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			Qname: "svc1.testns.svc.cluster.local.", Qtype: dns.TypePTR, | 
					
						
							| 
									
										
										
										
											2017-08-17 18:42:14 +01:00
										 |  |  | 			Rcode: dns.RcodeSuccess, | 
					
						
							|  |  |  | 			Ns: []dns.RR{ | 
					
						
							| 
									
										
										
										
											2019-01-10 10:49:53 -05:00
										 |  |  | 				test.SOA("cluster.local.       5     IN      SOA     ns.dns.cluster.local. hostmaster.cluster.local. 1502989566 7200 1800 86400 5"), | 
					
						
							| 
									
										
										
										
											2017-08-17 18:42:14 +01:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2018-02-28 10:53:12 -05:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			Qname: "svc1.testns.svc.0.10.in-addr.arpa.", Qtype: dns.TypeA, | 
					
						
							|  |  |  | 			Rcode: dns.RcodeNameError, | 
					
						
							|  |  |  | 			Ns: []dns.RR{ | 
					
						
							| 
									
										
										
										
											2019-01-10 10:49:53 -05:00
										 |  |  | 				test.SOA("0.10.in-addr.arpa.       5     IN      SOA     ns.dns.0.10.in-addr.arpa. hostmaster.0.10.in-addr.arpa. 1502989566 7200 1800 86400 5"), | 
					
						
							| 
									
										
										
										
											2018-02-28 10:53:12 -05:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			Qname: "100.0.0.10.cluster.local.", Qtype: dns.TypePTR, | 
					
						
							|  |  |  | 			Rcode: dns.RcodeNameError, | 
					
						
							|  |  |  | 			Ns: []dns.RR{ | 
					
						
							| 
									
										
										
										
											2019-01-10 10:49:53 -05:00
										 |  |  | 				test.SOA("cluster.local.       5     IN      SOA     ns.dns.cluster.local. hostmaster.cluster.local. 1502989566 7200 1800 86400 5"), | 
					
						
							| 
									
										
										
										
											2018-02-28 10:53:12 -05:00
										 |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2025-03-18 21:42:43 +02:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			Qname: "99.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, | 
					
						
							|  |  |  | 			Rcode: dns.RcodeSuccess, | 
					
						
							|  |  |  | 			Answer: []dns.RR{ | 
					
						
							|  |  |  | 				test.PTR("99.0.0.10.in-addr.arpa.      5    IN      PTR       double-ep.svc1.testns.svc.cluster.local."), | 
					
						
							|  |  |  | 				test.PTR("99.0.0.10.in-addr.arpa.      5    IN      PTR       double-ep.svc2.testns.svc.cluster.local."), | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ctx := context.TODO() | 
					
						
							|  |  |  | 	for i, tc := range tests { | 
					
						
							|  |  |  | 		r := tc.Msg() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-21 15:15:47 +01:00
										 |  |  | 		w := dnstest.NewRecorder(&test.ResponseWriter{}) | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		_, err := k.ServeDNS(ctx, w, r) | 
					
						
							|  |  |  | 		if err != tc.Error { | 
					
						
							|  |  |  | 			t.Errorf("Test %d: expected no error, got %v", i, err) | 
					
						
							|  |  |  | 			return | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		resp := w.Msg | 
					
						
							|  |  |  | 		if resp == nil { | 
					
						
							|  |  |  | 			t.Fatalf("Test %d: got nil message and no error for: %s %d", i, r.Question[0].Name, r.Question[0].Qtype) | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-01-19 11:23:13 +00:00
										 |  |  | 		if err := test.SortAndCheck(resp, tc); err != nil { | 
					
						
							| 
									
										
										
										
											2025-03-18 21:42:43 +02:00
										 |  |  | 			t.Error(err) | 
					
						
							| 
									
										
										
										
											2019-01-19 11:23:13 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-08-16 07:33:35 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | } |