mzcompose.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. """
  10. Test the consistency of Materialize against Postgres as an oracle.
  11. """
  12. from materialize.mzcompose.composition import Composition, WorkflowArgumentParser
  13. from materialize.mzcompose.services.materialized import Materialized
  14. from materialize.mzcompose.services.mz import Mz
  15. from materialize.mzcompose.services.postgres import (
  16. CockroachOrPostgresMetadata,
  17. Postgres,
  18. )
  19. from materialize.mzcompose.test_result import FailedTestExecutionError
  20. from materialize.output_consistency.execution.query_output_mode import QueryOutputMode
  21. from materialize.output_consistency.output_consistency_test import (
  22. upload_output_consistency_results_to_test_analytics,
  23. )
  24. from materialize.postgres_consistency.postgres_consistency_test import (
  25. PostgresConsistencyTest,
  26. )
  27. SERVICES = [
  28. CockroachOrPostgresMetadata(),
  29. Materialized(propagate_crashes=True, external_metadata_store=True),
  30. Postgres(),
  31. Mz(app_password=""),
  32. ]
  33. def workflow_default(c: Composition, parser: WorkflowArgumentParser) -> None:
  34. c.down(destroy_volumes=True)
  35. c.up("materialized", "postgres")
  36. test = PostgresConsistencyTest()
  37. args = test.parse_output_consistency_input_args(parser)
  38. default_connection = c.sql_connection()
  39. mz_system_connection = c.sql_connection(user="mz_system", port=6877)
  40. test.pg_connection = c.sql_connection(
  41. service="postgres",
  42. user="postgres",
  43. password="postgres",
  44. database="postgres",
  45. )
  46. test_summary = test.run_output_consistency_tests(
  47. default_connection,
  48. mz_system_connection,
  49. args,
  50. query_output_mode=QueryOutputMode.SELECT,
  51. )
  52. upload_output_consistency_results_to_test_analytics(c, test_summary)
  53. if not test_summary.all_passed():
  54. raise FailedTestExecutionError(errors=test_summary.failures)