Skip to content

Commit

Permalink
Enable running the test-operator role multiple times
Browse files Browse the repository at this point in the history
It was not possible to run the test-operator role multiple times
without cleaning up all resources created by the first role, such
as the logs pod created for the logs collection.

This patch makes it possible to run the test operator role
multiple times without cleaning up the resources (e.g., after the
update in an update job). It is possible because:

- test-operator-logs pod now has unique name for each job run
- The variable cifmw_test_operator_*_name is now exposed. By
  specifying a unique name, we can guarantee no name collisions
  between the test-operator related resources (logs pods, instances
  of CRs)

If you want to run test-operator role twice within a single job
then make sure that for the second run you specify a value for the
cifmw_test_operator_*_name. For example:

  cifmw_test_operator_tempest_name: "post-update-tempest-tests"
  • Loading branch information
lpiwowar committed Sep 30, 2024
1 parent 1d7b650 commit 4bc0d24
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
12 changes: 8 additions & 4 deletions roles/test_operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
* `cifmw_test_operator_privileged`: (Boolean) Spawn the test pods with `allowPrivilegedEscalation: true` and default linux capabilities. This is required for certain test-operator functionalities to work properly (e.g.: `extraRPMs`, certain set of tobiko tests). Default value: `true`

## Tempest specific parameters
* `cifmw_test_operator_tempest_name`: (String) Value used in the Tempest.Metadata.Name field. The value specifies name of some resources spawned by the test-operator role. Default value: `tempest-tests`
* `cifmw_test_operator_tempest_registry`: (String) The registry where to pull tempest container. Default value: `quay.io`
* `cifmw_test_operator_tempest_namespace`: (String) Registry's namespace where to pull tempest container. Default value: `podified-antelope-centos9`
* `cifmw_test_operator_tempest_container`: (String) Name of the tempest container. Default value: `openstack-tempest`
Expand All @@ -48,7 +49,7 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
apiVersion: test.openstack.org/v1beta1
kind: Tempest
metadata:
name: tempest-tests
name: "{{ cifmw_test_operator_tempest_name }}"
namespace: "{{ cifmw_test_operator_namespace }}"
spec:
containerImage: "{{ cifmw_test_operator_tempest_image }}:{{ cifmw_test_operator_tempest_image_tag }}"
Expand All @@ -69,6 +70,7 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
```

## Tobiko specific parameters
* `cifmw_test_operator_tobiko_name`: (String) Value used in the Tobiko.Metadata.Name field. The value specifies name of some resources spawned by the test-operator role. Default value: `tobiko-tests`
* `cifmw_test_operator_tobiko_registry`: (String) The registry where to pull tobiko container. Default value: `quay.io`
* `cifmw_test_operator_tobiko_namespace`: (String) Registry's namespace where to pull tobiko container. Default value: `podified-antelope-centos9`
* `cifmw_test_operator_tobiko_container`: (String) Name of the tobiko container. Default value: `openstack-tobiko`
Expand All @@ -90,7 +92,7 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
apiVersion: test.openstack.org/v1beta1
kind: Tobiko
metadata:
name: tobiko-tests
name: "{{ cifmw_test_operator_tobiko_name }}"
namespace: "{{ cifmw_test_operator_namespace }}"
spec:
kubeconfigSecretName: "{{ cifmw_test_operator_tobiko_kubeconfig_secret }}"
Expand All @@ -111,6 +113,7 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
```

## AnsibleTest specific parameters
* `cifmw_test_operator_ansibletest_name`: (String) Value used in the Ansibletest.Metadata.Name field. The value specifies name of some resources spawned by the test-operator role. Default value: `ansibletest`
* `cifmw_test_operator_ansibletest_registry`: (String) The registry where to pull ansibletests container. Default value: `quay.io`
* `cifmw_test_operator_ansibletest_namespace`: (String) Registry's namespace where to pull ansibletests container. Default value:podified-antelope-centos9
* `cifmw_test_operator_ansibletest_container`: (String) Name of the ansibletests container. Default value: `openstack-ansible-tests`
Expand All @@ -134,7 +137,7 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
apiVersion: test.openstack.org/v1beta1
kind: AnsibleTest
metadata:
name: horizontest-sample
name: "{{ cifmw_test_operator_ansibletest_name }}"
namespace: "{{ cifmw_test_operator_namespace }}"
spec:
containerImage: "{{ cifmw_test_operator_ansibletest_image }}:{{ cifmw_test_operator_ansibletest_image_tag }}"
Expand All @@ -155,6 +158,7 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
```

## Horizontest specific parameters
* `cifmw_test_operator_horizontest_name`: (String) Value used in the Ansibletest.Metadata.Name field. The value specifies name of some resources spawned by the test-operator role. Default value: `horizontest-tests`
* `cifmw_test_operator_horizontest_registry`: (String) The registry where to pull horizontest container. Default value: `quay.io`
* `cifmw_test_operator_horizontest_namespace`: (String) Registry's namespace where to pull horizontest container. Default value: `podified-antelope-centos9`
* `cifmw_test_operator_horizontest_container`: (String) Name of the horizontest container. Default value: `openstack-horizontest`
Expand All @@ -178,7 +182,7 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
apiVersion: test.openstack.org/v1beta1
kind: HorizonTest
metadata:
name: horizontest
name: "{{ cifmw_test_operator_horizontest_namespace }}"
namespace: "{{ cifmw_test_operator_namespace }}"
spec:
containerImage: "{{ cifmw_test_operator_horizontest_image }}:{{ cifmw_test_operator_horizontest_image_tag }}"
Expand Down
4 changes: 4 additions & 0 deletions roles/test_operator/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ cifmw_test_operator_delete_logs_pod: false
cifmw_test_operator_privileged: true

# Section 2: tempest parameters - used when run_test_fw is 'tempest'
cifmw_test_operator_tempest_name: "tempest-tests"
cifmw_test_operator_tempest_registry: quay.io
cifmw_test_operator_tempest_namespace: podified-antelope-centos9
cifmw_test_operator_tempest_container: openstack-tempest-all
Expand Down Expand Up @@ -120,6 +121,7 @@ cifmw_test_operator_tempest_config:
workflow: "{{ cifmw_test_operator_tempest_workflow }}"

# Section 3: tobiko parameters - used when run_test_fw is 'tobiko'
cifmw_test_operator_tobiko_name: "tobiko-tests"
cifmw_test_operator_tobiko_registry: quay.io
cifmw_test_operator_tobiko_namespace: podified-antelope-centos9
cifmw_test_operator_tobiko_container: openstack-tobiko
Expand Down Expand Up @@ -161,6 +163,7 @@ cifmw_test_operator_tobiko_config:
workflow: "{{ cifmw_test_operator_tobiko_workflow }}"

# Section 4: ansibletest parameters - used when run_test_fw is 'ansibletest'
cifmw_test_operator_ansibletest_name: "ansibletest"
cifmw_test_operator_ansibletest_registry: quay.io
cifmw_test_operator_ansibletest_namespace: podified-antelope-centos9
cifmw_test_operator_ansibletest_container: openstack-ansible-tests
Expand Down Expand Up @@ -204,6 +207,7 @@ cifmw_test_operator_ansibletest_config:
debug: "{{ cifmw_test_operator_ansibletest_debug }}"

# Section 5: horizontest parameters - used when run_test_fw is 'horizontest'
cifmw_test_operator_horizontest_name: "horizontest-tests"
cifmw_test_operator_horizontest_registry: quay.io
cifmw_test_operator_horizontest_namespace: podified-antelope-centos9
cifmw_test_operator_horizontest_container: openstack-horizontest
Expand Down
8 changes: 4 additions & 4 deletions roles/test_operator/tasks/run-test-operator-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
apiVersion: v1
kind: Pod
metadata:
name: "test-operator-logs-pod-{{ run_test_fw }}"
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}"
namespace: "{{ cifmw_test_operator_namespace }}"
spec:
containers:
Expand All @@ -134,7 +134,7 @@
context: "{{ cifmw_openshift_context | default(omit) }}"
namespace: "{{ cifmw_test_operator_namespace }}"
kind: Pod
name: "test-operator-logs-pod-{{ run_test_fw }}"
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}"
wait: true
register: logs_pod
until: logs_pod.resources[0].status.phase == "Running"
Expand All @@ -149,7 +149,7 @@
pod_path: mnt/logs-{{ test_operator_job_name }}-step-{{ index }}
ansible.builtin.shell: >
oc cp -n {{ cifmw_test_operator_namespace }}
openstack/test-operator-logs-pod-{{ run_test_fw }}:{{ pod_path }}
openstack/test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}:{{ pod_path }}
{{ cifmw_test_operator_artifacts_basedir }}
loop: "{{ logsPVCs.resources }}"
loop_control:
Expand Down Expand Up @@ -249,7 +249,7 @@
kind: Pod
state: absent
api_version: v1
name: "test-operator-logs-pod-{{ run_test_fw }}"
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}"
namespace: "{{ cifmw_test_operator_namespace }}"
wait: true
when:
Expand Down
4 changes: 0 additions & 4 deletions roles/test_operator/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
# under the License.

cifmw_test_operator_controller_priv_key_secret_name: "test-operator-controller-priv-key"
cifmw_test_operator_tempest_name: "tempest-tests"
cifmw_test_operator_tobiko_name: "tobiko-tests"
cifmw_test_operator_ansibletest_name: "ansibletest"
cifmw_test_operator_horizontest_name: "horizontest-tests"
cifmw_test_operator_tempest_kind_name: "Tempest"
cifmw_test_operator_tobiko_kind_name: "Tobiko"
cifmw_test_operator_ansibletest_kind_name: "AnsibleTest"
Expand Down

0 comments on commit 4bc0d24

Please sign in to comment.