blob: 3440b2d57aac3628190399fe80f8166804953307 [file] [log] [blame]
Mohammed Naser2145fc32023-01-29 23:23:03 +00001# Copyright (c) 2022 VEXXHOST, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15- name: Generate OpenStack-Helm endpoints
16 ansible.builtin.include_role:
17 name: openstack_helm_endpoints
18 vars:
19 openstack_helm_endpoints_chart: tempest
20
21- name: Configure tempest
22 block:
23 - name: Get test image object
24 openstack.cloud.image_info:
25 cloud: atmosphere
26 image: cirros
27 register: _tempest_test_image
28 when: tempest_helm_values.conf.tempest.compute.image_ref is not defined
29
30 - name: Configure test image ref
31 ansible.builtin.set_fact:
32 tempest_helm_values: "{{ tempest_helm_values | default({}) | combine({item.key: item.value}, recursive=True) }}"
33 with_dict:
34 conf:
35 tempest:
36 compute:
Mohammed Naser8ccabb62025-02-05 13:20:09 -050037 image_ref: "{{ _tempest_test_image.images.0.id }}"
Mohammed Naser2145fc32023-01-29 23:23:03 +000038 when:
39 - tempest_helm_values.conf.tempest.compute.image_ref is not defined
Mohammed Naser8ccabb62025-02-05 13:20:09 -050040 - _tempest_test_image.images | length > 0
Mohammed Naser2145fc32023-01-29 23:23:03 +000041
42 - name: Get test flavor object
43 openstack.cloud.compute_flavor_info:
44 cloud: atmosphere
45 name: m1.tiny
46 register: _tempest_test_flavor
47 when: tempest_helm_values.conf.tempest.compute.flavor_ref is not defined
48
49 - name: Set test flavor ref
50 ansible.builtin.set_fact:
51 tempest_helm_values: "{{ tempest_helm_values | default({}) | combine({item.key: item.value}, recursive=True) }}"
52 with_dict:
53 conf:
54 tempest:
55 compute:
Mohammed Naser8ccabb62025-02-05 13:20:09 -050056 flavor_ref: "{{ _tempest_test_flavor.flavors[0].id }}"
Mohammed Naser2145fc32023-01-29 23:23:03 +000057 when:
58 - tempest_helm_values.conf.tempest.compute.flavor_ref is not defined
Mohammed Naser8ccabb62025-02-05 13:20:09 -050059 - _tempest_test_flavor.flavors[0].id is defined
Mohammed Naser2145fc32023-01-29 23:23:03 +000060
61 - name: Get test network object
62 openstack.cloud.networks_info:
63 cloud: atmosphere
64 name: public
65 register: _tempest_test_network
66 when: tempest_helm_values.conf.tempest.network.public_network_id is not defined
67
68 - name: Set test network ref
69 ansible.builtin.set_fact:
70 tempest_helm_values: "{{ tempest_helm_values | default({}) | combine({item.key: item.value}, recursive=True) }}"
71 with_dict:
72 conf:
73 tempest:
74 network:
Mohammed Naser8ccabb62025-02-05 13:20:09 -050075 public_network_id: "{{ _tempest_test_network.networks[0].id }}"
Mohammed Naser2145fc32023-01-29 23:23:03 +000076 when:
77 - tempest_helm_values.conf.tempest.network.public_network_id is not defined
Mohammed Naser8ccabb62025-02-05 13:20:09 -050078 - _tempest_test_network.networks[0].id is defined
Mohammed Naser2145fc32023-01-29 23:23:03 +000079
80- name: Deploy Helm chart
81 failed_when: false
82 run_once: true
83 kubernetes.core.helm:
84 name: "{{ tempest_helm_release_name }}"
85 chart_ref: "{{ tempest_helm_chart_ref }}"
86 release_namespace: "{{ tempest_helm_release_namespace }}"
Austin Talbot78a774a2024-09-25 10:15:36 -060087 kubeconfig: "{{ tempest_helm_kubeconfig }}"
Mohammed Naserc6350c42023-07-23 20:35:29 +000088 values: "{{ _tempest_helm_values | combine(_tempest_network_backend_settings[atmosphere_network_backend], recursive=True) | combine(tempest_helm_values, recursive=True) }}" # noqa: yaml[line-length]
Mohammed Naser2145fc32023-01-29 23:23:03 +000089 wait: true
90 wait_timeout: 20m
91
92- name: Get tempest job object
93 kubernetes.core.k8s_info:
94 api_version: batch/v1
95 kind: Job
96 name: tempest-run-tests
97 namespace: openstack
98 register: _tempest_job_obj
99
100- name: Get tempest log
101 kubernetes.core.k8s_log:
102 namespace: openstack
103 label_selectors:
104 - job-name=tempest-run-tests
105 register: _tempest_log
106
107- name: Print tempest log details
108 ansible.builtin.debug:
109 msg: "{{ _tempest_log.log_lines }}"
110
111- name: Fail when tempest result is failed
112 ansible.builtin.fail:
113 msg: "Tempest failed!"
114 when: _tempest_job_obj.resources[0]['status']['succeeded'] is not defined or
115 _tempest_job_obj.resources[0]['status']['succeeded'] != 1