Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
99dd8f99
Commit
99dd8f99
authored
Nov 15, 2017
by
Chris O'Haver
Committed by
Miek Gieben
Nov 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin/k8s: clean up and add some ipv6 tests (#1237)
* clean up and add some ipv6 tests * aaaa endpoint * gofmt
parent
c37bf56b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
138 additions
and
233 deletions
+138
-233
plugin/kubernetes/handler_test.go
plugin/kubernetes/handler_test.go
+138
-233
No files found.
plugin/kubernetes/handler_test.go
View file @
99dd8f99
...
@@ -90,12 +90,16 @@ var dnsTestCases = []test.Case{
...
@@ -90,12 +90,16 @@ var dnsTestCases = []test.Case{
Qname
:
"_http._tcp.hdls1.testns.svc.cluster.local."
,
Qtype
:
dns
.
TypeSRV
,
Qname
:
"_http._tcp.hdls1.testns.svc.cluster.local."
,
Qtype
:
dns
.
TypeSRV
,
Rcode
:
dns
.
RcodeSuccess
,
Rcode
:
dns
.
RcodeSuccess
,
Answer
:
[]
dns
.
RR
{
Answer
:
[]
dns
.
RR
{
test
.
SRV
(
"_http._tcp.hdls1.testns.svc.cluster.local. 303 IN SRV 0 50 80 172-0-0-2.hdls1.testns.svc.cluster.local."
),
test
.
SRV
(
"_http._tcp.hdls1.testns.svc.cluster.local. 303 IN SRV 0 25 80 172-0-0-2.hdls1.testns.svc.cluster.local."
),
test
.
SRV
(
"_http._tcp.hdls1.testns.svc.cluster.local. 303 IN SRV 0 50 80 172-0-0-3.hdls1.testns.svc.cluster.local."
),
test
.
SRV
(
"_http._tcp.hdls1.testns.svc.cluster.local. 303 IN SRV 0 25 80 172-0-0-3.hdls1.testns.svc.cluster.local."
),
test
.
SRV
(
"_http._tcp.hdls1.testns.svc.cluster.local. 303 IN SRV 0 25 80 5678-abcd--1.hdls1.testns.svc.cluster.local."
),
test
.
SRV
(
"_http._tcp.hdls1.testns.svc.cluster.local. 303 IN SRV 0 25 80 5678-abcd--2.hdls1.testns.svc.cluster.local."
),
},
},
Extra
:
[]
dns
.
RR
{
Extra
:
[]
dns
.
RR
{
test
.
A
(
"172-0-0-2.hdls1.testns.svc.cluster.local. 303 IN A 172.0.0.2"
),
test
.
A
(
"172-0-0-2.hdls1.testns.svc.cluster.local. 303 IN A 172.0.0.2"
),
test
.
A
(
"172-0-0-3.hdls1.testns.svc.cluster.local. 303 IN A 172.0.0.3"
),
test
.
A
(
"172-0-0-3.hdls1.testns.svc.cluster.local. 303 IN A 172.0.0.3"
),
test
.
AAAA
(
"5678-abcd--1.hdls1.testns.svc.cluster.local. 303 IN AAAA 5678:abcd::1"
),
test
.
AAAA
(
"5678-abcd--2.hdls1.testns.svc.cluster.local. 303 IN AAAA 5678:abcd::2"
),
},
},
},
},
// CNAME External
// CNAME External
...
@@ -106,7 +110,7 @@ var dnsTestCases = []test.Case{
...
@@ -106,7 +110,7 @@ var dnsTestCases = []test.Case{
test
.
CNAME
(
"external.testns.svc.cluster.local. 303 IN CNAME ext.interwebs.test."
),
test
.
CNAME
(
"external.testns.svc.cluster.local. 303 IN CNAME ext.interwebs.test."
),
},
},
},
},
// AAAA Service (
existing service
)
// AAAA Service (
with an existing A record, but no AAAA record
)
{
{
Qname
:
"svc1.testns.svc.cluster.local."
,
Qtype
:
dns
.
TypeAAAA
,
Qname
:
"svc1.testns.svc.cluster.local."
,
Qtype
:
dns
.
TypeAAAA
,
Rcode
:
dns
.
RcodeSuccess
,
Rcode
:
dns
.
RcodeSuccess
,
...
@@ -154,6 +158,31 @@ var dnsTestCases = []test.Case{
...
@@ -154,6 +158,31 @@ var dnsTestCases = []test.Case{
test
.
SOA
(
"cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"
),
test
.
SOA
(
"cluster.local. 300 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1499347823 7200 1800 86400 60"
),
},
},
},
},
// AAAA Service
{
Qname
:
"svc6.testns.svc.cluster.local."
,
Qtype
:
dns
.
TypeAAAA
,
Rcode
:
dns
.
RcodeSuccess
,
Answer
:
[]
dns
.
RR
{
test
.
AAAA
(
"svc6.testns.svc.cluster.local. 5 IN AAAA 1234:abcd::1"
),
},
},
// AAAA Service (Headless)
{
Qname
:
"hdls1.testns.svc.cluster.local."
,
Qtype
:
dns
.
TypeAAAA
,
Rcode
:
dns
.
RcodeSuccess
,
Answer
:
[]
dns
.
RR
{
test
.
AAAA
(
"hdls1.testns.svc.cluster.local. 303 IN AAAA 5678:abcd::1"
),
test
.
AAAA
(
"hdls1.testns.svc.cluster.local. 303 IN AAAA 5678:abcd::2"
),
},
},
// AAAA Endpoint
{
Qname
:
"5678-abcd--1.hdls1.testns.svc.cluster.local."
,
Qtype
:
dns
.
TypeAAAA
,
Rcode
:
dns
.
RcodeSuccess
,
Answer
:
[]
dns
.
RR
{
test
.
AAAA
(
"5678-abcd--1.hdls1.testns.svc.cluster.local. 303 IN AAAA 5678:abcd::1"
),
},
},
}
}
func
TestServeDNS
(
t
*
testing
.
T
)
{
func
TestServeDNS
(
t
*
testing
.
T
)
{
...
@@ -209,264 +238,140 @@ func (APIConnServeTest) PodIndex(string) []*api.Pod {
...
@@ -209,264 +238,140 @@ func (APIConnServeTest) PodIndex(string) []*api.Pod {
return
a
return
a
}
}
func
(
APIConnServeTest
)
SvcIndex
(
string
)
[]
*
api
.
Service
{
var
svcIndex
=
map
[
string
][]
*
api
.
Service
{
svcs
:=
[]
*
api
.
Service
{
"svc1.testns"
:
{{
{
ObjectMeta
:
meta
.
ObjectMeta
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"svc1"
,
Name
:
"svc1"
,
Namespace
:
"testns"
,
Namespace
:
"testns"
,
},
},
Spec
:
api
.
ServiceSpec
{
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
"10.0.0.1"
,
ClusterIP
:
"10.0.0.1"
,
Ports
:
[]
api
.
ServicePort
{{
Ports
:
[]
api
.
ServicePort
{{
Name
:
"http"
,
Name
:
"http"
,
Protocol
:
"tcp"
,
Protocol
:
"tcp"
,
Port
:
80
,
Port
:
80
,
}},
}},
},
},
}},
},
"svc6.testns"
:
{{
{
ObjectMeta
:
meta
.
ObjectMeta
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"svc6"
,
Name
:
"hdls1"
,
Namespace
:
"testns"
,
Namespace
:
"testns"
,
},
},
Spec
:
api
.
ServiceSpec
{
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
"1234:abcd::1"
,
ClusterIP
:
api
.
ClusterIPNone
,
Ports
:
[]
api
.
ServicePort
{{
},
Name
:
"http"
,
Protocol
:
"tcp"
,
Port
:
80
,
}},
},
}},
"hdls1.testns"
:
{{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
},
{
Spec
:
api
.
ServiceSpec
{
ObjectMeta
:
meta
.
ObjectMeta
{
ClusterIP
:
api
.
ClusterIPNone
,
Name
:
"external"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ExternalName
:
"ext.interwebs.test"
,
Ports
:
[]
api
.
ServicePort
{{
Name
:
"http"
,
Protocol
:
"tcp"
,
Port
:
80
,
}},
},
},
},
}
}},
return
svcs
"external.testns"
:
{{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"external"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ExternalName
:
"ext.interwebs.test"
,
Ports
:
[]
api
.
ServicePort
{{
Name
:
"http"
,
Protocol
:
"tcp"
,
Port
:
80
,
}},
},
}},
}
func
(
APIConnServeTest
)
SvcIndex
(
s
string
)
[]
*
api
.
Service
{
return
svcIndex
[
s
]
}
}
func
(
APIConnServeTest
)
ServiceList
()
[]
*
api
.
Service
{
func
(
APIConnServeTest
)
ServiceList
()
[]
*
api
.
Service
{
svcs
:=
[]
*
api
.
Service
{
var
svcs
[]
*
api
.
Service
{
for
_
,
svc
:=
range
svcIndex
{
ObjectMeta
:
meta
.
ObjectMeta
{
svcs
=
append
(
svcs
,
svc
...
)
Name
:
"svc1"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
"10.0.0.1"
,
Ports
:
[]
api
.
ServicePort
{{
Name
:
"http"
,
Protocol
:
"tcp"
,
Port
:
80
,
}},
},
},
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ClusterIP
:
api
.
ClusterIPNone
,
},
},
{
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"external"
,
Namespace
:
"testns"
,
},
Spec
:
api
.
ServiceSpec
{
ExternalName
:
"ext.interwebs.test"
,
Ports
:
[]
api
.
ServicePort
{{
Name
:
"http"
,
Protocol
:
"tcp"
,
Port
:
80
,
}},
},
},
}
}
return
svcs
return
svcs
}
}
func
(
APIConnServeTest
)
EpIndex
(
string
)
[]
*
api
.
Endpoints
{
var
epsIndex
=
map
[
string
][]
*
api
.
Endpoints
{
n
:=
"test.node.foo.bar"
"svc1.testns"
:
{{
Subsets
:
[]
api
.
EndpointSubset
{
eps
:=
[]
*
api
.
Endpoints
{
{
{
Addresses
:
[]
api
.
EndpointAddress
{
Subsets
:
[]
api
.
EndpointSubset
{
{
{
IP
:
"172.0.0.1"
,
Addresses
:
[]
api
.
EndpointAddress
{
Hostname
:
"ep1a"
,
{
IP
:
"172.0.0.1"
,
Hostname
:
"ep1a"
,
},
},
},
Ports
:
[]
api
.
EndpointPort
{
},
{
Ports
:
[]
api
.
EndpointPort
{
Port
:
80
,
{
Protocol
:
"tcp"
,
Port
:
80
,
Name
:
"htt
p"
,
Protocol
:
"tc
p"
,
}
,
Name
:
"http"
,
},
},
},
},
},
},
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"svc1"
,
Namespace
:
"testns"
,
},
},
},
{
ObjectMeta
:
meta
.
ObjectMeta
{
Subsets
:
[]
api
.
EndpointSubset
{
Name
:
"svc1"
,
{
Namespace
:
"testns"
,
Addresses
:
[]
api
.
EndpointAddress
{
},
{
}},
IP
:
"172.0.0.2"
,
"hdls1.testns"
:
{{
},
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"172.0.0.2"
,
},
},
Ports
:
[]
api
.
EndpointPort
{
{
{
IP
:
"172.0.0.3"
,
Port
:
80
,
Protocol
:
"tcp"
,
Name
:
"http"
,
},
},
},
},
{
},
IP
:
"5678:abcd::1"
,
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
},
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"172.0.0.3"
,
},
},
},
Ports
:
[]
api
.
EndpointPort
{
{
{
IP
:
"5678:abcd::2"
,
Port
:
80
,
Protocol
:
"tcp"
,
Name
:
"http"
,
},
},
},
},
},
},
Ports
:
[]
api
.
EndpointPort
{
ObjectMeta
:
meta
.
ObjectMeta
{
{
Name
:
"hdls1"
,
Port
:
80
,
Namespace
:
"testns"
,
Protocol
:
"tcp"
,
},
Name
:
"http"
,
},
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"10.9.8.7"
,
NodeName
:
&
n
,
},
},
},
},
},
},
},
},
},
}
ObjectMeta
:
meta
.
ObjectMeta
{
return
eps
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
}},
}
}
func
(
APIConnServeTest
)
EndpointsList
()
[]
*
api
.
Endpoints
{
func
(
APIConnServeTest
)
EpIndex
(
s
string
)
[]
*
api
.
Endpoints
{
n
:=
"test.node.foo.bar"
return
epsIndex
[
s
]
}
eps
:=
[]
*
api
.
Endpoints
{
func
(
APIConnServeTest
)
EndpointsList
()
[]
*
api
.
Endpoints
{
{
var
eps
[]
*
api
.
Endpoints
Subsets
:
[]
api
.
EndpointSubset
{
for
_
,
ep
:=
range
epsIndex
{
{
eps
=
append
(
eps
,
ep
...
)
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"172.0.0.1"
,
Hostname
:
"ep1a"
,
},
},
Ports
:
[]
api
.
EndpointPort
{
{
Port
:
80
,
Protocol
:
"tcp"
,
Name
:
"http"
,
},
},
},
},
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"svc1"
,
Namespace
:
"testns"
,
},
},
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"172.0.0.2"
,
},
},
Ports
:
[]
api
.
EndpointPort
{
{
Port
:
80
,
Protocol
:
"tcp"
,
Name
:
"http"
,
},
},
},
},
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
},
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"172.0.0.3"
,
},
},
Ports
:
[]
api
.
EndpointPort
{
{
Port
:
80
,
Protocol
:
"tcp"
,
Name
:
"http"
,
},
},
},
},
ObjectMeta
:
meta
.
ObjectMeta
{
Name
:
"hdls1"
,
Namespace
:
"testns"
,
},
},
{
Subsets
:
[]
api
.
EndpointSubset
{
{
Addresses
:
[]
api
.
EndpointAddress
{
{
IP
:
"10.9.8.7"
,
NodeName
:
&
n
,
},
},
},
},
},
}
}
return
eps
return
eps
}
}
func
(
APIConnServeTest
)
GetNodeByName
(
name
string
)
(
*
api
.
Node
,
error
)
{
func
(
APIConnServeTest
)
GetNodeByName
(
name
string
)
(
*
api
.
Node
,
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment