def test_start_all_containers(self): """ Test node _start_all_containers """ node = Node(name='node') container = MagicMock() node.api.services.find = MagicMock(return_value=[container]) node._start_all_containers() container.schedule_action.assert_called_once_with('start')
def test_monitor_node(self): """ Test _monitor action without reboot """ node = Node(name='node') node.install = MagicMock() node._start_all_containers = MagicMock() node._start_all_vms = MagicMock() node.state.set('actions', 'install', 'ok') node._node_sal.is_running = MagicMock(return_value=True) node._node_sal.uptime = MagicMock(return_value=40.0) node._monitor() assert not node._start_all_containers.called assert not node._start_all_vms.called assert not node.install.called
def test_monitor_node_reboot(self): """ Test _monitor action called after node rebooted """ node = Node(name='node', data={'uptime': 40.0}) node.install = MagicMock() node._start_all_containers = MagicMock() node._start_all_vms = MagicMock() node.state.set('actions', 'install', 'ok') node.state.set('status', 'rebooting', 'ok') node._node_sal.is_running = MagicMock(return_value=True) node._node_sal.uptime = MagicMock(return_value=10.0) node._monitor() node._start_all_containers.assert_called_once_with() node._start_all_vms.assert_called_once_with() node.install.assert_called_once_with() with pytest.raises(StateCheckError, message='template should remove the rebooting status after monitoring'): node.state.check('status', 'rebooting', 'ok')