Browse Source

Convert tox to native zuul

This change implements a native zuul runner for all role tests.
The change will now run role tests, executing molecule, in the
same was as tripleo-ansible.

To ensure we're passing lint checks, several files have been
updated to resolve lint issues which are now more strict due
to the pre-commit changes.

Scripts have been added to allow developers to run molecule tests
on local environments. These tools will allow developers to mimic
the upstream test process locally.

Change-Id: I07bbcc0b331aa89dafdae5978ea2bb4859a59143
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
(cherry picked from commit 4908e1647f)
tags/10.5.1
Gael Chamoulaud 1 month ago
parent
commit
93bee0f53c

+ 1
- 1
.pre-commit-config.yaml View File

@@ -11,7 +11,7 @@ repos:
11 11
       - id: check-merge-conflict
12 12
       - id: debug-statements
13 13
       - id: flake8
14
-        entry: flake8 --ignore=E123,E125,W503,W504,W605
14
+        entry: flake8 --ignore=E24,E121,E122,E123,E124,E126,E226,E265,E305,E402,F401,F405,E501,E704,F403,F841,W503,W605
15 15
       - id: check-yaml
16 16
         files: .*\.(yaml|yml)$
17 17
   - repo: https://github.com/adrienverge/yamllint.git

+ 22
- 0
ansible-test-env.rc View File

@@ -0,0 +1,22 @@
1
+export TRIPLEO_VALIDATIONS_WORKPATH="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
2
+export ANSIBLE_STDOUT_CALLBACK=debug
3
+export ANSIBLE_CALLBACK_PLUGINS="${TRIPLEO_VALIDATIONS_WORKPATH}/callback_plugins"
4
+export ANSIBLE_LIBRARY="${TRIPLEO_VALIDATIONS_WORKPATH}/library"
5
+export ANSIBLE_LOOKUP_PLUGINS="${TRIPLEO_VALIDATIONS_WORKPATH}/lookup_plugins"
6
+export ANSIBLE_ROLES_PATH="${TRIPLEO_VALIDATIONS_WORKPATH}/roles"
7
+export ANSIBLE_INVENTORY="${TRIPLEO_VALIDATIONS_WORKPATH}/tests/hosts.ini"
8
+export ANSIBLE_RETRY_FILES_ENABLED="0"
9
+export ANSIBLE_LOAD_CALLBACK_PLUGINS="1"
10
+export ANSIBLE_HOST_KEY_CHECKING=False
11
+
12
+function unset-ansible-test-env {
13
+  for i in $(env | grep ANSIBLE_ | awk -F'=' '{print $1}'); do
14
+    unset ${i}
15
+  done
16
+  unset TRIPLEO_VALIDATIONS_WORKPATH
17
+  echo -e "Ansible test environment deactivated.\n"
18
+  unset -f unset-ansible-test-env
19
+}
20
+
21
+echo -e "Ansible test environment is now active"
22
+echo -e "Run 'unset-ansible-test-env' to deactivate.\n"

+ 3
- 2
callback_plugins/validation_output.py View File

@@ -175,8 +175,9 @@ class CallbackModule(CallbackBase):
175 175
 
176 176
     def v2_playbook_on_stats(self, stats):
177 177
         def failed(host):
178
-            return (stats.summarize(host).get('failures', 0) > 0 or
179
-                    stats.summarize(host).get('unreachable', 0) > 0)
178
+            _failures = stats.summarize(host).get('failures', 0) > 0
179
+            _unreachable = stats.summarize(host).get('unreachable', 0) > 0
180
+            return (_failures or _unreachable)
180 181
 
181 182
         hosts = sorted(stats.processed.keys())
182 183
         failed_hosts = [host for host in hosts if failed(host)]

+ 34
- 0
doc/source/readme.rst View File

@@ -524,3 +524,37 @@ will perform the basic tasks noted above.
524 524
 
525 525
     $ cd tripleo-validations/
526 526
     $ ansible-playbook -i localhost, role-addition.yml -e role_name=${NEWROLENAME}
527
+
528
+When the role is ready for CI, add a **job** entry into the
529
+`zuul.d/molecule.yaml`.
530
+
531
+.. code-block:: yaml
532
+
533
+    - job:
534
+        files:
535
+        - ^roles/${NEWROLENAME}/.*
536
+        name: tripleo-validations-centos-7-molecule-${NEWROLENAME}
537
+        parent: tripleo-validations-centos-7-base
538
+        vars:
539
+          tripleo_validations_role_name: ${NEWROLENAME}
540
+
541
+
542
+Make sure to add the **job** name into the check and gate section at the top
543
+of the `molecule.yaml` file.
544
+
545
+.. code-block:: yaml
546
+
547
+    - project:
548
+        check:
549
+          jobs:
550
+            - tripleo-validations-centos-7-molecule-${NEWROLENAME}
551
+        gate:
552
+          jobs:
553
+            - tripleo-validations-centos-7-molecule-${NEWROLENAME}
554
+
555
+
556
+Finally add a role documentation file at
557
+`doc/source/roles/role-${NEWROLENAME}.rst`. This file will need to contain
558
+a title, a literal include of the defaults yaml and a literal include of
559
+the molecule playbook, or playbooks, used to test the role, which is noted
560
+as an "example" playbook.

+ 45
- 0
role-addition.yml View File

@@ -34,6 +34,51 @@
34 34
       args:
35 35
         creates: "roles/{{ role_name }}"
36 36
 
37
+    - name: Read zuul molecule file
38
+      slurp:
39
+        src: zuul.d/molecule.yaml
40
+      register: molecule_yaml
41
+
42
+    - name: Create molecule entry
43
+      copy:
44
+        content: |-
45
+          ---
46
+          {% set items = molecule_yaml['content'] | b64decode | from_yaml %}
47
+          {% set job_index = [] %}
48
+          {% set new_job_name = "tripleo-validations-centos-7-molecule-" ~ role_name %}
49
+          {% for item in items %}
50
+          {%   if 'project-template' in item %}
51
+          {%     if item['project-template']['name'] == "tripleo-validations-molecule-jobs" %}
52
+          {%       if not (new_job_name in item['project-template']['check']['jobs']) %}
53
+          {%         set _ = item['project-template']['check']['jobs'].append(new_job_name) %}
54
+          {%       endif %}
55
+          {%       if not (new_job_name in item['project-template']['gate']['jobs']) %}
56
+          {%         set _ = item['project-template']['gate']['jobs'].append(new_job_name) %}
57
+          {%       endif %}
58
+          {%     endif %}
59
+          {%   else %}
60
+          {%     if item['job']['name'] == new_job_name %}
61
+          {%       set _ = job_index.append(new_job_name) %}
62
+          {%     endif %}
63
+          {%   endif %}
64
+          {% endfor %}
65
+          {% if (job_index | length) < 1 %}
66
+          {%   set new_job = {
67
+                  "name": new_job_name,
68
+                  "parent": "tripleo-validations-centos-7-base",
69
+                  "files": [
70
+                    "^roles/" ~ role_name ~ "/.*"
71
+                  ],
72
+                  "vars": {
73
+                    "tripleo_validations_role_name": role_name
74
+                  }
75
+               }
76
+          %}
77
+          {%   set _ = items.append({"job": new_job}) %}
78
+          {% endif %}
79
+          {{ items | to_nice_yaml(indent=2, width=1337) }}
80
+        dest: zuul.d/molecule.yaml
81
+
37 82
     - name: Create role documentation
38 83
       copy:
39 84
         content: |

+ 1
- 0
roles/service-status/tasks/main.yaml View File

@@ -4,6 +4,7 @@
4 4
     systemctl list-units --failed --plain --no-legend --no-pager |
5 5
     awk '{print $1}'
6 6
   register: systemd_status
7
+  changed_when: False
7 8
 
8 9
 - name: Fails if we find failed units
9 10
   assert:

+ 45
- 0
scripts/bindep-install View File

@@ -0,0 +1,45 @@
1
+#!/usr/bin/env bash
2
+# Copyright 2019 Red Hat, Inc.
3
+# All Rights Reserved.
4
+#
5
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+# not use this file except in compliance with the License. You may obtain
7
+# a copy of the License at
8
+#
9
+#     http://www.apache.org/licenses/LICENSE-2.0
10
+#
11
+# Unless required by applicable law or agreed to in writing, software
12
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+# License for the specific language governing permissions and limitations
15
+# under the License.
16
+
17
+
18
+## Shell Opts ----------------------------------------------------------------
19
+
20
+set -o pipefail
21
+set -xeuo
22
+
23
+
24
+## Vars ----------------------------------------------------------------------
25
+
26
+export BINDEP_FILE="${BINDEP_FILE:-$(dirname $(readlink -f ${BASH_SOURCE[0]}))/../bindep.txt}"
27
+
28
+
29
+## Main ----------------------------------------------------------------------
30
+
31
+# Source distribution information
32
+source /etc/os-release || source /usr/lib/os-release
33
+RHT_PKG_MGR=$(command -v dnf || command -v yum)
34
+
35
+# NOTE(cloudnull): Get a list of packages to install with bindep. If packages
36
+#                  need to be installed, bindep exits with an exit code of 1.
37
+BINDEP_PKGS=$(bindep -b -f "${BINDEP_FILE}" test || true)
38
+
39
+if [[ ${#BINDEP_PKGS} > 0 ]]; then
40
+    case "${ID,,}" in
41
+        amzn|rhel|centos|fedora)
42
+            sudo "${RHT_PKG_MGR}" install -y ${BINDEP_PKGS}
43
+            ;;
44
+    esac
45
+fi

+ 70
- 0
scripts/run-local-test View File

@@ -0,0 +1,70 @@
1
+#!/usr/bin/env bash
2
+# Copyright 2019 Red Hat, Inc.
3
+# All Rights Reserved.
4
+#
5
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+# not use this file except in compliance with the License. You may obtain
7
+# a copy of the License at
8
+#
9
+#     http://www.apache.org/licenses/LICENSE-2.0
10
+#
11
+# Unless required by applicable law or agreed to in writing, software
12
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+# License for the specific language governing permissions and limitations
15
+# under the License.
16
+
17
+
18
+## Shell Opts ----------------------------------------------------------------
19
+
20
+set -o pipefail
21
+set -xeuo
22
+
23
+## Vars ----------------------------------------------------------------------
24
+
25
+export PROJECT_DIR="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/../"
26
+export ROLE_NAME="${ROLE_NAME:-$1}"
27
+export TRIPLEO_JOB_ANSIBLE_ARGS=${TRIPLEO_JOB_ANSIBLE_ARGS:-"-v"}
28
+
29
+## Main ----------------------------------------------------------------------
30
+
31
+# Source distribution information
32
+source /etc/os-release || source /usr/lib/os-release
33
+RHT_PKG_MGR=$(command -v dnf || command -v yum)
34
+PYTHON_EXEC=$(command -v python3 || command -v python)
35
+
36
+# Install the one requirement we need to run any local test
37
+case "${ID,,}" in
38
+    amzn|rhel|centos|fedora)
39
+        sudo "${RHT_PKG_MGR}" install -y python*-virtualenv
40
+        ;;
41
+esac
42
+
43
+# Create a virtual env
44
+"${PYTHON_EXEC}" -m virtualenv --system-site-packages "${HOME}/test-python"
45
+
46
+# Run bindep
47
+"${HOME}/test-python/bin/pip" install pip setuptools bindep --upgrade
48
+"${PROJECT_DIR}/scripts/bindep-install"
49
+
50
+# Install local requirements
51
+if [[ -d "${HOME}/.cache/pip/wheels" ]]; then
52
+    rm -rf "${HOME}/.cache/pip/wheels"
53
+fi
54
+"${HOME}/test-python/bin/pip" install \
55
+                              -r "${PROJECT_DIR}/requirements.txt" \
56
+                              -r "${PROJECT_DIR}/test-requirements.txt" \
57
+                              -r "${PROJECT_DIR}/molecule-requirements.txt"
58
+
59
+# Run local test
60
+PS1="[\u@\h \W]\$" source "${HOME}/test-python/bin/activate"
61
+source "${PROJECT_DIR}/ansible-test-env.rc"
62
+export ANSIBLE_ROLES_PATH="${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles"
63
+ansible-playbook -i "${PROJECT_DIR}/tests/hosts.ini" \
64
+                 -e "tripleo_src=$(realpath --relative-to="${HOME}" "${PROJECT_DIR}")" \
65
+                 -e "tripleo_validations_role_name=${ROLE_NAME}" \
66
+                 -e "tripleo_job_ansible_args='${TRIPLEO_JOB_ANSIBLE_ARGS}'" \
67
+                 -e "ansible_user=${USER}" \
68
+                 -e "ansible_user_dir=${HOME}" \
69
+                 "${PROJECT_DIR}/tests/prepare-test-host.yml" \
70
+                 "${PROJECT_DIR}/zuul.d/playbooks/run-local.yml"

+ 18
- 0
tests/conftest.py View File

@@ -0,0 +1,18 @@
1
+# Licensed under the Apache License, Version 2.0 (the "License");
2
+# you may not use this file except in compliance with the License.
3
+# You may obtain a copy of the License at
4
+#
5
+#    http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+# Unless required by applicable law or agreed to in writing, software
8
+# distributed under the License is distributed on an "AS IS" BASIS,
9
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10
+# implied.
11
+# See the License for the specific language governing permissions and
12
+# limitations under the License.
13
+
14
+
15
+def pytest_addoption(parser):
16
+    parser.addoption('--scenario', help='scenario setting')
17
+    parser.addoption(
18
+        '--ansible-args', help='ansible args passed into test runner.')

+ 1
- 0
tests/hosts.ini View File

@@ -0,0 +1 @@
1
+test ansible_connection=local ansible_host=localhost

+ 68
- 0
tests/prepare-test-host.yml View File

@@ -0,0 +1,68 @@
1
+---
2
+# Copyright 2019 Red Hat, Inc.
3
+# All Rights Reserved.
4
+#
5
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+# not use this file except in compliance with the License. You may obtain
7
+# a copy of the License at
8
+#
9
+#     http://www.apache.org/licenses/LICENSE-2.0
10
+#
11
+# Unless required by applicable law or agreed to in writing, software
12
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+# License for the specific language governing permissions and limitations
15
+# under the License.
16
+
17
+
18
+- name: pre prepare
19
+  hosts: all
20
+  gather_facts: false
21
+  tasks:
22
+    - name: set basic user fact
23
+      fail:
24
+        msg: >-
25
+          The variable `ansible_user` set this option and try again. On the
26
+          CLI this can be defined with "-e ansible_user=${USER}"
27
+      when:
28
+        - ansible_user is undefined
29
+
30
+    - name: set basic home fact
31
+      fail:
32
+        msg: >-
33
+          The variable `ansible_user_dir` set this option and try again. On
34
+          the CLI this can be defined with "-e ansible_user_dir=${HOME}"
35
+      when:
36
+        - ansible_user_dir is undefined
37
+
38
+    - name: Ensure the user has a .ssh directory
39
+      file:
40
+        path: "{{ ansible_user_dir }}/.ssh"
41
+        state: directory
42
+        owner: "{{ ansible_user }}"
43
+        group: "{{ ansible_user }}"
44
+        mode: "0700"
45
+
46
+    - name: Create ssh key pair
47
+      user:
48
+        name: "{{ ansible_user }}"
49
+        generate_ssh_key: true
50
+        ssh_key_bits: 2048
51
+        ssh_key_file: "{{ ansible_user_dir }}/.ssh/id_rsa"
52
+
53
+    - name: Slurp pub key
54
+      slurp:
55
+        src: "{{ ansible_user_dir ~ '/.ssh/id_rsa.pub' }}"
56
+      register: pub_key
57
+
58
+    - name: Ensure can ssh to can connect to localhost
59
+      authorized_key:
60
+        user: "{{ ansible_user }}"
61
+        key: "{{ pub_key['content'] | b64decode }}"
62
+
63
+    - name: Get the zuul/zuul-jobs repo
64
+      git:
65
+        repo: https://opendev.org/zuul/zuul-jobs
66
+        dest: "{{ ansible_user_dir }}/zuul-jobs"
67
+        version: master
68
+        force: true

+ 44
- 0
tests/test_molecule.py View File

@@ -0,0 +1,44 @@
1
+# Licensed under the Apache License, Version 2.0 (the "License");
2
+# you may not use this file except in compliance with the License.
3
+# You may obtain a copy of the License at
4
+#
5
+#    http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+# Unless required by applicable law or agreed to in writing, software
8
+# distributed under the License is distributed on an "AS IS" BASIS,
9
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10
+# implied.
11
+# See the License for the specific language governing permissions and
12
+# limitations under the License.
13
+
14
+
15
+import pytest
16
+import subprocess
17
+
18
+
19
+def test_molecule(pytestconfig):
20
+    cmd = ['python', '-m', 'molecule']
21
+    scenario = pytestconfig.getoption("scenario")
22
+    ansible_args = pytestconfig.getoption("ansible_args")
23
+
24
+    if ansible_args:
25
+        cmd.append('converge')
26
+        if scenario:
27
+            cmd.extend(['--scenario-name', scenario])
28
+        cmd.append('--')
29
+        cmd.extend(ansible_args.split())
30
+    else:
31
+        cmd.append('test')
32
+        if scenario:
33
+            cmd.extend(['--scenario-name', scenario])
34
+        else:
35
+            cmd.append('--all')
36
+
37
+    try:
38
+        assert subprocess.call(cmd) == 0
39
+    finally:
40
+        if ansible_args:
41
+            cmd = ['python', '-m', 'molecule', 'destroy']
42
+            if scenario:
43
+                cmd.extend(['--scenario-name', scenario])
44
+            subprocess.call(cmd)

+ 0
- 20
tox.ini View File

@@ -82,7 +82,6 @@ deps =
82 82
     -r {toxinidir}/test-requirements.txt
83 83
     -r {toxinidir}/molecule-requirements.txt
84 84
 commands =
85
-    {[testenv:pep8]commands}
86 85
     {[testenv:ansible-lint]commands}
87 86
     {[testenv:bashate]commands}
88 87
     {[testenv:whitespace]commands}
@@ -117,25 +116,6 @@ commands=
117 116
 extensions = .rst
118 117
 ignore = D001
119 118
 
120
-[testenv:venv]
121
-commands = {posargs}
122
-
123
-[testenv:molecule]
124
-basepython = python3
125
-deps =
126
-    ansi2html
127
-    docker>=3.7
128
-    mock
129
-    molecule>=2.22rc3
130
-    pytest>=4.4.0
131
-    pytest-cov
132
-    pytest-html
133
-    pytest-molecule>=1.0rc1
134
-    pytest-xdist
135
-    selinux
136
-commands =
137
-    python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {posargs:roles}
138
-
139 119
 [testenv:lower-constraints]
140 120
 basepython = python3
141 121
 deps =

+ 8
- 4
tripleo_validations/tests/library/test_ip_range.py View File

@@ -59,10 +59,14 @@ class TestIPRange(base.TestCase):
59 59
         '''Test ip_range when range is less than minimal'''
60 60
         errors = validation.check_IP_range('192.168.0.1', '192.168.0.5', 6)
61 61
         self.assertEqual(len(errors), 2)
62
-        self.assertEqual('The IP range 192.168.0.1 - 192.168.0.5 ' +
63
-                         'contains 5 addresses.', errors[0])
64
-        self.assertEqual('This might not be enough for the deployment ' +
65
-                         'or later scaling.', errors[1])
62
+        self.assertEqual(
63
+            'The IP range 192.168.0.1 - 192.168.0.5 contains 5 addresses.',
64
+            errors[0]
65
+        )
66
+        self.assertEqual(
67
+            'This might not be enough for the deployment or later scaling.',
68
+            errors[1]
69
+        )
66 70
 
67 71
     def test_check_lower_bound_greater_than_upper(self):
68 72
         """Test ip_range when lower IP bound is greater than upper"""

+ 3
- 2
validations/callback_plugins/validation_output.py View File

@@ -175,8 +175,9 @@ class CallbackModule(CallbackBase):
175 175
 
176 176
     def v2_playbook_on_stats(self, stats):
177 177
         def failed(host):
178
-            return (stats.summarize(host).get('failures', 0) > 0 or
179
-                    stats.summarize(host).get('unreachable', 0) > 0)
178
+            _failures = stats.summarize(host).get('failures', 0) > 0
179
+            _unreachable = stats.summarize(host).get('unreachable', 0) > 0
180
+            return (_failures or _unreachable)
180 181
 
181 182
         hosts = sorted(stats.processed.keys())
182 183
         failed_hosts = [host for host in hosts if failed(host)]

+ 2
- 3
validations/files/rogue_dhcp.py View File

@@ -109,9 +109,8 @@ class DHCPDiscover(object):
109 109
 
110 110
     def udp_checksum(self):
111 111
         pseudo_header = self.ip_pseudo_header()
112
-        generated_checksum = self._checksum(pseudo_header +
113
-                                            self.udp_header(checksum=0) +
114
-                                            self.dhcp_discover_payload())
112
+        generated_checksum = self._checksum(pseudo_header + self.udp_header(
113
+            checksum=0) + self.dhcp_discover_payload())
115 114
         return socket.htons(generated_checksum)
116 115
 
117 116
     def ip_pseudo_header(self):

+ 21
- 0
zuul.d/base.yaml View File

@@ -0,0 +1,21 @@
1
+---
2
+- job:
3
+    description: Base tripleo-validations job
4
+    name: tripleo-validations-centos-7-base
5
+    nodeset: centos-7
6
+    parent: base
7
+    success-url: "reports.html"
8
+    failure-url: "reports.html"
9
+    pre-run:
10
+    - tests/prepare-test-host.yml
11
+    - zuul.d/playbooks/pre.yml
12
+    run:
13
+    - zuul.d/playbooks/run.yml
14
+    timeout: 1800
15
+    voting: true
16
+- job:
17
+    files:
18
+    - ^doc/.*
19
+    - ^README.rst
20
+    name: tripleo-validations-docs
21
+    parent: openstack-tox-docs

+ 6
- 1
zuul.d/layout.yaml View File

@@ -4,12 +4,13 @@
4 4
     - openstack-python-jobs
5 5
     - openstack-python35-jobs
6 6
     - openstack-python36-jobs
7
+    - tripleo-validations-molecule-jobs
7 8
     - check-requirements
8
-    - publish-openstack-docs-pti
9 9
     - release-notes-jobs-python3
10 10
     check:
11 11
       jobs:
12 12
       - openstack-tox-linters
13
+      - tripleo-validations-docs
13 14
       - openstack-tox-lower-constraints
14 15
       - tripleo-ci-centos-7-scenario004-standalone:
15 16
           files:
@@ -17,7 +18,11 @@
17 18
     gate:
18 19
       jobs:
19 20
       - openstack-tox-linters
21
+      - tripleo-validations-docs
20 22
       - openstack-tox-lower-constraints
21 23
       - tripleo-ci-centos-7-scenario004-standalone:
22 24
           files:
23 25
             - ^roles/ceph.*$
26
+    post:
27
+      jobs:
28
+      - publish-openstack-tox-docs

+ 109
- 0
zuul.d/molecule.yaml View File

@@ -0,0 +1,109 @@
1
+---
2
+- project-template:
3
+    check:
4
+      queue: integrated
5
+      jobs:
6
+      - tripleo-validations-centos-7-molecule-controller-token
7
+      - tripleo-validations-centos-7-molecule-controller-ulimits
8
+      - tripleo-validations-centos-7-molecule-ctlplane-ip-range
9
+      - tripleo-validations-centos-7-molecule-dns
10
+      - tripleo-validations-centos-7-molecule-haproxy
11
+      - tripleo-validations-centos-7-molecule-repos
12
+      - tripleo-validations-centos-7-molecule-undercloud-cpu
13
+      - tripleo-validations-centos-7-molecule-undercloud-ram
14
+      - tripleo-validations-centos-7-molecule-undercloud-debug
15
+      - tripleo-validations-centos-7-molecule-undercloud-disk-space
16
+      - tripleo-validations-centos-7-molecule-xfs-check-ftype
17
+    gate:
18
+      queue: integrated
19
+      jobs:
20
+      - tripleo-validations-centos-7-molecule-controller-token
21
+      - tripleo-validations-centos-7-molecule-controller-ulimits
22
+      - tripleo-validations-centos-7-molecule-ctlplane-ip-range
23
+      - tripleo-validations-centos-7-molecule-dns
24
+      - tripleo-validations-centos-7-molecule-haproxy
25
+      - tripleo-validations-centos-7-molecule-repos
26
+      - tripleo-validations-centos-7-molecule-undercloud-cpu
27
+      - tripleo-validations-centos-7-molecule-undercloud-ram
28
+      - tripleo-validations-centos-7-molecule-undercloud-debug
29
+      - tripleo-validations-centos-7-molecule-undercloud-disk-space
30
+      - tripleo-validations-centos-7-molecule-xfs-check-ftype
31
+    name: tripleo-validations-molecule-jobs
32
+- job:
33
+    files:
34
+    - ^roles/controller-token/.*
35
+    name: tripleo-validations-centos-7-molecule-controller-token
36
+    parent: tripleo-validations-centos-7-base
37
+    vars:
38
+      tripleo_validations_role_name: controller-token
39
+- job:
40
+    files:
41
+    - ^roles/controller-ulimits/.*
42
+    name: tripleo-validations-centos-7-molecule-controller-ulimits
43
+    parent: tripleo-validations-centos-7-base
44
+    vars:
45
+      tripleo_validations_role_name: controller-ulimits
46
+- job:
47
+    files:
48
+    - ^roles/ctlplane-ip-range/.*
49
+    name: tripleo-validations-centos-7-molecule-ctlplane-ip-range
50
+    parent: tripleo-validations-centos-7-base
51
+    vars:
52
+      tripleo_validations_role_name: ctlplane-ip-range
53
+- job:
54
+    files:
55
+    - ^roles/dns/.*
56
+    name: tripleo-validations-centos-7-molecule-dns
57
+    parent: tripleo-validations-centos-7-base
58
+    vars:
59
+      tripleo_validations_role_name: dns
60
+- job:
61
+    files:
62
+    - ^roles/haproxy/.*
63
+    name: tripleo-validations-centos-7-molecule-haproxy
64
+    parent: tripleo-validations-centos-7-base
65
+    vars:
66
+      tripleo_validations_role_name: haproxy
67
+- job:
68
+    files:
69
+    - ^roles/repos/.*
70
+    name: tripleo-validations-centos-7-molecule-repos
71
+    parent: tripleo-validations-centos-7-base
72
+    vars:
73
+      tripleo_validations_role_name: repos
74
+- job:
75
+    files:
76
+    - ^roles/undercloud-cpu/.*
77
+    name: tripleo-validations-centos-7-molecule-undercloud-cpu
78
+    parent: tripleo-validations-centos-7-base
79
+    vars:
80
+      tripleo_validations_role_name: undercloud-cpu
81
+- job:
82
+    files:
83
+    - ^roles/undercloud-ram/.*
84
+    name: tripleo-validations-centos-7-molecule-undercloud-ram
85
+    parent: tripleo-validations-centos-7-base
86
+    vars:
87
+      tripleo_validations_role_name: undercloud-ram
88
+- job:
89
+    files:
90
+    - ^roles/undercloud-debug/.*
91
+    name: tripleo-validations-centos-7-molecule-undercloud-debug
92
+    parent: tripleo-validations-centos-7-base
93
+    vars:
94
+      tripleo_validations_role_name: undercloud-debug
95
+- job:
96
+    files:
97
+    - ^roles/undercloud-disk-space/.*
98
+    name: tripleo-validations-centos-7-molecule-undercloud-disk-space
99
+    parent: tripleo-validations-centos-7-base
100
+    vars:
101
+      tripleo_validations_role_name: undercloud-disk-space
102
+- job:
103
+    files:
104
+    - ^roles/xfs-check-ftype/.*
105
+    name: tripleo-validations-centos-7-molecule-xfs-check-ftype
106
+    parent: tripleo-validations-centos-7-base
107
+    voting: false
108
+    vars:
109
+      tripleo_validations_role_name: xfs-check-ftype

+ 28
- 0
zuul.d/playbooks/pre.yml View File

@@ -0,0 +1,28 @@
1
+---
2
+- hosts: all
3
+  pre_tasks:
4
+    - name: Ensure output dirs
5
+      file:
6
+        path: "{{ ansible_user_dir }}/zuul-output/logs"
7
+        state: directory
8
+
9
+    - name: Setup bindep
10
+      pip:
11
+        name: "bindep"
12
+        virtualenv: "{{ ansible_user_dir }}/test-python"
13
+        virtualenv_site_packages: true
14
+
15
+    - name: Run bindep
16
+      shell: |-
17
+        . {{ ansible_user_dir }}/test-python/bin/activate
18
+        {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/scripts/bindep-install
19
+      become: true
20
+      changed_when: False
21
+
22
+    - name: Setup test-python
23
+      pip:
24
+        requirements: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/molecule-requirements.txt"
25
+        virtualenv: "{{ ansible_user_dir }}/test-python"
26
+        virtualenv_site_packages: true
27
+  roles:
28
+    - role: install-docker

+ 13
- 0
zuul.d/playbooks/run-local.yml View File

@@ -0,0 +1,13 @@
1
+---
2
+- hosts: all
3
+  tasks:
4
+    - name: set basic zuul fact
5
+      set_fact:
6
+        zuul:
7
+          project:
8
+            src_dir: "{{ tripleo_src }}"
9
+        ansible_connection: ssh
10
+
11
+- import_playbook: pre.yml
12
+
13
+- import_playbook: run.yml

+ 19
- 0
zuul.d/playbooks/run.yml View File

@@ -0,0 +1,19 @@
1
+---
2
+
3
+- hosts: all
4
+  environment:
5
+    ANSIBLE_LOG_PATH: "{{ ansible_user_dir }}/zuul-output/logs/ansible-execution.log"
6
+  tasks:
7
+    - name: Run role test job
8
+      shell: |-
9
+        . {{ ansible_user_dir }}/test-python/bin/activate
10
+        . {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/ansible-test-env.rc
11
+        pytest --color=no \
12
+               --html={{ ansible_user_dir }}/zuul-output/logs/reports.html \
13
+               --self-contained-html \
14
+               --ansible-args='{{ tripleo_job_ansible_args | default("-v") }}' \
15
+               {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/test_molecule.py
16
+      args:
17
+        chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/roles/{{ tripleo_validations_role_name }}"
18
+        executable: /bin/bash
19
+      changed_when: False

Loading…
Cancel
Save