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
565a13e8
Commit
565a13e8
authored
Jul 09, 2015
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
E2E tests for kubectl run command
parent
de6d8705
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
kubectl.go
test/e2e/kubectl.go
+43
-0
util.go
test/e2e/util.go
+15
-0
No files found.
test/e2e/kubectl.go
View file @
565a13e8
...
...
@@ -482,6 +482,49 @@ var _ = Describe("Kubectl client", func() {
}
})
})
Describe
(
"Kubectl run"
,
func
()
{
var
nsFlag
string
var
rcName
string
BeforeEach
(
func
()
{
nsFlag
=
fmt
.
Sprintf
(
"--namespace=%v"
,
ns
)
rcName
=
"e2e-test-nginx-rc"
})
AfterEach
(
func
()
{
runKubectl
(
"stop"
,
"rc"
,
rcName
,
nsFlag
)
})
It
(
"should create an rc from an image"
,
func
()
{
image
:=
"nginx"
By
(
"running the image "
+
image
)
runKubectl
(
"run"
,
rcName
,
"--image="
+
image
,
nsFlag
)
By
(
"verifying the rc "
+
rcName
+
" was created"
)
rc
,
err
:=
c
.
ReplicationControllers
(
ns
)
.
Get
(
rcName
)
if
err
!=
nil
{
Failf
(
"Failed getting rc %s: %v"
,
rcName
,
err
)
}
containers
:=
rc
.
Spec
.
Template
.
Spec
.
Containers
if
containers
==
nil
||
len
(
containers
)
!=
1
||
containers
[
0
]
.
Image
!=
image
{
Failf
(
"Failed creating rc %s for 1 pod with expected image %s"
,
rcName
,
image
)
}
By
(
"verifying the pod controlled by rc "
+
rcName
+
" was created"
)
label
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
"run"
:
rcName
}))
podlist
,
err
:=
waitForPodsWithLabel
(
c
,
ns
,
label
)
if
err
!=
nil
{
Failf
(
"Failed getting pod controlled by rc %s: %v"
,
rcName
,
err
)
}
pods
:=
podlist
.
Items
if
pods
==
nil
||
len
(
pods
)
!=
1
||
len
(
pods
[
0
]
.
Spec
.
Containers
)
!=
1
||
pods
[
0
]
.
Spec
.
Containers
[
0
]
.
Image
!=
image
{
runKubectl
(
"get"
,
"pods"
,
"-L"
,
"run"
,
nsFlag
)
Failf
(
"Failed creating 1 pod with expected image %s. Number of pods = %v"
,
image
,
len
(
pods
))
}
})
})
})
// Checks whether the output split by line contains the required elements.
...
...
test/e2e/util.go
View file @
565a13e8
...
...
@@ -1274,6 +1274,21 @@ waitLoop:
return
nil
}
// Wait up to 10 minutes for getting pods with certain label
func
waitForPodsWithLabel
(
c
*
client
.
Client
,
ns
string
,
label
labels
.
Selector
)
(
pods
*
api
.
PodList
,
err
error
)
{
for
t
:=
time
.
Now
();
time
.
Since
(
t
)
<
podListTimeout
;
time
.
Sleep
(
poll
)
{
pods
,
err
=
c
.
Pods
(
ns
)
.
List
(
label
,
fields
.
Everything
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
if
len
(
pods
.
Items
)
>
0
{
break
}
}
if
pods
==
nil
||
len
(
pods
.
Items
)
==
0
{
err
=
fmt
.
Errorf
(
"Timeout while waiting for pods with label %v"
,
label
)
}
return
}
// Delete a Replication Controller and all pods it spawned
func
DeleteRC
(
c
*
client
.
Client
,
ns
,
name
string
)
error
{
By
(
fmt
.
Sprintf
(
"%v Deleting replication controller %s in namespace %s"
,
time
.
Now
(),
name
,
ns
))
...
...
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