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
6136d4c2
Commit
6136d4c2
authored
May 30, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #25981 from liggitt/test-cmd-osx
Automatic merge from submit-queue Allow running test-cmd on osx
parents
6a234a2c
33ae2b85
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
test-cmd.sh
hack/test-cmd.sh
+18
-8
No files found.
hack/test-cmd.sh
View file @
6136d4c2
...
@@ -147,6 +147,16 @@ IMAGE_PERL="gcr.io/google-containers/perl"
...
@@ -147,6 +147,16 @@ IMAGE_PERL="gcr.io/google-containers/perl"
# ensure ~/.kube/config isn't loaded by tests
# ensure ~/.kube/config isn't loaded by tests
HOME
=
"
${
KUBE_TEMP
}
"
HOME
=
"
${
KUBE_TEMP
}
"
# Find a standard sed instance for use with edit scripts
SED
=
sed
if
which gsed &>/dev/null
;
then
SED
=
gsed
fi
if
!
(
$SED
--version
2>&1 |
grep
-q
GNU
)
;
then
echo
"!!! GNU sed is required. If on OS X, use 'brew install gnu-sed'."
exit
1
fi
# Check kubectl
# Check kubectl
kube::log::status
"Running kubectl with no options"
kube::log::status
"Running kubectl with no options"
"
${
KUBE_OUTPUT_HOSTBIN
}
/kubectl"
"
${
KUBE_OUTPUT_HOSTBIN
}
/kubectl"
...
@@ -314,7 +324,7 @@ runTests() {
...
@@ -314,7 +324,7 @@ runTests() {
kubectl config
set
clusters.test-cluster.certificate-authority-data
"
$cert_data
"
--set-raw-bytes
kubectl config
set
clusters.test-cluster.certificate-authority-data
"
$cert_data
"
--set-raw-bytes
r_writen
=
$(
kubectl config view
--raw
-o
jsonpath
=
'{.clusters[?(@.name == "test-cluster")].cluster.certificate-authority-data}'
)
r_writen
=
$(
kubectl config view
--raw
-o
jsonpath
=
'{.clusters[?(@.name == "test-cluster")].cluster.certificate-authority-data}'
)
encoded
=
$(
echo
-n
"
$cert_data
"
|
base64
--wrap
=
0
)
encoded
=
$(
echo
-n
"
$cert_data
"
|
base64
)
kubectl config
set
clusters.test-cluster.certificate-authority-data
"
$encoded
"
kubectl config
set
clusters.test-cluster.certificate-authority-data
"
$encoded
"
e_writen
=
$(
kubectl config view
--raw
-o
jsonpath
=
'{.clusters[?(@.name == "test-cluster")].cluster.certificate-authority-data}'
)
e_writen
=
$(
kubectl config view
--raw
-o
jsonpath
=
'{.clusters[?(@.name == "test-cluster")].cluster.certificate-authority-data}'
)
...
@@ -439,7 +449,7 @@ runTests() {
...
@@ -439,7 +449,7 @@ runTests() {
create_and_use_new_namespace
create_and_use_new_namespace
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
''
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
''
# Command
# Command
echo
"
${
output_pod
}
"
|
sed
'/namespace:/d'
| kubectl create
-f
-
"
${
kube_flags
[@]
}
"
echo
"
${
output_pod
}
"
|
$SED
'/namespace:/d'
| kubectl create
-f
-
"
${
kube_flags
[@]
}
"
# Post-condition: valid-pod POD is created
# Post-condition: valid-pod POD is created
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
'valid-pod:'
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
'valid-pod:'
...
@@ -678,7 +688,7 @@ runTests() {
...
@@ -678,7 +688,7 @@ runTests() {
## --force replace pod can change other field, e.g., spec.container.name
## --force replace pod can change other field, e.g., spec.container.name
# Command
# Command
kubectl get
"
${
kube_flags
[@]
}
"
pod valid-pod
-o
json |
sed
's/"kubernetes-serve-hostname"/"replaced-k8s-serve-hostname"/g'
>
/tmp/tmp-valid-pod.json
kubectl get
"
${
kube_flags
[@]
}
"
pod valid-pod
-o
json |
$SED
's/"kubernetes-serve-hostname"/"replaced-k8s-serve-hostname"/g'
>
/tmp/tmp-valid-pod.json
kubectl replace
"
${
kube_flags
[@]
}
"
--force
-f
/tmp/tmp-valid-pod.json
kubectl replace
"
${
kube_flags
[@]
}
"
--force
-f
/tmp/tmp-valid-pod.json
# Post-condition: spec.container.name = "replaced-k8s-serve-hostname"
# Post-condition: spec.container.name = "replaced-k8s-serve-hostname"
kube::test::get_object_assert
'pod valid-pod'
"{{(index .spec.containers 0).name}}"
'replaced-k8s-serve-hostname'
kube::test::get_object_assert
'pod valid-pod'
"{{(index .spec.containers 0).name}}"
'replaced-k8s-serve-hostname'
...
@@ -711,7 +721,7 @@ __EOF__
...
@@ -711,7 +721,7 @@ __EOF__
kubectl delete node node-
${
version
}
-test
"
${
kube_flags
[@]
}
"
kubectl delete node node-
${
version
}
-test
"
${
kube_flags
[@]
}
"
## kubectl edit can update the image field of a POD. tmp-editor.sh is a fake editor
## kubectl edit can update the image field of a POD. tmp-editor.sh is a fake editor
echo
-e
'#!/bin/bash\nsed -i "s/nginx/gcr.io\/google_containers\/serve_hostname/g" $1'
>
/tmp/tmp-editor.sh
echo
-e
"#!/bin/bash
\n
$SED
-i
\"
s/nginx/gcr.io
\/
google_containers
\/
serve_hostname/g
\"
\$
1"
>
/tmp/tmp-editor.sh
chmod
+x /tmp/tmp-editor.sh
chmod
+x /tmp/tmp-editor.sh
# Pre-condition: valid-pod POD has image nginx
# Pre-condition: valid-pod POD has image nginx
kube::test::get_object_assert pods
"{{range.items}}{{
$image_field
}}:{{end}}"
'nginx:'
kube::test::get_object_assert pods
"{{range.items}}{{
$image_field
}}:{{end}}"
'nginx:'
...
@@ -780,7 +790,7 @@ __EOF__
...
@@ -780,7 +790,7 @@ __EOF__
# Post-Condition: pod "test-pod" doesn't have configuration annotation
# Post-Condition: pod "test-pod" doesn't have configuration annotation
!
[[
"
$(
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
kubectl.kubernetes.io/last-applied-configuration
)
"
]]
!
[[
"
$(
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
kubectl.kubernetes.io/last-applied-configuration
)
"
]]
## 2. kubectl replace doesn't set the annotation
## 2. kubectl replace doesn't set the annotation
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
sed
's/test-pod-label/test-pod-replaced/g'
>
"
${
KUBE_TEMP
}
"
/test-pod-replace.yaml
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
$SED
's/test-pod-label/test-pod-replaced/g'
>
"
${
KUBE_TEMP
}
"
/test-pod-replace.yaml
# Command: replace the pod "test-pod"
# Command: replace the pod "test-pod"
kubectl replace
-f
"
${
KUBE_TEMP
}
"
/test-pod-replace.yaml
"
${
kube_flags
[@]
}
"
kubectl replace
-f
"
${
KUBE_TEMP
}
"
/test-pod-replace.yaml
"
${
kube_flags
[@]
}
"
# Post-Condition: pod "test-pod" is replaced
# Post-Condition: pod "test-pod" is replaced
...
@@ -796,7 +806,7 @@ __EOF__
...
@@ -796,7 +806,7 @@ __EOF__
[[
"
$(
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
kubectl.kubernetes.io/last-applied-configuration
)
"
]]
[[
"
$(
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
kubectl.kubernetes.io/last-applied-configuration
)
"
]]
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
kubectl.kubernetes.io/last-applied-configuration
>
"
${
KUBE_TEMP
}
"
/annotation-configuration
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
kubectl.kubernetes.io/last-applied-configuration
>
"
${
KUBE_TEMP
}
"
/annotation-configuration
## 4. kubectl replace updates an existing annotation
## 4. kubectl replace updates an existing annotation
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
sed
's/test-pod-applied/test-pod-replaced/g'
>
"
${
KUBE_TEMP
}
"
/test-pod-replace.yaml
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
$SED
's/test-pod-applied/test-pod-replaced/g'
>
"
${
KUBE_TEMP
}
"
/test-pod-replace.yaml
# Command: replace the pod "test-pod"
# Command: replace the pod "test-pod"
kubectl replace
-f
"
${
KUBE_TEMP
}
"
/test-pod-replace.yaml
"
${
kube_flags
[@]
}
"
kubectl replace
-f
"
${
KUBE_TEMP
}
"
/test-pod-replace.yaml
"
${
kube_flags
[@]
}
"
# Post-Condition: pod "test-pod" is replaced
# Post-Condition: pod "test-pod" is replaced
...
@@ -828,7 +838,7 @@ __EOF__
...
@@ -828,7 +838,7 @@ __EOF__
!
[[
"
$(
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
kubectl.kubernetes.io/last-applied-configuration
)
"
]]
!
[[
"
$(
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
kubectl.kubernetes.io/last-applied-configuration
)
"
]]
# Command: edit the pod "test-pod"
# Command: edit the pod "test-pod"
temp_editor
=
"
${
KUBE_TEMP
}
/tmp-editor.sh"
temp_editor
=
"
${
KUBE_TEMP
}
/tmp-editor.sh"
echo
-e
'#!/bin/bash\nsed -i "s/test-pod-label/test-pod-label-edited/g" $@'
>
"
${
temp_editor
}
"
echo
-e
"#!/bin/bash
\n
$SED
-i
\"
s/test-pod-label/test-pod-label-edited/g
\"
\$
@"
>
"
${
temp_editor
}
"
chmod
+x
"
${
temp_editor
}
"
chmod
+x
"
${
temp_editor
}
"
EDITOR
=
${
temp_editor
}
kubectl edit pod test-pod
--save-config
"
${
kube_flags
[@]
}
"
EDITOR
=
${
temp_editor
}
kubectl edit pod test-pod
--save-config
"
${
kube_flags
[@]
}
"
# Post-Condition: pod "test-pod" has configuration annotation
# Post-Condition: pod "test-pod" has configuration annotation
...
@@ -1951,7 +1961,7 @@ __EOF__
...
@@ -1951,7 +1961,7 @@ __EOF__
fi
fi
# Command: kubectl edit multiple resources
# Command: kubectl edit multiple resources
temp_editor
=
"
${
KUBE_TEMP
}
/tmp-editor.sh"
temp_editor
=
"
${
KUBE_TEMP
}
/tmp-editor.sh"
echo
-e
'#!/bin/bash\nsed -i "s/status\:\ replaced/status\:\ edited/g" $@'
>
"
${
temp_editor
}
"
echo
-e
"#!/bin/bash
\n
$SED
-i
\"
s/status
\:\
replaced/status
\:\
edited/g
\"
\$
@"
>
"
${
temp_editor
}
"
chmod
+x
"
${
temp_editor
}
"
chmod
+x
"
${
temp_editor
}
"
EDITOR
=
"
${
temp_editor
}
"
kubectl edit
"
${
kube_flags
[@]
}
"
-f
"
${
file
}
"
EDITOR
=
"
${
temp_editor
}
"
kubectl edit
"
${
kube_flags
[@]
}
"
-f
"
${
file
}
"
# Post-condition: mock service (and mock2) and mock rc (and mock2) are edited
# Post-condition: mock service (and mock2) and mock rc (and mock2) are edited
...
...
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