diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 123b7ead40..6c039df710 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,10 @@ jobs: - { python-version: "3.8", os: "ubuntu-latest", backend-db: postgresql } - { python-version: "3.9", os: "ubuntu-latest", backend-db: postgresql } - { python-version: "3.10", os: "ubuntu-latest", backend-db: postgresql } + - { python-version: "3.7", os: "windows-latest", backend-db: sqlite } # We'd like to run Windows tests for all backend-dbs see https://github.com/meltano/meltano/issues/6281 + - { python-version: "3.8", os: "windows-latest", backend-db: sqlite } + - { python-version: "3.9", os: "windows-latest", backend-db: sqlite } + - { python-version: "3.10", os: "windows-latest", backend-db: sqlite } fail-fast: false name: "Pytest on py${{ matrix.python-version }} (OS: ${{ matrix.os }}, DB: ${{ matrix.backend-db }})" @@ -86,7 +90,7 @@ jobs: POSTGRES_PASSWORD: postgres POSTGRES_DB: pytest_warehouse run: | - poetry run coverage run --parallel -m pytest -m "$PYTEST_MARKERS" + poetry run coverage run --parallel -m pytest -m "${{ env.PYTEST_MARKERS }}" - name: Upload coverage data if: always() && (matrix.python-version == '3.9') diff --git a/src/meltano/cli/elt.py b/src/meltano/cli/elt.py index b460045616..bae638094d 100644 --- a/src/meltano/cli/elt.py +++ b/src/meltano/cli/elt.py @@ -2,6 +2,7 @@ import datetime import logging +import platform from contextlib import asynccontextmanager, contextmanager import click @@ -104,6 +105,11 @@ async def elt( \b\nRead more at https://docs.meltano.com/reference/command-line-interface#elt """ + if platform.system() == "Windows": + raise CliError( + "ELT command not supported on Windows. Please use the Run command as documented here https://docs.meltano.com/reference/command-line-interface#run" + ) + tracker = Tracker(project) legacy_tracker = LegacyTracker(project, context_overrides=tracker.contexts) @@ -135,7 +141,6 @@ async def elt( job_id=state_id or f'{datetime.datetime.utcnow().strftime("%Y-%m-%dT%H%M%S")}--{extractor}--{loader}' ) - _, Session = project_engine(project) # noqa: N806 session = Session() try: diff --git a/tests/fixtures/cli.py b/tests/fixtures/cli.py index a65507000c..13059dcdac 100644 --- a/tests/fixtures/cli.py +++ b/tests/fixtures/cli.py @@ -2,7 +2,6 @@ import logging import os -import shutil from pathlib import Path from typing import TYPE_CHECKING, Any @@ -60,5 +59,4 @@ def project_files_cli(test_dir, compatible_copy_tree): finally: Project.deactivate() os.chdir(test_dir) - shutil.rmtree(project.root) logging.debug(f"Cleaned project at {project.root}") diff --git a/tests/fixtures/core.py b/tests/fixtures/core.py index eeba64229b..5e92fa1b93 100644 --- a/tests/fixtures/core.py +++ b/tests/fixtures/core.py @@ -2,7 +2,6 @@ import itertools import logging import os -import shutil from collections import defaultdict, namedtuple from copy import deepcopy from pathlib import Path @@ -39,8 +38,6 @@ from meltano.core.task_sets_service import TaskSetsService from meltano.core.utils import merge -PROJECT_NAME = "a_meltano_project" - @pytest.fixture(scope="class") def discovery(): # noqa: WPS213 @@ -238,8 +235,8 @@ def locked_definition_service(project): @pytest.fixture(scope="class") -def project_init_service(): - return ProjectInitService(PROJECT_NAME) +def project_init_service(request): + return ProjectInitService(f"project_{request.node.name}") @pytest.fixture(scope="class") @@ -455,10 +452,6 @@ def job_logging_service(project): @pytest.fixture(scope="class") def project(test_dir, project_init_service): - # Clean up whatever might be left behind. Nothing should be left, but some fixtures - # occasionally do not clean up after themselves properly. - shutil.rmtree(test_dir / PROJECT_NAME, ignore_errors=True) - project = project_init_service.init(add_discovery=True) logging.debug(f"Created new project at {project.root}") @@ -476,7 +469,6 @@ def project(test_dir, project_init_service): finally: Project.deactivate() os.chdir(test_dir) - shutil.rmtree(project.root) logging.debug(f"Cleaned project at {project.root}") @@ -499,7 +491,6 @@ def project_files(test_dir, compatible_copy_tree): finally: Project.deactivate() os.chdir(test_dir) - shutil.rmtree(project.root) logging.debug(f"Cleaned project at {project.root}") diff --git a/tests/meltano/cli/test_add.py b/tests/meltano/cli/test_add.py index 7c041888e9..35a80410d3 100644 --- a/tests/meltano/cli/test_add.py +++ b/tests/meltano/cli/test_add.py @@ -1,4 +1,5 @@ import os +import platform import shutil import mock @@ -166,6 +167,10 @@ def test_add_files_with_updates( project_plugins_service, plugin_settings_service_factory, ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) # if plugin is locked, we actually wouldn't expect it to update. # So we must remove lockfile shutil.rmtree("plugins/files", ignore_errors=True) @@ -215,6 +220,10 @@ def test_add_files_without_updates( def test_add_files_that_already_exists( self, project, cli_runner, project_plugins_service ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) # dbt lockfile was created in an upstream test. Need to remove. shutil.rmtree(project.root_dir("plugins/files"), ignore_errors=True) project.root_dir("transform/dbt_project.yml").write_text("Exists!") diff --git a/tests/meltano/cli/test_config.py b/tests/meltano/cli/test_config.py index 987ba240ad..83abaac9fb 100644 --- a/tests/meltano/cli/test_config.py +++ b/tests/meltano/cli/test_config.py @@ -1,5 +1,7 @@ import json +import platform +import pytest from mock import AsyncMock, mock from asserts import assert_cli_runner @@ -12,6 +14,10 @@ def test_config(self, project, cli_runner, tap, project_plugins_service): "meltano.cli.config.ProjectPluginsService", return_value=project_plugins_service, ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) result = cli_runner.invoke(cli, ["config", tap.name]) assert_cli_runner(result) @@ -34,6 +40,10 @@ def test_config_env(self, project, cli_runner, tap, project_plugins_service): "meltano.cli.config.ProjectPluginsService", return_value=project_plugins_service, ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) result = cli_runner.invoke(cli, ["config", "--format=env", tap.name]) assert_cli_runner(result) diff --git a/tests/meltano/cli/test_elt.py b/tests/meltano/cli/test_elt.py index 717f8f2b4b..3f73c03b4b 100644 --- a/tests/meltano/cli/test_elt.py +++ b/tests/meltano/cli/test_elt.py @@ -1,5 +1,6 @@ import asyncio import json +import platform from typing import List, Optional import pytest @@ -76,7 +77,7 @@ def assert_lines(output, *lines): def exception_logged(result_output: str, exc: Exception) -> bool: - """Small utility to search click result output for a specific excpetion . + """Small utility to search click result output for a specific exception. Args: result_output: The click result output string to search. @@ -217,6 +218,38 @@ def dbt_process(process_mock_factory, dbt): return dbt +class TestWindowsELT: + @pytest.mark.skipif( + platform.system() != "Windows", + reason="Test is only for Windows", + ) + @pytest.mark.backend("sqlite") + @mock.patch.object(LegacyTracker, "track_event", return_value=None) + @mock.patch( + "meltano.core.logging.utils.default_config", return_value=test_log_config + ) + def test_elt_windows( + self, + google_tracker, + default_config, + cli_runner, + tap, + target, + ): + args = ["elt", tap.name, target.name] + result = cli_runner.invoke(cli, args) + assert result.exit_code == 1 + # Didn't use exception_logged() as result.stderr doensn't contain the error for some reason + assert ( + "ELT command not supported on Windows. Please use the Run command as documented here https://docs.meltano.com/reference/command-line-interface#run" + in str(result.exception) + ) + + +@pytest.mark.skipif( + platform.system() == "Windows", + reason="ELT is not supported on Windows", +) class TestCliEltScratchpadOne: @pytest.mark.backend("sqlite") @mock.patch.object(LegacyTracker, "track_event", return_value=None) @@ -1006,6 +1039,10 @@ def test_dump_loader_config( ) +@pytest.mark.skipif( + platform.system() == "Windows", + reason="ELT is not supported on Windows", +) class TestCliEltScratchpadTwo: @pytest.mark.backend("sqlite") @mock.patch.object(LegacyTracker, "track_event", return_value=None) @@ -1173,6 +1210,10 @@ def test_elt_transform_run_dbt_failure( ) +@pytest.mark.skipif( + platform.system() == "Windows", + reason="ELT is not supported on Windows", +) class TestCliEltScratchpadThree: @pytest.mark.backend("sqlite") @mock.patch.object(LegacyTracker, "track_event", return_value=None) diff --git a/tests/meltano/cli/test_invoke.py b/tests/meltano/cli/test_invoke.py index b5044ba50f..bbaf073693 100644 --- a/tests/meltano/cli/test_invoke.py +++ b/tests/meltano/cli/test_invoke.py @@ -1,5 +1,6 @@ import asyncio import json +import platform import mock import pytest @@ -89,6 +90,11 @@ def test_invoke_command_containerized( # noqa: WPS210 cli_runner, mock_invoke_containers, ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + async def async_generator(*args, **kwargs): yield "Line 1" yield "Line 2" # noqa: WPS354 diff --git a/tests/meltano/cli/test_state.py b/tests/meltano/cli/test_state.py index 2275efe14a..df2866167f 100644 --- a/tests/meltano/cli/test_state.py +++ b/tests/meltano/cli/test_state.py @@ -1,5 +1,6 @@ import json import os +import platform import sys import mock @@ -148,6 +149,10 @@ def test_merge_from_string(self, state_service, state_ids, cli_runner): def test_merge_from_file( self, tmp_path, state_service, state_ids, payloads, cli_runner ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) with mock.patch("meltano.cli.state.StateService", return_value=state_service): job_pairs = [] for idx in range(0, len(state_ids) - 1, 2): @@ -200,7 +205,7 @@ def test_copy_to_new(self, state_service, state_ids, cli_runner): with mock.patch("meltano.cli.state.StateService", return_value=state_service): for job_src_id in state_ids: job_src_state = state_service.get_state(job_src_id) - job_dst_id = "{0}-test-copy".format(job_src_id) + job_dst_id = f"{job_src_id}-test-copy" result = cli_runner.invoke( cli, ["state", "copy", job_src_id, job_dst_id, "--force"], diff --git a/tests/meltano/cli/test_upgrade.py b/tests/meltano/cli/test_upgrade.py index 0c1b074269..ea25accc7c 100644 --- a/tests/meltano/cli/test_upgrade.py +++ b/tests/meltano/cli/test_upgrade.py @@ -1,6 +1,8 @@ +import platform import shutil import mock +import pytest from asserts import assert_cli_runner from meltano.cli import cli @@ -8,6 +10,10 @@ class TestCliUpgrade: def test_upgrade(self, project, cli_runner): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) result = cli_runner.invoke(cli, ["upgrade"]) assert_cli_runner(result) @@ -35,6 +41,10 @@ def test_upgrade_skip_package(self, project, cli_runner): assert "Your Meltano project has been upgraded!" in result.output def test_upgrade_package(self, project, cli_runner): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) result = cli_runner.invoke(cli, ["upgrade", "package"]) assert_cli_runner(result) @@ -46,6 +56,10 @@ def test_upgrade_package(self, project, cli_runner): def test_upgrade_files( self, session, project, cli_runner, config_service, meltano_hub_service ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) result = cli_runner.invoke(cli, ["upgrade", "files"]) assert_cli_runner(result) diff --git a/tests/meltano/core/container/test_container_spec.py b/tests/meltano/core/container/test_container_spec.py index 08548a0fed..56107a8294 100644 --- a/tests/meltano/core/container/test_container_spec.py +++ b/tests/meltano/core/container/test_container_spec.py @@ -1,5 +1,6 @@ """Test container commands.""" +import platform from collections import defaultdict import pytest @@ -61,5 +62,9 @@ class TestContainerService: @pytest.mark.asyncio async def test_docker_config(self, spec: ContainerSpec, payload: dict): """Check Docker container config from container spec.""" + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) config = spec.get_docker_config() assert config == payload diff --git a/tests/meltano/core/job/test_job.py b/tests/meltano/core/job/test_job.py index 3355eba572..c3ea67c69a 100644 --- a/tests/meltano/core/job/test_job.py +++ b/tests/meltano/core/job/test_job.py @@ -1,4 +1,5 @@ import asyncio +import platform import signal import uuid from datetime import datetime, timedelta @@ -89,6 +90,11 @@ async def test_run_failed(self, session): @pytest.mark.asyncio async def test_run_interrupted(self, session): + + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/2842" + ) subject = self.sample_job({"original_state": 1}).save(session) with pytest.raises(KeyboardInterrupt): @@ -102,6 +108,11 @@ async def test_run_interrupted(self, session): @pytest.mark.asyncio async def test_run_terminated(self, session): + + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/2842" + ) subject = self.sample_job({"original_state": 1}).save(session) with pytest.raises(SystemExit): diff --git a/tests/meltano/core/logging/test_output_logger.py b/tests/meltano/core/logging/test_output_logger.py index 190666f123..cdd11badc4 100644 --- a/tests/meltano/core/logging/test_output_logger.py +++ b/tests/meltano/core/logging/test_output_logger.py @@ -1,5 +1,6 @@ import json import logging +import platform import sys import tempfile @@ -48,6 +49,10 @@ def redirect_handler(self, subject: OutputLogger) -> logging.Handler: @pytest.mark.asyncio async def test_stdio_capture(self, log, subject, log_output): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) stdout_out = subject.out("stdout") stderr_out = subject.out("stderr") @@ -92,6 +97,11 @@ async def test_stdio_capture(self, log, subject, log_output): @pytest.mark.asyncio async def test_out_writers(self, log, subject, log_output): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + writer_out = subject.out("writer") line_writer_out = subject.out("lwriter") basic_out = subject.out("basic") @@ -140,6 +150,11 @@ async def test_out_writers(self, log, subject, log_output): @pytest.mark.asyncio async def test_set_custom_logger(self, log, subject, log_output): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + logger = structlog.getLogger() out = subject.out("basic", logger.bind(is_test=True)) @@ -154,8 +169,17 @@ async def test_set_custom_logger(self, log, subject, log_output): }, ) + @pytest.mark.skipif( + platform.system() == "Windows", + reason="Test fails if even attempted to be run, xfail can't save us here.", + ) @pytest.mark.asyncio async def test_logging_redirect(self, log, subject, log_output, redirect_handler): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + logging_out = subject.out("logging") with mock.patch.object(Out, "redirect_log_handler", redirect_handler): @@ -174,7 +198,16 @@ async def test_logging_redirect(self, log, subject, log_output, redirect_handler {"event": "error"}, ) + @pytest.mark.skipif( + platform.system() == "Windows", + reason="Test fails if even attempted to be run, xfail can't save us here.", + ) def test_logging_exception(self, log, subject, redirect_handler): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + logging_out = subject.out("logging") # it raises logs unhandled exceptions @@ -186,6 +219,7 @@ def test_logging_exception(self, log, subject, redirect_handler): raise exception # make sure it let the exception through + # All code below here in this test cannot be reached assert exc.value is exception # noqa: WPS441 log_content = json.loads(log.read()) diff --git a/tests/meltano/core/plugin/test_plugin_settings.py b/tests/meltano/core/plugin/test_plugin_settings.py index 69ce99a8fa..2d2bbc11e6 100644 --- a/tests/meltano/core/plugin/test_plugin_settings.py +++ b/tests/meltano/core/plugin/test_plugin_settings.py @@ -1,3 +1,4 @@ +import platform from datetime import date, datetime import dotenv @@ -496,6 +497,10 @@ def test_store_dotenv(self, subject, project, tap): def test_env_var_expansion( self, session, subject, project, tap, monkeypatch, env_var ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) monkeypatch.setenv("VAR", "hello world!") monkeypatch.setenv("FOO", "42") diff --git a/tests/meltano/core/plugin/test_superset.py b/tests/meltano/core/plugin/test_superset.py index 1b12a11d31..5d5ab697e7 100644 --- a/tests/meltano/core/plugin/test_superset.py +++ b/tests/meltano/core/plugin/test_superset.py @@ -1,3 +1,4 @@ +import platform import sys from importlib.util import module_from_spec, spec_from_file_location from pathlib import Path @@ -41,6 +42,10 @@ def subject(self, project_add_service): async def test_hooks( # noqa: WPS210 self, subject, project, session, plugin_invoker_factory, monkeypatch ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) run_dir = project.run_dir("superset") config_path = run_dir.joinpath("superset_config.py") diff --git a/tests/meltano/core/test_environment_service.py b/tests/meltano/core/test_environment_service.py index b325d555e9..14120c5d63 100644 --- a/tests/meltano/core/test_environment_service.py +++ b/tests/meltano/core/test_environment_service.py @@ -1,3 +1,5 @@ +import platform + import pytest from meltano.core.environment import Environment @@ -56,5 +58,9 @@ def test_list_environments( self, subject: EnvironmentService, ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) new_environment = subject.add("new-environment") assert subject.list_environments() == [new_environment] diff --git a/tests/meltano/core/test_environment_variables.py b/tests/meltano/core/test_environment_variables.py index 5f2d7bd5dc..1976a8fd73 100644 --- a/tests/meltano/core/test_environment_variables.py +++ b/tests/meltano/core/test_environment_variables.py @@ -1,3 +1,4 @@ +import platform from typing import NamedTuple import pytest @@ -184,6 +185,10 @@ class TestEnvVarResolution: def test_env_var_resolution( self, scenario, env_var_resolution_expectation, cli_runner, project, monkeypatch ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) with project.meltano_update() as meltanofile: meltanofile.update(env_var_resolution_expectation.meltanofile_updates) diff --git a/tests/meltano/core/test_meltano_invoker.py b/tests/meltano/core/test_meltano_invoker.py index e517350196..8fd67efd85 100644 --- a/tests/meltano/core/test_meltano_invoker.py +++ b/tests/meltano/core/test_meltano_invoker.py @@ -1,4 +1,5 @@ import os +import platform import subprocess import sys from pathlib import Path @@ -16,11 +17,19 @@ def subject(self, project): return MeltanoInvoker(project) def test_invoke(self, subject): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) process = subject.invoke(["--version"], stdout=subprocess.PIPE) assert process.returncode == 0 assert meltano.__version__ in str(process.stdout) # noqa: WPS609 def test_invoke_executable(self, subject, project): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) process_mock = mock.Mock(returncode=0) with mock.patch("subprocess.run", return_value=process_mock) as run_mock: subject.invoke(["--version"]) diff --git a/tests/meltano/core/test_plugin_invoker.py b/tests/meltano/core/test_plugin_invoker.py index 65f653bfc0..de3c46538e 100644 --- a/tests/meltano/core/test_plugin_invoker.py +++ b/tests/meltano/core/test_plugin_invoker.py @@ -1,3 +1,5 @@ +import platform + import dotenv import pytest @@ -70,6 +72,10 @@ async def test_environment_env( async def test_expanded_environment_env( self, project_with_environment, tap, session, plugin_invoker_factory ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) subject = plugin_invoker_factory(tap) async with subject.prepared(session): env = subject.env() @@ -138,19 +144,23 @@ def test_alternate_command_executable(self, plugin_invoker): @pytest.mark.parametrize( "executable_str,assert_fn", [ - ("tap-test", lambda exe: exe == "tap-test"), - ("./tap-test", lambda exe: exe.endswith("meltano_project/tap-test")), - ("/apps/tap-test", lambda exe: exe == "/apps/tap-test"), + ("tap-test", lambda exe, name: exe == "tap-test"), + ("./tap-test", lambda exe, name: exe.endswith(f"{name}/tap-test")), + ("/apps/tap-test", lambda exe, name: exe == "/apps/tap-test"), ], ) @pytest.mark.asyncio async def test_expand_nonpip_command_exec_args( self, nonpip_plugin_invoker, session, executable_str, assert_fn ): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) nonpip_plugin_invoker.plugin.executable = executable_str exec_args = nonpip_plugin_invoker.exec_args() - assert assert_fn(exec_args[0]) + assert assert_fn(exec_args[0], nonpip_plugin_invoker.project.root) await nonpip_plugin_invoker.prepare(session) env = nonpip_plugin_invoker.env() diff --git a/tests/meltano/core/test_project.py b/tests/meltano/core/test_project.py index 1cce5ec670..db6e6ca71f 100644 --- a/tests/meltano/core/test_project.py +++ b/tests/meltano/core/test_project.py @@ -1,3 +1,4 @@ +import platform import threading import time from multiprocessing import Pool @@ -25,7 +26,10 @@ def update(payload): class IndefiniteThread(threading.Thread): + """Never ending thread.""" + def __init__(self): + """Set stop event.""" super().__init__() self._stop_event = threading.Event() @@ -38,7 +42,10 @@ def run(self, *args, **kwargs): class ProjectReader(IndefiniteThread): + """Project using a never ending thread.""" + def __init__(self, project): + """Set the project.""" self.project = project super().__init__() @@ -92,6 +99,11 @@ def test_find_threadsafe(self, project, concurrency): @pytest.mark.concurrent def test_meltano_concurrency(self, project, concurrency): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + payloads = [{f"test_{i}": i} for i in range(1, concurrency["cases"] + 1)] reader = ProjectReader(project) diff --git a/tests/meltano/core/test_project_files.py b/tests/meltano/core/test_project_files.py index 58bb0a6bbb..47e33177a5 100644 --- a/tests/meltano/core/test_project_files.py +++ b/tests/meltano/core/test_project_files.py @@ -1,6 +1,7 @@ import datetime import json import os +import platform import tempfile from pathlib import Path @@ -70,7 +71,16 @@ def test_resolve_subfiles(self, project_files): (project_files.root / "subfolder" / "subconfig_1.yml"), ] + @pytest.mark.skipif( + platform.system() == "Windows", + reason="Test fails if even attempted to be run, xfail can't save us here.", + ) def test_resolve_from_subdir(self, project_files, cd_temp_subdir): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + assert Path.cwd() == cd_temp_subdir assert cd_temp_subdir.parent == project_files.root assert project_files.include_paths == [ @@ -78,7 +88,16 @@ def test_resolve_from_subdir(self, project_files, cd_temp_subdir): (project_files.root / "subfolder" / "subconfig_1.yml"), ] + @pytest.mark.skipif( + platform.system() == "Windows", + reason="Test fails if even attempted to be run, xfail can't save us here.", + ) def test_resolve_from_any_dir(self, project_files, cd_temp_dir): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + assert Path.cwd() == cd_temp_dir assert project_files.include_paths == [ (project_files.root / "subconfig_2.yml"), diff --git a/tests/meltano/core/test_schedule_service.py b/tests/meltano/core/test_schedule_service.py index baf3508435..d77502c089 100644 --- a/tests/meltano/core/test_schedule_service.py +++ b/tests/meltano/core/test_schedule_service.py @@ -1,3 +1,4 @@ +import platform from datetime import datetime import mock @@ -86,6 +87,11 @@ def test_add_schedules(self, subject, create_elt_schedule, create_job_schedule): subject.add_schedule(all_schedules[0]) def test_remove_schedule(self, subject): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + schedules = list(subject.schedules()) schedules_count = len(schedules) @@ -153,6 +159,11 @@ def test_schedule_start_date( assert schedule.start_date def test_run_elt_schedule(self, subject, session, tap, target): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + schedule = subject.add_elt( session, "tap-to-target", @@ -190,6 +201,11 @@ def test_run_elt_schedule(self, subject, session, tap, target): ) def test_run_job_schedule(self, subject, session, tap, target): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + schedule = subject.add( "mock-job-schedule", "mock-job", diff --git a/tests/meltano/core/test_state_service.py b/tests/meltano/core/test_state_service.py index 6cce71c261..f1c2f44d31 100644 --- a/tests/meltano/core/test_state_service.py +++ b/tests/meltano/core/test_state_service.py @@ -1,4 +1,5 @@ import json +import platform import pytest @@ -39,6 +40,11 @@ def test_add_state(self, state_service, payloads): assert state_service.get_state(mock_state_id) == payloads.mock_state_payloads[0] def test_set_state(self, job_history_session, jobs, payloads, state_service): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + for job in jobs: for state in payloads.mock_state_payloads: state_service.set_state(job.job_id, json.dumps(state)) diff --git a/tests/meltano/core/test_venv_service.py b/tests/meltano/core/test_venv_service.py index 9f417da9ac..3a47344982 100644 --- a/tests/meltano/core/test_venv_service.py +++ b/tests/meltano/core/test_venv_service.py @@ -1,4 +1,5 @@ import os +import platform import re import subprocess @@ -24,6 +25,11 @@ def test_clean_run_files(self, project: Project, subject: VenvService): @pytest.mark.asyncio async def test_clean_install(self, project, subject: VenvService): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + await subject.install("example", clean=True) venv_dir = subject.project.venvs_dir("namespace", "name") @@ -73,6 +79,11 @@ async def test_clean_install(self, project, subject: VenvService): @pytest.mark.asyncio async def test_install(self, project, subject: VenvService): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + # Make sure the venv exists already await subject.install("example", clean=True) venv_dir = subject.project.venvs_dir("namespace", "name") diff --git a/tests/meltano/core/tracking/test_exception.py b/tests/meltano/core/tracking/test_exception.py index fd540f2904..0a2b806d01 100644 --- a/tests/meltano/core/tracking/test_exception.py +++ b/tests/meltano/core/tracking/test_exception.py @@ -2,12 +2,14 @@ import inspect import json +import platform import uuid import warnings from pathlib import Path from platform import python_version_tuple from typing import Any +import pytest from jsonschema import ValidationError, validate from meltano.core.tracking import ExceptionContext @@ -91,6 +93,11 @@ def test_simple_exception_context(): def test_complex_exception_context(): + if platform.system() == "Windows": + pytest.xfail( + "Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444" + ) + line_nums: list[int] = [] def _function_to_deepen_traceback() -> None: diff --git a/tests/meltano/core/tracking/test_tracker.py b/tests/meltano/core/tracking/test_tracker.py index d75ee349d4..05c67c3de5 100644 --- a/tests/meltano/core/tracking/test_tracker.py +++ b/tests/meltano/core/tracking/test_tracker.py @@ -2,6 +2,7 @@ import json import os +import platform import subprocess import uuid from contextlib import contextmanager @@ -89,6 +90,10 @@ def test_update_analytics_json(self, project: Project): != analytics_json_post["send_anonymous_usage_stats"] ) + @pytest.mark.xfail( + platform.system() == "Windows", + reason="Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444", + ) def test_restore_project_id_from_analytics_json(self, project: Project): Tracker(project) # Ensure `analytics.json` exists and is valid @@ -107,6 +112,10 @@ def test_restore_project_id_from_analytics_json(self, project: Project): assert original_project_id == restored_project_id + @pytest.mark.xfail( + platform.system() == "Windows", + reason="Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444", + ) def test_no_project_id_state_change_if_tracking_disabled(self, project: Project): clear_telemetry_settings(project) setting_service = ProjectSettingsService(project) @@ -146,6 +155,10 @@ def test_analytics_json_is_created(self, project: Project): Tracker(project) check_analytics_json(project) + @pytest.mark.xfail( + platform.system() == "Windows", + reason="Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444", + ) @pytest.mark.parametrize( "analytics_json_content", [ @@ -173,6 +186,10 @@ def test_invalid_analytics_json_is_overwritten( check_analytics_json(project) + @pytest.mark.xfail( + platform.system() == "Windows", + reason="Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444", + ) def test_restore_project_id_and_telemetry_state_change(self, project: Project): """ Test that `project_id` is restored from `analytics.json`, and a telemetry state @@ -209,6 +226,10 @@ def test_restore_project_id_and_telemetry_state_change(self, project: Project): finally: ProjectSettingsService.config_override = original_config_override + @pytest.mark.xfail( + platform.system() == "Windows", + reason="Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444", + ) @pytest.mark.parametrize( "snowplow_endpoints,send_stats,expected", ( @@ -230,6 +251,10 @@ def test_can_track( setting_service.set("send_anonymous_usage_stats", send_stats) assert Tracker(project).can_track() is expected + @pytest.mark.xfail( + platform.system() == "Windows", + reason="Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444", + ) def test_send_anonymous_usage_stats(self, project: Project): clear_telemetry_settings(project) @@ -255,10 +280,18 @@ def test_send_anonymous_usage_stats(self, project: Project): ProjectSettingsService(project).set("send_anonymous_usage_stats", True) assert Tracker(project).send_anonymous_usage_stats is True + @pytest.mark.xfail( + platform.system() == "Windows", + reason="Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444", + ) def test_default_send_anonymous_usage_stats(self, project: Project): clear_telemetry_settings(project) assert Tracker(project).send_anonymous_usage_stats + @pytest.mark.xfail( + platform.system() == "Windows", + reason="Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444", + ) def test_exit_event_is_fired(self, project: Project, snowplow: SnowplowMicro): subprocess.run(("meltano", "invoke", "alpha-beta-fox")) diff --git a/tests/meltano/core/tracking/test_tracking.py b/tests/meltano/core/tracking/test_tracking.py index 2f88c257cb..8b2b57313c 100644 --- a/tests/meltano/core/tracking/test_tracking.py +++ b/tests/meltano/core/tracking/test_tracking.py @@ -1,11 +1,17 @@ import logging +import platform +import pytest from snowplow_tracker import Emitter from meltano.core.project_settings_service import ProjectSettingsService from meltano.core.tracking import Tracker +@pytest.mark.xfail( + platform.system() == "Windows", + reason="Doesn't pass on windows, this is currently being tracked here https://github.com/meltano/meltano/issues/3444", +) def test_get_snowplow_tracker_invalid_endpoint(project, caplog): endpoints = """ [