Skip to content

Commit

Permalink
Add integration test for case when desired number of Pods in DaemonSe…
Browse files Browse the repository at this point in the history
…t is 0
  • Loading branch information
azaleski9 authored and gravesm committed Jul 10, 2024
1 parent 9305f4f commit 45331cb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/integration/targets/k8s_waiter/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ k8s_pod_metadata:

k8s_pod_spec:
serviceAccount: "{{ k8s_pod_service_account }}"
nodeSelector: "{{ k8s_pod_node_selector }}"
containers:
- image: "{{ k8s_pod_image }}"
imagePullPolicy: Always
Expand Down Expand Up @@ -33,6 +34,8 @@ k8s_pod_ports: []

k8s_pod_env: []

k8s_pod_node_selector: {}

k8s_pod_template:
metadata: "{{ k8s_pod_metadata }}"
spec: "{{ k8s_pod_spec }}"
Expand Down
42 changes: 42 additions & 0 deletions tests/integration/targets/k8s_waiter/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,48 @@
- ds.result.status.currentNumberScheduled == ds.result.status.desiredNumberScheduled
- updated_ds_pods.resources[0].spec.containers[0].image.endswith(":3")

- name: Create daemonset with nodeSelector and not existing label
k8s:
definition:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: wait-daemonset-not-existing-label
namespace: "{{ wait_namespace }}"
spec:
selector:
matchLabels:
app: "{{ k8s_pod_name }}"
template: "{{ k8s_pod_template }}"
wait: yes
wait_sleep: 5
wait_timeout: "{{ k8s_wait_timeout | default(omit) }}"
vars:
k8s_pod_name: wait-daemonset-not-existing-label
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1
k8s_pod_command:
- sleep
- "600"
k8s_pod_node_selector:
nonExisitingLabel: test-not-exiting-label
register: ds_not_existing_label

- name: Get updated pods
k8s_info:
api_version: v1
kind: Pod
namespace: "{{ wait_namespace }}"
label_selectors:
- app=wait-daemonset-not-existing-label
register: updated_ds_pods_not_existing_label

- name: Check that daemonset wait worked (when desired number is 0)
assert:
that:
- ds_not_existing_label.result.status.currentNumberScheduled == ds_not_existing_label.result.status.desiredNumberScheduled
- ds_not_existing_label.result.status.desiredNumberScheduled == 0
- updated_ds_pods_not_existing_label.resources | length == 0

- name: Add a statefulset
k8s:
definition:
Expand Down

0 comments on commit 45331cb

Please sign in to comment.