def test_main_no_chronos_config():
    with contextlib.nested(
        patch("paasta_tools.marathon_tools.load_marathon_config", autospec=True),
        patch("paasta_tools.chronos_tools.load_chronos_config", autospec=True),
        patch("paasta_tools.paasta_metastatus.get_mesos_state_from_leader", autospec=True),
        patch("paasta_tools.paasta_metastatus.get_mesos_status", autospec=True, return_value=([("fake_output", True)])),
        patch(
            "paasta_tools.paasta_metastatus.get_marathon_status", autospec=True, return_value=([("fake_output", True)])
        ),
        patch("paasta_tools.paasta_metastatus.parse_args", autospec=True),
    ) as (
        load_marathon_config_patch,
        load_chronos_config_patch,
        load_get_mesos_state_from_leader_patch,
        load_get_mesos_status_patch,
        load_get_marathon_status_patch,
        parse_args_patch,
    ):

        fake_args = Mock(verbose=0)
        parse_args_patch.return_value = fake_args
        load_chronos_config_patch.side_effect = ChronosNotConfigured
        with raises(SystemExit) as excinfo:
            paasta_metastatus.main()
        assert excinfo.value.code == 0
Esempio n. 2
0
def test_main_no_chronos_config():
    with contextlib.nested(
        patch('paasta_tools.marathon_tools.load_marathon_config', autospec=True),
        patch('paasta_tools.paasta_metastatus.load_chronos_config', autospec=True),
        patch('paasta_tools.paasta_metastatus.get_mesos_master', autospec=True),
        patch('paasta_tools.metrics.metastatus_lib.get_mesos_state_status', autospec=True,
              return_value=([('fake_output', True)])),
        patch('paasta_tools.metrics.metastatus_lib.get_mesos_resource_utilization_health', autospec=True),
        patch('paasta_tools.metrics.metastatus_lib.get_marathon_status', autospec=True,
              return_value=([('fake_output', True)])),
        patch('paasta_tools.paasta_metastatus.parse_args', autospec=True),
    ) as (
        load_marathon_config_patch,
        load_chronos_config_patch,
        get_mesos_master,
        get_mesos_state_status_patch,
        get_mesos_resource_utilization_health_patch,
        load_get_marathon_status_patch,
        parse_args_patch,
    ):

        fake_args = Mock(
            verbose=0,
        )
        fake_master = Mock(autospace=True)
        fake_master.metrics_snapshot.return_value = {
            'master/frameworks_active': 2,
            'master/frameworks_inactive': 0,
            'master/frameworks_connected': 2,
            'master/frameworks_disconnected': 0,
        }
        fake_master.state.return_value = {}
        get_mesos_master.return_value = fake_master

        parse_args_patch.return_value = fake_args
        load_marathon_config_patch.return_value = {}

        get_mesos_state_status_patch.return_value = []
        get_mesos_resource_utilization_health_patch.return_value = []

        load_chronos_config_patch.return_value = {}
        with raises(SystemExit) as excinfo:
            paasta_metastatus.main()
        assert excinfo.value.code == 0
Esempio n. 3
0
def test_main_no_chronos_config():
    with contextlib.nested(
        patch('paasta_tools.marathon_tools.load_marathon_config', autospec=True),
        patch('paasta_tools.paasta_metastatus.load_chronos_config', autospec=True),
        patch('paasta_tools.paasta_metastatus.get_mesos_state_from_leader', autospec=True, return_value={}),
        patch('paasta_tools.paasta_metastatus.get_mesos_state_status', autospec=True,
              return_value=([('fake_output', True)])),
        patch('paasta_tools.paasta_metastatus.get_mesos_stats', autospec=True),
        patch('paasta_tools.paasta_metastatus.get_mesos_metrics_health', autospec=True),
        patch('paasta_tools.paasta_metastatus.get_marathon_status', autospec=True,
              return_value=([('fake_output', True)])),
        patch('paasta_tools.paasta_metastatus.parse_args', autospec=True),
    ) as (
        load_marathon_config_patch,
        load_chronos_config_patch,
        get_mesos_state_from_leader_patch,
        get_mesos_state_status_patch,
        get_mesos_stats_patch,
        get_mesos_metrics_health_patch,
        load_get_marathon_status_patch,
        parse_args_patch,
    ):

        fake_args = Mock(
            verbose=0,
        )
        parse_args_patch.return_value = fake_args
        load_marathon_config_patch.side_effect = MarathonNotConfigured

        get_mesos_state_from_leader_patch.return_value = {}
        get_mesos_stats_patch.return_value = {}

        get_mesos_state_status_patch.return_value = []
        get_mesos_metrics_health_patch.return_value = []

        load_chronos_config_patch.side_effect = PaastaNotConfiguredError
        with raises(SystemExit) as excinfo:
            paasta_metastatus.main()
        assert excinfo.value.code == 0