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
d60b7d6a
Unverified
Commit
d60b7d6a
authored
Feb 20, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Feb 20, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #73866 from apelisse/add-ssa-tests
Add basic server-side apply test to test-cmd
parents
3ecd17d2
308c9816
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
1 deletion
+72
-1
test-cmd.sh
hack/make-rules/test-cmd.sh
+1
-1
apply.sh
test/cmd/apply.sh
+71
-0
No files found.
hack/make-rules/test-cmd.sh
View file @
d60b7d6a
...
...
@@ -41,7 +41,7 @@ function run_kube_apiserver() {
AUTHORIZATION_MODE
=
"RBAC,AlwaysAllow"
# Enable features
ENABLE_FEATURE_GATES
=
"
DryRun
=true"
ENABLE_FEATURE_GATES
=
"
ServerSideApply
=true"
"
${
KUBE_OUTPUT_HOSTBIN
}
/kube-apiserver"
\
--insecure-bind-address
=
"127.0.0.1"
\
...
...
test/cmd/apply.sh
View file @
d60b7d6a
...
...
@@ -227,3 +227,74 @@ __EOF__
set
+o nounset
set
+o errexit
}
# Runs tests related to kubectl apply (server-side)
run_kubectl_apply_tests
()
{
set
-o
nounset
set
-o
errexit
set
-x
create_and_use_new_namespace
kube::log::status
"Testing kubectl apply --server-side"
## kubectl apply should create the resource that doesn't exist yet
# Pre-Condition: no POD exists
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
''
# Command: apply a pod "test-pod" (doesn't exist) should create this pod
kubectl apply
--server-side
-f
hack/testdata/pod.yaml
"
${
kube_flags
[@]
}
"
# Post-Condition: pod "test-pod" is created
kube::test::get_object_assert
'pods test-pod'
"{{
${
labels_field
}
.name}}"
'test-pod-label'
# Clean up
kubectl delete pods test-pod
"
${
kube_flags
[@]
}
"
## kubectl apply --server-dry-run
# Pre-Condition: no POD exists
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
''
# apply dry-run
kubectl apply
--server-side
--server-dry-run
-f
hack/testdata/pod.yaml
"
${
kube_flags
[@]
}
"
# No pod exists
kube::test::get_object_assert pods
"{{range.items}}{{
$id_field
}}:{{end}}"
''
# apply non dry-run creates the pod
kubectl apply
--server-side
-f
hack/testdata/pod.yaml
"
${
kube_flags
[@]
}
"
# apply changes
kubectl apply
--server-side
--server-dry-run
-f
hack/testdata/pod-apply.yaml
"
${
kube_flags
[@]
}
"
# Post-Condition: label still has initial value
kube::test::get_object_assert
'pods test-pod'
"{{
${
labels_field
}
.name}}"
'test-pod-label'
# clean-up
kubectl delete
-f
hack/testdata/pod.yaml
"
${
kube_flags
[@]
}
"
## kubectl apply dry-run on CR
# Create CRD
kubectl
"
${
kube_flags_with_token
[@]
}
"
create
-f
-
<<
__EOF__
{
"kind": "CustomResourceDefinition",
"apiVersion": "apiextensions.k8s.io/v1beta1",
"metadata": {
"name": "resources.mygroup.example.com"
},
"spec": {
"group": "mygroup.example.com",
"version": "v1alpha1",
"scope": "Namespaced",
"names": {
"plural": "resources",
"singular": "resource",
"kind": "Kind",
"listKind": "KindList"
}
}
}
__EOF__
# Dry-run create the CR
kubectl
"
${
kube_flags
[@]
}
"
apply
--server-side
--server-dry-run
-f
hack/testdata/CRD/resource.yaml
"
${
kube_flags
[@]
}
"
# Make sure that the CR doesn't exist
!
kubectl
"
${
kube_flags
[@]
}
"
get resource/myobj
# clean-up
kubectl
"
${
kube_flags
[@]
}
"
delete customresourcedefinition resources.mygroup.example.com
set
+o nounset
set
+o errexit
}
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