Skip to content

Commit 59c7797

Browse files
update orchestratord tests for blancerd and console replicas
1 parent 1be406d commit 59c7797

File tree

2 files changed

+68
-50
lines changed

2 files changed

+68
-50
lines changed

misc/helm-charts/operator/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ operator:
1313
# -- The Docker repository for the operator image
1414
repository: materialize/orchestratord
1515
# -- The tag/version of the operator image to be used
16-
tag: v0.158.0
16+
tag: v0.159.0-dev.0--pr.g1be406dc1fc56a0568365ca0b58042d88970b125
1717
# -- Policy for pulling the image: "IfNotPresent" avoids unnecessary re-pulling of images
1818
pullPolicy: IfNotPresent
1919

test/orchestratord/mzcompose.py

Lines changed: 67 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -49,57 +49,46 @@ def get_tag(tag: str | None) -> str:
4949
return tag
5050

5151

52-
def get_orchestratord_data() -> dict[str, Any]:
52+
def get_pod_data(labels: dict[str, str], namespace="materialize-environment") -> dict[str, Any]:
5353
return json.loads(
5454
spawn.capture(
5555
[
5656
"kubectl",
5757
"get",
5858
"pod",
5959
"-l",
60-
"app.kubernetes.io/instance=operator",
60+
",".join(f"{key}={value}" for key, value in labels.items()),
6161
"-n",
62-
"materialize",
62+
namespace,
6363
"-o",
6464
"json",
6565
]
6666
)
6767
)
6868

6969

70+
def get_orchestratord_data() -> dict[str, Any]:
71+
return get_pod_data(
72+
labels={"app.kubernetes.io/instance": "operator"},
73+
namespace="materialize",
74+
)
75+
76+
7077
def get_balancerd_data() -> dict[str, Any]:
71-
return json.loads(
72-
spawn.capture(
73-
[
74-
"kubectl",
75-
"get",
76-
"pod",
77-
"-l",
78-
"app=balancerd",
79-
"-n",
80-
"materialize-environment",
81-
"-o",
82-
"json",
83-
]
84-
)
78+
return get_pod_data(
79+
labels={"materialize.cloud/app": "balancerd"},
80+
)
81+
82+
83+
def get_console_data() -> dict[str, Any]:
84+
return get_pod_data(
85+
labels={"materialize.cloud/app": "console"},
8586
)
8687

8788

8889
def get_environmentd_data() -> dict[str, Any]:
89-
return json.loads(
90-
spawn.capture(
91-
[
92-
"kubectl",
93-
"get",
94-
"pod",
95-
"-l",
96-
"app=environmentd",
97-
"-n",
98-
"materialize-environment",
99-
"-o",
100-
"json",
101-
]
102-
)
90+
return get_pod_data(
91+
labels={"materialize.cloud/app": "environmentd"},
10392
)
10493

10594

@@ -515,6 +504,53 @@ def validate(self, mods: dict[type[Modification], Any]) -> None:
515504
), f"Expected no {expected} in environmentd args, but found it: {args}"
516505

517506

507+
class BalancerdReplicas(Modification):
508+
@classmethod
509+
def values(cls) -> list[Any]:
510+
return [None, 1, 2]
511+
512+
@classmethod
513+
def default(cls) -> Any:
514+
return None
515+
516+
def modify(self, definition: dict[str, Any]) -> None:
517+
if self.value is not None:
518+
definition["materialize"]["spec"]["balancerdReplicas"] = self.value
519+
520+
def validate(self, mods: dict[type[Modification], Any]) -> None:
521+
def check_replicas():
522+
balancerd = get_balancerd_data()
523+
num_pods = len(balancerd["items"])
524+
expected = self.value if self.value is not None else 2
525+
assert num_pods == expected, f"Expected {expected} balancerd pods, but found {num_pods}"
526+
527+
retry(check_replicas, 5)
528+
529+
530+
class ConsoleReplicas(Modification):
531+
@classmethod
532+
def values(cls) -> list[Any]:
533+
return [None, 1, 2]
534+
535+
@classmethod
536+
def default(cls) -> Any:
537+
return None
538+
539+
def modify(self, definition: dict[str, Any]) -> None:
540+
if self.value is not None:
541+
definition["materialize"]["spec"]["consoleReplicas"] = self.value
542+
543+
def validate(self, mods: dict[type[Modification], Any]) -> None:
544+
def check_replicas():
545+
console = get_console_data()
546+
num_pods = len(console["items"])
547+
expected = self.value if self.value is not None else 2
548+
assert num_pods == expected, f"Expected {expected} console pods, but found {num_pods}"
549+
550+
# console doesn't get launched until last
551+
retry(check_replicas, 120)
552+
553+
518554
def validate_cluster_replica_size(
519555
size: dict[str, Any], swap_enabled: bool, storage_class_name_set: bool
520556
):
@@ -558,24 +594,6 @@ def validate_container_resources(
558594
assert resources["requests"]["memory"] == resources["limits"]["memory"]
559595

560596

561-
def get_pod_data(labels: dict[str, str]) -> dict[str, Any]:
562-
return json.loads(
563-
spawn.capture(
564-
[
565-
"kubectl",
566-
"get",
567-
"pod",
568-
"-l",
569-
",".join(f"{key}={value}" for key, value in labels.items()),
570-
"-n",
571-
"materialize-environment",
572-
"-o",
573-
"json",
574-
]
575-
)
576-
)
577-
578-
579597
class SwapEnabledGlobal(Modification):
580598
@classmethod
581599
def values(cls) -> list[Any]:

0 commit comments

Comments
 (0)