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
This commit is contained in:
Ilya Tyaptin 2015-05-14 18:04:03 +03:00
parent c0b9db16a5
commit afe7af8218
3 changed files with 64 additions and 1 deletions

View File

View File

@ -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

19
tox.ini
View File

@ -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-<backend>" 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}"