From afe7af821824ac0b102df86080e4966543606d9f Mon Sep 17 00:00:00 2001 From: Ilya Tyaptin Date: Thu, 14 May 2015 18:04:03 +0300 Subject: [PATCH] Initial commit for functional tests In this patchset added a starting point for running ceilometer functional tests. Next points include a creating scripts for using a different env setup for different backends, creating a new job in openstack-infra/project-config and separating ceilometer tests to unit and functional. Partially implements: blueprint ceilometer-functional-tests Change-Id: I3ecadd388812afde5c48aff8214597d76faccf33 --- ceilometer/tests/functional/__init__.py | 0 .../tests/functional/hooks/post_test_hook.sh | 46 +++++++++++++++++++ tox.ini | 19 +++++++- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 ceilometer/tests/functional/__init__.py create mode 100644 ceilometer/tests/functional/hooks/post_test_hook.sh diff --git a/ceilometer/tests/functional/__init__.py b/ceilometer/tests/functional/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/ceilometer/tests/functional/hooks/post_test_hook.sh b/ceilometer/tests/functional/hooks/post_test_hook.sh new file mode 100644 index 000000000..6701ac9a1 --- /dev/null +++ b/ceilometer/tests/functional/hooks/post_test_hook.sh @@ -0,0 +1,46 @@ +#!/bin/bash -xe + +# 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. + +# This script is executed inside post_test_hook function in devstack gate. + +function generate_testr_results { + if [ -f .testrepository/0 ]; then + sudo .tox/functional/bin/testr last --subunit > $WORKSPACE/testrepository.subunit + sudo mv $WORKSPACE/testrepository.subunit $BASE/logs/testrepository.subunit + sudo .tox/functional/bin/python /usr/local/jenkins/slave_scripts/subunit2html.py $BASE/logs/testrepository.subunit $BASE/logs/testr_results.html + sudo gzip -9 $BASE/logs/testrepository.subunit + sudo gzip -9 $BASE/logs/testr_results.html + sudo chown jenkins:jenkins $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz + sudo chmod a+r $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz + fi +} + +export CEILOMETER_DIR="$BASE/new/ceilometer" + +# Go to the ceilometer dir +cd $CEILOMETER_DIR + +sudo chown -R jenkins:stack $CEILOMETER_DIR + +# Run tests +echo "Running ceilometer functional test suite" +set +e + +sudo -E -H -u jenkins tox -efunctional +EXIT_CODE=$? +set -e + +# Collect and parse result +generate_testr_results +exit $EXIT_CODE diff --git a/tox.ini b/tox.ini index 8cf67c963..d11b1fdc1 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,14 @@ commands = downloadcache = {toxworkdir}/_download whitelist_externals = bash +# TODO(ityaptin): With separation tests to unit and functional folders we need +# set environment variable OS_TEST_PATH=./ceilometer/tests/functional +# in "py-" jobs + +[testenv:py-mongodb] +commands = + bash -x {toxinidir}/setup-test-env-mongodb.sh python setup.py testr --slowest --testr-args="{posargs}" + [testenv:py-mysql] commands = bash -x {toxinidir}/setup-test-env-mysql.sh python setup.py testr --slowest --testr-args="{posargs}" @@ -23,10 +31,20 @@ commands = commands = bash -x {toxinidir}/setup-test-env-postgresql.sh python setup.py testr --slowest --testr-args="{posargs}" +# Functional tests for elastic search [testenv:py-elastic] commands = bash -x {toxinidir}/setup-test-env-elastic.sh python setup.py testr --slowest --testr-args="{posargs}" +# TODO(ityaptin) create a script for running different setup-test-env-*.sh +# for different backends +[testenv:functional] +setenv = VIRTUAL_ENV={envdir} + EVENTLET_NO_GREENDNS=yes + OS_TEST_PATH=ceilometer/tests/functional +commands = + bash -x {toxinidir}/setup-test-env-mongodb.sh python setup.py testr --slowest --testr-args="{posargs}" + [testenv:py34] deps = -r{toxinidir}/requirements-py3.txt -r{toxinidir}/test-requirements-py3.txt @@ -43,7 +61,6 @@ commands = bash -x {toxinidir}/setup-test-env-mongodb.sh \ python setup.py testr --testr-args="{posargs}" - [testenv:cover] commands = bash -x {toxinidir}/setup-test-env-mongodb.sh python setup.py testr --slowest --coverage --testr-args="{posargs}"