aboutsummaryrefslogtreecommitdiff
path: root/tests/post.yml
blob: 46e4370960d134a1cd25008b67c3c3456225ce9f (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
- hosts: all
  vars:
    logs_dir: "/tmp/logs"
  roles:
    - role: fetch-subunit-output
      zuul_work_dir: '/home/zuul/tempest'

  tasks:
    # TODO(mhiner): Currently only Docker to Podman migration is tested.
    # If we want to test the other direction we have to rework this.
    - name: Change container engine after the migration
      set_fact:
        container_engine: "podman"
      when: scenario == "container-engine-migration"

    - name: Print all facts
      copy:
        content: "{{ hostvars[inventory_hostname] | to_nice_json }}"
        dest: "{{ logs_dir }}/facts.json"

    # NOTE(yoctozepto): this might not have been run during the
    # regular run due to some earlier failure, yet logs content may
    # still provide insight into that other, breaking issue
    - name: Run check-logs.sh script
      script: check-logs.sh
      failed_when: false
      when: not zuul_success | bool
      register: check_logs_result

    - name: Print check-logs output
      debug:
        msg: "{{ check_logs_result.stdout }}"
      when: not check_logs_result.skipped | default(False)

    - name: Run diagnostics script
      environment:
        CONTAINER_ENGINE: "{{ container_engine }}"
        KOLLA_INTERNAL_VIP_ADDRESS: "{{ kolla_internal_vip_address }}"
      script: get_logs.sh
      register: get_logs_result
      become: true
      failed_when: false

    - name: Print get_logs output
      debug:
        msg: "{{ get_logs_result.stdout }}"

    - name: Download /etc/hosts file to executor
      synchronize:
        src: "/etc/hosts"
        dest: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/"
        mode: pull
      ignore_errors: yes

    - name: Dump all iptables rules
      shell: "iptables-save > /tmp/logs/iptables"
      args:
        creates: /tmp/logs/iptables
      become: true

    - name: Download /tmp/logs file to executor
      synchronize:
        src: "/tmp/logs"
        dest: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/"
        mode: pull
        rsync_opts:
          - "--quiet"

- hosts: primary
  environment:
    PATH: >-
      {{ ansible_env.HOME + '/kolla-ansible-venv/bin:'
      + ansible_env.PATH }}
  vars:
    ara_report_local_dir: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/ara-report"
    kolla_ansible_local_src_dir: "{{ zuul.executor.work_root }}/src/{{ zuul.project.canonical_hostname }}/openstack/kolla-ansible"
  tasks:
    - name: Download testinfra to executor
      synchronize:
        src: "/home/zuul/testinfra"
        dest: "{{ zuul.executor.log_root }}/"
        mode: pull
      # TODO(mnasiadka): Remove in G/2026.1 cycle
      ignore_errors: true

    - name: Return artifact to Zuul
      zuul_return:
        data:
          zuul:
            artifacts:
              - name: "TestInfra Unit Test Report"
                url: "testinfra/test-results-testinfra.html"
                metadata:
                  type: unit_test_report
              - name: "TestInfra Screenshots"
                url: "testinfra/screenshots"

    - name: Check for existence of ara sqlite
      stat:
        path: "{{ ansible_env.HOME }}/.ara/server/ansible.sqlite"
      register: ara_stat_result

    - block:
        - name: Ensure ara-report folder existence
          file:
            path: "{{ ara_report_local_dir }}"
            state: directory
          delegate_to: localhost

        - name: Download ara sqlite
          synchronize:
            src: "{{ ansible_env.HOME }}/.ara/server/ansible.sqlite"
            dest: "{{ ara_report_local_dir }}/"
            mode: pull

        - name: Get ara version
          command: "ara --version"
          register: ara_version

        - name: Template ara readme
          template:
            src: "{{ kolla_ansible_local_src_dir }}/tests/ara-readme.md.j2"
            dest: "{{ ara_report_local_dir }}/README.md"
            mode: '0644'
          delegate_to: localhost

        - name: Generate HTML from ARA database
          command: "ara-manage generate {{ ansible_env.HOME }}/ara-html"
          when: (zuul.change_message | default('')) is search('#ara_verbose')

        - name: Download ARA HTML
          synchronize:
            src: "{{ ansible_env.HOME }}/ara-html"
            dest: "{{ ara_report_local_dir }}/"
            mode: pull
            rsync_opts:
              - "--quiet"
          when: (zuul.change_message | default('')) is search('#ara_verbose')
      when: ara_stat_result.stat.exists