conftest.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from typing import TYPE_CHECKING, Any
  10. if TYPE_CHECKING:
  11. from _pytest.config import Config
  12. import pytest
  13. from materialize.cloudtest.app.materialize_application import MaterializeApplication
  14. def pytest_configure(config: "Config") -> None:
  15. config.addinivalue_line(
  16. "markers",
  17. "long: A long running test. Select with -m=long, deselect with -m 'not long'",
  18. )
  19. config.addinivalue_line(
  20. "markers",
  21. "node_recovery: Tests that require a separate cluster definition",
  22. )
  23. @pytest.fixture(scope="session")
  24. def mz(pytestconfig: pytest.Config) -> MaterializeApplication:
  25. return MaterializeApplication(
  26. release_mode=(not pytestconfig.getoption("dev")),
  27. # NOTE(necaris): pyright doesn't like that the `getoption` default type is `Notset`
  28. aws_region=pytestconfig.getoption("aws_region", None), # type: ignore
  29. log_filter=pytestconfig.getoption("log_filter", None), # type: ignore
  30. apply_node_selectors=bool(
  31. pytestconfig.getoption("apply_node_selectors", None) or False # type: ignore
  32. ),
  33. )
  34. @pytest.fixture(scope="session")
  35. def log_filter(pytestconfig: pytest.Config) -> Any:
  36. return pytestconfig.getoption("log_filter")
  37. @pytest.fixture(scope="session")
  38. def dev(pytestconfig: pytest.Config) -> Any:
  39. return pytestconfig.getoption("dev")
  40. @pytest.fixture(scope="session")
  41. def aws_region(pytestconfig: pytest.Config) -> Any:
  42. return pytestconfig.getoption("aws_region")
  43. def pytest_addoption(parser: pytest.Parser) -> None:
  44. parser.addoption("--dev", action="store_true")
  45. parser.addoption(
  46. "--aws-region",
  47. action="store",
  48. default=None,
  49. help="AWS region to pass to testdrive",
  50. )
  51. parser.addoption(
  52. "--log-filter",
  53. action="store",
  54. default=None,
  55. help="Log filter for Materialize binaries",
  56. )
  57. parser.addoption(
  58. "--apply-node-selectors",
  59. action="store_true",
  60. default=False,
  61. )