First pass at tempest_lib based functional testing
Begin moving tempest based CLI tests out of murano repo and into this repo using tempest-lib. This patch adds the framework to run the functional tests. Use standard OpenStack environment variables to get keystone auth. Change-Id: Ic0952dcf721a4d20378cc593d59a7c1e1e794cfc
This commit is contained in:
parent
2bbc396b0b
commit
7d1443f2fc
|
@ -0,0 +1,47 @@
|
|||
# Copyright (c) 2014 Mirantis, Inc.
|
||||
#
|
||||
# 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):
|
||||
|
||||
def murano(self, action, flags='', params='',
|
||||
fail_ok=False, endpoint_type='publicURL', merge_stderr=True):
|
||||
return self.clients.cmd_with_auth(
|
||||
'murano', action, flags, params, fail_ok, merge_stderr)
|
||||
|
||||
def _get_clients(self):
|
||||
cli_dir = os.environ.get(
|
||||
'OS_MURANOCLIENT_EXEC_DIR',
|
||||
os.path.join(os.path.abspath('.'), '.tox/functional/bin'))
|
||||
|
||||
clients = 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
|
||||
)
|
||||
return clients
|
||||
|
||||
def listing(self, command, params=""):
|
||||
return self.parser.listing(self.murano(command, params=params))
|
||||
|
||||
def get_value(self, need_field, known_field, known_value, somelist):
|
||||
for element in somelist:
|
||||
if element[known_field] == known_value:
|
||||
return element[need_field]
|
|
@ -0,0 +1,129 @@
|
|||
# Copyright (c) 2014 Mirantis, Inc.
|
||||
#
|
||||
# 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 time
|
||||
import uuid
|
||||
|
||||
from muranoclient.tests.functional import muranoclient
|
||||
|
||||
|
||||
class SimpleReadOnlyMuranoClientTest(muranoclient.ClientTestBase):
|
||||
"""Basic, read-only tests for Murano CLI client.
|
||||
|
||||
Basic smoke test for the Murano CLI commands which do not require
|
||||
creating or modifying murano objects.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(SimpleReadOnlyMuranoClientTest, cls).setUpClass()
|
||||
|
||||
def test_environment_list(self):
|
||||
environments = self.listing('environment-list')
|
||||
|
||||
self.assertTableStruct(environments,
|
||||
['ID', 'Name', 'Created', 'Updated'])
|
||||
|
||||
def test_package_list(self):
|
||||
packages = self.listing('package-list')
|
||||
|
||||
self.assertTableStruct(packages,
|
||||
['ID', 'Name', 'FQN', 'Author', 'Is Public'])
|
||||
|
||||
def test_category_list(self):
|
||||
self.murano('category-list')
|
||||
|
||||
def test_table_struct_of_environment_create(self):
|
||||
env_name = "gg" + uuid.uuid4().hex
|
||||
environment = self.listing('environment-create', params=env_name)
|
||||
|
||||
self.assertTableStruct(environment,
|
||||
['ID', 'Name', 'Created', 'Updated'])
|
||||
|
||||
def test_table_struct_of_environment_delete(self):
|
||||
env_name = "gg" + uuid.uuid4().hex
|
||||
environment = self.listing('environment-create', params=env_name)
|
||||
|
||||
ID = self.get_value('ID', 'Name', env_name, environment)
|
||||
|
||||
delete_env = self.listing('environment-delete', params=ID)
|
||||
|
||||
self.assertTableStruct(delete_env,
|
||||
['ID', 'Name', 'Created', 'Updated'])
|
||||
|
||||
|
||||
class EnvironmentMuranoClientTest(muranoclient.ClientTestBase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(EnvironmentMuranoClientTest, cls).setUpClass()
|
||||
|
||||
def test_environment_create(self):
|
||||
env_name = "gg" + uuid.uuid4().hex
|
||||
environment = self.listing('environment-create', params=env_name)
|
||||
|
||||
environment_list = self.listing('environment-list')
|
||||
|
||||
self.assertIn(env_name, [env['Name'] for env in environment])
|
||||
self.assertIn(env_name, [env['Name'] for env in environment_list])
|
||||
|
||||
def test_environment_delete(self):
|
||||
env_name = "gg" + uuid.uuid4().hex
|
||||
environments = self.listing('environment-create', params=env_name)
|
||||
|
||||
ID = self.get_value('ID', 'Name', env_name, environments)
|
||||
|
||||
self.listing('environment-delete', params=ID)
|
||||
|
||||
start_time = time.time()
|
||||
while env_name in [env['Name']
|
||||
for env in self.listing('environment-list')]:
|
||||
if start_time - time.time() > 60:
|
||||
self.fail("Environment is not deleted in 60 seconds")
|
||||
|
||||
def test_environment_show(self):
|
||||
env_name = "gg" + uuid.uuid4().hex
|
||||
environment = self.listing('environment-create', params=env_name)
|
||||
|
||||
ID = self.get_value('ID', 'Name', env_name, environment)
|
||||
|
||||
created = self.get_value('Created', 'Name', env_name, environment)
|
||||
updated = self.get_value('Updated', 'Name', env_name, environment)
|
||||
|
||||
show_env = self.listing('environment-show', params=ID)
|
||||
|
||||
self.assertEqual(env_name, self.get_value('Value', 'Property', 'name',
|
||||
show_env))
|
||||
self.assertEqual(created, self.get_value('Value', 'Property',
|
||||
'created', show_env))
|
||||
self.assertEqual(updated, self.get_value('Value', 'Property',
|
||||
'updated', show_env))
|
||||
|
||||
def test_environment_rename(self):
|
||||
env_name = "gg" + uuid.uuid4().hex
|
||||
environment = self.listing('environment-create', params=env_name)
|
||||
|
||||
ID = self.get_value('ID', 'Name', env_name, environment)
|
||||
|
||||
new_name = "renamed" + uuid.uuid4().hex
|
||||
rename_env = self.listing('environment-rename',
|
||||
params='{id} {name}'.format(id=ID,
|
||||
name=new_name))
|
||||
|
||||
show_env = self.listing('environment-show', params=ID)
|
||||
|
||||
self.assertEqual(new_name, self.get_value('Name', 'ID', ID,
|
||||
rename_env))
|
||||
self.assertEqual(new_name, self.get_value('Value', 'Property', 'name',
|
||||
show_env))
|
|
@ -8,7 +8,7 @@ discover
|
|||
fixtures>=0.3.14
|
||||
mock>=1.0
|
||||
requests-mock>=0.6.0 # Apache-2.0
|
||||
tempest-lib>=0.4.0
|
||||
tempest-lib>=0.5.0
|
||||
testrepository>=0.0.18
|
||||
testscenarios>=0.4
|
||||
testtools>=0.9.36,!=1.2.0
|
||||
|
|
Loading…
Reference in New Issue