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
88dbcffd
Commit
88dbcffd
authored
Feb 03, 2016
by
Tim Hockin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix wrong timeout param to wget
parent
83ac9cd1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
service.go
test/e2e/service.go
+25
-14
No files found.
test/e2e/service.go
View file @
88dbcffd
...
@@ -239,8 +239,10 @@ var _ = Describe("Services", func() {
...
@@ -239,8 +239,10 @@ var _ = Describe("Services", func() {
ns
:=
f
.
Namespace
.
Name
ns
:=
f
.
Namespace
.
Name
numPods
,
servicePort
:=
3
,
80
numPods
,
servicePort
:=
3
,
80
By
(
"creating service1 in namespace "
+
ns
)
podNames1
,
svc1IP
,
err
:=
startServeHostnameService
(
c
,
ns
,
"service1"
,
servicePort
,
numPods
)
podNames1
,
svc1IP
,
err
:=
startServeHostnameService
(
c
,
ns
,
"service1"
,
servicePort
,
numPods
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
By
(
"creating service2 in namespace "
+
ns
)
podNames2
,
svc2IP
,
err
:=
startServeHostnameService
(
c
,
ns
,
"service2"
,
servicePort
,
numPods
)
podNames2
,
svc2IP
,
err
:=
startServeHostnameService
(
c
,
ns
,
"service2"
,
servicePort
,
numPods
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
...
@@ -251,28 +253,35 @@ var _ = Describe("Services", func() {
...
@@ -251,28 +253,35 @@ var _ = Describe("Services", func() {
}
}
host
:=
hosts
[
0
]
host
:=
hosts
[
0
]
By
(
"verifying service1 is up"
)
expectNoError
(
verifyServeHostnameServiceUp
(
c
,
ns
,
host
,
podNames1
,
svc1IP
,
servicePort
))
expectNoError
(
verifyServeHostnameServiceUp
(
c
,
ns
,
host
,
podNames1
,
svc1IP
,
servicePort
))
By
(
"verifying service2 is up"
)
expectNoError
(
verifyServeHostnameServiceUp
(
c
,
ns
,
host
,
podNames2
,
svc2IP
,
servicePort
))
expectNoError
(
verifyServeHostnameServiceUp
(
c
,
ns
,
host
,
podNames2
,
svc2IP
,
servicePort
))
// Stop service 1 and make sure it is gone.
// Stop service 1 and make sure it is gone.
By
(
"stopping service1"
)
expectNoError
(
stopServeHostnameService
(
c
,
ns
,
"service1"
))
expectNoError
(
stopServeHostnameService
(
c
,
ns
,
"service1"
))
By
(
"verifying service1 is not up"
)
expectNoError
(
verifyServeHostnameServiceDown
(
c
,
host
,
svc1IP
,
servicePort
))
expectNoError
(
verifyServeHostnameServiceDown
(
c
,
host
,
svc1IP
,
servicePort
))
By
(
"verifying service2 is still up"
)
expectNoError
(
verifyServeHostnameServiceUp
(
c
,
ns
,
host
,
podNames2
,
svc2IP
,
servicePort
))
expectNoError
(
verifyServeHostnameServiceUp
(
c
,
ns
,
host
,
podNames2
,
svc2IP
,
servicePort
))
// Start another service and verify both are up.
// Start another service and verify both are up.
By
(
"creating service3 in namespace "
+
ns
)
podNames3
,
svc3IP
,
err
:=
startServeHostnameService
(
c
,
ns
,
"service3"
,
servicePort
,
numPods
)
podNames3
,
svc3IP
,
err
:=
startServeHostnameService
(
c
,
ns
,
"service3"
,
servicePort
,
numPods
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
if
svc2IP
==
svc3IP
{
if
svc2IP
==
svc3IP
{
Failf
(
"
V
IPs conflict: %v"
,
svc2IP
)
Failf
(
"
service
IPs conflict: %v"
,
svc2IP
)
}
}
By
(
"verifying service2 is still up"
)
expectNoError
(
verifyServeHostnameServiceUp
(
c
,
ns
,
host
,
podNames2
,
svc2IP
,
servicePort
))
expectNoError
(
verifyServeHostnameServiceUp
(
c
,
ns
,
host
,
podNames2
,
svc2IP
,
servicePort
))
expectNoError
(
verifyServeHostnameServiceUp
(
c
,
ns
,
host
,
podNames3
,
svc3IP
,
servicePort
))
expectNoError
(
stopServeHostnameService
(
c
,
ns
,
"service2"
)
)
By
(
"verifying service3 is up"
)
expectNoError
(
stopServeHostnameService
(
c
,
ns
,
"service3"
))
expectNoError
(
verifyServeHostnameServiceUp
(
c
,
ns
,
host
,
podNames3
,
svc3IP
,
servicePort
))
})
})
It
(
"should work after restarting kube-proxy [Disruptive]"
,
func
()
{
It
(
"should work after restarting kube-proxy [Disruptive]"
,
func
()
{
...
@@ -1290,17 +1299,18 @@ func verifyServeHostnameServiceUp(c *client.Client, ns, host string, expectedPod
...
@@ -1290,17 +1299,18 @@ func verifyServeHostnameServiceUp(c *client.Client, ns, host string, expectedPod
defer
func
()
{
defer
func
()
{
deletePodOrFail
(
c
,
ns
,
execPodName
)
deletePodOrFail
(
c
,
ns
,
execPodName
)
}()
}()
// Loop a bunch of times - the proxy is randomized, so we want a good
// Loop a bunch of times - the proxy is randomized, so we want a good
// chance of hitting each backend at least once.
// chance of hitting each backend at least once.
command
:=
fmt
.
Sprintf
(
buildCommand
:=
func
(
wget
string
)
string
{
"for i in $(seq 1 %d); do wget -q -T 1 -O -
http://%s:%d 2>&1 || true; echo; done"
,
return
fmt
.
Sprintf
(
"for i in $(seq 1 %d); do %s
http://%s:%d 2>&1 || true; echo; done"
,
50
*
len
(
expectedPods
)
,
serviceIP
,
servicePort
)
50
*
len
(
expectedPods
),
wget
,
serviceIP
,
servicePort
)
}
commands
:=
[]
func
()
string
{
commands
:=
[]
func
()
string
{
// verify service from node
// verify service from node
func
()
string
{
func
()
string
{
cmd
:=
fmt
.
Sprintf
(
`set -e; %s`
,
command
)
cmd
:=
"set -e; "
+
buildCommand
(
"wget -q --timeout=0.2 --tries=1 -O -"
)
Logf
(
"Executing cmd %
v
on host %v"
,
cmd
,
host
)
Logf
(
"Executing cmd %
q
on host %v"
,
cmd
,
host
)
result
,
err
:=
SSH
(
cmd
,
host
,
testContext
.
Provider
)
result
,
err
:=
SSH
(
cmd
,
host
,
testContext
.
Provider
)
if
err
!=
nil
||
result
.
Code
!=
0
{
if
err
!=
nil
||
result
.
Code
!=
0
{
LogSSHResult
(
result
)
LogSSHResult
(
result
)
...
@@ -1310,11 +1320,12 @@ func verifyServeHostnameServiceUp(c *client.Client, ns, host string, expectedPod
...
@@ -1310,11 +1320,12 @@ func verifyServeHostnameServiceUp(c *client.Client, ns, host string, expectedPod
},
},
// verify service from pod
// verify service from pod
func
()
string
{
func
()
string
{
Logf
(
"Executing cmd %v in pod %v/%v"
,
command
,
ns
,
execPodName
)
cmd
:=
buildCommand
(
"wget -q -T 1 -O -"
)
Logf
(
"Executing cmd %q in pod %v/%v"
,
cmd
,
ns
,
execPodName
)
// TODO: Use exec-over-http via the netexec pod instead of kubectl exec.
// TODO: Use exec-over-http via the netexec pod instead of kubectl exec.
output
,
err
:=
RunHostCmd
(
ns
,
execPodName
,
c
omman
d
)
output
,
err
:=
RunHostCmd
(
ns
,
execPodName
,
c
m
d
)
if
err
!=
nil
{
if
err
!=
nil
{
Logf
(
"error while kubectl execing %
v in pod %v/%v: %v
\n
Output: %v"
,
comman
d
,
ns
,
execPodName
,
err
,
output
)
Logf
(
"error while kubectl execing %
q in pod %v/%v: %v
\n
Output: %v"
,
cm
d
,
ns
,
execPodName
,
err
,
output
)
}
}
return
output
return
output
},
},
...
@@ -1329,7 +1340,7 @@ func verifyServeHostnameServiceUp(c *client.Client, ns, host string, expectedPod
...
@@ -1329,7 +1340,7 @@ func verifyServeHostnameServiceUp(c *client.Client, ns, host string, expectedPod
pods
:=
strings
.
Split
(
strings
.
TrimSpace
(
cmdFunc
()),
"
\n
"
)
pods
:=
strings
.
Split
(
strings
.
TrimSpace
(
cmdFunc
()),
"
\n
"
)
// Uniq pods before the sort because inserting them into a set
// Uniq pods before the sort because inserting them into a set
// (which is implemented using dicts) can re-order them.
// (which is implemented using dicts) can re-order them.
gotPods
:
=
sets
.
NewString
(
pods
...
)
.
List
()
gotPods
=
sets
.
NewString
(
pods
...
)
.
List
()
if
api
.
Semantic
.
DeepEqual
(
gotPods
,
expectedPods
)
{
if
api
.
Semantic
.
DeepEqual
(
gotPods
,
expectedPods
)
{
passed
=
true
passed
=
true
break
break
...
...
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