diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-02-13 15:56:05 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-02-13 15:56:05 +0000 |
commit | 4e2a14a132dc7d423824963681687644b73b3145 (patch) | |
tree | 77a553f0b436a533464fd5ead3d415d24fe8d651 | |
parent | ae784225627f1652638edc0bf273a41519a438d5 (diff) | |
parent | ffe34935a4ec69cd3e1e31ddff1b8cbdfaf35ab0 (diff) | |
download | python-keystoneclient-4e2a14a132dc7d423824963681687644b73b3145.tar.gz |
Merge "Create functional test base"
-rw-r--r-- | .testr.conf | 2 | ||||
-rw-r--r-- | keystoneclient/tests/functional/__init__.py | 0 | ||||
-rw-r--r-- | keystoneclient/tests/functional/base.py | 32 | ||||
-rw-r--r-- | keystoneclient/tests/functional/hooks/post_test_hook.sh | 50 | ||||
-rw-r--r-- | keystoneclient/tests/functional/test_fake.py | 25 | ||||
-rwxr-xr-x | run_tests.sh | 2 | ||||
-rw-r--r-- | test-requirements.txt | 1 | ||||
-rw-r--r-- | tox.ini | 3 |
8 files changed, 113 insertions, 2 deletions
diff --git a/.testr.conf b/.testr.conf index 9355c27..3d3e1e6 100644 --- a/.testr.conf +++ b/.testr.conf @@ -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 diff --git a/keystoneclient/tests/functional/__init__.py b/keystoneclient/tests/functional/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/keystoneclient/tests/functional/__init__.py diff --git a/keystoneclient/tests/functional/base.py b/keystoneclient/tests/functional/base.py new file mode 100644 index 0000000..2f8eff5 --- /dev/null +++ b/keystoneclient/tests/functional/base.py @@ -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) diff --git a/keystoneclient/tests/functional/hooks/post_test_hook.sh b/keystoneclient/tests/functional/hooks/post_test_hook.sh new file mode 100644 index 0000000..0a07aa7 --- /dev/null +++ b/keystoneclient/tests/functional/hooks/post_test_hook.sh @@ -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 diff --git a/keystoneclient/tests/functional/test_fake.py b/keystoneclient/tests/functional/test_fake.py new file mode 100644 index 0000000..3aecba2 --- /dev/null +++ b/keystoneclient/tests/functional/test_fake.py @@ -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') diff --git a/run_tests.sh b/run_tests.sh index ecfb325..30f4150 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -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 diff --git a/test-requirements.txt b/test-requirements.txt index 79b5e75..1bbc10d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 @@ -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 |