diff --git a/.testr.conf b/.testr.conf index 9355c2748..3d3e1e6ee 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 000000000..e69de29bb diff --git a/keystoneclient/tests/functional/base.py b/keystoneclient/tests/functional/base.py new file mode 100644 index 000000000..2f8eff5e1 --- /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 000000000..0a07aa77d --- /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 000000000..3aecba276 --- /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 ecfb32568..30f415067 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 79b5e7574..1bbc10d12 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 diff --git a/tox.ini b/tox.ini index 3f12ef3aa..56a432002 100644 --- a/tox.ini +++ b/tox.ini @@ -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