MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / check_workload_class

Function check_workload_class

test/cluster/mzcompose.py:3424–3460  ·  view source on GitHub ↗

Assert that metrics on both envd and clusterd are labeled with the given expected workload class.

(expected: str | None)

Source from the content-addressed store, hash-verified

3422 clusterd_port = find_proxy_port(logs, cluster_id, "internal-http")
3423
3424 def check_workload_class(expected: str | None):
3425 """
3426 Assert that metrics on both envd and clusterd are labeled with the
3427 given expected workload class.
3428 """
3429
3430 # Sleep a bit to give workload class changes time to propagate.
3431 time.sleep(1)
3432
3433 envd_metrics = c.exec(
3434 "materialized", "curl", "localhost:6878/metrics", capture=True
3435 ).stdout
3436 clusterd_metrics = c.exec(
3437 "materialized", "curl", f"localhost:{clusterd_port}/metrics", capture=True
3438 ).stdout
3439
3440 envd_classes = {
3441 m.group("value") for m in RE_WORKLOAD_CLASS_LABEL.finditer(envd_metrics)
3442 }
3443 clusterd_classes = {
3444 m.group("value") for m in RE_WORKLOAD_CLASS_LABEL.finditer(clusterd_metrics)
3445 }
3446
3447 if expected is None:
3448 assert (
3449 not envd_classes
3450 ), f"envd: expected no workload classes, found {envd_classes}"
3451 assert (
3452 not clusterd_classes
3453 ), f"clusterd: expected no workload classes, found {clusterd_classes}"
3454 else:
3455 assert envd_classes == {
3456 expected
3457 }, f"envd: expected workload class '{expected}', found {envd_classes}"
3458 assert clusterd_classes == {
3459 expected
3460 }, f"clusterd: expected workload class '{expected}', found {clusterd_classes}"
3461
3462 check_workload_class(None)
3463

Calls 3

execMethod · 0.80
groupMethod · 0.80
sleepMethod · 0.45

Tested by

no test coverage detected