Verified types of errors for sriov test suites.

Verification is done by checking whether certain messages
are shown in the response.json['error_message']. The original
error message "Unable to provision pci-sriov interface
without configured mgmt interface" is promptly caught, causing
the test to fail, as expected.

Since the intended error message is supposed to be something
that's not "Unable to provision pci-sriov interface without
configured mgmt interface," I added mgmt interface
configuration so the test won't fail.

Closes-Bug: 1860030

Change-Id: I6a2f11d6cf5b37166fc44b722deab47e696f9fd6
Signed-off-by: Thomas Gao <Thomas.Gao@windriver.com>
This commit is contained in:
Thomas Gao 2020-01-16 14:38:32 -05:00
parent 737b98c456
commit c22e5787c8
1 changed files with 12 additions and 0 deletions

View File

@ -2133,6 +2133,7 @@ class TestAIOPatch(InterfaceTestCase):
# Expected error: Value for number of SR-IOV VFs must be > 0. # Expected error: Value for number of SR-IOV VFs must be > 0.
def test_invalid_sriov_numvfs(self): def test_invalid_sriov_numvfs(self):
self._create_ethernet('mgmt', constants.NETWORK_TYPE_MGMT)
port, interface = self._create_ethernet('eth0', port, interface = self._create_ethernet('eth0',
constants.NETWORK_TYPE_NONE) constants.NETWORK_TYPE_NONE)
response = self.patch_dict_json( response = self.patch_dict_json(
@ -2141,9 +2142,12 @@ class TestAIOPatch(InterfaceTestCase):
expect_errors=True) expect_errors=True)
self.assertEqual(http_client.BAD_REQUEST, response.status_int) self.assertEqual(http_client.BAD_REQUEST, response.status_int)
self.assertEqual('application/json', response.content_type) self.assertEqual('application/json', response.content_type)
self.assertIn('Value for number of SR-IOV VFs must be > 0.',
response.json['error_message'])
# Expected error: SR-IOV can't be configured on this interface # Expected error: SR-IOV can't be configured on this interface
def test_invalid_sriov_totalvfs_zero(self): def test_invalid_sriov_totalvfs_zero(self):
self._create_ethernet('mgmt', constants.NETWORK_TYPE_MGMT)
interface = dbutils.create_test_interface(forihostid='1') interface = dbutils.create_test_interface(forihostid='1')
dbutils.create_test_ethernet_port( dbutils.create_test_ethernet_port(
id=1, name='eth1', host_id=1, interface_id=interface.id, id=1, name='eth1', host_id=1, interface_id=interface.id,
@ -2155,9 +2159,12 @@ class TestAIOPatch(InterfaceTestCase):
expect_errors=True) expect_errors=True)
self.assertEqual(http_client.BAD_REQUEST, response.status_int) self.assertEqual(http_client.BAD_REQUEST, response.status_int)
self.assertEqual('application/json', response.content_type) self.assertEqual('application/json', response.content_type)
self.assertIn('SR-IOV can\'t be configured on this interface',
response.json['error_message'])
# Expected error: The interface support a maximum of ___ VFs # Expected error: The interface support a maximum of ___ VFs
def test_invalid_sriov_exceeded_totalvfs(self): def test_invalid_sriov_exceeded_totalvfs(self):
self._create_ethernet('mgmt', constants.NETWORK_TYPE_MGMT)
interface = dbutils.create_test_interface(forihostid='1') interface = dbutils.create_test_interface(forihostid='1')
dbutils.create_test_ethernet_port( dbutils.create_test_ethernet_port(
id=1, name='eth1', host_id=1, interface_id=interface.id, id=1, name='eth1', host_id=1, interface_id=interface.id,
@ -2171,9 +2178,12 @@ class TestAIOPatch(InterfaceTestCase):
expect_errors=True) expect_errors=True)
self.assertEqual(http_client.BAD_REQUEST, response.status_int) self.assertEqual(http_client.BAD_REQUEST, response.status_int)
self.assertEqual('application/json', response.content_type) self.assertEqual('application/json', response.content_type)
self.assertIn('The interface support a maximum of',
response.json['error_message'])
# Expected error: Corresponding port has invalid driver # Expected error: Corresponding port has invalid driver
def test_invalid_driver_for_sriov(self): def test_invalid_driver_for_sriov(self):
self._create_ethernet('mgmt', constants.NETWORK_TYPE_MGMT)
interface = dbutils.create_test_interface(forihostid='1') interface = dbutils.create_test_interface(forihostid='1')
dbutils.create_test_ethernet_port( dbutils.create_test_ethernet_port(
id=1, name='eth1', host_id=1, interface_id=interface.id, id=1, name='eth1', host_id=1, interface_id=interface.id,
@ -2187,6 +2197,8 @@ class TestAIOPatch(InterfaceTestCase):
expect_errors=True) expect_errors=True)
self.assertEqual(http_client.BAD_REQUEST, response.status_int) self.assertEqual(http_client.BAD_REQUEST, response.status_int)
self.assertEqual('application/json', response.content_type) self.assertEqual('application/json', response.content_type)
self.assertIn('Corresponding port has invalid driver',
response.json['error_message'])
class IPv4TestPost(TestPostMixin, class IPv4TestPost(TestPostMixin,