Create generic ansible Tobiko role for CI

Change-Id: I1d31d9ff30fbde418d0abcc84212b4408ed7e515
This commit is contained in:
Federico Ressi 2019-11-18 12:10:33 +01:00
parent c463d741e8
commit 7095ff11e9
11 changed files with 123 additions and 24 deletions

View File

@ -14,6 +14,11 @@
---
- hosts: tempest
- name: Run Tobiko
hosts: tempest
roles:
- run-tox
- role: tobiko
become: true
become_user: stack
vars:
tobiko_dir: /opt/stack/tobiko

View File

@ -1,4 +0,0 @@
tox_dir: /opt/stack/tobiko
tox_envlist: scenario
tox_extra_args: ''
tox_python_version: ''

View File

@ -1,8 +0,0 @@
- name: Run Tobiko test cases
shell:
chdir: "{{ tox_dir }}"
cmd: |
export PYTHON_VERSION={{ tox_python_version }}
tools/ci/tox -e "{{ tox_envlist }}" {{ tox_extra_args }}
become: true
become_user: stack

View File

@ -0,0 +1,20 @@
---
# Tobiko workflow parameters
tobiko_check_tools: true
tobiko_run_tests: true
tobiko_run_faults: false
# Remote tobiko directory
tobiko_dir: "~/src/tobiko"
# Python parameteres
python_version: ''
python_command: "{{ tobiko_dir }}/tools/ci/python"
# Tobiko tox parameters
tox_dir: "{{ tobiko_dir }}"
tox_command: "{{ tobiko_dir }}/tools/ci/tox"
tox_envlist: scenario
tox_extra_args: ''
tox_posargs: ''

View File

@ -0,0 +1,16 @@
---
- name: "Check Python command '{{ python_command }}'"
shell: "{{ python_command }} --version"
- name: "Check Python command version is '{{ python_version }}'"
shell: |
{{ python_command }} '{{ tobiko_dir }}/tools/ci/python_version' \
--check-prefix
- name: "Check Tox command: '{{ tox_command }}'"
shell:
chdir: "{{ tox_dir }}"
cmd: "{{ tox_command }} --version"

View File

@ -0,0 +1,29 @@
---
- environment:
PYTHON_VERSION: "{{ python_version }}"
block:
- name: "Check CLI tools"
when: tobiko_check_tools | bool
include: check_tools.yaml
- when: tobiko_run_tests
block:
- name: "Run tests"
when: tobiko_run_tests | bool
include: tasks/run_tests.yaml
- when: tobiko_run_faults | bool
block:
- name: "Run faults"
include: run_tests.yaml
vars:
tox_envlist: faults
- name: "Run tests after faults"
include: run_tests.yaml
vars:
tox_posargs: "--combine"

View File

@ -0,0 +1,8 @@
---
- name: "Run test '{{ tox_envlist }}' cases from '{{ tox_dir }}'"
shell:
chdir: "{{ tox_dir }}"
cmd: |
{{ tox_command }} -e '{{ tox_envlist }}' {{ tox_extra_args }} -- \
{{ tox_posargs }}

35
tools/ci/python_version Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env python
import argparse
import os
import sys
def get_python_version():
return '.'.join(str(i) for i in sys.version_info[:3])
def main():
parser = argparse.ArgumentParser(description='Print Python version')
parser.add_argument('--check-prefix', action='store_const', const=True,
default=False,
help='check version matches $PYTHON_VERSION prefix')
args = parser.parse_args()
version = get_python_version()
if args.check_prefix:
expected_version = os.environ.get('PYTHON_VERSION')
if expected_version and not version.startswith(expected_version):
message = ("Version {version!r} must starts with"
" {expected_version!r}\n").format(
version=version,
expected_version=expected_version)
sys.stderr.write(message)
sys.exit(1)
sys.stdout.write(version + '\n')
if __name__ == '__main__':
main()

View File

@ -140,11 +140,10 @@ deps = {[testenv:scenario]deps}
passenv = {[testenv:scenario]passenv}
setenv =
{[testenv:scenario]setenv}
OS_TEST_PATH={toxinidir}/tobiko/tests/faults
TOBIKO_PREVENT_CREATE=true
commands =
stestr run --serial \
--test-path '{toxinidir}/tobiko/tests/faults' {posargs}
stestr run --combine {posargs}
stestr run --serial {posargs}
[testenv:venv]

View File

@ -1,6 +1,6 @@
- job:
name: tobiko-devstack-ovn
parent: tobiko-devstack-multinode
parent: tobiko-devstack-scenario-multinode
abstract: true
nodeset: openstack-three-node-bionic
description: |

View File

@ -17,7 +17,6 @@
- x/tobiko
timeout: 7200
vars:
tox_python_version: 3
devstack_localrc:
MULTI_HOST: 0
USE_PYTHON3: true
@ -168,8 +167,8 @@
- job:
name: tobiko-devstack-multinode
parent: tobiko-devstack
name: tobiko-devstack-scenario-multinode
parent: tobiko-devstack-scenario
abstract: true
description: Base Tobiko devstack job with multinode.
vars:
@ -201,12 +200,12 @@
- job:
name: tobiko-devstack-faults
parent: tobiko-devstack-multinode
parent: tobiko-devstack-scenario-multinode
abstract: true
description: |
Base Tobiko devstack job to execute scenario+faults+scenario test cases.
vars:
tox_envlist: scenario,faults
tobiko_run_faults: true
irrelevant-files:
- ^.*\.rst$
- ^doc/
@ -226,7 +225,7 @@
devstack_localrc:
# CentOS has no support for Python3
USE_PYTHON3: false
tox_python_version: 2
python_version: 2
- job: