toxiproxy.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 random
  10. from materialize.mzcompose.service import (
  11. Service,
  12. )
  13. class Toxiproxy(Service):
  14. def __init__(
  15. self,
  16. name: str = "toxiproxy",
  17. image: str = "jauderho/toxiproxy:v2.8.0",
  18. port: int = 8474,
  19. seed: int = random.randrange(2**63),
  20. ) -> None:
  21. super().__init__(
  22. name=name,
  23. config={
  24. "image": image,
  25. "command": ["-host=0.0.0.0", f"-seed={seed}"],
  26. "ports": [port],
  27. "healthcheck": {
  28. "test": ["CMD", "nc", "-z", "localhost", "8474"],
  29. "interval": "1s",
  30. "start_period": "30s",
  31. },
  32. },
  33. )