def test_server_restart_port_in_use(self, mock_port_in_use, mock_version_check, mock_check_status, mock_sudo): env.host = "good_node" mock_version_check.return_value = '' mock_port_in_use.return_value = 1 server.restart() mock_sudo.assert_called_with('set -m; ' + INIT_SCRIPTS + ' stop') mock_version_check.assert_called_with() self.assertEqual(False, mock_check_status.called)
def test_server_restart_fail(self, mock_port_in_use, mock_version_check, mock_warn, mock_status, mock_sudo): mock_status.return_value = False env.host = "failed_node1" mock_version_check.return_value = '' mock_port_in_use.return_value = 0 server.restart() mock_sudo.assert_any_call('set -m; ' + INIT_SCRIPTS + ' stop') mock_sudo.assert_any_call('set -m; ' + INIT_SCRIPTS + ' start') mock_version_check.assert_called_with() mock_warn.assert_called_with(self.SERVER_FAIL_MSG)
def test_server_restart(self, mock_port_in_use, mock_version_check, mock_status, mock_sudo, mock_lookup_host): mock_status.return_value = True env.host = 'good_node' mock_version_check.return_value = '' mock_port_in_use.return_value = 0 server.restart() mock_sudo.assert_any_call('set -m; ' + INIT_SCRIPTS + ' stop') mock_sudo.assert_any_call('set -m; ' + INIT_SCRIPTS + ' start') mock_version_check.assert_called_with() self.assertEqual('Waiting to make sure we can connect to the Presto ' 'server on good_node, please wait. This check will ' 'time out after 2 minutes if the server does not ' 'respond.\nServer started successfully on: ' 'good_node\n', self.test_stdout.getvalue())