Move to stestr for functional/integration tests

This moves to stestr for functional/integration tests to
align with preferred OpenStack test runner and also because
py.test is causing issues here: [0].

[0] http://logs.openstack.org/45/573045/8/check/airship-deckhand-integration-uwsgi-py35/60bd7ae/job-output.txt.gz#_2018-06-22_03_00_51_267408

Change-Id: I701c71aef2a122b8f1fc64285cb799f71cfe520f
This commit is contained in:
Felipe Monteiro 2018-06-22 06:47:33 +01:00
parent 1583b78902
commit 29894ee854
7 changed files with 17 additions and 22 deletions

View File

@ -21,7 +21,6 @@ import tempfile
import yaml import yaml
from gabbi import driver from gabbi import driver
from gabbi.driver import test_pytest # noqa
from gabbi.handlers import jsonhandler from gabbi.handlers import jsonhandler
TEST_DIR = None TEST_DIR = None
@ -93,19 +92,18 @@ class MultidocJsonpaths(jsonhandler.JSONHandler):
return list(yaml.load_all(string)) return list(yaml.load_all(string))
def pytest_generate_tests(metafunc): def load_tests(loader, tests, pattern):
# NOTE(fmontei): While only `url` or `host` is needed, strangely both """Provide a TestSuite to the discovery process."""
# are needed because we use `pytest-html` which throws an error without
# `host`.
global TEST_DIR global TEST_DIR
driver.py_test_generator( return driver.build_tests(
TEST_DIR, TEST_DIR,
url=os.environ.get('DECKHAND_TEST_URL', '127.0.0.1:9000'), loader,
host='localhost', host='localhost',
url=os.environ.get('DECKHAND_TEST_URL', '127.0.0.1:9000'),
# NOTE(fmontei): When there are multiple handlers listed that accept # NOTE(fmontei): When there are multiple handlers listed that accept
# the same content-type, the one that is earliest in the list will be # the same content-type, the one that is earliest in the list will be
# used. Thus, we cannot specify multiple content handlers for handling # used. Thus, we cannot specify multiple content handlers for handling
# list/dictionary responses from the server using different handlers. # list/dictionary responses from the server using different handlers.
content_handlers=[MultidocJsonpaths], content_handlers=[MultidocJsonpaths],
metafunc=metafunc) verbose=True)

View File

@ -214,7 +214,7 @@ tests:
status: 200 status: 200
data: <@resources/layering-and-substitution-sample.yaml data: <@resources/layering-and-substitution-sample.yaml
- name: verify_multiple_empty_top_layers - name: verify_multiple_empty_interspersed_layers
desc: Check for expected substitutions desc: Check for expected substitutions
GET: /api/v1.0/revisions/$RESPONSE['$.[0].status.revision']/rendered-documents GET: /api/v1.0/revisions/$RESPONSE['$.[0].status.revision']/rendered-documents
query_parameters: query_parameters:

View File

@ -57,9 +57,9 @@ export DECKHAND_TEST_DIR=${CURRENT_DIR}/deckhand/tests/functional/gabbits
set +e set +e
posargs=$@ posargs=$@
if [ ${#posargs} -ge 1 ]; then if [ ${#posargs} -ge 1 ]; then
py.test -k $1 -svx ${CURRENT_DIR}/deckhand/tests/common/test_gabbi.py stestr --test-path deckhand/tests/common/ run --serial --slowest --force-subunit-trace --color $1
else else
py.test -svx ${CURRENT_DIR}/deckhand/tests/common/test_gabbi.py stestr --test-path deckhand/tests/common/ run --serial --slowest --force-subunit-trace --color
fi fi
TEST_STATUS=$? TEST_STATUS=$?
set -e set -e

View File

@ -22,4 +22,4 @@
DECKHAND_TEST_URL: "127.0.0.1:9000" DECKHAND_TEST_URL: "127.0.0.1:9000"
DECKHAND_TEST_DIR: "{{ airship_deckhand_path.stdout }}/deckhand/tests/functional/gabbits" DECKHAND_TEST_DIR: "{{ airship_deckhand_path.stdout }}/deckhand/tests/functional/gabbits"
register: result register: result
failed_when: "'commands failed' in result.stdout" failed_when: "result.rc != 0"

View File

@ -15,10 +15,9 @@
- name: Install pip3 and gabbi - name: Install pip3 and gabbi
shell: | shell: |
set -xe; set -xe;
apt-get install -y python3-pip apt-get install -y python-pip
pip3 install --upgrade pip pip install --upgrade pip
# Includes required requirements for testing. pip install -r test-requirements.txt
pip3 install -r test-requirements.txt
args: args:
chdir: "{{ zuul.project.src_dir }}" chdir: "{{ zuul.project.src_dir }}"
become: yes become: yes
@ -39,8 +38,7 @@
- name: Run Integration Tests - name: Run Integration Tests
shell: | shell: |
set -ex; set -ex;
py.test -svx "{{ airship_deckhand_path.stdout }}"/deckhand/tests/common/test_gabbi.py \ stestr --test-path deckhand/tests/common/ run --serial --slowest --force-subunit-trace --color
&& echo "Done SUCCESS" || echo "Done FAILURE"
args: args:
chdir: "{{ zuul.project.src_dir }}" chdir: "{{ zuul.project.src_dir }}"
environment: environment:

View File

@ -133,9 +133,9 @@ function run_tests {
posargs=$@ posargs=$@
if [ ${#posargs} -ge 1 ]; then if [ ${#posargs} -ge 1 ]; then
py.test -k $1 -svx ${CURRENT_DIR}/deckhand/tests/common/test_gabbi.py stestr --test-path deckhand/tests/common/ run --serial --slowest --force-subunit-trace --color $1
else else
py.test -svx ${CURRENT_DIR}/deckhand/tests/common/test_gabbi.py stestr --test-path deckhand/tests/common/ run --serial --slowest --force-subunit-trace --color
fi fi
TEST_STATUS=$? TEST_STATUS=$?

View File

@ -53,8 +53,7 @@ deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = commands =
find . -type f -name "*.pyc" -delete find . -type f -name "*.pyc" -delete
# TODO(felipemonteiro): Use OpenStack test runner. stestr --test-path deckhand/tests/common/ run --serial --slowest --force-subunit-trace --color '{posargs}'
py.test -svx {toxinidir}/deckhand/tests/common/test_gabbi.py -k '{posargs}'
[testenv:functional-dev] [testenv:functional-dev]
basepython=python3 basepython=python3