Update tests for plugin, cluster and image
Added getting plugin config. Also updated cluster tests with scaling, updating and verification of cluster. Besides, there is new test for setting tags for images Change-Id: I65dec973c0999cfa0e9b91dd59bea1dcd84cf509
This commit is contained in:
parent
b86f25e711
commit
288d96323f
|
@ -0,0 +1,5 @@
|
|||
================
|
||||
Sahara CLI Tests
|
||||
================
|
||||
|
||||
This directory contains tests to cover CLI commands of saharaclient.
|
|
@ -11,9 +11,16 @@
|
|||
# under the License.
|
||||
|
||||
import os
|
||||
import fixtures
|
||||
import time
|
||||
|
||||
from tempest.lib.cli import base
|
||||
from tempest.test import BaseTestCase
|
||||
from tempest.lib import exceptions as exc
|
||||
|
||||
DEL_RESULT = '''\
|
||||
{} "{}" has been removed successfully.
|
||||
'''
|
||||
|
||||
|
||||
class ClientTestBase(base.ClientTestBase):
|
||||
|
@ -49,6 +56,9 @@ class ClientTestBase(base.ClientTestBase):
|
|||
def openstack(self, *args, **kwargs):
|
||||
return self.clients.openstack(*args, **kwargs)
|
||||
|
||||
def neutron(self, *args, **kwargs):
|
||||
return self.clients.neutron(*args, **kwargs)
|
||||
|
||||
def listing_result(self, command):
|
||||
command_for_item = self.openstack('dataprocessing', params=command)
|
||||
result = self.parser.listing(command_for_item)
|
||||
|
@ -66,9 +76,7 @@ class ClientTestBase(base.ClientTestBase):
|
|||
def check_if_delete(self, command, name):
|
||||
delete_cmd = self.openstack('dataprocessing %s delete' % command,
|
||||
params=name)
|
||||
result = ('''\
|
||||
%s "%s" has been removed successfully.
|
||||
''' % (command, name))
|
||||
result = DEL_RESULT.format(command, name)
|
||||
# lower() is required because "command" in the result string could
|
||||
# have the first letter capitalized.
|
||||
self.assertEqual(delete_cmd.lower(), result.lower())
|
||||
|
@ -84,7 +92,7 @@ class ClientTestBase(base.ClientTestBase):
|
|||
return found_plugin
|
||||
|
||||
def find_id_of_pool(self):
|
||||
floating_pool_list = self.openstack('ip floating pool list')
|
||||
floating_pool_list = self.neutron('floatingip-list')
|
||||
floating_pool = self.parser.listing(floating_pool_list)
|
||||
network_list = self.openstack('network list')
|
||||
networks = self.parser.listing(network_list)
|
||||
|
@ -101,9 +109,45 @@ class ClientTestBase(base.ClientTestBase):
|
|||
if net_name == pool_name:
|
||||
name_net_pool = net_name
|
||||
if name_net_pool is None:
|
||||
raise self.skipException('Network list and floating pool ip list'
|
||||
' dont have common networks')
|
||||
raise self.skipException('Network list and floating ip list do '
|
||||
'not have common networks')
|
||||
for network in networks:
|
||||
if network['Name'] == name_net_pool:
|
||||
id_net_pool = network['ID']
|
||||
return id_net_pool
|
||||
|
||||
def _get_cluster_status(self, cluster_name):
|
||||
status = None
|
||||
show_cluster = self.listing_result(''.join(['cluster show ',
|
||||
cluster_name]))
|
||||
for line in show_cluster:
|
||||
if line['Field'] == 'Status':
|
||||
status = line['Value']
|
||||
if status is None:
|
||||
raise self.skipException('Can not find the cluster to get its '
|
||||
'status')
|
||||
return status
|
||||
|
||||
def _poll_cluster_status(self, cluster_name):
|
||||
with fixtures.Timeout(300, gentle=True):
|
||||
while True:
|
||||
status = self._get_cluster_status(cluster_name)
|
||||
if status == 'Active':
|
||||
break
|
||||
if status == 'Error':
|
||||
raise exc.TempestException("Cluster in %s state" % status)
|
||||
time.sleep(3)
|
||||
|
||||
def wait_for_resource_deletion(self, name, type):
|
||||
# type can be cluster, cluster template or node group template string
|
||||
name_exist = False
|
||||
# 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_names = [p['Name'] for p in list_of_types]
|
||||
for resource_name in list_names:
|
||||
if resource_name == name:
|
||||
name_exist = True
|
||||
if not name_exist:
|
||||
break
|
||||
|
|
|
@ -46,13 +46,17 @@ class SaharaClusterTemplateCLITest(base.ClientTestBase):
|
|||
cluster_template_name)
|
||||
|
||||
def openstack_cluster_template_update(self, cluster_template_name):
|
||||
new_cluster_template_name = ''.join([cluster_template_name, '1'])
|
||||
self.assertTableStruct(
|
||||
self.listing_result(
|
||||
''.join(['cluster template update ', cluster_template_name])),
|
||||
''.join(['cluster template update --name ',
|
||||
new_cluster_template_name, ' ',
|
||||
cluster_template_name])),
|
||||
[
|
||||
'Field',
|
||||
'Value'
|
||||
])
|
||||
return new_cluster_template_name
|
||||
|
||||
def openstack_cluster_template_delete(self, cluster_template_name):
|
||||
self.check_if_delete('cluster template', cluster_template_name)
|
||||
|
|
|
@ -12,6 +12,11 @@
|
|||
|
||||
from sahara_tempest_plugin.tests.cli import base
|
||||
from tempest.lib.common.utils import data_utils
|
||||
import fixtures
|
||||
|
||||
VERIF_RESULT = '''\
|
||||
Cluster "%s" health verification has been started.
|
||||
'''
|
||||
|
||||
|
||||
class SaharaClusterCLITest(base.ClientTestBase):
|
||||
|
@ -39,16 +44,52 @@ class SaharaClusterCLITest(base.ClientTestBase):
|
|||
'Field',
|
||||
'Value'
|
||||
])
|
||||
self._poll_cluster_status(cluster_name)
|
||||
return cluster_name
|
||||
|
||||
def openstack_cluster_delete(self, cluster_name):
|
||||
self.assertTableStruct(
|
||||
self.listing_result(''.join(['cluster delete ', cluster_name])), [
|
||||
'Field',
|
||||
'Value'
|
||||
])
|
||||
delete_cluster = self.listing_result(''.join(['cluster delete ',
|
||||
cluster_name]))
|
||||
self.assertTableStruct(delete_cluster, [
|
||||
'Field',
|
||||
'Value'
|
||||
])
|
||||
|
||||
def openstack_cluster_show(self, cluster_name):
|
||||
self.find_in_listing(
|
||||
self.listing_result(''.join(['cluster show ', cluster_name])),
|
||||
cluster_name)
|
||||
|
||||
def openstack_cluster_update(self, cluster_name):
|
||||
self.assertTableStruct(
|
||||
self.listing_result(''.join(['cluster update ',
|
||||
'--description cli-tests ',
|
||||
cluster_name])), [
|
||||
'Field',
|
||||
'Value'
|
||||
])
|
||||
|
||||
def openstack_cluster_verification_show(self, cluster_name):
|
||||
self.assertTableStruct(
|
||||
self.listing_result(''.join(['cluster verification --show ',
|
||||
cluster_name])), [
|
||||
'Field',
|
||||
'Value'
|
||||
])
|
||||
|
||||
def openstack_cluster_verification_start(self, cluster_name):
|
||||
result = self.openstack('dataprocessing cluster verification --start',
|
||||
params=cluster_name)
|
||||
expected_result = VERIF_RESULT % cluster_name
|
||||
self.assertEqual(result, expected_result)
|
||||
|
||||
def openstack_cluster_scale(self, cluster_name, ng_worker):
|
||||
with fixtures.Timeout(300, gentle=True):
|
||||
scale_cluster = self.listing_result(
|
||||
''.join(['cluster scale --instances ', ng_worker,
|
||||
':2 --wait ', cluster_name]))
|
||||
self.assertTableStruct(scale_cluster, [
|
||||
'Field',
|
||||
'Value'
|
||||
])
|
||||
self._poll_cluster_status(cluster_name)
|
||||
|
|
|
@ -55,8 +55,16 @@ class SaharaImageCLITest(base.ClientTestBase):
|
|||
'Value'
|
||||
])
|
||||
|
||||
def openstack_image_tags_set(self, image_name):
|
||||
flag = ''.join([image_name, ' --tags update_tag'])
|
||||
self.assertTableStruct(
|
||||
self.listing_result(''.join(['image tags set ', flag])), [
|
||||
'Field',
|
||||
'Value'
|
||||
])
|
||||
|
||||
def openstack_image_tags_remove(self, image_name):
|
||||
flag = ''.join([image_name, ' --tags test'])
|
||||
flag = ''.join([image_name, ' --tags update_tag'])
|
||||
self.assertTableStruct(
|
||||
self.listing_result(''.join(['image tags remove ', flag])), [
|
||||
'Field',
|
||||
|
|
|
@ -54,12 +54,16 @@ class SaharaNodeGroupCLITest(base.ClientTestBase):
|
|||
node_group_name)
|
||||
|
||||
def openstack_node_group_template_update(self, node_group_name):
|
||||
new_node_group_name = ''.join([node_group_name, '1'])
|
||||
self.assertTableStruct(
|
||||
self.listing_result(
|
||||
''.join(['node group template update ', node_group_name])), [
|
||||
''.join(['node group template update --name ',
|
||||
new_node_group_name, ' ',
|
||||
node_group_name])), [
|
||||
'Field',
|
||||
'Value'
|
||||
])
|
||||
return new_node_group_name
|
||||
|
||||
def openstack_node_group_template_delete(self, node_group_name):
|
||||
self.check_if_delete('node group template', node_group_name)
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from os import path
|
||||
|
||||
from sahara_tempest_plugin.tests.cli import base
|
||||
|
||||
|
||||
|
@ -31,3 +33,16 @@ class SaharaPluginCLITest(base.ClientTestBase):
|
|||
'Field',
|
||||
'Value'
|
||||
])
|
||||
|
||||
def openstack_plugin_configs_get(self):
|
||||
list_plugin = self.listing_result('plugin list')
|
||||
name = [p['Name'] for p in list_plugin]
|
||||
version = [p['Versions'] for p in list_plugin]
|
||||
if len(name) == 0:
|
||||
raise self.SkipException('No plugin to get configs')
|
||||
plugin_name = name[0]
|
||||
self.openstack('dataprocessing plugin configs get',
|
||||
params=''.join([plugin_name, ' ',
|
||||
version[0]]))
|
||||
result = path.exists(plugin_name)
|
||||
self.assertTrue(result)
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import time
|
||||
from sahara_tempest_plugin.tests.cli import clusters
|
||||
from sahara_tempest_plugin.tests.cli import cluster_templates
|
||||
from sahara_tempest_plugin.tests.cli import images
|
||||
|
@ -21,7 +20,6 @@ from sahara_tempest_plugin.tests.cli import jobs
|
|||
from sahara_tempest_plugin.tests.cli import job_templates
|
||||
from sahara_tempest_plugin.tests.cli import data_sources
|
||||
from sahara_tempest_plugin.tests.cli import job_types
|
||||
from tempest.test import BaseTestCase
|
||||
|
||||
|
||||
class Scenario(images.SaharaImageCLITest,
|
||||
|
@ -38,15 +36,18 @@ class Scenario(images.SaharaImageCLITest,
|
|||
def test_plugin_cli(self):
|
||||
self.openstack_plugin_list()
|
||||
self.openstack_plugin_show()
|
||||
self.openstack_plugin_configs_get()
|
||||
|
||||
def test_node_group_cli(self):
|
||||
master_ngt = self.openstack_node_group_template_create('master', '4')
|
||||
worker_ngt = self.openstack_node_group_template_create('worker', '3')
|
||||
self.openstack_node_group_template_list()
|
||||
self.openstack_node_group_template_update(master_ngt)
|
||||
self.openstack_node_group_template_show(master_ngt)
|
||||
self.openstack_node_group_template_delete(master_ngt)
|
||||
new_master_ngt = self.openstack_node_group_template_update(master_ngt)
|
||||
self.openstack_node_group_template_show(new_master_ngt)
|
||||
self.openstack_node_group_template_delete(new_master_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')
|
||||
|
||||
def test_cluster_template_cli(self):
|
||||
ng_master = (
|
||||
|
@ -57,14 +58,21 @@ class Scenario(images.SaharaImageCLITest,
|
|||
self.openstack_cluster_template_create(ng_master, ng_worker))
|
||||
self.openstack_cluster_template_list()
|
||||
self.openstack_cluster_template_show(cluster_template_name)
|
||||
self.openstack_cluster_template_update(cluster_template_name)
|
||||
self.openstack_cluster_template_delete(cluster_template_name)
|
||||
new_cluster_template_name = self.openstack_cluster_template_update(
|
||||
cluster_template_name)
|
||||
self.openstack_cluster_template_delete(new_cluster_template_name)
|
||||
self.wait_for_resource_deletion(new_cluster_template_name, 'cluster '
|
||||
'template')
|
||||
self.openstack_node_group_template_delete(ng_master)
|
||||
self.openstack_node_group_template_delete(ng_worker)
|
||||
self.wait_for_resource_deletion(ng_master, 'node group template')
|
||||
self.wait_for_resource_deletion(ng_worker, 'node group template')
|
||||
|
||||
def test_cluster_cli(self):
|
||||
image_name = self.openstack_image_register(
|
||||
'xenial-server-cloudimg-amd64-disk1')
|
||||
self.openstack_image_tags_set(image_name)
|
||||
self.openstack_image_tags_remove(image_name)
|
||||
self.openstack_image_tags_add(image_name)
|
||||
self.openstack_image_show(image_name)
|
||||
self.openstack_image_list()
|
||||
|
@ -86,13 +94,19 @@ class Scenario(images.SaharaImageCLITest,
|
|||
self.openstack_cluster_create(cluster_template_name, image_name))
|
||||
self.openstack_cluster_list()
|
||||
self.openstack_cluster_show(cluster_name)
|
||||
self.openstack_cluster_update(cluster_name)
|
||||
self.openstack_cluster_verification_show(cluster_name)
|
||||
self.openstack_cluster_verification_start(cluster_name)
|
||||
self.openstack_cluster_scale(cluster_name, ng_worker)
|
||||
self.openstack_cluster_delete(cluster_name)
|
||||
# FIXME: this should be replaced by a proper busy waiting
|
||||
time.sleep(300)
|
||||
self.wait_for_resource_deletion(cluster_name, 'cluster')
|
||||
self.openstack_cluster_template_delete(cluster_template_name)
|
||||
self.wait_for_resource_deletion(cluster_template_name, 'cluster '
|
||||
'template')
|
||||
self.openstack_node_group_template_delete(ng_master)
|
||||
self.openstack_node_group_template_delete(ng_worker)
|
||||
self.openstack_image_tags_remove(image_name)
|
||||
self.wait_for_resource_deletion(ng_master, 'node group template')
|
||||
self.wait_for_resource_deletion(ng_worker, 'node group template')
|
||||
self.openstack_image_unregister(image_name)
|
||||
|
||||
def test_job_binary_cli(self):
|
||||
|
|
Loading…
Reference in New Issue