mirror of
https://github.com/ansible/awx-operator.git
synced 2026-05-08 06:12:54 +00:00
Allow {web_,task_,}replicas to be 0 and split out molecule tests (#1468)
Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
35
molecule/default/tasks/_test_case_replicas.yml
Normal file
35
molecule/default/tasks/_test_case_replicas.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
- name: Get web pod details
|
||||
k8s_info:
|
||||
namespace: '{{ namespace }}'
|
||||
kind: Pod
|
||||
label_selectors:
|
||||
- app.kubernetes.io/name = example-awx-web
|
||||
register: awx_web_pod
|
||||
# This can take a while to actually make it to the cluster
|
||||
retries: 30
|
||||
delay: 5
|
||||
until: awx_web_pod.resources | length == expected_web_replicas
|
||||
ignore_errors: true
|
||||
|
||||
- name: Get task pod details
|
||||
k8s_info:
|
||||
namespace: '{{ namespace }}'
|
||||
kind: Pod
|
||||
label_selectors:
|
||||
- app.kubernetes.io/name = example-awx-task
|
||||
register: awx_task_pod
|
||||
# This can take a while to actually make it to the cluster
|
||||
retries: 30
|
||||
delay: 5
|
||||
until: awx_task_pod.resources | length == expected_task_replicas
|
||||
ignore_errors: true
|
||||
|
||||
- name: Ensure that the correct number of web and task pods exist
|
||||
assert:
|
||||
that:
|
||||
- awx_web_pod.resources | length == expected_web_replicas
|
||||
- awx_task_pod.resources | length == expected_task_replicas
|
||||
fail_msg: >-
|
||||
Web pods: Expected {{ expected_web_replicas }}, got {{ awx_web_pod.resources | length }}.
|
||||
Task pods: Expected {{ expected_task_replicas }}, got {{ awx_task_pod.resources | length }}.
|
||||
13
molecule/default/tasks/apply_awx_spec.yml
Normal file
13
molecule/default/tasks/apply_awx_spec.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: Create or update the awx.ansible.com/v1alpha1.AWX
|
||||
k8s:
|
||||
state: present
|
||||
namespace: '{{ namespace }}'
|
||||
definition: "{{ lookup('template', 'awx_cr_molecule.yml.j2') | from_yaml }}"
|
||||
apply: true
|
||||
wait: yes
|
||||
wait_timeout: 900
|
||||
wait_condition:
|
||||
type: Running
|
||||
reason: Successful
|
||||
status: "True"
|
||||
64
molecule/default/tasks/awx_replicas_test.yml
Normal file
64
molecule/default/tasks/awx_replicas_test.yml
Normal file
@@ -0,0 +1,64 @@
|
||||
---
|
||||
- block:
|
||||
- debug:
|
||||
msg: test - web_replicas and task_replicas should override replicas
|
||||
|
||||
- include_tasks: apply_awx_spec.yml
|
||||
vars:
|
||||
additional_fields:
|
||||
replicas: 2
|
||||
web_replicas: 0
|
||||
task_replicas: 0
|
||||
|
||||
- include_tasks: _test_case_replicas.yml
|
||||
vars:
|
||||
expected_web_replicas: 0
|
||||
expected_task_replicas: 0
|
||||
|
||||
####
|
||||
|
||||
- debug:
|
||||
msg: test - replicas should act as a default
|
||||
|
||||
- include_tasks: apply_awx_spec.yml
|
||||
vars:
|
||||
additional_fields:
|
||||
replicas: 2
|
||||
web_replicas: 1
|
||||
|
||||
- include_tasks: _test_case_replicas.yml
|
||||
vars:
|
||||
expected_web_replicas: 1
|
||||
expected_task_replicas: 2
|
||||
|
||||
####
|
||||
|
||||
- debug:
|
||||
msg: test - replicas=0 should kill all pods
|
||||
|
||||
- include_tasks: apply_awx_spec.yml
|
||||
vars:
|
||||
additional_fields:
|
||||
replicas: 0
|
||||
|
||||
- include_tasks: _test_case_replicas.yml
|
||||
vars:
|
||||
expected_web_replicas: 0
|
||||
expected_task_replicas: 0
|
||||
|
||||
####
|
||||
|
||||
- debug:
|
||||
msg: test - replicas=3 should give 3 of each
|
||||
|
||||
- include_tasks: apply_awx_spec.yml
|
||||
vars:
|
||||
additional_fields:
|
||||
replicas: 3
|
||||
|
||||
- include_tasks: _test_case_replicas.yml
|
||||
vars:
|
||||
expected_web_replicas: 3
|
||||
expected_task_replicas: 3
|
||||
tags:
|
||||
- replicas
|
||||
@@ -1,15 +1,5 @@
|
||||
---
|
||||
- name: Create the awx.ansible.com/v1alpha1.AWX
|
||||
k8s:
|
||||
state: present
|
||||
namespace: '{{ namespace }}'
|
||||
definition: "{{ lookup('template', 'awx_cr_molecule.yml.j2') | from_yaml }}"
|
||||
wait: yes
|
||||
wait_timeout: 900
|
||||
wait_condition:
|
||||
type: Running
|
||||
reason: Successful
|
||||
status: "True"
|
||||
- include_tasks: apply_awx_spec.yml
|
||||
|
||||
- name: Obtain generated admin password
|
||||
k8s_info:
|
||||
|
||||
Reference in New Issue
Block a user