Browse Source

First pass at tempest_lib based functional testing

Begin moving tempest nova CLI tests out of tempest and into this repo
using tempest-lib. This patch adds the framework to run the functional
tests, later patches will port the existing tempest tests.

Use standard OpenStack environment variables to get keystone auth

Change-Id: Ie957bd450bfed97b63788cfb488f92988fbbc889
Joe Gordon 4 years ago
parent
commit
b89da9be28

+ 0
- 0
novaclient/tests/functional/__init__.py View File


+ 44
- 0
novaclient/tests/functional/base.py View File

@@ -0,0 +1,44 @@
1
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+#    not use this file except in compliance with the License. You may obtain
3
+#    a copy of the License at
4
+#
5
+#         http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+#    Unless required by applicable law or agreed to in writing, software
8
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+#    License for the specific language governing permissions and limitations
11
+#    under the License.
12
+
13
+import os
14
+
15
+from tempest_lib.cli import base
16
+
17
+
18
+class ClientTestBase(base.ClientTestBase):
19
+    """
20
+    This is a first pass at a simple read only python-novaclient test. This
21
+    only exercises client commands that are read only.
22
+
23
+    This should test commands:
24
+    * as a regular user
25
+    * as a admin user
26
+    * with and without optional parameters
27
+    * initially just check return codes, and later test command outputs
28
+
29
+    """
30
+    def _get_clients(self):
31
+        cli_dir = os.environ.get(
32
+            'OS_NOVACLIENT_EXEC_DIR',
33
+            os.path.join(os.path.abspath('.'), '.tox/functional/bin'))
34
+
35
+        return base.CLIClient(
36
+            username=os.environ.get('OS_USERNAME'),
37
+            password=os.environ.get('OS_PASSWORD'),
38
+            tenant_name=os.environ.get('OS_TENANT_NAME'),
39
+            uri=os.environ.get('OS_AUTH_URL'),
40
+            cli_dir=cli_dir)
41
+
42
+    def nova(self, *args, **kwargs):
43
+        return self.clients.nova(*args,
44
+                                 **kwargs)

+ 51
- 0
novaclient/tests/functional/test_readonly_nova.py View File

@@ -0,0 +1,51 @@
1
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+#    not use this file except in compliance with the License. You may obtain
3
+#    a copy of the License at
4
+#
5
+#         http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+#    Unless required by applicable law or agreed to in writing, software
8
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+#    License for the specific language governing permissions and limitations
11
+#    under the License.
12
+
13
+from tempest_lib import exceptions
14
+
15
+from novaclient.tests.functional import base
16
+
17
+
18
+class SimpleReadOnlyNovaClientTest(base.ClientTestBase):
19
+
20
+    """
21
+    This is a first pass at a simple read only python-novaclient test. This
22
+    only exercises client commands that are read only.
23
+
24
+    This should test commands:
25
+    * as a regular user
26
+    * as a admin user
27
+    * with and without optional parameters
28
+    * initially just check return codes, and later test command outputs
29
+
30
+    """
31
+
32
+    def test_admin_fake_action(self):
33
+        self.assertRaises(exceptions.CommandFailed,
34
+                          self.nova,
35
+                          'this-does-nova-exist')
36
+
37
+    # NOTE(jogo): Commands in order listed in 'nova help'
38
+
39
+    # Optional arguments:
40
+
41
+    def test_admin_version(self):
42
+        self.nova('', flags='--version')
43
+
44
+    def test_admin_debug_list(self):
45
+        self.nova('list', flags='--debug')
46
+
47
+    def test_admin_timeout(self):
48
+        self.nova('list', flags='--timeout %d' % 10)
49
+
50
+    def test_admin_timing(self):
51
+        self.nova('list', flags='--timing')

+ 1
- 0
test-requirements.txt View File

@@ -14,3 +14,4 @@ oslosphinx>=2.2.0  # Apache-2.0
14 14
 testrepository>=0.0.18
15 15
 testscenarios>=0.4
16 16
 testtools>=0.9.36,!=1.2.0
17
+tempest-lib>=0.1.0

+ 4
- 0
tox.ini View File

@@ -23,6 +23,10 @@ commands = flake8 {posargs}
23 23
 [testenv:venv]
24 24
 commands = {posargs}
25 25
 
26
+[testenv:functional]
27
+setenv =
28
+  OS_TEST_PATH = ./novaclient/tests/functional
29
+
26 30
 [testenv:cover]
27 31
 commands = python setup.py testr --coverage --testr-args='{posargs}'
28 32
 

Loading…
Cancel
Save