Example #1
0
def test_dagster_telemetry_upload(env):
    logger = logging.getLogger("dagster_telemetry_logger")
    for handler in logger.handlers:
        logger.removeHandler(handler)

    responses.add(responses.POST, DAGSTER_TELEMETRY_URL)

    with environ(env):
        with instance_for_test():
            runner = CliRunner()
            with pushd(path_to_file("")):
                pipeline_attribute = "foo_pipeline"
                runner.invoke(
                    pipeline_execute_command,
                    [
                        "-f",
                        path_to_file("test_cli_commands.py"), "-a",
                        pipeline_attribute
                    ],
                )

            mock_stop_event = mock.MagicMock()
            mock_stop_event.is_set.return_value = False

            def side_effect(_):
                mock_stop_event.is_set.return_value = True

            mock_stop_event.wait.side_effect = side_effect

            # Needed to avoid file contention issues on windows with the telemetry log file
            cleanup_telemetry_logger()

            upload_logs(mock_stop_event, raise_errors=True)
            assert responses.assert_call_count(DAGSTER_TELEMETRY_URL, 1)
Example #2
0
def test_dagster_telemetry_upload(env):
    logger = logging.getLogger("dagster_telemetry_logger")
    for handler in logger.handlers:
        logger.removeHandler(handler)

    with environ(env):
        with instance_for_test(enable_telemetry=True):
            runner = CliRunner()
            with pushd(path_to_file("")):
                pipeline_attribute = "foo_pipeline"
                runner.invoke(
                    pipeline_execute_command,
                    [
                        "-f",
                        path_to_file("test_cli_commands.py"), "-a",
                        pipeline_attribute
                    ],
                )

            mock_stop_event = mock.MagicMock()
            mock_stop_event.is_set.return_value = False

            def side_effect():
                mock_stop_event.is_set.return_value = True

            mock_stop_event.wait.side_effect = side_effect

            upload_logs(mock_stop_event)
            assert responses.assert_call_count(DAGSTER_TELEMETRY_URL, 1)
Example #3
0
def test_dagster_telemetry_no_test_env_upload(env):
    with environ(env):
        with instance_for_test():
            runner = CliRunner()
            with pushd(path_to_file("")):
                pipeline_attribute = "foo_pipeline"
                runner.invoke(
                    pipeline_execute_command,
                    [
                        "-f",
                        path_to_file("test_cli_commands.py"), "-a",
                        pipeline_attribute
                    ],
                )

            upload_logs(mock.MagicMock())
            assert responses.assert_call_count(DAGSTER_TELEMETRY_URL, 0)