Create functional test base

Setup test runners to run unit tests by default and add a stub
functional test that we can get gating.

Change-Id: I6627925ab63340c880adc7c938a0b74faff47bc7
Implements: bp functional-testing
This commit is contained in:
Jamie Lennox 2015-02-13 11:16:03 +11:00
parent 32c18a83e2
commit ffe34935a4
8 changed files with 113 additions and 2 deletions

View File

@ -1,4 +1,4 @@
[DEFAULT]
test_command=${PYTHON:-python} -m subunit.run discover -t ./ ./keystoneclient/tests $LISTOPT $IDOPTION
test_command=${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./keystoneclient/tests/unit} $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list

View File

@ -0,0 +1,32 @@
# 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
from tempest_lib.cli import base
class TestCase(base.ClientTestBase):
def _get_clients(self):
path = os.path.join(os.path.abspath('.'), '.tox/functional/bin')
cli_dir = os.environ.get('OS_KEYSTONECLIENT_EXEC_DIR', path)
return base.CLIClient(
username=os.environ.get('OS_USERNAME'),
password=os.environ.get('OS_PASSWORD'),
tenant_name=os.environ.get('OS_TENANT_NAME'),
uri=os.environ.get('OS_AUTH_URL'),
cli_dir=cli_dir)
def keystone(self, *args, **kwargs):
return self.clients.keystone(*args, **kwargs)

View File

@ -0,0 +1,50 @@
#!/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 KEYSTONECLIENT_DIR="$BASE/new/python-keystoneclient"
# Get admin credentials
cd $BASE/new/devstack
source openrc admin admin
# Go to the keystoneclient dir
cd $KEYSTONECLIENT_DIR
sudo chown -R jenkins:stack $KEYSTONECLIENT_DIR
# Run tests
echo "Running keystoneclient functional test suite"
set +e
# Preserve env for OS_ credentials
sudo -E -H -u jenkins tox -efunctional
EXIT_CODE=$?
set -e
# Collect and parse result
generate_testr_results
exit $EXIT_CODE

View File

@ -0,0 +1,25 @@
# 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.
from keystoneclient.tests.functional import base
class FakeTests(base.TestCase):
# NOTE(jamielennox): These are purely to have something that passes to
# submit to the gate. After that is working this file can be removed and
# the real tests can begin to be ported from tempest.
def test_version(self):
# NOTE(jamilennox): lol, 1st bug: version goes to stderr - can't test
# value, however it tests that return value = 0 automatically.
self.keystone('', flags='--version')

View File

@ -81,7 +81,7 @@ function run_tests {
if [ "$testropts" = "" ] && [ "$testrargs" = "" ]; then
# Default to running all tests if specific test is not
# provided.
testrargs="discover ./keystoneclient/tests"
testrargs="discover ./keystoneclient/tests/unit"
fi
${wrapper} python -m testtools.run $testropts $testrargs

View File

@ -17,6 +17,7 @@ oslotest>=1.2.0 # Apache-2.0
pycrypto>=2.6
requests-mock>=0.5.1 # Apache-2.0
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
tempest-lib>=0.2.0
testrepository>=0.0.18
testresources>=0.2.4
testtools>=0.9.36,!=1.2.0

View File

@ -30,6 +30,9 @@ downloadcache = ~/cache/pip
[testenv:debug]
commands = oslo_debug_helper -t keystoneclient/tests {posargs}
[testenv:functional]
setenv = OS_TEST_PATH=./keystoneclient/tests/functional
[flake8]
# H405: multi line docstring summary not separated with an empty line
ignore = H405