Merge "Add new negative cli tests for node group templates"

This commit is contained in:
Jenkins 2017-01-18 12:08:32 +00:00 committed by Gerrit Code Review
commit 99f7190ad5
3 changed files with 60 additions and 22 deletions

View File

@ -108,8 +108,7 @@ class ClientTestBase(base.ClientTestBase):
def _get_cluster_status(self, cluster_name):
status = None
show_cluster = self.listing_result(''.join(['cluster show ',
cluster_name]))
show_cluster = self.listing_result('cluster show %s' % cluster_name)
for line in show_cluster:
if line['Field'] == 'Status':
status = line['Value']
@ -146,7 +145,7 @@ class ClientTestBase(base.ClientTestBase):
# if name exists in the command "type list" than tests should fail
with fixtures.Timeout(300, gentle=True):
while True:
list_of_types = self.listing_result(''.join([type, ' list']))
list_of_types = self.listing_result('%s list' % type)
list_names = [p['Name'] for p in list_of_types]
if name in list_names:
name_exist = True

View File

@ -10,9 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from sahara_tempest_plugin.tests.cli import base
from tempest.lib.common.utils import data_utils
from sahara_tempest_plugin.tests.cli import base
class SaharaNodeGroupCLITest(base.ClientTestBase):
@ -31,17 +32,15 @@ class SaharaNodeGroupCLITest(base.ClientTestBase):
node_group_name = data_utils.rand_name(ng_type)
flags = ("%(ngt_name)s %(plugin)s %(plugin-version)s "
"%(processes)s %(flavor)s %(floating-pool)s"
% {'floating-pool': ''.join([' --floating-ip-pool ',
id_net_pool]),
'flavor': ''.join([' --flavor ', flavor_id]),
% {'floating-pool': ' --floating-ip-pool %s' % id_net_pool,
'flavor': ' --flavor %s' % flavor_id,
'processes': ' --processes datanode',
'plugin-version':
''.join([' --plugin-version ', plugin['Versions']]),
'plugin': ''.join([' --plugin ', plugin['Name']]),
'ngt_name': ''.join(['--name ', node_group_name])})
'plugin-version': ' --plugin-version %s'
% plugin['Versions'],
'plugin': ' --plugin %s' % plugin['Name'],
'ngt_name': '--name %s' % node_group_name})
self.assertTableStruct(
self.listing_result(''.join(['node group template create ',
flags])), [
self.listing_result('node group template create %s' % flags), [
'Field',
'Value'
])
@ -49,17 +48,32 @@ class SaharaNodeGroupCLITest(base.ClientTestBase):
def openstack_node_group_template_show(self, node_group_name):
self.find_in_listing(
self.listing_result(
''.join(['node group template show ', node_group_name])),
self.listing_result('node group template show %s'
% node_group_name),
node_group_name)
def openstack_node_group_template_update(self, node_group_name):
new_node_group_name = ''.join([node_group_name, '1'])
def openstack_node_group_template_update(self, node_group_name,
update_field=None):
"""Update node group template with necessary parameters
Args:
node_group_name (str): name of node group to update
update_field (str): param how to update the node group. Using
this arg, there are several available updates of node group:
name, public/private, protected/unprotected
"""
new_node_group_name = None
cmd = 'node group template update %s' % node_group_name
if update_field == 'name':
new_node_group_name = data_utils.rand_name(node_group_name)
update_cmd = '--%s %s' % (update_field, new_node_group_name)
elif update_field:
# here we check only updating with public/protected flags for now
update_cmd = '--%s' % update_field
else:
# if update_field is None, update_command should be empty
update_cmd = ''
self.assertTableStruct(
self.listing_result(
''.join(['node group template update --name ',
new_node_group_name, ' ',
node_group_name])), [
self.listing_result('%s %s' % (cmd, update_cmd)), [
'Field',
'Value'
])
@ -67,3 +81,25 @@ class SaharaNodeGroupCLITest(base.ClientTestBase):
def openstack_node_group_template_delete(self, node_group_name):
self.check_if_delete('node group template', node_group_name)
def negative_delete_removed_node_group(self, node_group_name):
"""Test to remove already deleted node group template"""
command_to_execute = 'node group template delete'
self.check_negative_scenarios(base.TEMPEST_ERROR_MESSAGE,
command_to_execute,
node_group_name)
def negative_try_to_delete_protected_node_group(self, node_group_name):
"""Test to delete protected node group template"""
self.openstack_node_group_template_update(node_group_name,
update_field='protected')
error_message = ("NodeGroupTemplate with id '%s' could not be deleted "
"because it's marked as protected"
% self._get_resource_id('node group template',
node_group_name))
command_to_execute = 'node group template delete'
self.check_negative_scenarios(error_message,
command_to_execute,
node_group_name)
self.openstack_node_group_template_update(node_group_name,
update_field='unprotected')

View File

@ -54,15 +54,18 @@ class Scenario(images.SaharaImageCLITest,
worker_ngt)
self.openstack_node_group_template_list()
new_master_ngt = self.openstack_node_group_template_update(master_ngt)
new_master_ngt = self.openstack_node_group_template_update(
master_ngt, update_field='name')
self.addCleanup(self.delete_resource, 'node group template',
new_master_ngt)
self.openstack_node_group_template_show(new_master_ngt)
self.openstack_node_group_template_delete(new_master_ngt)
self.negative_try_to_delete_protected_node_group(worker_ngt)
self.openstack_node_group_template_delete(worker_ngt)
self.wait_for_resource_deletion(new_master_ngt, 'node group template')
self.wait_for_resource_deletion(worker_ngt, 'node group template')
self.negative_delete_removed_node_group(worker_ngt)
def test_cluster_template_cli(self):
ng_master = (