HTML test report for Deckhand functional tests
This PS leverages pytest-html to generate an HTML report for Deckhand functional tests. The test_gabbi.py file was updated to use pytest as the test runner as it is compatible with pytest-html. The report is saved in results/index.html. Test docs were updated. Change-Id: I0b611bf124bf87d801ab93dd2a5d16f136e4801d
This commit is contained in:
parent
0e0d96ef71
commit
bead00e23e
1
.gitignore
vendored
1
.gitignore
vendored
@ -47,6 +47,7 @@ coverage.xml
|
|||||||
.hypothesis/
|
.hypothesis/
|
||||||
.testrepository/*
|
.testrepository/*
|
||||||
cover/*
|
cover/*
|
||||||
|
results/*
|
||||||
|
|
||||||
# Translations
|
# Translations
|
||||||
*.mo
|
*.mo
|
||||||
|
@ -15,16 +15,16 @@
|
|||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
import gabbi.driver
|
from gabbi import driver
|
||||||
import gabbi.handlers.jsonhandler
|
from gabbi.driver import test_pytest # noqa
|
||||||
import gabbi.json_parser
|
from gabbi.handlers import jsonhandler
|
||||||
|
|
||||||
TESTS_DIR = 'gabbits'
|
TESTS_DIR = 'gabbits'
|
||||||
|
|
||||||
|
|
||||||
# This is quite similar to the existing JSONHandler, so use it as the base
|
# This is quite similar to the existing JSONHandler, so use it as the base
|
||||||
# class instead of gabbi.handlers.base.ContentHandler
|
# class instead of `gabbi.handlers.base.ContentHandler`.
|
||||||
class MultidocJsonpaths(gabbi.handlers.jsonhandler.JSONHandler):
|
class MultidocJsonpaths(jsonhandler.JSONHandler):
|
||||||
test_key_suffix = 'multidoc_jsonpaths'
|
test_key_suffix = 'multidoc_jsonpaths'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -46,14 +46,15 @@ class MultidocJsonpaths(gabbi.handlers.jsonhandler.JSONHandler):
|
|||||||
return list(yaml.safe_load_all(string))
|
return list(yaml.safe_load_all(string))
|
||||||
|
|
||||||
|
|
||||||
def load_tests(loader, tests, pattern):
|
def pytest_generate_tests(metafunc):
|
||||||
test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
|
test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
|
||||||
return gabbi.driver.build_tests(test_dir, loader,
|
# NOTE(fmontei): While only `url` or `host` is needed, strangely both
|
||||||
# NOTE(fmontei): When there are multiple handlers listed that
|
# are needed because we use `pytest-html` which throws an error without
|
||||||
# accept the same content-type, the one that is earliest in the
|
# `host`.
|
||||||
# list will be used. Thus, we cannot specify multiple content
|
driver.py_test_generator(
|
||||||
# handlers for handling list/dictionary responses from the server
|
test_dir, url=os.environ['DECKHAND_TEST_URL'], host='localhost',
|
||||||
# using different handlers.
|
# NOTE(fmontei): When there are multiple handlers listed that accept
|
||||||
content_handlers=[MultidocJsonpaths],
|
# the same content-type, the one that is earliest in the list will be
|
||||||
verbose=True,
|
# used. Thus, we cannot specify multiple content handlers for handling
|
||||||
url=os.environ['DECKHAND_TEST_URL'])
|
# list/dictionary responses from the server using different handlers.
|
||||||
|
content_handlers=[MultidocJsonpaths], metafunc=metafunc)
|
||||||
|
@ -90,6 +90,8 @@ The command executes ``tools/functional-tests.sh`` which:
|
|||||||
Keystone and pass an admin token to Deckhand.
|
Keystone and pass an admin token to Deckhand.
|
||||||
4) Instantiates Deckhand via ``uwisgi``.
|
4) Instantiates Deckhand via ``uwisgi``.
|
||||||
5) Calls gabbi which runs a battery of functional tests.
|
5) Calls gabbi which runs a battery of functional tests.
|
||||||
|
6) An HTML report that visualizes the result of the test run is output to
|
||||||
|
``results/index.html``.
|
||||||
|
|
||||||
At this time, there are no functional tests for policy enforcement
|
At this time, there are no functional tests for policy enforcement
|
||||||
verification. Negative tests will be added at a later date to confirm that
|
verification. Negative tests will be added at a later date to confirm that
|
||||||
|
@ -19,3 +19,4 @@ gabbi==1.35.1
|
|||||||
sphinx_rtd_theme==0.2.4
|
sphinx_rtd_theme==0.2.4
|
||||||
pifpaf==0.10.0
|
pifpaf==0.10.0
|
||||||
reno>=2.5.0 # Apache-2.0
|
reno>=2.5.0 # Apache-2.0
|
||||||
|
pytest-html==1.16.0
|
||||||
|
@ -127,12 +127,14 @@ sleep 5
|
|||||||
|
|
||||||
log_section Running tests
|
log_section Running tests
|
||||||
|
|
||||||
|
ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
posargs=$@
|
posargs=$@
|
||||||
if [ ${#posargs} -ge 1 ]; then
|
if [ ${#posargs} -ge 1 ]; then
|
||||||
ostestr --concurrency 1 --regex $1
|
py.test -k $1 -svx $( dirname $ROOTDIR )/deckhand/tests/functional/test_gabbi.py --html=results/index.html
|
||||||
else
|
else
|
||||||
ostestr --concurrency 1
|
py.test -svx $( dirname $ROOTDIR )/deckhand/tests/functional/test_gabbi.py --html=results/index.html
|
||||||
fi
|
fi
|
||||||
TEST_STATUS=$?
|
TEST_STATUS=$?
|
||||||
set -e
|
set -e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user