mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
add tests
This commit is contained in:
parent
e4aff1b2eb
commit
c29a19610a
21
hack/testdata/null-propagation/deployment-null.yml
vendored
Normal file
21
hack/testdata/null-propagation/deployment-null.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: my-dep-null
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
l1: l1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
l1: l1
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: registry.k8s.io/nginx:1.7.9
|
||||
resources:
|
||||
requests:
|
||||
memory: "64Mi"
|
||||
cpu: null
|
||||
terminationMessagePolicy: null
|
8
hack/testdata/null-propagation/resourcesquota-null.yml
vendored
Normal file
8
hack/testdata/null-propagation/resourcesquota-null.yml
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
kind: ResourceQuota
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: my-rq
|
||||
spec:
|
||||
hard:
|
||||
limits.cpu: null
|
||||
limits.memory: null
|
@ -96,6 +96,34 @@ run_kubectl_apply_tests() {
|
||||
# cleanup
|
||||
kubectl delete pods selector-test-pod
|
||||
|
||||
# Create a deployment
|
||||
kubectl apply -f hack/testdata/null-propagation/deployment-null.yml "${kube_flags[@]:?}"
|
||||
# resources.limits.cpu should be nil.
|
||||
kube::test::get_object_jsonpath_assert "deployment/my-dep-null" "{.spec.template.spec.containers[0].resources.requests.cpu}" ''
|
||||
kube::test::get_object_jsonpath_assert "deployment/my-dep-null" "{.spec.template.spec.containers[0].resources.requests.memory}" '64Mi'
|
||||
# The default value of the terminationMessagePolicy field is `File`, so the result will not be changed.
|
||||
kube::test::get_object_jsonpath_assert "deployment/my-dep-null" "{.spec.template.spec.containers[0].terminationMessagePolicy}" 'File'
|
||||
|
||||
# kubectl apply on create should do what kubectl apply on update will accomplish.
|
||||
kubectl apply -f hack/testdata/null-propagation/deployment-null.yml "${kube_flags[@]}"
|
||||
kube::test::get_object_jsonpath_assert "deployment/my-dep-null" "{.spec.template.spec.containers[0].resources.requests.cpu}" ''
|
||||
kube::test::get_object_jsonpath_assert "deployment/my-dep-null" "{.spec.template.spec.containers[0].resources.requests.memory}" '64Mi'
|
||||
kube::test::get_object_jsonpath_assert "deployment/my-dep-null" "{.spec.template.spec.containers[0].terminationMessagePolicy}" 'File'
|
||||
|
||||
# hard.limits.cpu should be nil.
|
||||
kubectl apply -f hack/testdata/null-propagation/resourcesquota-null.yml "${kube_flags[@]}"
|
||||
kube::test::get_object_jsonpath_assert "resourcequota/my-rq" "{.spec.hard['limits\.cpu']}" ''
|
||||
kube::test::get_object_jsonpath_assert "resourcequota/my-rq" "{.spec.hard['limits\.memory']}" ''
|
||||
|
||||
# kubectl apply on create should do what kubectl apply on update will accomplish.
|
||||
kubectl apply -f hack/testdata/null-propagation/resourcesquota-null.yml "${kube_flags[@]}"
|
||||
kube::test::get_object_jsonpath_assert "resourcequota/my-rq" "{.spec.hard['limits\.cpu']}" ''
|
||||
kube::test::get_object_jsonpath_assert "resourcequota/my-rq" "{.spec.hard['limits\.memory']}" ''
|
||||
|
||||
# cleanup
|
||||
kubectl delete deployment my-dep-null
|
||||
kubectl delete resourcequota my-rq
|
||||
|
||||
## kubectl apply --dry-run=server
|
||||
# Pre-Condition: no POD exists
|
||||
kube::test::get_object_assert pods "{{range.items}}{{${id_field:?}}}:{{end}}" ''
|
||||
|
Loading…
Reference in New Issue
Block a user