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
04cf8c9e
Commit
04cf8c9e
authored
Feb 03, 2015
by
Zach Loafman
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4066 from jlowdermilk/e2e-kubectl
Replace kubecfg with kubectl in e2e tests
parents
a31cc679
890615d9
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
60 deletions
+39
-60
guestbook.sh
hack/e2e-suite/guestbook.sh
+10
-12
liveness.sh
hack/e2e-suite/liveness.sh
+9
-9
monitoring.sh
hack/e2e-suite/monitoring.sh
+3
-8
pd.sh
hack/e2e-suite/pd.sh
+10
-10
services.sh
hack/e2e-suite/services.sh
+6
-7
update.sh
hack/e2e-suite/update.sh
+1
-1
e2e.go
hack/e2e.go
+0
-13
No files found.
hack/e2e-suite/guestbook.sh
View file @
04cf8c9e
...
...
@@ -29,23 +29,21 @@ source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
GUESTBOOK
=
"
${
KUBE_ROOT
}
/examples/guestbook"
# Launch the guestbook example
$KUBECFG
-c
"
${
GUESTBOOK
}
/redis-master.json"
create /pods
$KUBECFG
-c
"
${
GUESTBOOK
}
/redis-master-service.json"
create /services
$KUBECFG
-c
"
${
GUESTBOOK
}
/redis-slave-controller.json"
create /replicationControllers
${
KUBECTL
}
create
-f
"
${
GUESTBOOK
}
"
sleep
5
sleep
1
5
POD_LIST_1
=
$(
$
KUBECFG
'-template={{range.items}}{{.id}} {{end}}'
list pods
)
POD_LIST_1
=
$($
{
KUBECTL
}
get pods
-o
template
'--template={{range.items}}{{.id}} {{end}}'
)
echo
"Pods running:
${
POD_LIST_1
}
"
$KUBECFG
stop redis-slave-controller
# Needed until issue #103 gets fixed
sleep
25
$KUBECFG
rm
redis-slave-controller
$KUBECFG
delete services/redis-master
$KUBECFG
delete pods/redis-master
# TODO make this an actual test. Open up a firewall and use curl to post and
# read a message via the frontend
POD_LIST_2
=
$(
$KUBECFG
'-template={{range.items}}{{.id}} {{end}}'
list pods
)
${
KUBECTL
}
stop rc redis-slave-controller
${
KUBECTL
}
delete services redis-master
${
KUBECTL
}
delete pods redis-master
POD_LIST_2
=
$(${
KUBECTL
}
get pods
-o
template
'--template={{range.items}}{{.id}} {{end}}'
)
echo
"Pods running after shutdown:
${
POD_LIST_2
}
"
exit
0
hack/e2e-suite/liveness.sh
View file @
04cf8c9e
...
...
@@ -37,12 +37,12 @@ fi
function
teardown
()
{
echo
"Cleaning up test artifacts"
for
test
in
${
liveness_tests
}
;
do
${
KUBEC
FG
}
delete pods/
liveness-
${
test
}
${
KUBEC
TL
}
delete pods
liveness-
${
test
}
done
}
function
waitForNotPending
()
{
pod_id_list
=
$(
$
KUBECFG
'-template={{range.items}}{{.id}} {{end}}'
-l
test
=
liveness list pod
s
)
pod_id_list
=
$($
{
KUBECTL
}
get pods
-o
template
'--template={{range.items}}{{.id}} {{end}}'
-l
test
=
livenes
s
)
# Pod turn up on a clean cluster can take a while for the docker image pull.
all_running
=
0
for
i
in
$(
seq
1 24
)
;
do
...
...
@@ -50,7 +50,7 @@ function waitForNotPending() {
sleep
5
all_running
=
1
for
id
in
$pod_id_list
;
do
current_status
=
$(
$
KUBECFG
-template
'{{.currentState.status}}'
get pods/
$id
)
||
true
current_status
=
$($
{
KUBECTL
}
get pods
$id
-o
template
'--template={{.currentState.status}}'
)
||
true
if
[[
"
$current_status
"
==
"Pending"
]]
;
then
all_running
=
0
break
...
...
@@ -70,18 +70,18 @@ trap "teardown" EXIT
for
test
in
${
liveness_tests
}
;
do
echo
"Liveness test:
${
test
}
"
${
KUBEC
FG
}
-c
${
KUBE_ROOT
}
/examples/liveness/
${
test
}
-liveness
.yaml create pods
${
KUBEC
TL
}
create
-f
${
KUBE_ROOT
}
/examples/liveness/
${
test
}
-liveness
.yaml
waitForNotPending
before
=
$(${
KUBEC
FG
}
'-template={{.currentState.info.liveness.restartCount}}'
get pods/liveness-
${
test
}
)
before
=
$(${
KUBEC
TL
}
get pods
"liveness-
${
test
}
"
-o
template
'--template={{.currentState.info.liveness.restartCount}}'
)
while
[[
"
${
before
}
"
==
"<no value>"
]]
;
do
before
=
$(${
KUBEC
FG
}
'-template={{.currentState.info.liveness.restartCount}}'
get pods/liveness-
${
test
}
)
before
=
$(${
KUBEC
TL
}
get pods
"liveness-
${
test
}
"
-o
template
'--template={{.currentState.info.liveness.restartCount}}'
)
done
echo
"Waiting for restarts."
for
i
in
$(
seq
1 24
)
;
do
sleep
10
after
=
$(${
KUBEC
FG
}
'-template={{.currentState.info.liveness.restartCount}}'
get pods/liveness-
${
test
}
)
sleep
10
after
=
$(${
KUBEC
TL
}
get pods
"liveness-
${
test
}
"
-o
template
'--template={{.currentState.info.liveness.restartCount}}'
)
echo
"Restarts:
${
after
}
>
${
before
}
"
if
[[
"
${
after
}
"
==
"<no value>"
]]
;
then
continue
...
...
hack/e2e-suite/monitoring.sh
View file @
04cf8c9e
...
...
@@ -28,7 +28,6 @@ source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
MONITORING
=
"
${
KUBE_ROOT
}
/cluster/addons/cluster-monitoring"
KUBECTL
=
"
${
KUBE_ROOT
}
/cluster/kubectl.sh"
KUBECFG
=
"
${
KUBE_ROOT
}
/cluster/kubecfg.sh"
BIGRAND
=
$(
printf
"%x
\n
"
$((
$RANDOM
<<
16
|
$RANDOM
))) # random 2^32 in hex
MONITORING_FIREWALL_RULE="monitoring-test-
${
BIGRAND
}
"
...
...
@@ -49,13 +48,9 @@ function setup {
}
function cleanup {
"
${
KUBECFG
}
" resize monitoring-influx-grafana-controller 0 &> /dev/null || true
"
${
KUBECFG
}
" resize monitoring-heapster-controller 0 &> /dev/null || true
while "
${
KUBECTL
}
" get pods -l "name=influxGrafana" -o template -t {{range.items}}{{.id}}:{{end}} | grep -c . &> /dev/null \
|| "
${
KUBECTL
}
" get pods -l "name=heapster" -o template -t {{range.items}}{{.id}}:{{end}} | grep -c . &> /dev/null; do
sleep 2
done
"
${
KUBECTL
}
" delete -f "
${
MONITORING
}
/" &> /dev/null || true
"
${
KUBECTL
}
" stop rc monitoring-influx-grafana-controller &> /dev/null || true
"
${
KUBECTL
}
" stop rc monitoring-heapster-controller &> /dev/null || true
r "
${
KUBECTL
}
" delete -f "
${
MONITORING
}
/" &> /dev/null || true
# This only has work to do on gce and gke
if [[ "
${
KUBERNETES_PROVIDER
}
" == "gce" ]] || [[ "
${
KUBERNETES_PROVIDER
}
" == "gke" ]]; then
...
...
hack/e2e-suite/pd.sh
View file @
04cf8c9e
...
...
@@ -35,13 +35,13 @@ config="/tmp/${disk_name}.yaml"
function
delete_pd_pod
()
{
# Delete the pod this should unmount the PD
${
KUBEC
FG
}
delete pods/
testpd
${
KUBEC
TL
}
delete pods
testpd
for
i
in
$(
seq
1 30
)
;
do
echo
"Waiting for pod to be deleted."
sleep
5
all_running
=
0
for
id
in
$pod_id_list
;
do
current_status
=
$(
$
KUBECFG
-template
'{{.currentState.status}}'
get pods/
$id
)
||
true
current_status
=
$($
{
KUBECTL
}
get pods
$id
-o
template
'--template={{.currentState.status}}'
)
||
true
if
[[
"
$current_status
"
==
"Running"
]]
;
then
all_running
=
1
break
...
...
@@ -99,17 +99,17 @@ perl -p -e "s/%.*%/${disk_name}/g" ${KUBE_ROOT}/examples/gce-pd/testpd.yaml > ${
# Create and format the disk.
"
${
GCLOUD
}
"
compute disks create
--zone
=
"
${
ZONE
}
"
--size
=
10GB
"
${
disk_name
}
"
"
${
GCLOUD
}
"
compute instances attach-disk
--zone
=
"
${
ZONE
}
"
--disk
=
"
${
disk_name
}
"
\
--device-name
temp
-
data
"
${
MASTER_NAME
}
"
--device-name
tempdata
"
${
MASTER_NAME
}
"
"
${
GCLOUD
}
"
compute ssh
--zone
=
"
${
ZONE
}
"
"
${
MASTER_NAME
}
"
--command
"sudo rm -rf /mnt/tmp"
"
${
GCLOUD
}
"
compute ssh
--zone
=
"
${
ZONE
}
"
"
${
MASTER_NAME
}
"
--command
"sudo mkdir -p /mnt/tmp"
"
${
GCLOUD
}
"
compute ssh
--zone
=
"
${
ZONE
}
"
"
${
MASTER_NAME
}
"
--command
"sudo /usr/share/google/safe_format_and_mount /dev/disk/by-id/google-temp
-
data /mnt/tmp"
"
${
GCLOUD
}
"
compute ssh
--zone
=
"
${
ZONE
}
"
"
${
MASTER_NAME
}
"
--command
"sudo /usr/share/google/safe_format_and_mount /dev/disk/by-id/google-tempdata /mnt/tmp"
"
${
GCLOUD
}
"
compute ssh
--zone
=
"
${
ZONE
}
"
"
${
MASTER_NAME
}
"
--command
"sudo umount /mnt/tmp"
"
${
GCLOUD
}
"
compute instances detach-disk
--zone
=
"
${
ZONE
}
"
--disk
"
${
disk_name
}
"
"
${
MASTER_NAME
}
"
# Create a pod that uses the PD
${
KUBEC
FG
}
-c
${
config
}
create pods
${
KUBEC
TL
}
create
-f
${
config
}
pod_id_list
=
$(
$
KUBECFG
'-template={{range.items}}{{.id}} {{end}}'
-l
test
=
testpd list pods
)
pod_id_list
=
$($
{
KUBECTL
}
get pods
-o
template
'--template={{range.items}}{{.id}} {{end}}'
-l
test
=
testpd
)
# Pod turn up on a clean cluster can take a while for the docker image
# pull, and even longer if the PD mount takes a bit.
all_running
=
0
...
...
@@ -118,7 +118,7 @@ for i in $(seq 1 30); do
sleep
5
all_running
=
1
for
id
in
$pod_id_list
;
do
current_status
=
$(
$
KUBECFG
-template
'{{.currentState.status}}'
get pods/
$id
)
||
true
current_status
=
$($
{
KUBECTL
}
get pods
$id
-o
template
'--template={{.currentState.status}}'
)
||
true
if
[[
"
$current_status
"
!=
"Running"
]]
;
then
all_running
=
0
break
...
...
@@ -141,9 +141,9 @@ sleep 20
# Recreate the pod, this should re-mount the PD
${
KUBEC
FG
}
-c
${
config
}
create pods
${
KUBEC
TL
}
create
-f
${
config
}
pod_id_list
=
$(
$
KUBECFG
'-template={{range.items}}{{.id}} {{end}}'
-l
test
=
testpd list pods
)
pod_id_list
=
$($
{
KUBECTL
}
get pods
-o
template
'--template={{range.items}}{{.id}} {{end}}'
-l
test
=
testpd
)
# Pod turn up on a clean cluster can take a while for the docker image pull.
all_running
=
0
for
i
in
$(
seq
1 30
)
;
do
...
...
@@ -151,7 +151,7 @@ for i in $(seq 1 30); do
sleep
5
all_running
=
1
for
id
in
$pod_id_list
;
do
current_status
=
$(
$
KUBECFG
-template
'{{.currentState.status}}'
get pods/
$id
)
||
true
current_status
=
$($
{
KUBECTL
}
get pods
$id
-o
template
'--template={{.currentState.status}}'
)
||
true
if
[[
"
$current_status
"
!=
"Running"
]]
;
then
all_running
=
0
break
...
...
hack/e2e-suite/services.sh
View file @
04cf8c9e
...
...
@@ -135,9 +135,8 @@ __EOF__
# $1: service name
function
stop_service
()
{
echo
"Stopping service '
$1
'"
${
KUBECFG
}
stop
"
$1
"
||
true
${
KUBECFG
}
delete
"/replicationControllers/
$1
"
||
true
${
KUBECFG
}
delete
"/services/
$1
"
||
true
${
KUBECTL
}
stop rc
"
$1
"
||
true
${
KUBECTL
}
delete services
"
$1
"
||
true
}
# Args:
...
...
@@ -309,9 +308,9 @@ svc1_pods=$(query_pods "${svc1_name}" "${svc1_count}")
svc2_pods
=
$(
query_pods
"
${
svc2_name
}
"
"
${
svc2_count
}
"
)
# Get the portal IPs.
svc1_ip
=
$(${
KUBEC
FG
}
-template
'{{.portalIP}}'
get
"services/
${
svc1_name
}
"
)
svc1_ip
=
$(${
KUBEC
TL
}
get services
-o
template
'--template={{.portalIP}}'
"
${
svc1_name
}
"
)
test
-n
"
${
svc1_ip
}
"
||
error
"Service1 IP is blank"
svc2_ip
=
$(${
KUBEC
FG
}
-template
'{{.portalIP}}'
get
"services/
${
svc2_name
}
"
)
svc2_ip
=
$(${
KUBEC
TL
}
get services
-o
template
'--template={{.portalIP}}'
"
${
svc2_name
}
"
)
test
-n
"
${
svc2_ip
}
"
||
error
"Service2 IP is blank"
if
[[
"
${
svc1_ip
}
"
==
"
${
svc2_ip
}
"
]]
;
then
error
"Portal IPs conflict:
${
svc1_ip
}
"
...
...
@@ -381,7 +380,7 @@ wait_for_pods "${svc3_name}" "${svc3_count}"
svc3_pods
=
$(
query_pods
"
${
svc3_name
}
"
"
${
svc3_count
}
"
)
# Get the portal IP.
svc3_ip
=
$(${
KUBEC
FG
}
-template
'{{.portalIP}}'
get
"services/
${
svc3_name
}
"
)
svc3_ip
=
$(${
KUBEC
TL
}
get services
-o
template
'--template={{.portalIP}}'
"
${
svc3_name
}
"
)
test
-n
"
${
svc3_ip
}
"
||
error
"Service3 IP is blank"
echo
"Verifying the portals from the host"
...
...
@@ -437,7 +436,7 @@ wait_for_pods "${svc4_name}" "${svc4_count}"
svc4_pods
=
$(
query_pods
"
${
svc4_name
}
"
"
${
svc4_count
}
"
)
# Get the portal IP.
svc4_ip
=
$(${
KUBEC
FG
}
-template
'{{.portalIP}}'
get
"services/
${
svc4_name
}
"
)
svc4_ip
=
$(${
KUBEC
TL
}
get services
-o
template
'--template={{.portalIP}}'
"
${
svc4_name
}
"
)
test
-n
"
${
svc4_ip
}
"
||
error
"Service4 IP is blank"
if
[[
"
${
svc4_ip
}
"
==
"
${
svc2_ip
}
"
||
"
${
svc4_ip
}
"
==
"
${
svc3_ip
}
"
]]
;
then
error
"Portal IPs conflict:
${
svc4_ip
}
"
...
...
hack/e2e-suite/update.sh
View file @
04cf8c9e
...
...
@@ -53,7 +53,7 @@ function validate() {
for
id
in
"
${
pod_id_list
[@]+
${
pod_id_list
[@]
}}
"
;
do
local
template_string current_status current_image host_ip
# NB: kubectl
& kubecfg add
the "exists" function to the standard template functions.
# NB: kubectl
adds
the "exists" function to the standard template functions.
# This lets us check to see if the "running" entry exists for each of the containers
# we care about. Exists will never return an error and it's safe to check a chain of
# things, any one of which may not exist. In the below template, all of info,
...
...
hack/e2e.go
View file @
04cf8c9e
...
...
@@ -57,7 +57,6 @@ var (
"You can explicitly set to false if you're, e.g., testing client changes "
+
"for which the server version doesn't make a difference."
)
cfgCmd
=
flag
.
String
(
"cfg"
,
""
,
"If nonempty, pass this as an argument, and call kubecfg. Implies -v."
)
ctlCmd
=
flag
.
String
(
"ctl"
,
""
,
"If nonempty, pass this as an argument, and call kubectl. Implies -v. (-test, -cfg, -ctl are mutually exclusive)"
)
)
...
...
@@ -164,8 +163,6 @@ func main() {
failure
:=
false
switch
{
case
*
cfgCmd
!=
""
:
failure
=
!
runBash
(
"'kubecfg "
+*
cfgCmd
+
"'"
,
"$KUBECFG "
+*
cfgCmd
)
case
*
ctlCmd
!=
""
:
failure
=
!
runBash
(
"'kubectl "
+*
ctlCmd
+
"'"
,
"$KUBECTL "
+*
ctlCmd
)
case
*
tests
!=
""
:
...
...
@@ -537,15 +534,6 @@ func printPrefixedLines(prefix, s string) {
}
// returns either "", or a list of args intended for appending with the
// kubecfg or kubectl commands (begining with a space).
func
kubecfgArgs
()
string
{
if
*
checkVersionSkew
{
return
" -expect_version_match"
}
return
""
}
// returns either "", or a list of args intended for appending with the
// kubectl command (begining with a space).
func
kubectlArgs
()
string
{
if
*
checkVersionSkew
{
...
...
@@ -564,7 +552,6 @@ export KUBE_CONFIG_FILE="config-test.sh"
# TODO(jbeda): This will break on usage if there is a space in
# ${KUBE_ROOT}. Convert to an array? Or an exported function?
export KUBECFG="`
+
versionRoot
+
`/cluster/kubecfg.sh`
+
kubecfgArgs
()
+
`"
export KUBECTL="`
+
versionRoot
+
`/cluster/kubectl.sh`
+
kubectlArgs
()
+
`"
source "`
+
*
root
+
`/cluster/kube-env.sh"
...
...
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