Skip to content

Commit aab783d

Browse files
update orchestratord tests for blancerd and console replicas
1 parent 799b4af commit aab783d

File tree

1 file changed

+73
-49
lines changed

1 file changed

+73
-49
lines changed

test/orchestratord/mzcompose.py

Lines changed: 73 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -56,57 +56,48 @@ def get_image(image: str, tag: str | None) -> str:
5656
return f'{image.rsplit(":", 1)[0]}:{tag or LOCAL_TAG}'
5757

5858

59-
def get_orchestratord_data() -> dict[str, Any]:
59+
def get_pod_data(
60+
labels: dict[str, str], namespace="materialize-environment"
61+
) -> dict[str, Any]:
6062
return json.loads(
6163
spawn.capture(
6264
[
6365
"kubectl",
6466
"get",
6567
"pod",
6668
"-l",
67-
"app.kubernetes.io/instance=operator",
69+
",".join(f"{key}={value}" for key, value in labels.items()),
6870
"-n",
69-
"materialize",
71+
namespace,
7072
"-o",
7173
"json",
7274
]
7375
)
7476
)
7577

7678

79+
def get_orchestratord_data() -> dict[str, Any]:
80+
return get_pod_data(
81+
labels={"app.kubernetes.io/instance": "operator"},
82+
namespace="materialize",
83+
)
84+
85+
7786
def get_balancerd_data() -> dict[str, Any]:
78-
return json.loads(
79-
spawn.capture(
80-
[
81-
"kubectl",
82-
"get",
83-
"pod",
84-
"-l",
85-
"app=balancerd",
86-
"-n",
87-
"materialize-environment",
88-
"-o",
89-
"json",
90-
]
91-
)
87+
return get_pod_data(
88+
labels={"materialize.cloud/app": "balancerd"},
89+
)
90+
91+
92+
def get_console_data() -> dict[str, Any]:
93+
return get_pod_data(
94+
labels={"materialize.cloud/app": "console"},
9295
)
9396

9497

9598
def get_environmentd_data() -> dict[str, Any]:
96-
return json.loads(
97-
spawn.capture(
98-
[
99-
"kubectl",
100-
"get",
101-
"pod",
102-
"-l",
103-
"app=environmentd",
104-
"-n",
105-
"materialize-environment",
106-
"-o",
107-
"json",
108-
]
109-
)
99+
return get_pod_data(
100+
labels={"materialize.cloud/app": "environmentd"},
110101
)
111102

112103

@@ -522,6 +513,57 @@ def validate(self, mods: dict[type[Modification], Any]) -> None:
522513
), f"Expected no {expected} in environmentd args, but found it: {args}"
523514

524515

516+
class BalancerdReplicas(Modification):
517+
@classmethod
518+
def values(cls) -> list[Any]:
519+
return [None, 1, 2]
520+
521+
@classmethod
522+
def default(cls) -> Any:
523+
return None
524+
525+
def modify(self, definition: dict[str, Any]) -> None:
526+
if self.value is not None:
527+
definition["materialize"]["spec"]["balancerdReplicas"] = self.value
528+
529+
def validate(self, mods: dict[type[Modification], Any]) -> None:
530+
def check_replicas():
531+
balancerd = get_balancerd_data()
532+
num_pods = len(balancerd["items"])
533+
expected = self.value if self.value is not None else 2
534+
assert (
535+
num_pods == expected
536+
), f"Expected {expected} balancerd pods, but found {num_pods}"
537+
538+
retry(check_replicas, 120)
539+
540+
541+
class ConsoleReplicas(Modification):
542+
@classmethod
543+
def values(cls) -> list[Any]:
544+
return [None, 1, 2]
545+
546+
@classmethod
547+
def default(cls) -> Any:
548+
return None
549+
550+
def modify(self, definition: dict[str, Any]) -> None:
551+
if self.value is not None:
552+
definition["materialize"]["spec"]["consoleReplicas"] = self.value
553+
554+
def validate(self, mods: dict[type[Modification], Any]) -> None:
555+
def check_replicas():
556+
console = get_console_data()
557+
num_pods = len(console["items"])
558+
expected = self.value if self.value is not None else 2
559+
assert (
560+
num_pods == expected
561+
), f"Expected {expected} console pods, but found {num_pods}"
562+
563+
# console doesn't get launched until last
564+
retry(check_replicas, 120)
565+
566+
525567
def validate_cluster_replica_size(
526568
size: dict[str, Any], swap_enabled: bool, storage_class_name_set: bool
527569
):
@@ -565,24 +607,6 @@ def validate_container_resources(
565607
assert resources["requests"]["memory"] == resources["limits"]["memory"]
566608

567609

568-
def get_pod_data(labels: dict[str, str]) -> dict[str, Any]:
569-
return json.loads(
570-
spawn.capture(
571-
[
572-
"kubectl",
573-
"get",
574-
"pod",
575-
"-l",
576-
",".join(f"{key}={value}" for key, value in labels.items()),
577-
"-n",
578-
"materialize-environment",
579-
"-o",
580-
"json",
581-
]
582-
)
583-
)
584-
585-
586610
class SwapEnabledGlobal(Modification):
587611
@classmethod
588612
def values(cls) -> list[Any]:

0 commit comments

Comments
 (0)