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
33ae2b85
Commit
33ae2b85
authored
May 20, 2016
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow running test-cmd on osx
parent
4a78db61
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 @
33ae2b85
...
...
@@ -144,6 +144,16 @@ IMAGE_PERL="gcr.io/google-containers/perl"
# ensure ~/.kube/config isn't loaded by tests
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
kube::log::status
"Running kubectl with no options"
"
${
KUBE_OUTPUT_HOSTBIN
}
/kubectl"
...
...
@@ -310,7 +320,7 @@ runTests() {
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}'
)
encoded
=
$(
echo
-n
"
$cert_data
"
|
base64
--wrap
=
0
)
encoded
=
$(
echo
-n
"
$cert_data
"
|
base64
)
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}'
)
...
...
@@ -435,7 +445,7 @@ runTests() {
create_and_use_new_namespace
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
''
# 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
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
'valid-pod:'
...
...
@@ -674,7 +684,7 @@ runTests() {
## --force replace pod can change other field, e.g., spec.container.name
# 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
# 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'
...
...
@@ -707,7 +717,7 @@ __EOF__
kubectl delete node node-
${
version
}
-test
## 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
EDITOR
=
/tmp/tmp-editor.sh
${
KUBE_OUTPUT_HOSTBIN
}
/kubectl edit
"
${
kube_flags
[@]
}
"
pods/valid-pod
# Post-condition: valid-pod POD has image gcr.io/google_containers/serve_hostname
...
...
@@ -772,7 +782,7 @@ __EOF__
# 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
)
"
]]
## 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"
kubectl replace
-f
"
${
KUBE_TEMP
}
"
/test-pod-replace.yaml
"
${
kube_flags
[@]
}
"
# Post-Condition: pod "test-pod" is replaced
...
...
@@ -788,7 +798,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
>
"
${
KUBE_TEMP
}
"
/annotation-configuration
## 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"
kubectl replace
-f
"
${
KUBE_TEMP
}
"
/test-pod-replace.yaml
"
${
kube_flags
[@]
}
"
# Post-Condition: pod "test-pod" is replaced
...
...
@@ -820,7 +830,7 @@ __EOF__
!
[[
"
$(
kubectl get pods test-pod
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
kubectl.kubernetes.io/last-applied-configuration
)
"
]]
# Command: edit the pod "test-pod"
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
}
"
EDITOR
=
${
temp_editor
}
kubectl edit pod test-pod
--save-config
"
${
kube_flags
[@]
}
"
# Post-Condition: pod "test-pod" has configuration annotation
...
...
@@ -1882,7 +1892,7 @@ __EOF__
fi
# Command: kubectl edit multiple resources
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
}
"
EDITOR
=
"
${
temp_editor
}
"
kubectl edit
"
${
kube_flags
[@]
}
"
-f
"
${
file
}
"
# 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