diff options
author | Zuul <zuul@review.opendev.org> | 2021-09-02 12:43:39 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-09-02 12:43:39 +0000 |
commit | 667e83da0e1e90ca49b14607af0faccb4b791fd4 (patch) | |
tree | 90a3f8255248cd7877e427d71235efe380110ea6 | |
parent | 438a1f44451ce3902971137e1a0427cd89897783 (diff) | |
parent | a86e21e4f46d7a68e979f99722593412802dc750 (diff) | |
download | ironic-python-agent-667e83da0e1e90ca49b14607af0faccb4b791fd4.tar.gz |
Merge "Check the network burnin roles and partner"
-rw-r--r-- | ironic_python_agent/burnin.py | 8 | ||||
-rw-r--r-- | ironic_python_agent/tests/unit/test_burnin.py | 21 |
2 files changed, 29 insertions, 0 deletions
diff --git a/ironic_python_agent/burnin.py b/ironic_python_agent/burnin.py index 375f11d3..f3918173 100644 --- a/ironic_python_agent/burnin.py +++ b/ironic_python_agent/burnin.py @@ -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 ...") diff --git a/ironic_python_agent/tests/unit/test_burnin.py b/ironic_python_agent/tests/unit/test_burnin.py index 18025b41..2258352e 100644 --- a/ironic_python_agent/tests/unit/test_burnin.py +++ b/ironic_python_agent/tests/unit/test_burnin.py @@ -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): |