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
beb2088b
Commit
beb2088b
authored
Aug 16, 2016
by
bprashanth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test-cmd
parent
30f3cb9d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
1 deletion
+52
-1
test-cmd.sh
hack/make-rules/test-cmd.sh
+52
-1
No files found.
hack/make-rules/test-cmd.sh
View file @
beb2088b
...
@@ -125,6 +125,25 @@ function kubectl-with-retry()
...
@@ -125,6 +125,25 @@ function kubectl-with-retry()
done
done
}
}
# Waits for the pods with the given label to match the list of names. Don't call
# this function unless you know the exact pod names, or expect no pods.
# $1: label to match
# $2: list of pod names sorted by name
# Example invocation:
# wait-for-pods-with-label "app=foo" "nginx-0nginx-1"
function
wait-for-pods-with-label
()
{
for
i
in
$(
seq
1 10
)
;
do
kubeout
=
`
kubectl get po
-l
$1
--template
'{{range.items}}{{.metadata.name}}{{end}}'
--sort-by
metadata.name
"
${
kube_flags
[@]
}
"
`
if
[[
$kubeout
=
$2
]]
;
then
return
fi
echo
Waiting
for
pods:
$2
, found
$kubeout
sleep
$i
done
kube::log::error_exit
"Timeout waiting for pods with label
$1
"
}
kube::util::trap_add cleanup EXIT SIGINT
kube::util::trap_add cleanup EXIT SIGINT
kube::util::ensure-temp-dir
kube::util::ensure-temp-dir
...
@@ -311,6 +330,7 @@ runTests() {
...
@@ -311,6 +330,7 @@ runTests() {
hpa_min_field
=
".spec.minReplicas"
hpa_min_field
=
".spec.minReplicas"
hpa_max_field
=
".spec.maxReplicas"
hpa_max_field
=
".spec.maxReplicas"
hpa_cpu_field
=
".spec.targetCPUUtilizationPercentage"
hpa_cpu_field
=
".spec.targetCPUUtilizationPercentage"
petset_replicas_field
=
".spec.replicas"
job_parallelism_field
=
".spec.parallelism"
job_parallelism_field
=
".spec.parallelism"
deployment_replicas
=
".spec.replicas"
deployment_replicas
=
".spec.replicas"
secret_data
=
".data"
secret_data
=
".data"
...
@@ -2096,6 +2116,37 @@ __EOF__
...
@@ -2096,6 +2116,37 @@ __EOF__
kubectl delete rs frontend
"
${
kube_flags
[@]
}
"
kubectl delete rs frontend
"
${
kube_flags
[@]
}
"
############
# Pet Sets #
############
kube::log::status
"Testing kubectl(
${
version
}
:petsets)"
### Create and stop petset, make sure it doesn't leak pods
# Pre-condition: no petset exists
kube::test::get_object_assert petset
"{{range.items}}{{
$id_field
}}:{{end}}"
''
# Command: create petset
kubectl create
-f
hack/testdata/nginx-petset.yaml
"
${
kube_flags
[@]
}
"
### Scale petset test with current-replicas and replicas
# Pre-condition: 0 replicas
kube::test::get_object_assert
'petset nginx'
"{{
$petset_replicas_field
}}"
'0'
# Command: Scale up
kubectl scale
--current-replicas
=
0
--replicas
=
1 petset nginx
"
${
kube_flags
[@]
}
"
# Post-condition: 1 replica, named nginx-0
kube::test::get_object_assert
'petset nginx'
"{{
$petset_replicas_field
}}"
'1'
# Typically we'd wait and confirm that N>1 replicas are up, but this framework
# doesn't start the scheduler, so pet-0 will block all others.
# TODO: test robust scaling in an e2e.
wait-for-pods-with-label
"app=nginx-petset"
"nginx-0"
### Clean up
kubectl delete
-f
hack/testdata/nginx-petset.yaml
"
${
kube_flags
[@]
}
"
# Post-condition: no pods from petset controller
wait-for-pods-with-label
"app=nginx-petset"
""
######################
######################
# Lists #
# Lists #
######################
######################
...
@@ -2406,7 +2457,7 @@ __EOF__
...
@@ -2406,7 +2457,7 @@ __EOF__
exit
1
exit
1
fi
fi
rm
"
${
SAR_RESULT_FILE
}
"
rm
"
${
SAR_RESULT_FILE
}
"
#####################
#####################
# Retrieve multiple #
# Retrieve multiple #
...
...
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