Check the network burnin roles and partner

The network burnin roles are 'reader' and 'writer'. Raise an error
if the role is not provided or if the role is unknown. Equally,
raise an error if the partner is not provided.

Change-Id: I6259a7b0d15d62e68b1dc27f0cb511f8563c02ce
This commit is contained in:
Arne Wiebalck 2021-08-10 16:20:18 +02:00
parent 91f0248164
commit a86e21e4f4
2 changed files with 29 additions and 0 deletions

View File

@ -183,8 +183,16 @@ def fio_network(node):
"'agent_burnin_fio_network_config' in driver_info")
raise errors.CleaningError(error_msg)
LOG.debug("agent_burnin_fio_network_config is %s", str(config))
role = config.get('role')
if role not in NETWORK_BURNIN_ROLES:
error_msg = ("fio (network) found an unknown role: %s", role)
raise errors.CleaningError(error_msg)
partner = config.get('partner')
if not partner:
error_msg = ("fio (network) failed to find partner")
raise errors.CleaningError(error_msg)
_do_fio_network(role == 'writer', runtime, partner)
LOG.debug("fio (network): first direction done, swapping roles ...")

View File

@ -198,6 +198,27 @@ class TestBurnin(base.IronicAgentTest):
self.assertRaises(errors.CommandExecutionError,
burnin.fio_network, node)
def test_fio_network_unknown_role(self, mock_execute):
node = {'driver_info': {'agent_burnin_fio_network_config':
{'partner': 'host-003', 'role': 'read'}}}
self.assertRaises(errors.CleaningError, burnin.fio_network, node)
def test_fio_network_no_role(self, mock_execute):
node = {'driver_info': {'agent_burnin_fio_network_config':
{'partner': 'host-003'}}}
self.assertRaises(errors.CleaningError, burnin.fio_network, node)
def test_fio_network_no_partner(self, mock_execute):
node = {'driver_info': {'agent_burnin_fio_network_config':
{'role': 'reader'}}}
self.assertRaises(errors.CleaningError, burnin.fio_network, node)
@mock.patch('time.sleep', autospec=True)
def test_fio_network_reader_loop(self, mock_time, mock_execute):