From a9e9d5ee600413ef451904a2591d955b65945e62 Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Tue, 7 Jan 2020 16:13:19 +0100 Subject: [PATCH] Create Tox InfraRed upstream job Change-Id: Ib816520d63a51ae37a9be8f2036131bd58ecd054 --- ansible.cfg | 9 +++++ bindep.txt | 24 +++++++++---- infrared/plugin.spec | 72 +++++++++++++++++++++++++++++++++++++ playbooks/infrared/pre.yaml | 7 ++++ tools/ci/ir | 71 ++++++++++++++++++++++++++++++++++++ tox.ini | 27 ++++++++++++-- zuul.d/infrared.yaml | 16 +++++++++ zuul.d/project.yaml | 2 +- 8 files changed, 217 insertions(+), 11 deletions(-) create mode 100644 ansible.cfg create mode 100644 infrared/plugin.spec create mode 100644 playbooks/infrared/pre.yaml create mode 100755 tools/ci/ir create mode 100644 zuul.d/infrared.yaml diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 000000000..023dc6cf3 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,9 @@ +[defaults] +host_key_checking = False +forks = 500 +timeout = 30 +force_color = 1 + +[ssh_connection] +pipelining = True +ssh_args = -o ControlMaster=auto -o ControlPersist=60s diff --git a/bindep.txt b/bindep.txt index a792b1610..a0f5f677c 100644 --- a/bindep.txt +++ b/bindep.txt @@ -1,14 +1,24 @@ # This file contains runtime (non-python) dependencies # More info at: https://docs.openstack.org/infra/bindep/readme.html -libffi-dev [platform:dpkg] -libffi-devel [platform:rpm] gcc [platform:rpm] gcc [platform:dpkg] -python3 [platform:dpkg] -python3 [platform:rpm] -python3-dev [platform:dpkg] -python3-devel [platform:rpm] + +git [platform:dpkg] +git [platform:rpm] + +iproute [platform:rpm] + +libffi-devel [platform:rpm] +libffi-dev [platform:dpkg] + +libselinux-python [platform:rpm] + openssl-devel [platform:rpm] libssl-dev [platform:dpkg] -iproute [platform:rpm] + +python3 [platform:rpm] +python3 [platform:dpkg] + +python3-devel [platform:rpm] +python3-dev [platform:dpkg] diff --git a/infrared/plugin.spec b/infrared/plugin.spec new file mode 100644 index 000000000..d6bd3e319 --- /dev/null +++ b/infrared/plugin.spec @@ -0,0 +1,72 @@ + +--- + +config: + plugin_type: test + entry_point: ../roles/tobiko/main.yml + +subparsers: + tobiko: + description: Configure and Run Tobiko Test Cases + + include_groups: + - "Ansible options" + - "Inventory" + - "Common options" + - "Answers file" + + groups: + - title: Stages Control + options: + + pre_run: + type: Bool + help: install and configure Tobiko test cases + + run_tests: + type: Bool + help: run verification test cases + + run_faults: + type: Bool + help: run disruptive operation test cases + + post_run: + type: Bool + help: fetch artifacts after test case execution + + - title: Install Options + options: + tox_dir: + type: Value + default: "{{ ansible_env.HOME }}/tobiko" + help: | + The directory where Tobiko will be installed and used + overcloudrc: + type: Value + default: "{{ ansible_env.HOME }}/overcloudrc" + help: | + The path to the overcloudrc file + floating_network: + type: Value + default: "public" + help: | + Name of overcloud's floating_network + tests: + type: Value + help: | + The set of tests to execute + default: scenario + results_dir_suffix: + type: Value + help: | + Suffix string to add to tobiko_results dir + example : default will be tobiko_results_1st + default: "1st" + refsec: + type: Value + help: | + specific gerrit patch refsec to + checkout, example: + --refsec refs/changes/66/665966/7 + default: '' diff --git a/playbooks/infrared/pre.yaml b/playbooks/infrared/pre.yaml new file mode 100644 index 000000000..210ab93f0 --- /dev/null +++ b/playbooks/infrared/pre.yaml @@ -0,0 +1,7 @@ +--- + +- hosts: all + tasks: + - debug: + msg: | + TODO(fressi): prepare here host before executing tox -e infrared diff --git a/tools/ci/ir b/tools/ci/ir new file mode 100755 index 000000000..2ff6d67c7 --- /dev/null +++ b/tools/ci/ir @@ -0,0 +1,71 @@ +#!/bin/bash + +source $(dirname "$0")/activate +source $(dirname "$0")/tox + +set -eu + +IR_VIRTUAL_ENV=$(realpath "${IR_VIRTUAL_ENV:-.tox/infrared}") +IR_REPO="https://github.com/redhat-openstack/infrared.git" +IR_BRANCH=${IR_BRANCH:-master} +IR_SOURCE_DIR=$(realpath "${IR_SOURCE_DIR:-${IR_VIRTUAL_ENV}/infrared}") +IR_EXECUTABLE=${IR_VIRTUAL_ENV}/bin/infrared +export IR_HOME=$(realpath ${IR_HOME:-../.infrared/}) +IR_TOBIKO_PLUGIN=$(realpath ${IR_TOBIKO_PLUGIN:-$(pwd)}) + + +function ir { + ir_setup + "${IR_EXECUTABLE}" "$@" +} + + +function ir_setup { + if ! ir_activate; then + tox -e infrared --notest + ir_activate + fi + + if ! [ -x "${IR_EXECUTABLE}" ]; then + git clone "${IR_REPO}" -b "${IR_BRANCH}" "${IR_SOURCE_DIR}" + local package_name + for package_name in pip setuptools "${IR_SOURCE_DIR}"; do + pip install --upgrade "${package_name}" + done + + ( + cd "${IR_SOURCE_DIR}" + "${IR_EXECUTABLE}" plugin list --available --versions || true + "${IR_EXECUTABLE}" plugin remove tobiko || true + "${IR_EXECUTABLE}" plugin add "${IR_TOBIKO_PLUGIN}" + ) + fi + + mkdir -p "${IR_HOME}" +} + + +function ir_activate { + local venv_script=${IR_VIRTUAL_ENV}/bin/activate + if ! [ -r "${venv_script}" ]; then + return 1 + fi + + if ! ir_is_active; then + # Activate only once + set +eu + source "${venv_script}" + set -eu + ir_is_active + fi +} + + +function ir_is_active { + [ "$(python_prefix)" == "${IR_VIRTUAL_ENV}" ] +} + + +if [ $(basename "$0") == ir ]; then + ir "$@" +fi diff --git a/tox.ini b/tox.ini index 50736f510..05e9a5fa7 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,7 @@ deps = -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt} -r{toxinidir}/requirements.txt passenv = + PS1 TOBIKO_* setenv = OS_LOG_CAPTURE={env:OS_LOG_CAPTURE:true} @@ -21,6 +22,7 @@ setenv = PYTHONWARNINGS=ignore::Warning,{env:PYTHONWARNINGS:} TOBIKO_PREVENT_CREATE={env:TOBIKO_PREVENT_CREATE:false} VIRTUAL_ENV={envdir} + PS1=[tobiko@{envname}] {env:PS1:} commands = stestr run {posargs} @@ -106,12 +108,15 @@ import-order-style = pep8 [openstack] basepython = {env:PYTHON:python3} -deps = {[base]deps} +deps = + {[base]deps} passenv = {[base]passenv} *_proxy OS_* -setenv = {[base]setenv} +setenv = + {[base]setenv} + ANSIBLE_CONFIG={env:ANSIBLE_CONFIG:{toxinidir}/ansible.cfg} commands = {[base]commands} @@ -168,7 +173,23 @@ deps = {[testenv:scenario]deps} passenv = {[testenv:scenario]passenv} setenv = {[testenv:scenario]setenv} whitelist_externals = * -commands = {posargs} +commands = {posargs:bash} + + +[testenv:infrared] + +basepython = {[testenv:venv]basepython} +deps = {[testenv:venv]deps} +passenv = + {[testenv:venv]passenv} + IR_* +setenv = + {[testenv:venv]setenv} + IR_HOME={env:IR_HOME:{toxinidir}/../.infrared} + IR_TOBIKO_PLUGIN={env:IR_TOBIKO_PLUGIN:{toxinidir}} +whitelist_externals = * +commands = + bash {toxinidir}/tools/ci/ir {posargs:tobiko} # --- documentation environments ---------------------------------------------- diff --git a/zuul.d/infrared.yaml b/zuul.d/infrared.yaml new file mode 100644 index 000000000..af8e91920 --- /dev/null +++ b/zuul.d/infrared.yaml @@ -0,0 +1,16 @@ +--- + +- job: + name: tobiko-tox-infrared-centos-7 + parent: openstack-tox + voting: false + nodeset: centos-7 + timeout: 2400 + description: | + Run tobiko infrared plugin + vars: + tox_envlist: infrared + bindep_profile: test + python_version: 3.6 + # compile and install python3.8 from source code + pre-run: playbooks/infrared/pre.yaml diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 863116479..2a2739187 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -18,7 +18,7 @@ - tobiko-devstack-functional - tobiko-devstack-faults-centos-7 - tobiko-devstack-faults-ubuntu-bionic - + - tobiko-tox-infrared-centos-7 gate: jobs: - tobiko-tox-py36-centos-7