Skip to content

Commit d9c9b67

Browse files
authored
Add deferred cleanup option for autoscaling tests (infrawatch#314)
* Add deferred cleanup option for autoscaling tests Introduces a new variable (default: true) that controls when autoscaling stack cleanup runs. When set to false, cleanup is deferred to an always block in the playbook, ensuring resources are properly torn down even if tests fail. Changes: - Add telemetry_autoscaling_cleanup variable to role defaults - Make cleanup task conditional on telemetry_autoscaling_cleanup flag - Move cleanup to always block in run_autoscaling_tests.yml playbook - Document new variable in role README Assisted-by: claude * [ci] Delete instance created by make edpm_deploy_instance
1 parent 926036a commit d9c9b67

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

ci/run_autoscaling_tests.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,22 @@
6262
- name: "Run Telemetry Autoscaling tests"
6363
ansible.builtin.import_role:
6464
name: telemetry_autoscaling
65+
vars:
66+
telemetry_autoscaling_cleanup: false
6567
ignore_errors: true
6668

6769
- name: "Run Telemetry Verify Metrics tests"
6870
ansible.builtin.import_role:
6971
name: telemetry_verify_metrics
7072
ignore_errors: true
73+
74+
always:
75+
- name: "Run Telemetry Autoscaling cleanup"
76+
ansible.builtin.include_role:
77+
name: telemetry_autoscaling
78+
tasks_from: post_teardown
79+
80+
- name: Delete test_0 VM
81+
ansible.builtin.shell:
82+
cmd: |
83+
{{ openstack_cmd }} server delete test_0

roles/telemetry_autoscaling/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ The following resources are required in the OpenStack cloud
1212
* a flavor called m1.small
1313
* an image called cirros
1414

15+
Role Variables
16+
--------------
17+
* `telemetry_autoscaling_cleanup` (default: `true`) - Controls whether the autoscaling stack
18+
cleanup task runs at the end of the role. Set to `false` to skip cleanup during the main role
19+
execution, allowing cleanup to be deferred to a later task (e.g., in a block's `always`
20+
section to ensure cleanup runs even on failure).
21+
1522
Tests:
1623
------
1724
* Verify overcloud deployment for autoscaling

roles/telemetry_autoscaling/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
openstack_cmd: "openstack"
44
stack_name: vnf
55
metrics_backend: gnocchi
6+
telemetry_autoscaling_cleanup: true

roles/telemetry_autoscaling/tasks/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
tags: test
3131

3232
- name: Run the cleanup task
33-
ansible.builtin.include_tasks:
33+
ansible.builtin.include_tasks:
3434
file: post_teardown.yml
35+
when: telemetry_autoscaling_cleanup | bool
3536
tags: cleanup

0 commit comments

Comments
 (0)