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 instance_for_test(overrides={"telemetry": {"enabled": True}}): with environ(env): 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)
def cleanup_test_instance(instance): check.inst_param(instance, "instance", DagsterInstance) # To avoid filesystem contention when we close the temporary directory, wait for # all runs to reach a terminal state, and close any subprocesses or threads # that might be accessing the run history DB. instance.run_launcher.join() cleanup_telemetry_logger()