def test_main_deploy_secondary(mocker):

    parent_mock = mocker.Mock()

    mocker.patch("nuke_from_orbit.utils.nuke_utils.set_variables").return_value = MOCK_USER_CONFIG
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_gke")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_test_container_image")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_ip_address")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_persistent_disk")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.get_ip_address")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.collect_kube_yaml_templates")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.render_kubernetes_templates")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_looker_secret")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_oauth_secret")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_external")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_locust")

    context_mock = mocker.patch("nuke_from_orbit.utils.nuke_utils.set_kubernetes_context")
    deploy_mock = mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_secondary")

    parent_mock.attach_mock(context_mock, "context_mock")
    parent_mock.attach_mock(deploy_mock, "deploy_mock")

    setup_commands.main(config_file="mock_config.yaml", external=True, persistence=False)

    # determine if context call occurs before deployment
    expected_call_order = [mocker.call.context_mock(MOCK_USER_CONFIG), mocker.call.deploy_mock()]
    assert parent_mock.mock_calls == expected_call_order
def test_main_set_k8s_context(mocker):
    mocker.patch("nuke_from_orbit.utils.nuke_utils.set_variables").return_value = MOCK_USER_CONFIG
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_gke")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_test_container_image")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_ip_address")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_persistent_disk")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.get_ip_address")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.collect_kube_yaml_templates")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.render_kubernetes_templates")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.set_kubernetes_context")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_looker_secret")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_oauth_secret")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_external")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_locust")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_secondary")

    setup_commands.main(config_file="mock_config.yaml", external=True, persistence=False)

    nuke_utils.set_kubernetes_context.assert_called_with(MOCK_USER_CONFIG)
def test_main_run_threads_no_persistence_no_external(mocker):
    mocker.patch("nuke_from_orbit.utils.nuke_utils.set_variables").return_value = MOCK_USER_CONFIG
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_gke")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_test_container_image")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_ip_address")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_persistent_disk")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.get_ip_address")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.collect_kube_yaml_templates")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.render_kubernetes_templates")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.set_kubernetes_context")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_looker_secret")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_oauth_secret")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_external")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_locust")
    mocker.patch("nuke_from_orbit.utils.nuke_utils.deploy_secondary")

    setup_commands.main(config_file="mock_config.yaml", external=False, persistence=False)

    nuke_utils.deploy_gke.assert_called_with(MOCK_USER_CONFIG)
    nuke_utils.deploy_test_container_image.assert_called_with(MOCK_USER_CONFIG)
    # deploy ip and persistent disk shouldn't be called in multithread
    nuke_utils.deploy_ip_address.assert_not_called()
    nuke_utils.deploy_persistent_disk.assert_not_called()
Exemplo n.º 4
0
def setup(**kwargs):
    setup_commands.main(**kwargs)