Negative tests for testing actions with Chassis
Negative tests for the Ironic CLI commands which checks actions with chassis command like show, update, delete either using with arguments or without arguments. Change-Id: I7431febddbdf7b064932d208a36f99317145d5e7
This commit is contained in:
parent
7548aca0ab
commit
a7fc7901a7
@ -278,11 +278,12 @@ class FunctionalTestBase(base.ClientTestBase):
|
||||
driver_list = self.list_driver()
|
||||
return [x['Supported driver(s)'] for x in driver_list]
|
||||
|
||||
def delete_chassis(self, chassis_id):
|
||||
chassis_list = self.list_chassis()
|
||||
|
||||
if utils.get_object(chassis_list, chassis_id):
|
||||
def delete_chassis(self, chassis_id, ignore_exceptions=False):
|
||||
try:
|
||||
self.ironic('chassis-delete', params=chassis_id)
|
||||
except exceptions.CommandFailed:
|
||||
if not ignore_exceptions:
|
||||
raise
|
||||
|
||||
def get_chassis_uuids_from_chassis_list(self):
|
||||
chassis_list = self.list_chassis()
|
||||
@ -295,7 +296,9 @@ class FunctionalTestBase(base.ClientTestBase):
|
||||
self.fail('Ironic chassis has not been created!')
|
||||
|
||||
chassis = utils.get_dict_from_output(chassis)
|
||||
self.addCleanup(self.delete_chassis, chassis['uuid'])
|
||||
self.addCleanup(self.delete_chassis,
|
||||
chassis['uuid'],
|
||||
ignore_exceptions=True)
|
||||
return chassis
|
||||
|
||||
def list_chassis(self, params=''):
|
||||
@ -306,7 +309,7 @@ class FunctionalTestBase(base.ClientTestBase):
|
||||
params='{0} {1}'.format(chassis_id, params))
|
||||
return utils.get_dict_from_output(chassis_show)
|
||||
|
||||
def update_chassis(self, chassis_id, operation, params):
|
||||
def update_chassis(self, chassis_id, operation, params=''):
|
||||
updated_chassis = self.ironic(
|
||||
'chassis-update',
|
||||
params='{0} {1} {2}'.format(chassis_id, operation, params))
|
||||
|
@ -12,6 +12,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest.lib import exceptions
|
||||
|
||||
from ironicclient.tests.functional import base
|
||||
|
||||
|
||||
@ -112,3 +116,98 @@ class ChassisSanityTestIronicClient(base.FunctionalTestBase):
|
||||
nodes_uuids.sort()
|
||||
self.assertEqual(nodes, nodes_uuids)
|
||||
self.assertNotIn(node3['uuid'], nodes_uuids)
|
||||
|
||||
|
||||
class ChassisNegativeTestsIronicClient(base.FunctionalTestBase):
|
||||
"""Negative tests for testing actions with Chassis.
|
||||
|
||||
Negative tests for the Ironic CLI commands which checks actions with
|
||||
chassis command like show, update, delete either using with arguments
|
||||
or without arguments.
|
||||
"""
|
||||
|
||||
def test_chassis_delete_without_arguments(self):
|
||||
"""Test step:
|
||||
|
||||
1) check that chassis-delete command without arguments
|
||||
triggers an exception
|
||||
"""
|
||||
ex_text = r'chassis-delete: error: too few arguments'
|
||||
|
||||
six.assertRaisesRegex(self, exceptions.CommandFailed,
|
||||
ex_text,
|
||||
self.delete_chassis, '')
|
||||
|
||||
def test_chassis_delete_with_incorrect_chassis_uuid(self):
|
||||
"""Test step:
|
||||
|
||||
1) check that deleting non-exist chassis triggers an exception
|
||||
triggers an exception
|
||||
"""
|
||||
uuid = data_utils.rand_uuid()
|
||||
ex_text = (r"Chassis {0} "
|
||||
r"could not be found. \(HTTP 404\)".format(uuid))
|
||||
|
||||
six.assertRaisesRegex(self, exceptions.CommandFailed,
|
||||
ex_text,
|
||||
self.delete_chassis,
|
||||
'{0}'.format(uuid))
|
||||
|
||||
def test_chassis_show_without_arguments(self):
|
||||
"""Test step:
|
||||
|
||||
1) check that chassis-show command without arguments
|
||||
triggers an exception
|
||||
"""
|
||||
ex_text = r'chassis-show: error: too few arguments'
|
||||
|
||||
six.assertRaisesRegex(self, exceptions.CommandFailed,
|
||||
ex_text,
|
||||
self.show_chassis, '')
|
||||
|
||||
def test_chassis_show_with_incorrect_chassis_uuid(self):
|
||||
"""Test step:
|
||||
|
||||
1) check that chassis-show command with incorrect chassis
|
||||
uuid triggers an exception
|
||||
"""
|
||||
uuid = data_utils.rand_uuid()
|
||||
ex_text = (r"Chassis {0} "
|
||||
r"could not be found. \(HTTP 404\)".format(uuid))
|
||||
|
||||
six.assertRaisesRegex(self, exceptions.CommandFailed,
|
||||
ex_text,
|
||||
self.show_chassis,
|
||||
'{0}'.format(uuid))
|
||||
|
||||
def test_chassis_update_without_arguments(self):
|
||||
"""Test steps:
|
||||
|
||||
1) create chassis
|
||||
2) check that chassis-update command without arguments
|
||||
triggers an exception
|
||||
"""
|
||||
ex_text = r'chassis-update: error: too few arguments'
|
||||
|
||||
six.assertRaisesRegex(self, exceptions.CommandFailed,
|
||||
ex_text,
|
||||
self.update_chassis,
|
||||
chassis_id='',
|
||||
operation='')
|
||||
|
||||
def test_chassis_update_with_incorrect_chassis_uuid(self):
|
||||
"""Test steps:
|
||||
|
||||
1) create chassis
|
||||
2) check that chassis-update command with incorrect arguments
|
||||
triggers an exception
|
||||
"""
|
||||
uuid = data_utils.rand_uuid()
|
||||
ex_text = r'chassis-update: error: too few arguments'
|
||||
|
||||
six.assertRaisesRegex(self,
|
||||
exceptions.CommandFailed,
|
||||
ex_text,
|
||||
self.update_chassis,
|
||||
chassis_id='{0}'.format(uuid),
|
||||
operation='')
|
||||
|
Loading…
Reference in New Issue
Block a user