mzcompose.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. Maelstrom test against the Persist subsystem.
  11. """
  12. import argparse
  13. from materialize.mzcompose.composition import (
  14. Composition,
  15. Service,
  16. WorkflowArgumentParser,
  17. )
  18. from materialize.mzcompose.services.cockroach import Cockroach
  19. from materialize.mzcompose.services.postgres import PostgresMetadata
  20. SERVICES = [
  21. Cockroach(setup_materialize=True),
  22. PostgresMetadata(),
  23. Service(
  24. "maelstrom-persist",
  25. {"mzbuild": "maelstrom-persist", "volumes": ["./maelstrom:/store"]},
  26. ),
  27. ]
  28. def workflow_default(c: Composition, parser: WorkflowArgumentParser) -> None:
  29. """Run maelstrom against persist"""
  30. # Please see `docker run materialize/maelstrom-persist:mzbuild-... --help` for
  31. # the meaning of the various arguments
  32. parser.add_argument(
  33. "--time-limit",
  34. type=int,
  35. default=60,
  36. )
  37. parser.add_argument("--node-count", type=int, default=1)
  38. parser.add_argument("--concurrency", type=int, default=2)
  39. parser.add_argument("--rate", type=int, default=100)
  40. parser.add_argument("--max-txn-length", type=int, default=4)
  41. parser.add_argument("--unreliability", type=float, default=None)
  42. parser.add_argument(
  43. "--consensus",
  44. type=str,
  45. choices=["mem", "cockroach", "maelstrom", "postgres"],
  46. default="maelstrom",
  47. )
  48. parser.add_argument(
  49. "--blob", type=str, choices=["mem", "maelstrom"], default="maelstrom"
  50. )
  51. parser.add_argument(
  52. "--txn-wal", type=bool, default=False, action=argparse.BooleanOptionalAction
  53. )
  54. args = parser.parse_args()
  55. if args.consensus == "mem":
  56. consensus_uri = "mem://consensus"
  57. elif args.consensus == "cockroach":
  58. consensus_uri = (
  59. "postgres://root@cockroach:26257?options=--search_path=consensus"
  60. )
  61. c.up("cockroach")
  62. elif args.consensus == "postgres":
  63. consensus_uri = (
  64. "postgres://root@postgres-metadata:26257?options=--search_path=consensus"
  65. )
  66. c.up("postgres-metadata")
  67. else:
  68. # empty consensus uri defaults to Maelstrom consensus implementation
  69. consensus_uri = ""
  70. if args.blob == "mem":
  71. blob_uri = "mem://blob"
  72. else:
  73. # empty blob uri defaults to Maelstrom blob implementation
  74. blob_uri = ""
  75. maelstrom_cmd = "maelstrom"
  76. if args.txn_wal:
  77. maelstrom_cmd = "maelstrom-txn"
  78. c.run(
  79. "maelstrom-persist",
  80. f"--time-limit={args.time_limit}",
  81. f"--node-count={args.node_count}",
  82. f"--concurrency={args.concurrency}",
  83. f"--rate={args.rate}",
  84. "--",
  85. maelstrom_cmd,
  86. *([f"--blob-uri={blob_uri}"] if blob_uri else []),
  87. *([f"--consensus-uri={consensus_uri}"] if consensus_uri else []),
  88. *([f"--unreliability={args.unreliability}"] if args.unreliability else []),
  89. )
  90. # TODO: Reenable this when we un-break MaelstromConsensus
  91. # c.run("maelstrom-persist", "--time-limit=5", "--", "maelstrom")