summaryrefslogtreecommitdiff
path: root/tasks/main.yml
blob: ec8b6f9670bc2bed0ed322e907a046416dc4b5d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
- name: Install Red Hat Certification rpms
  include: prepare.yml

- name: Test if rhosp-release is available (OSP10 and above)
  package:
    list: rhosp-release
  register: rhosp_status

- name: Install rhosp-release
  become: True
  package:
    name: rhosp-release
    state: latest
  when: rhosp_status.results|length >= 1

- name: Combine all certification tags, tests and programs
  set_fact:
    all_certification_types: '{{ openstack_certification_tags }} + {{ openstack_certification_tests }} + {{ openstack_certification_programs }}'

- block:
    - name: Register keystone_auth_url
      shell: "source {{ openstack_certification_overcloudrc }} && echo \"$OS_AUTH_URL\""
      register: keystone_auth_url

    - name: Register admin_username
      shell: "source {{ openstack_certification_overcloudrc }} && echo \"$OS_USERNAME\""
      register: admin_username

    - name: Register admin_password
      shell: "source {{ openstack_certification_overcloudrc }} && echo \"$OS_PASSWORD\""
      register: admin_password

    - name: Register admin_tenant_name
      shell: "source {{ openstack_certification_overcloudrc }} && echo \"$OS_TENANT_NAME\""
      register: admin_tenant_name

    - name: Register admin_project_name
      shell: "source {{ openstack_certification_overcloudrc }} && echo \"$OS_PROJECT_NAME\""
      register: admin_project_name

    - name: Create the test_config.json file
      become: True
      template:
        src: test_config.json.j2
        dest: /etc/redhat-certification-openstack/test_config.json

    - name: copy the tempest configuration file
      become: True
      copy:
        src: '{{ openstack_certification_tempest_conf_path }}'
        dest: /etc/redhat-certification-openstack
        remote_src: '{{ openstack_certification_tempest_conf_path_is_remote|bool }}'
      when: openstack_certification_tempest_conf_path is defined
  when: 'baremetal' not in all_certification_types

- name: Create the baremetal.json file
  become: True
  template:
    src: baremetal.json
    dest: /etc/redhat-certification-openstack/baremetal.json
  when: 'baremetal' in all_certification_types

- name: Run certification test suite with tag argument
  become: True
  shell: >
    set -x
    rhcert-ci clean all && rhcert-ci run --tag {{ item }} && rhcert-ci save
  with_items: "{{ openstack_certification_tags }}"
  ignore_errors: True
  when: openstack_certification_test_type == "tag"

- name: Run certification test suite with program argument
  become: True
  shell: >
    set -x
    rhcert-ci clean all && rhcert-ci run --program {{ item }} && rhcert-ci save
  with_items: "{{ openstack_certification_programs }}"
  ignore_errors: True
  when: openstack_certification_test_type == "program"

- name: Run certification test suite with test argument
  become: True
  shell: >
    set -x
    rhcert-ci clean all && rhcert-ci run --test {{" --test ".join(openstack_certification_tests)}} && rhcert-ci save
  ignore_errors: True
  when: openstack_certification_test_type != "tag" and openstack_certification_test_type != "program"

- name: Retrieve certification test results
  become: True
  shell: rhcert-ci print --format {{ openstack_certification_output_format }} | tail -n +2 | tee {{ openstack_certification_output_filename }}

- name: Download output file
  become: True
  fetch:
    src: '{{ openstack_certification_output_filename }}'
    dest: "{{ openstack_certification_dest_dir }}/{{ openstack_certification_output_filename }}"
    flat: yes

- block:
  - name: Compress results file
    become: True
    archive:
      path: /var/rhcert/results.xml
      dest: /home/stack/certification.xml.gz
      format: gz

  - name: Download results file
    become: True
    fetch:
      src: 'certification.xml.gz'
      dest: "{{ openstack_certification_dest_dir }}/certification.xml.gz"
      flat: yes
  when: openstack_certification_results_download|bool

- name: Tempest cleanup
  become: True
  file:
    path: /tmp/tempest-lock
    state: absent
  when: "'tempest_config' in openstack_certification_tests"