diff --git a/scripts/tripleo-jobs-gerrit.py b/scripts/tripleo-jobs-gerrit.py
index e9b938ec6..5a86000c4 100755
--- a/scripts/tripleo-jobs-gerrit.py
+++ b/scripts/tripleo-jobs-gerrit.py
@@ -193,18 +193,22 @@ def gen_html(data, html_file, table_file, stats_hours, job_names, options):
fp.write("Limit: " + options.l)
total = passed_jobs + partial_jobs + failed_jobs
+ if total:
+ passed_percent = float(passed_jobs) / float(total) * 100
+ partial_percent = float(partial_jobs) / float(total) * 100
+ failed_percent = float(failed_jobs) / float(total) * 100
+ else:
+ passed_percent = 0
+ partial_percent = 0
+ failed_percent = 0
+
fp.write("
Overall
")
+ fp.write("Passed: %d/%d (%d %%)
" % (passed_jobs, total, passed_percent))
fp.write(
- "Passed: %d/%d (%d %%)
"
- % (passed_jobs, total, float(passed_jobs) / float(total) * 100)
+ "Partial Failures: %d/%d (%d %%)
" % (partial_jobs, total, partial_percent)
)
fp.write(
- "Partial Failures: %d/%d (%d %%)
"
- % (partial_jobs, total, float(partial_jobs) / float(total) * 100)
- )
- fp.write(
- "Complete Failures: %d/%d (%d %%)
"
- % (failed_jobs, total, float(failed_jobs) / float(total) * 100)
+ "Complete Failures: %d/%d (%d %%)
" % (failed_jobs, total, failed_percent)
)
fp.close()
diff --git a/setup.cfg b/setup.cfg
index 39cfaba16..3da94aaaf 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -31,7 +31,7 @@ universal = 1
warnerrors = False
[tool:pytest]
-norecursedirs = .git .tox dist
+norecursedirs = .git .tox dist .eggs
log_cli = true
[flake8]
diff --git a/test-requirements.txt b/test-requirements.txt
index 67a29b960..7f07d8662 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -1,10 +1,15 @@
+PyYAML
ansi2html # GPL (soft-dependency of pytest-html)
+docker>=3.7 # Apache
+mock
+molecule>=3.0.2 # MIT
+paramiko>=2.5.0 # LGPL (soft-dependency of docker that enables ssh protocol)
+pprint
+pre-commit>=1.10 # MIT License
pytest # MIT
pytest-cov # MIT
pytest-html # MPL 2.0
+pytest-molecule # MIT
+pytest-plus # MIT
pytest-xdist # MIT
-mock
requests
-pprint
-pre-commit>=1.10 # MIT License
-PyYAML
diff --git a/tests/test_jobs_gerrit.py b/tests/test_jobs_gerrit.py
new file mode 100644
index 000000000..f4f880e9b
--- /dev/null
+++ b/tests/test_jobs_gerrit.py
@@ -0,0 +1,7 @@
+import os
+
+
+def test_jobs_gerrit():
+ f = os.path.join(os.path.dirname(__file__), "../scripts/tripleo-jobs-gerrit.py")
+ result = os.system(f)
+ assert result == 0
diff --git a/tests/test_molecule.py b/tests/test_molecule.py
deleted file mode 100644
index 572bf3056..000000000
--- a/tests/test_molecule.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-import os
-import pytest
-import subprocess
-
-
-# detect if we have a working docker setup and skip with warning if not
-docker_skip = False
-docker_reason = ''
-try:
- import docker
-
- client = docker.from_env(timeout=5)
- if not client.ping():
- raise Exception("Failed to ping docker server.")
-except Exception as e:
- docker_reason = "Skipping molecule tests due: %s" % e
- docker_skip = True
-
-
-def pytest_generate_tests(metafunc):
- # detects all molecule scenarios inside the project
- matches = []
- if 'testdata' in metafunc.fixturenames:
- for role in os.listdir("./roles"):
- role_path = os.path.abspath('./roles/%s' % role)
- for _, dirnames, _ in os.walk(role_path + '/molecule'):
- for scenario in dirnames:
- if os.path.isfile(
- '%s/molecule/%s/molecule.yml' % (role_path, scenario)
- ):
- matches.append([role_path, scenario])
- metafunc.parametrize('testdata', matches)
-
-
-@pytest.mark.skipif(docker_skip, reason=docker_reason)
-def test_molecule(testdata):
- cwd, scenario = testdata
- cmd = ['python', '-m', 'molecule', 'test', '-s', scenario]
- print("running: %s (from %s)" % (" ".join(cmd), cwd))
- r = subprocess.call(cmd, cwd=cwd)
- assert r == 0
diff --git a/tox.ini b/tox.ini
index 91a0a3e02..7790c01c4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
[tox]
# keep py3 before py2 to assure they are preffered for envs like linters:
-envlist = linters,py{37,36,35,27}
+envlist = linters,py{37,36,35,27},molecule
minversion = 3.4.0
ignore_basepython_conflict = True
skip_missing_interpreters = True
@@ -18,6 +18,8 @@ setenv =
# Avoid 2020-01-01 warnings: https://github.com/pypa/pip/issues/6207
PYTHONWARNINGS=ignore:DEPRECATION::pip._internal.cli.base_command
PIP_DISABLE_PIP_VERSION_CHECK=1
+ TEST_PARAMS=--cov=emit_releases_file -k "not molecule"
+ molecule: TEST_PARAMS=-ra -k molecule
passenv =
ANSIBLE_*
CURL_CA_BUNDLE
@@ -35,7 +37,7 @@ commands_pre =
pip install -q bindep
bindep test
commands =
- python -m pytest --html={envlogdir}/reports.html --self-contained-html --cov=emit_releases_file {posargs:scripts}
+ python -m pytest --html={envlogdir}/reports.html --self-contained-html {tty:-s} {env:TEST_PARAMS} {posargs}
[testenv:venv]
commands = {posargs}
@@ -45,19 +47,3 @@ deps =
pre-commit>=1.20.0
commands =
python -m pre_commit run -a
-
-[testenv:cireport]
-commands = python scripts/tripleo-jobs-gerrit.py {posargs}
-
-[testenv:molecule]
-deps =
- ansi2html # GPL (soft-dependency of pytest-html)
- docker>=3.7 # Apache
- molecule==3.0a9 # MIT
- paramiko>=2.5.0 # LGPL (soft-dependency of docker that enables ssh protocol)
- pytest # MIT
- pytest-cov # MIT
- pytest-html # MPL 2.0
- pytest-xdist # MIT
-commands =
- python -m pytest -ra --html={envlogdir}/reports.html --self-contained-html {tty:-s} {posargs} tests
diff --git a/zuul.d/layout.yaml b/zuul.d/layout.yaml
index f4bdf64c4..0a41be414 100644
--- a/zuul.d/layout.yaml
+++ b/zuul.d/layout.yaml
@@ -17,7 +17,10 @@
check:
jobs:
- openstack-tox-linters
- - tripleo-tox-molecule
+ - tripleo-tox-molecule:
+ vars:
+ tox_environment:
+ PYTEST_REQPASS: 1
- openstack-tox-py35:
success-url: "tox/reports.html"
failure-url: "tox/reports.html"
@@ -28,6 +31,10 @@
- ^setup.cfg$
- ^setup.py$
- ^tox.ini$
+ vars:
+ tox_environment:
+ PYTEST_REQPASS: 84
+
- tripleo-buildimage-overcloud-full-centos-8:
files: &build_images_files
- ^playbooks/tripleo-buildimages/.*$