test_mz_debug_tool.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 glob
  10. import subprocess
  11. from materialize import MZ_ROOT, spawn
  12. from materialize.cloudtest import DEFAULT_K8S_CONTEXT_NAME, DEFAULT_K8S_NAMESPACE
  13. from materialize.cloudtest.app.materialize_application import MaterializeApplication
  14. from materialize.cloudtest.util.wait import wait
  15. def test_successful_zip_creation(mz: MaterializeApplication) -> None:
  16. # Wait until the Materialize instance is ready
  17. wait(
  18. condition="condition=Ready",
  19. resource="pod",
  20. label="cluster.environmentd.materialize.cloud/cluster-id=u1",
  21. )
  22. print("-- Port forwarding the internal SQL port")
  23. subprocess.Popen(
  24. [
  25. "kubectl",
  26. "--context",
  27. DEFAULT_K8S_CONTEXT_NAME,
  28. "port-forward",
  29. "pods/environmentd-0",
  30. "6877:6877",
  31. ]
  32. )
  33. print("-- Running mz-debug")
  34. spawn.runv(
  35. [
  36. "cargo",
  37. "run",
  38. "--bin",
  39. "mz-debug",
  40. "--",
  41. "self-managed",
  42. "--k8s-context",
  43. DEFAULT_K8S_CONTEXT_NAME,
  44. "--k8s-namespace",
  45. DEFAULT_K8S_NAMESPACE,
  46. # We need to disable auto-port-forwarding because auto-portforward expects a balancerd service we're not running the
  47. # tool against our helm chart installation
  48. "--auto-port-forward",
  49. "false",
  50. "--mz-connection-url",
  51. "postgresql://mz_system@localhost:6877/materialize",
  52. ],
  53. cwd=MZ_ROOT,
  54. )
  55. print("-- Looking for mz-debug zip files")
  56. zip_files = glob.glob(str(MZ_ROOT / "mz_debug*.zip"))
  57. assert len(zip_files) > 0, "No mz-debug zip file was created"