Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI test and fix awx-operator CI failure in awx repo #1342

Merged
merged 1 commit into from
Apr 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 53 additions & 28 deletions molecule/default/tasks/awx_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
kind: Pod
label_selectors:
- app.kubernetes.io/name = example-awx-web
register: awx_pod
register: awx_web_pod
when: not awx_version

- name: Get task pod details
Expand All @@ -37,10 +37,18 @@
register: awx_task_pod
when: not awx_version

- name: Extract tags from images
- name: Extract tags from images from web pod
set_fact:
image_tags: |
{{ awx_pod.resources[0].spec.containers |
web_image_tags: |
{{ awx_web_pod.resources[0].spec.containers |
map(attribute='image') |
map('regex_search', default_awx_version) }}
when: not awx_version

- name: Extract tags from images from task pod
set_fact:
task_image_tags: |
{{ awx_task_pod.resources[0].spec.containers |
map(attribute='image') |
map('regex_search', default_awx_version) }}
when: not awx_version
Expand All @@ -51,7 +59,8 @@
This is an environment variable that is set via build arg when releasing awx-operator.
when:
- not awx_version
- default_awx_version not in image_tags
- default_awx_version not in web_image_tags
- default_awx_version not in task_image_tags

- name: Launch Demo Job Template
awx.awx.job_launch:
Expand Down Expand Up @@ -102,13 +111,21 @@
name: example-awx
register: this_awx

- name: Get pod details
- name: Get web pod details
k8s_info:
namespace: '{{ namespace }}'
kind: Pod
label_selectors:
- app.kubernetes.io/name = example-awx-web
register: awx_pod
register: awx_web_pod

- name: Get task pod details
k8s_info:
namespace: '{{ namespace }}'
kind: Pod
label_selectors:
- app.kubernetes.io/name = example-awx-task
register: awx_task_pod

- name: Extract additional_labels from AWX spec
set_fact:
Expand All @@ -117,51 +134,59 @@
| dict2items | selectattr('key', 'in', this_awx.resources[0].spec.additional_labels)
| list
}}
- name: Extract additional_labels from AWX Task spec
set_fact:
awx_task_pod_additional_labels: >-
{{ this_awx.resources[0].metadata.labels
| dict2items | selectattr('key', 'in', this_awx.resources[0].spec.additional_labels)
| list
}}
- name: Extract additional_labels from AWX Web Pod

- name: Extract additional_labels from AWX web Pod
set_fact:
pod_additional_labels: >-
{{ awx_pod.resources[0].metadata.labels
awx_web_pod_additional_labels: >-
{{ awx_web_pod.resources[0].metadata.labels
| dict2items | selectattr('key', 'in', this_awx.resources[0].spec.additional_labels)
| list
}}

- name: Extract additional_labels from AWX Task Pod
- name: Extract additional_labels from AWX task Pod
set_fact:
task_pod_additional_labels: >-
awx_task_pod_additional_labels: >-
{{ awx_task_pod.resources[0].metadata.labels
| dict2items | selectattr('key', 'in', this_awx.resources[0].spec.additional_labels)
| list
}}

- name: AWX Web Pod contains additional_labels
- name: Assert AWX web Pod contains additional_labels
ansible.builtin.assert:
that:
- awx_web_pod_additional_labels == awx_additional_labels

- name: Assert AWX task Pod contains additional_labels
ansible.builtin.assert:
that:
- pod_additional_labels == awx_additional_labels
- awx_task_pod_additional_labels == awx_additional_labels

- name: Extract web Pod labels which shouldn't have been propagated to it from AWX
set_fact:
awx_web_pod_extra_labels: >-
{{ awx_web_pod.resources[0].metadata.labels
| dict2items | selectattr('key', 'in', ["my/do-not-inherit"])
| list
}}

- name: AWX Task Pod contains additional_labels
- name: AWX web Pod doesn't contain AWX labels not in additional_labels
ansible.builtin.assert:
that:
- task_pod_additional_labels == awx_task_pod_additional_labels
- awx_web_pod_extra_labels == []

- name: Extract Pod labels which shouldn't have been propagated to it from AWX
- name: Extract task Pod labels which shouldn't have been propagated to it from AWX
set_fact:
pod_extra_labels: >-
{{ awx_pod.resources[0].metadata.labels
awx_task_pod_extra_labels: >-
{{ awx_task_pod.resources[0].metadata.labels
| dict2items | selectattr('key', 'in', ["my/do-not-inherit"])
| list
}}

- name: AWX Pod doesn't contain AWX labels not in additional_labels
- name: AWX task Pod doesn't contain AWX labels not in additional_labels
ansible.builtin.assert:
that:
- pod_extra_labels == []
- awx_task_pod_extra_labels == []

rescue:
- name: Re-emit failure
vars:
Expand Down