From 5d52f773090ee2d21c4b1d7d5a660be5db9bb48a Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Thu, 12 Mar 2015 14:01:11 +0000 Subject: [PATCH] Add cli functional tests from tempest test_readonly_ceilometer is migrated from ./tempest/cli/simple_read_only/telemetry A new 'functional' target is available in tox. In order for these tests to pass OS_PASSWORD, OS_AUTH_URL, OS_USERNAME and OS_TENANT_NAME need to be set in the environment before running the tests, e.g: source src/devstack/openrc demo demo && tox -efunctional Subsequent patches will remove tests from tempest and add thes tests to project-config for gate checks. Change-Id: I3ce5ddbe471d70e8775ec5a1cc908a95a335b5e7 --- ceilometerclient/tests/functional/__init__.py | 0 ceilometerclient/tests/functional/base.py | 38 +++++++++++++++++++ .../functional/test_readonly_ceilometer.py | 34 +++++++++++++++++ test-requirements.txt | 1 + tox.ini | 3 ++ 5 files changed, 76 insertions(+) create mode 100644 ceilometerclient/tests/functional/__init__.py create mode 100644 ceilometerclient/tests/functional/base.py create mode 100644 ceilometerclient/tests/functional/test_readonly_ceilometer.py diff --git a/ceilometerclient/tests/functional/__init__.py b/ceilometerclient/tests/functional/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/ceilometerclient/tests/functional/base.py b/ceilometerclient/tests/functional/base.py new file mode 100644 index 00000000..839748bf --- /dev/null +++ b/ceilometerclient/tests/functional/base.py @@ -0,0 +1,38 @@ +# 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 ClientTestBase(base.ClientTestBase): + """Base class for ceilometerclient tests. + + Establishes the ceilometer client and retrieves the essential environment + information. + """ + + def _get_clients(self): + cli_dir = os.environ.get( + 'OS_CEILOMETER_CLIENT_EXEC_DIR', + os.path.join(os.path.abspath('.'), '.tox/functional/bin')) + + 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 ceilometer(self, *args, **kwargs): + return self.clients.ceilometer(*args, **kwargs) diff --git a/ceilometerclient/tests/functional/test_readonly_ceilometer.py b/ceilometerclient/tests/functional/test_readonly_ceilometer.py new file mode 100644 index 00000000..1fa9748f --- /dev/null +++ b/ceilometerclient/tests/functional/test_readonly_ceilometer.py @@ -0,0 +1,34 @@ +# 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 ceilometerclient.tests.functional import base + + +class SimpleReadOnlyCeilometerClientTest(base.ClientTestBase): + """Basic, read-only tests for Ceilometer CLI client. + + Checks return values and output of read-only commands. + These tests do not presume any content, nor do they create + their own. They only verify the structure of output if present. + """ + + def test_ceilometer_meter_list(self): + self.ceilometer('meter-list') + + def test_ceilometer_resource_list(self): + self.ceilometer('resource-list') + + def test_ceilometermeter_alarm_list(self): + self.ceilometer('alarm-list') + + def test_ceilometer_version(self): + self.ceilometer('', flags='--version') diff --git a/test-requirements.txt b/test-requirements.txt index 6dffed55..e4594233 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -10,5 +10,6 @@ mock>=1.0 oslosphinx>=2.2.0 # Apache-2.0 python-subunit>=0.0.18 sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3 +tempest-lib>=0.3.0 testrepository>=0.0.18 testtools>=0.9.36,!=1.2.0 diff --git a/tox.ini b/tox.ini index 2c5a5428..baca9187 100644 --- a/tox.ini +++ b/tox.ini @@ -24,6 +24,9 @@ commands = python setup.py testr --coverage --testr-args='{posargs}' [testenv:venv] commands = {posargs} +[testenv:functional] +setenv = OS_TEST_PATH=./ceilometerclient/tests/functional + [testenv:docs] commands= python setup.py build_sphinx