| # Copyright (c) 2022 VEXXHOST, Inc. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| # not use this file except in compliance with the License. You may obtain |
| # a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations |
| # under the License. |
| |
| - name: Generate OpenStack-Helm endpoints |
| ansible.builtin.include_role: |
| name: openstack_helm_endpoints |
| vars: |
| openstack_helm_endpoints_chart: tempest |
| |
| - name: Configure tempest |
| block: |
| - name: Get test image object |
| openstack.cloud.image_info: |
| cloud: atmosphere |
| image: cirros |
| register: _tempest_test_image |
| when: tempest_helm_values.conf.tempest.compute.image_ref is not defined |
| |
| - name: Configure test image ref |
| ansible.builtin.set_fact: |
| tempest_helm_values: "{{ tempest_helm_values | default({}) | combine({item.key: item.value}, recursive=True) }}" |
| with_dict: |
| conf: |
| tempest: |
| compute: |
| image_ref: "{{ _tempest_test_image.images.0.id }}" |
| when: |
| - tempest_helm_values.conf.tempest.compute.image_ref is not defined |
| - _tempest_test_image.images | length > 0 |
| |
| - name: Get test flavor object |
| openstack.cloud.compute_flavor_info: |
| cloud: atmosphere |
| name: m1.tiny |
| register: _tempest_test_flavor |
| when: tempest_helm_values.conf.tempest.compute.flavor_ref is not defined |
| |
| - name: Set test flavor ref |
| ansible.builtin.set_fact: |
| tempest_helm_values: "{{ tempest_helm_values | default({}) | combine({item.key: item.value}, recursive=True) }}" |
| with_dict: |
| conf: |
| tempest: |
| compute: |
| flavor_ref: "{{ _tempest_test_flavor.flavors[0].id }}" |
| when: |
| - tempest_helm_values.conf.tempest.compute.flavor_ref is not defined |
| - _tempest_test_flavor.flavors[0].id is defined |
| |
| - name: Get test network object |
| openstack.cloud.networks_info: |
| cloud: atmosphere |
| name: public |
| register: _tempest_test_network |
| when: tempest_helm_values.conf.tempest.network.public_network_id is not defined |
| |
| - name: Set test network ref |
| ansible.builtin.set_fact: |
| tempest_helm_values: "{{ tempest_helm_values | default({}) | combine({item.key: item.value}, recursive=True) }}" |
| with_dict: |
| conf: |
| tempest: |
| network: |
| public_network_id: "{{ _tempest_test_network.networks[0].id }}" |
| when: |
| - tempest_helm_values.conf.tempest.network.public_network_id is not defined |
| - _tempest_test_network.networks[0].id is defined |
| |
| - name: Deploy Helm chart |
| failed_when: false |
| run_once: true |
| kubernetes.core.helm: |
| name: "{{ tempest_helm_release_name }}" |
| chart_ref: "{{ tempest_helm_chart_ref }}" |
| release_namespace: "{{ tempest_helm_release_namespace }}" |
| kubeconfig: "{{ tempest_helm_kubeconfig }}" |
| values: "{{ _tempest_helm_values | combine(_tempest_network_backend_settings[atmosphere_network_backend], recursive=True) | combine(tempest_helm_values, recursive=True) }}" # noqa: yaml[line-length] |
| wait: true |
| wait_timeout: 20m |
| |
| - name: Get tempest job object |
| kubernetes.core.k8s_info: |
| api_version: batch/v1 |
| kind: Job |
| name: tempest-run-tests |
| namespace: openstack |
| register: _tempest_job_obj |
| |
| - name: Get tempest log |
| kubernetes.core.k8s_log: |
| namespace: openstack |
| label_selectors: |
| - job-name=tempest-run-tests |
| register: _tempest_log |
| |
| - name: Print tempest log details |
| ansible.builtin.debug: |
| msg: "{{ _tempest_log.log_lines }}" |
| |
| - name: Fail when tempest result is failed |
| ansible.builtin.fail: |
| msg: "Tempest failed!" |
| when: _tempest_job_obj.resources[0]['status']['succeeded'] is not defined or |
| _tempest_job_obj.resources[0]['status']['succeeded'] != 1 |