mzcompose.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. import requests
  10. from materialize.mzcompose.composition import (
  11. Composition,
  12. Service,
  13. WorkflowArgumentParser,
  14. )
  15. from materialize.mzcompose.services.debezium import Debezium
  16. from materialize.mzcompose.services.kafka import Kafka
  17. from materialize.mzcompose.services.materialized import Materialized
  18. from materialize.mzcompose.services.metabase import Metabase
  19. from materialize.mzcompose.services.mysql import MySql
  20. from materialize.mzcompose.services.mz import Mz
  21. from materialize.mzcompose.services.schema_registry import SchemaRegistry
  22. from materialize.mzcompose.services.zookeeper import Zookeeper
  23. SERVICES = [
  24. Zookeeper(),
  25. Kafka(auto_create_topics=True),
  26. SchemaRegistry(),
  27. Debezium(),
  28. MySql(root_password="rootpw"),
  29. Mz(app_password=""),
  30. Materialized(),
  31. Metabase(),
  32. Service(
  33. name="chbench",
  34. config={
  35. "mzbuild": "chbenchmark",
  36. "init": True,
  37. "volumes": ["mydata:/gen"],
  38. },
  39. ),
  40. ]
  41. def workflow_default(c: Composition) -> None:
  42. def process(name: str) -> None:
  43. if name == "default":
  44. return
  45. with c.test_case(name):
  46. c.workflow(name)
  47. c.test_parts(list(c.workflows.keys()), process)
  48. def workflow_no_load(c: Composition, parser: WorkflowArgumentParser) -> None:
  49. """Run CH-benCHmark without any load on Materialize"""
  50. # Parse arguments.
  51. parser.add_argument(
  52. "--wait", action="store_true", help="wait for the load generator to exit"
  53. )
  54. args, unknown_args = parser.parse_known_args()
  55. # Start Materialize.
  56. c.up("materialized")
  57. # Start MySQL and Debezium.
  58. c.up("zookeeper", "kafka", "schema-registry", "mysql", "debezium")
  59. # Generate initial data.
  60. c.run(
  61. "chbench",
  62. "gen",
  63. "--config-file-path=/etc/chbenchmark/mz-default-mysql.cfg",
  64. "--warehouses=1",
  65. )
  66. # Start Debezium.
  67. response = requests.post(
  68. f"http://localhost:{c.default_port('debezium')}/connectors",
  69. json={
  70. "name": "mysql-connector",
  71. "config": {
  72. "connector.class": "io.debezium.connector.mysql.MySqlConnector",
  73. "database.hostname": "mysql",
  74. "database.port": "3306",
  75. "database.user": "root",
  76. "database.password": "rootpw",
  77. "database.server.name": "debezium",
  78. "database.server.id": "1234",
  79. "database.history.kafka.bootstrap.servers": "kafka:9092",
  80. "database.history.kafka.topic": "mysql-history",
  81. "database.allowPublicKeyRetrieval": "true",
  82. "time.precision.mode": "connect",
  83. "topic.prefix": "mysql",
  84. },
  85. },
  86. )
  87. # Don't error if the connector already exists.
  88. if response.status_code != requests.codes.conflict:
  89. response.raise_for_status()
  90. # Run load generator.
  91. c.run(
  92. "chbench",
  93. "run",
  94. "--config-file-path=/etc/chbenchmark/mz-default-mysql.cfg",
  95. "--dsn=mysql",
  96. "--gen-dir=/var/lib/mysql-files",
  97. "--analytic-threads=0",
  98. "--transactional-threads=1",
  99. "--run-seconds=86400",
  100. "--mz-sources",
  101. *unknown_args,
  102. detach=not args.wait,
  103. )
  104. # invoked by ci/load
  105. def workflow_load_test(c: Composition) -> None:
  106. """Run CH-benCHmark with a selected amount of load against Materialize."""
  107. c.workflow(
  108. "default",
  109. "--peek-conns=1",
  110. "--mz-views=q01,q02,q05,q06,q08,q09,q12,q14,q17,q19",
  111. "--transactional-threads=2",
  112. )