test_labels.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 json
  10. from materialize.cloudtest.app.materialize_application import MaterializeApplication
  11. # NOTE [btv] - Quick and dirty hack: assume s1 is always mz_system and
  12. # s2 is always mz_support.
  13. #
  14. # This will need to be done properly (i.e., by actually looking up
  15. # the cluster id->name mapping in SQL) if that assumption ever changes.
  16. def test_roles(mz: MaterializeApplication) -> None:
  17. mz.wait_replicas()
  18. pods = json.loads(mz.kubectl("get", "pods", "-o", "json"))
  19. names_roles = (
  20. (
  21. item["metadata"]["name"],
  22. item["metadata"]
  23. .get("labels", {})
  24. .get("cluster.environmentd.materialize.cloud/replica-role"),
  25. )
  26. for item in pods["items"]
  27. )
  28. n_replica_pods = 0
  29. for name, role in names_roles:
  30. if name.startswith("cluster-s1"):
  31. assert role == "system-critical"
  32. n_replica_pods += 1
  33. elif name.startswith("cluster-s2"):
  34. assert role == "system"
  35. n_replica_pods += 1
  36. elif name.startswith("cluster-u"):
  37. assert role == "user"
  38. n_replica_pods += 1
  39. assert n_replica_pods >= 3