test_input_data.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 materialize.output_consistency.input_data.test_input_operations import (
  10. ConsistencyTestOperationsInput,
  11. )
  12. from materialize.output_consistency.input_data.test_input_types import (
  13. ConsistencyTestTypesInput,
  14. )
  15. from materialize.output_consistency.query.query_template import QueryTemplate
  16. from materialize.output_consistency.selection.randomized_picker import RandomizedPicker
  17. class ConsistencyTestInputData:
  18. """Provides input data for the test execution"""
  19. def __init__(
  20. self,
  21. ) -> None:
  22. self.types_input = ConsistencyTestTypesInput()
  23. self.operations_input = ConsistencyTestOperationsInput()
  24. self.predefined_queries: list[QueryTemplate] = []
  25. def assign_columns_to_tables(
  26. self, vertical_tables: int, randomized_picker: RandomizedPicker
  27. ) -> None:
  28. self.types_input.assign_columns_to_tables(vertical_tables, randomized_picker)
  29. def get_stats(self) -> str:
  30. return (
  31. f"Input stats:"
  32. f" count_data_types={self.count_available_data_types()},"
  33. f" count_ops={self.count_available_ops()} (with variants {self.count_available_op_variants()}),"
  34. f" count_predefined_queries={self.count_predefined_queries()}"
  35. )
  36. def count_available_data_types(self) -> int:
  37. return len(self.types_input.all_data_types_with_values)
  38. def count_available_ops(self) -> int:
  39. return len(self.operations_input.all_operation_types)
  40. def count_available_op_variants(self) -> int:
  41. count = 0
  42. for operation in self.operations_input.all_operation_types:
  43. count = count + operation.count_variants()
  44. return count
  45. def count_predefined_queries(self) -> int:
  46. return len(self.predefined_queries)