blob: 742b5a43106a73dc2a3110c2f021d562c60a0963 [file] [log] [blame]
Joe Gordonc97f5c72013-02-14 01:15:57 +00001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2013 OpenStack Foundation
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
18import logging
19import shlex
20import subprocess
21
22import testtools
23
24import cli
25
26from tempest import config
27from tempest.openstack.common import cfg
28
29
30CONF = cfg.CONF
31
32
33LOG = logging.getLogger(__name__)
34
35
36class SimpleReadOnlyNovaCLientTest(testtools.TestCase):
37
38 """
39 This is a first pass at a simple read only python-novaclient test. This
40 only exercises client commands that are read only.
41
42 This should test commands:
43 * as a regular user
44 * as a admin user
45 * with and without optional parameters
46 * initially just check return codes, and later test command outputs
47
48 """
49
50 @classmethod
51 def setUpClass(cls):
52 if not CONF.cli.enabled:
53 msg = "cli testing disabled"
54 raise cls.skipException(msg)
55 cls.identity = config.TempestConfig().identity
56 super(SimpleReadOnlyNovaCLientTest, cls).setUpClass()
57
58 def nova(self, action, flags='', params='', admin=True, fail_ok=False):
59 """Executes nova command for the given action."""
60 #TODO(jogo) make admin=False work
61 creds = ('--os-username %s --os-tenant-name %s --os-password %s '
62 '--os-auth-url %s ' % (self.identity.admin_username,
63 self.identity.admin_tenant_name, self.identity.admin_password,
64 self.identity.uri))
65 flags = creds + ' ' + flags
66 cmd = ' '.join([CONF.cli.cli_dir + 'nova', flags, action, params])
67 LOG.info("running: '%s'" % cmd)
68 cmd = shlex.split(cmd)
69 result = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
70 return result
71
72 def test_admin_version(self):
73 self.nova('', flags='--version')
74
75 def test_admin_timing(self):
76 self.nova('list', flags='--timing')
77
78 def test_admin_timeout(self):
79 self.nova('list', flags='--timeout 2')
80
81 def test_admin_debug_list(self):
82 self.nova('list', flags='--debug')
83
84 def test_admin_fake_action(self):
85 self.assertRaises(subprocess.CalledProcessError,
86 self.nova,
87 'this-does-nova-exist')
88
89 def test_admin_aggregate_list(self):
90 self.nova('aggregate-list')
91
92 def test_admin_cloudpipe_list(self):
93 self.nova('cloudpipe-list')
94
95 def test_admin_image_list(self):
96 self.nova('image-list')
97
98 def test_admin_dns_domains(self):
99 self.nova('dns-domains')
100
101 def test_admin_flavor_list(self):
102 self.nova('flavor-list')
103
104 #TODO(jogo) add more tests