Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0768fa56
Unverified
Commit
0768fa56
authored
Oct 29, 2018
by
k8s-ci-robot
Committed by
GitHub
Oct 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #70188 from rajansandeep/ipv6tests
Extend DNS ConfigMap tests to support IPv6
parents
5cf90790
9e8bd5cc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
138 additions
and
30 deletions
+138
-30
dns_common.go
test/e2e/network/dns_common.go
+15
-5
dns_configmap.go
test/e2e/network/dns_configmap.go
+123
-25
No files found.
test/e2e/network/dns_common.go
View file @
0768fa56
...
...
@@ -112,14 +112,15 @@ func (t *dnsTestCommon) runDig(dnsName, target string) []string {
cmd
=
append
(
cmd
,
"@"
+
t
.
dnsPod
.
Status
.
PodIP
)
case
"kube-dns"
:
cmd
=
append
(
cmd
,
"@"
+
t
.
dnsPod
.
Status
.
PodIP
,
"-p"
,
"10053"
)
case
"ptr-record"
:
cmd
=
append
(
cmd
,
"-x"
)
case
"cluster-dns"
:
case
"cluster-dns-ipv6"
:
cmd
=
append
(
cmd
,
"AAAA"
)
break
default
:
panic
(
fmt
.
Errorf
(
"invalid target: "
+
target
))
}
if
strings
.
HasSuffix
(
dnsName
,
"in-addr.arpa"
)
||
strings
.
HasSuffix
(
dnsName
,
"in-addr.arpa."
)
{
cmd
=
append
(
cmd
,
[]
string
{
"-t"
,
"ptr"
}
...
)
}
cmd
=
append
(
cmd
,
dnsName
)
stdout
,
stderr
,
err
:=
t
.
f
.
ExecWithOptions
(
framework
.
ExecOptions
{
...
...
@@ -327,7 +328,7 @@ func (t *dnsTestCommon) createDNSServer(aRecords map[string]string) {
t
.
createDNSPodFromObj
(
generateDNSServerPod
(
aRecords
))
}
func
(
t
*
dnsTestCommon
)
createDNSServerWithPtrRecord
()
{
func
(
t
*
dnsTestCommon
)
createDNSServerWithPtrRecord
(
isIPv6
bool
)
{
pod
:=
&
v1
.
Pod
{
TypeMeta
:
metav1
.
TypeMeta
{
Kind
:
"Pod"
,
...
...
@@ -345,7 +346,6 @@ func (t *dnsTestCommon) createDNSServerWithPtrRecord() {
"-u"
,
"root"
,
"-k"
,
"--log-facility"
,
"-"
,
"--host-record=my.test,192.0.2.123"
,
"-q"
,
},
},
...
...
@@ -354,6 +354,16 @@ func (t *dnsTestCommon) createDNSServerWithPtrRecord() {
},
}
if
isIPv6
{
pod
.
Spec
.
Containers
[
0
]
.
Command
=
append
(
pod
.
Spec
.
Containers
[
0
]
.
Command
,
fmt
.
Sprintf
(
"--host-record=my.test,2001:db8::29"
))
}
else
{
pod
.
Spec
.
Containers
[
0
]
.
Command
=
append
(
pod
.
Spec
.
Containers
[
0
]
.
Command
,
fmt
.
Sprintf
(
"--host-record=my.test,192.0.2.123"
))
}
t
.
createDNSPodFromObj
(
pod
)
}
...
...
test/e2e/network/dns_configmap.go
View file @
0768fa56
...
...
@@ -64,15 +64,6 @@ func (t *dnsFederationsConfigMapTest) run() {
if
t
.
name
==
"coredns"
{
t
.
labels
=
[]
string
{
"abc"
,
"ghi"
}
defaultConfig
:=
map
[
string
]
string
{
"Corefile"
:
`.:53 {
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
}
}`
}
valid1
:=
map
[
string
]
string
{
"Corefile"
:
`.:53 {
kubernetes cluster.local in-addr.arpa ip6.arpa {
...
...
@@ -112,10 +103,12 @@ func (t *dnsFederationsConfigMapTest) run() {
t
.
validate
()
By
(
"valid2 -> default"
)
t
.
setConfigMap
(
&
v1
.
ConfigMap
{
Data
:
defaultConfig
},
nil
,
false
)
t
.
setConfigMap
(
&
v1
.
ConfigMap
{
Data
:
originalConfigMapData
},
nil
,
false
)
t
.
deleteCoreDNSPods
()
t
.
validate
()
t
.
restoreDNSConfigMap
(
originalConfigMapData
)
}
else
{
t
.
labels
=
[]
string
{
"abc"
,
"ghi"
}
valid1
:=
map
[
string
]
string
{
"federations"
:
t
.
labels
[
0
]
+
"=def"
}
...
...
@@ -209,7 +202,7 @@ type dnsNameserverTest struct {
dnsTestCommon
}
func
(
t
*
dnsNameserverTest
)
run
()
{
func
(
t
*
dnsNameserverTest
)
run
(
isIPv6
bool
)
{
t
.
init
()
t
.
createUtilPodLabel
(
"e2e-dns-configmap"
)
...
...
@@ -217,11 +210,19 @@ func (t *dnsNameserverTest) run() {
originalConfigMapData
:=
t
.
fetchDNSConfigMapData
()
defer
t
.
restoreDNSConfigMap
(
originalConfigMapData
)
if
isIPv6
{
t
.
createDNSServer
(
map
[
string
]
string
{
"abc.acme.local"
:
"2606:4700:4700::1111"
,
"def.acme.local"
:
"2606:4700:4700::2222"
,
"widget.local"
:
"2606:4700:4700::3333"
,
})
}
else
{
t
.
createDNSServer
(
map
[
string
]
string
{
"abc.acme.local"
:
"1.1.1.1"
,
"def.acme.local"
:
"2.2.2.2"
,
"widget.local"
:
"3.3.3.3"
,
})
}
defer
t
.
deleteDNSServerPod
()
if
t
.
name
==
"coredns"
{
...
...
@@ -247,6 +248,23 @@ func (t *dnsNameserverTest) run() {
}})
}
if
isIPv6
{
t
.
checkDNSRecordFrom
(
"abc.acme.local"
,
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
==
1
&&
actual
[
0
]
==
"2606:4700:4700::1111"
},
"cluster-dns-ipv6"
,
moreForeverTestTimeout
)
t
.
checkDNSRecordFrom
(
"def.acme.local"
,
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
==
1
&&
actual
[
0
]
==
"2606:4700:4700::2222"
},
"cluster-dns-ipv6"
,
moreForeverTestTimeout
)
t
.
checkDNSRecordFrom
(
"widget.local"
,
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
==
1
&&
actual
[
0
]
==
"2606:4700:4700::3333"
},
"cluster-dns-ipv6"
,
moreForeverTestTimeout
)
}
else
{
t
.
checkDNSRecordFrom
(
"abc.acme.local"
,
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
==
1
&&
actual
[
0
]
==
"1.1.1.1"
},
...
...
@@ -262,6 +280,7 @@ func (t *dnsNameserverTest) run() {
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
==
1
&&
actual
[
0
]
==
"3.3.3.3"
},
"cluster-dns"
,
moreForeverTestTimeout
)
}
t
.
restoreDNSConfigMap
(
originalConfigMapData
)
// Wait for the deleted ConfigMap to take effect, otherwise the
...
...
@@ -277,7 +296,7 @@ type dnsPtrFwdTest struct {
dnsTestCommon
}
func
(
t
*
dnsPtrFwdTest
)
run
()
{
func
(
t
*
dnsPtrFwdTest
)
run
(
isIPv6
bool
)
{
t
.
init
()
t
.
createUtilPodLabel
(
"e2e-dns-configmap"
)
...
...
@@ -285,15 +304,23 @@ func (t *dnsPtrFwdTest) run() {
originalConfigMapData
:=
t
.
fetchDNSConfigMapData
()
defer
t
.
restoreDNSConfigMap
(
originalConfigMapData
)
t
.
createDNSServerWithPtrRecord
()
t
.
createDNSServerWithPtrRecord
(
isIPv6
)
defer
t
.
deleteDNSServerPod
()
// Should still be able to lookup public nameserver without explicit upstream nameserver set.
if
isIPv6
{
t
.
checkDNSRecordFrom
(
"8.8.8.8.in-addr.arpa
"
,
"2001:4860:4860::8888
"
,
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
==
1
&&
actual
[
0
]
==
googleDnsHostname
+
"."
},
"cluster-dns
"
,
"ptr-record
"
,
moreForeverTestTimeout
)
}
else
{
t
.
checkDNSRecordFrom
(
"8.8.8.8"
,
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
==
1
&&
actual
[
0
]
==
googleDnsHostname
+
"."
},
"ptr-record"
,
moreForeverTestTimeout
)
}
if
t
.
name
==
"coredns"
{
t
.
setConfigMap
(
&
v1
.
ConfigMap
{
Data
:
map
[
string
]
string
{
...
...
@@ -314,25 +341,41 @@ func (t *dnsPtrFwdTest) run() {
}})
}
if
isIPv6
{
t
.
checkDNSRecordFrom
(
"123.2.0.192.in-addr.arpa
"
,
"2001:db8::29
"
,
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
==
1
&&
actual
[
0
]
==
"my.test."
},
"cluster-dns
"
,
"ptr-record
"
,
moreForeverTestTimeout
)
t
.
restoreDNSConfigMap
(
originalConfigMapData
)
t
.
checkDNSRecordFrom
(
"123.2.0.192.in-addr.arpa
"
,
"2001:db8::29
"
,
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
==
0
},
"cluster-dns"
,
"ptr-record"
,
moreForeverTestTimeout
)
}
else
{
t
.
checkDNSRecordFrom
(
"192.0.2.123"
,
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
==
1
&&
actual
[
0
]
==
"my.test."
},
"ptr-record"
,
moreForeverTestTimeout
)
t
.
restoreDNSConfigMap
(
originalConfigMapData
)
t
.
checkDNSRecordFrom
(
"192.0.2.123"
,
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
==
0
},
"ptr-record"
,
moreForeverTestTimeout
)
}
}
type
dnsExternalNameTest
struct
{
dnsTestCommon
}
func
(
t
*
dnsExternalNameTest
)
run
()
{
func
(
t
*
dnsExternalNameTest
)
run
(
isIPv6
bool
)
{
t
.
init
()
t
.
createUtilPodLabel
(
"e2e-dns-configmap"
)
...
...
@@ -341,9 +384,15 @@ func (t *dnsExternalNameTest) run() {
defer
t
.
restoreDNSConfigMap
(
originalConfigMapData
)
fooHostname
:=
"foo.example.com"
if
isIPv6
{
t
.
createDNSServer
(
map
[
string
]
string
{
fooHostname
:
"2001:db8::29"
,
})
}
else
{
t
.
createDNSServer
(
map
[
string
]
string
{
fooHostname
:
"192.0.2.123"
,
})
}
defer
t
.
deleteDNSServerPod
()
f
:=
t
.
f
...
...
@@ -364,6 +413,15 @@ func (t *dnsExternalNameTest) run() {
f
.
ClientSet
.
CoreV1
()
.
Services
(
f
.
Namespace
.
Name
)
.
Delete
(
externalNameServiceLocal
.
Name
,
nil
)
}()
if
isIPv6
{
t
.
checkDNSRecordFrom
(
fmt
.
Sprintf
(
"%s.%s.svc.cluster.local"
,
serviceName
,
f
.
Namespace
.
Name
),
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
>=
1
&&
actual
[
0
]
==
googleDnsHostname
+
"."
},
"cluster-dns-ipv6"
,
moreForeverTestTimeout
)
}
else
{
t
.
checkDNSRecordFrom
(
fmt
.
Sprintf
(
"%s.%s.svc.cluster.local"
,
serviceName
,
f
.
Namespace
.
Name
),
func
(
actual
[]
string
)
bool
{
...
...
@@ -371,6 +429,7 @@ func (t *dnsExternalNameTest) run() {
},
"cluster-dns"
,
moreForeverTestTimeout
)
}
if
t
.
name
==
"coredns"
{
t
.
setConfigMap
(
&
v1
.
ConfigMap
{
Data
:
map
[
string
]
string
{
...
...
@@ -390,7 +449,15 @@ func (t *dnsExternalNameTest) run() {
"upstreamNameservers"
:
fmt
.
Sprintf
(
`["%v"]`
,
t
.
dnsServerPod
.
Status
.
PodIP
),
}})
}
if
isIPv6
{
t
.
checkDNSRecordFrom
(
fmt
.
Sprintf
(
"%s.%s.svc.cluster.local"
,
serviceNameLocal
,
f
.
Namespace
.
Name
),
func
(
actual
[]
string
)
bool
{
return
len
(
actual
)
>=
1
&&
actual
[
0
]
==
fooHostname
+
"."
&&
actual
[
1
]
==
"2001:db8::29"
},
"cluster-dns-ipv6"
,
moreForeverTestTimeout
)
}
else
{
t
.
checkDNSRecordFrom
(
fmt
.
Sprintf
(
"%s.%s.svc.cluster.local"
,
serviceNameLocal
,
f
.
Namespace
.
Name
),
func
(
actual
[]
string
)
bool
{
...
...
@@ -398,18 +465,49 @@ func (t *dnsExternalNameTest) run() {
},
"cluster-dns"
,
moreForeverTestTimeout
)
}
t
.
restoreDNSConfigMap
(
originalConfigMapData
)
}
var
_
=
SIGDescribe
(
"DNS configMap nameserver"
,
func
()
{
var
_
=
SIGDescribe
(
"DNS configMap nameserver [IPv4]"
,
func
()
{
Context
(
"Change stubDomain"
,
func
()
{
nsTest
:=
&
dnsNameserverTest
{
dnsTestCommon
:
newDnsTestCommon
()}
It
(
"should be able to change stubDomain configuration [Slow][Serial]"
,
func
()
{
nsTest
.
c
=
nsTest
.
f
.
ClientSet
nsTest
.
run
(
false
)
})
})
Context
(
"Forward PTR lookup"
,
func
()
{
fwdTest
:=
&
dnsPtrFwdTest
{
dnsTestCommon
:
newDnsTestCommon
()}
It
(
"should forward PTR records lookup to upstream nameserver [Slow][Serial]"
,
func
()
{
fwdTest
.
c
=
fwdTest
.
f
.
ClientSet
fwdTest
.
run
(
false
)
})
})
Context
(
"Forward external name lookup"
,
func
()
{
externalNameTest
:=
&
dnsExternalNameTest
{
dnsTestCommon
:
newDnsTestCommon
()}
It
(
"should forward externalname lookup to upstream nameserver [Slow][Serial]"
,
func
()
{
externalNameTest
.
c
=
externalNameTest
.
f
.
ClientSet
externalNameTest
.
run
(
false
)
})
})
})
var
_
=
SIGDescribe
(
"DNS configMap nameserver [Feature:Networking-IPv6]"
,
func
()
{
Context
(
"Change stubDomain"
,
func
()
{
nsTest
:=
&
dnsNameserverTest
{
dnsTestCommon
:
newDnsTestCommon
()}
It
(
"should be able to change stubDomain configuration [Slow][Serial]"
,
func
()
{
nsTest
.
c
=
nsTest
.
f
.
ClientSet
nsTest
.
run
()
nsTest
.
run
(
true
)
})
})
...
...
@@ -418,7 +516,7 @@ var _ = SIGDescribe("DNS configMap nameserver", func() {
It
(
"should forward PTR records lookup to upstream nameserver [Slow][Serial]"
,
func
()
{
fwdTest
.
c
=
fwdTest
.
f
.
ClientSet
fwdTest
.
run
()
fwdTest
.
run
(
true
)
})
})
...
...
@@ -427,7 +525,7 @@ var _ = SIGDescribe("DNS configMap nameserver", func() {
It
(
"should forward externalname lookup to upstream nameserver [Slow][Serial]"
,
func
()
{
externalNameTest
.
c
=
externalNameTest
.
f
.
ClientSet
externalNameTest
.
run
()
externalNameTest
.
run
(
true
)
})
})
})
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