Exemple #1
0
    def test_if_standby_fails_timeout_exception_raised(self):
        stub_executor = CliExecutor()
        stub_executor.get_full_status_xml = MagicMock()
        stub_executor.get_full_status_xml.return_value = GOOD_XML
        stub_executor.shutdown_node = MagicMock()

        connector = CliConnector(executor=stub_executor)

        connector.ensure_shutdown_possible = MagicMock()
        connector.get_nodes = MagicMock(return_value=[
            Node(name='test',
                 online=True,
                 standby=False,
                 unclean=False,
                 resources_running=2)
        ])

        connector.standby_node = MagicMock()

        client = Client(connector=connector)

        with self.assertRaises(TimeoutException):
            client.shutdown_node('test', timeout=2)

        connector.standby_node.assert_called_with('test')
        self.assertFalse(stub_executor.shutdown_node.called)
Exemple #2
0
    def test_before_shutdown_standby_invoked(self):
        stub_executor = CliExecutor()
        stub_executor.get_full_status_xml = MagicMock()
        stub_executor.get_full_status_xml.return_value = GOOD_XML

        connector = CliConnector(executor=stub_executor)
        connector.ensure_shutdown_possible = MagicMock()
        connector.manual_shutdown_node = MagicMock()

        connector.get_nodes = MagicMock(
            side_effect=[[
                Node(name='test',
                     online=True,
                     standby=False,
                     unclean=False,
                     resources_running=2)
            ],
                [
                Node(name='test',
                     online=True,
                     standby=False,
                     unclean=False,
                     resources_running=2)
            ],
                [
                Node(name='test',
                     online=True,
                     standby=False,
                     unclean=False,
                     resources_running=0)
            ]])

        connector.standby_node = MagicMock()

        client = Client(connector=connector)

        client.shutdown_node('test')

        connector.standby_node.assert_called_with('test')
        self.assertEqual(1, connector.manual_shutdown_node.call_count)