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
70237e9c
Commit
70237e9c
authored
Feb 05, 2015
by
Robert Rati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed to return in the success case testing testContext instead of using
an else statement. #4162
parent
d3e04cd2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
96 deletions
+96
-96
service.go
test/e2e/service.go
+96
-96
No files found.
test/e2e/service.go
View file @
70237e9c
...
@@ -38,121 +38,121 @@ var _ = Describe("Services", func() {
...
@@ -38,121 +38,121 @@ var _ = Describe("Services", func() {
It
(
"should provide DNS for the cluster"
,
func
()
{
It
(
"should provide DNS for the cluster"
,
func
()
{
if
testContext
.
provider
==
"vagrant"
{
if
testContext
.
provider
==
"vagrant"
{
By
(
"Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)"
)
By
(
"Skipping test which is broken for vagrant (See https://github.com/GoogleCloudPlatform/kubernetes/issues/3580)"
)
}
else
{
return
podClient
:=
c
.
Pods
(
api
.
NamespaceDefault
)
}
//TODO: Wait for skyDNS
podClient
:=
c
.
Pods
(
api
.
NamespaceDefault
)
// All the names we need to be able to resolve.
//TODO: Wait for skyDNS
namesToResolve
:=
[]
string
{
"kubernetes-ro"
,
"kubernetes-ro.default"
,
"kubernetes-ro.default.kubernetes.local"
,
"google.com"
,
}
probeCmd
:=
"for i in `seq 1 600`; do "
// All the names we need to be able to resolve.
for
_
,
name
:=
range
namesToResolve
{
namesToResolve
:=
[]
string
{
probeCmd
+=
fmt
.
Sprintf
(
"wget -O /dev/null %s && echo OK > /results/%s;"
,
name
,
name
)
"kubernetes-ro"
,
}
"kubernetes-ro.default"
,
probeCmd
+=
"sleep 1; done"
"kubernetes-ro.default.kubernetes.local"
,
"google.com"
,
// Run a pod which probes DNS and exposes the results by HTTP.
}
By
(
"creating a pod to probe DNS"
)
pod
:=
&
api
.
Pod
{
probeCmd
:=
"for i in `seq 1 600`; do "
TypeMeta
:
api
.
TypeMeta
{
for
_
,
name
:=
range
namesToResolve
{
Kind
:
"Pod"
,
probeCmd
+=
fmt
.
Sprintf
(
"wget -O /dev/null %s && echo OK > /results/%s;"
,
name
,
name
)
APIVersion
:
"v1beta1"
,
}
},
probeCmd
+=
"sleep 1; done"
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"dns-test-"
+
string
(
util
.
NewUUID
()),
// Run a pod which probes DNS and exposes the results by HTTP.
},
By
(
"creating a pod to probe DNS"
)
Spec
:
api
.
PodSpec
{
pod
:=
&
api
.
Pod
{
Volumes
:
[]
api
.
Volume
{
TypeMeta
:
api
.
TypeMeta
{
{
Kind
:
"Pod"
,
Name
:
"results"
,
APIVersion
:
"v1beta1"
,
Source
:
api
.
VolumeSource
{
},
EmptyDir
:
&
api
.
EmptyDir
{},
ObjectMeta
:
api
.
ObjectMeta
{
},
Name
:
"dns-test-"
+
string
(
util
.
NewUUID
()),
},
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{
{
Name
:
"results"
,
Source
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDir
{},
},
},
},
},
Containers
:
[]
api
.
Container
{
},
{
Containers
:
[]
api
.
Container
{
Name
:
"webserver"
,
{
Image
:
"kubernetes/test-
webserver"
,
Name
:
"
webserver"
,
VolumeMounts
:
[]
api
.
VolumeMount
{
Image
:
"kubernetes/test-webserver"
,
{
VolumeMounts
:
[]
api
.
VolumeMount
{
Name
:
"results"
,
{
MountPath
:
"/
results"
,
Name
:
"
results"
,
}
,
MountPath
:
"/results"
,
},
},
},
},
{
},
Name
:
"pinger"
,
{
Image
:
"busybox
"
,
Name
:
"pinger
"
,
Command
:
[]
string
{
"sh"
,
"-c"
,
probeCmd
}
,
Image
:
"busybox"
,
VolumeMounts
:
[]
api
.
VolumeMount
{
Command
:
[]
string
{
"sh"
,
"-c"
,
probeCmd
},
{
VolumeMounts
:
[]
api
.
VolumeMount
{
Name
:
"results"
,
{
MountPath
:
"/
results"
,
Name
:
"
results"
,
}
,
MountPath
:
"/results"
,
},
},
},
},
},
},
},
},
}
},
}
By
(
"submitting the pod to kuberenetes"
)
_
,
err
:=
podClient
.
Create
(
pod
)
if
err
!=
nil
{
Fail
(
fmt
.
Sprintf
(
"Failed to create %s pod: %v"
,
pod
.
Name
,
err
))
}
defer
func
()
{
By
(
"deleting the pod"
)
defer
GinkgoRecover
()
podClient
.
Delete
(
pod
.
Name
)
}()
By
(
"submitting the pod to kuberenetes"
)
_
,
err
:=
podClient
.
Create
(
pod
)
if
err
!=
nil
{
Fail
(
fmt
.
Sprintf
(
"Failed to create %s pod: %v"
,
pod
.
Name
,
err
))
}
defer
func
()
{
By
(
"deleting the pod"
)
defer
GinkgoRecover
()
podClient
.
Delete
(
pod
.
Name
)
}()
By
(
"waiting for the pod to start running"
)
By
(
"waiting for the pod to start running"
)
waitForPodRunning
(
c
,
pod
.
Name
)
waitForPodRunning
(
c
,
pod
.
Name
)
By
(
"retrieving the pod"
)
By
(
"retrieving the pod"
)
pod
,
err
=
podClient
.
Get
(
pod
.
Name
)
pod
,
err
=
podClient
.
Get
(
pod
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
Fail
(
fmt
.
Sprintf
(
"Failed to get pod %s: %v"
,
pod
.
Name
,
err
))
Fail
(
fmt
.
Sprintf
(
"Failed to get pod %s: %v"
,
pod
.
Name
,
err
))
}
}
// Try to find results for each expected name.
// Try to find results for each expected name.
By
(
"looking for the results for each expected name"
)
By
(
"looking for the results for each expected name"
)
var
failed
[]
string
var
failed
[]
string
for
try
:=
1
;
try
<
100
;
try
++
{
for
try
:=
1
;
try
<
100
;
try
++
{
failed
=
[]
string
{}
failed
=
[]
string
{}
for
_
,
name
:=
range
namesToResolve
{
for
_
,
name
:=
range
namesToResolve
{
_
,
err
:=
c
.
Get
()
.
_
,
err
:=
c
.
Get
()
.
Prefix
(
"proxy"
)
.
Prefix
(
"proxy"
)
.
Resource
(
"pods"
)
.
Resource
(
"pods"
)
.
Namespace
(
"default"
)
.
Namespace
(
"default"
)
.
Name
(
pod
.
Name
)
.
Name
(
pod
.
Name
)
.
Suffix
(
"results"
,
name
)
.
Suffix
(
"results"
,
name
)
.
Do
()
.
Raw
()
Do
()
.
Raw
()
if
err
!=
nil
{
if
err
!=
nil
{
failed
=
append
(
failed
,
name
)
failed
=
append
(
failed
,
name
)
fmt
.
Printf
(
"Lookup using %s for %s failed: %v
\n
"
,
pod
.
Name
,
name
,
err
)
fmt
.
Printf
(
"Lookup using %s for %s failed: %v
\n
"
,
pod
.
Name
,
name
,
err
)
}
}
if
len
(
failed
)
==
0
{
break
}
}
fmt
.
Printf
(
"lookups using %s failed for: %v
\n
"
,
pod
.
Name
,
failed
)
time
.
Sleep
(
10
*
time
.
Second
)
}
}
Expect
(
len
(
failed
))
.
To
(
Equal
(
0
))
if
len
(
failed
)
==
0
{
break
}
fmt
.
Printf
(
"lookups using %s failed for: %v
\n
"
,
pod
.
Name
,
failed
)
time
.
Sleep
(
10
*
time
.
Second
)
}
Expect
(
len
(
failed
))
.
To
(
Equal
(
0
))
// TODO: probe from the host, too.
// TODO: probe from the host, too.
fmt
.
Printf
(
"DNS probes using %s succeeded
\n
"
,
pod
.
Name
)
fmt
.
Printf
(
"DNS probes using %s succeeded
\n
"
,
pod
.
Name
)
}
})
})
It
(
"should provide RW and RO services"
,
func
()
{
It
(
"should provide RW and RO services"
,
func
()
{
...
...
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