Skip to content

Commit 47bbd2c

Browse files
committed
[python] Enable metrics integration test for multihost.
This doesn't test JSON metrics, which haven't been implemented in multihost and maybe will never need to be. Signed-off-by: Ben Pfaff <blp@feldera.com>
1 parent c541719 commit 47bbd2c

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

python/tests/platform/test_metrics_logs.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
gen_pipeline_name,
1818
)
1919

20-
from feldera.testutils import single_host_only
20+
from feldera.testutils import FELDERA_TEST_NUM_HOSTS
2121

2222

2323
def _ingest_lines(name: str, table: str, body: str):
@@ -49,7 +49,6 @@ def _adhoc_count(name: str, table: str) -> int:
4949

5050

5151
@gen_pipeline_name
52-
@single_host_only
5352
def test_pipeline_metrics(pipeline_name):
5453
"""
5554
Tests that circuit metrics can be retrieved from the pipeline.
@@ -60,30 +59,28 @@ def test_pipeline_metrics(pipeline_name):
6059
# Default
6160
r_default = get(api_url(f"/pipelines/{pipeline_name}/metrics"))
6261
assert r_default.status_code == HTTPStatus.OK
63-
text_default = r_default.text
62+
assert "# TYPE records_processed_total counter" in r_default.text
6463

6564
# Prometheus
6665
r_prom = get(api_url(f"/pipelines/{pipeline_name}/metrics?format=prometheus"))
6766
assert r_prom.status_code == HTTPStatus.OK
68-
text_prom = r_prom.text
67+
assert "# TYPE records_processed_total counter" in r_prom.text
6968

7069
# JSON
71-
r_json = get(api_url(f"/pipelines/{pipeline_name}/metrics?format=json"))
72-
assert r_json.status_code == HTTPStatus.OK
73-
parsed_json = json.loads(r_json.text)
74-
assert isinstance(parsed_json, list), "Expected JSON metrics array"
70+
if FELDERA_TEST_NUM_HOSTS == 1:
71+
r_json = get(api_url(f"/pipelines/{pipeline_name}/metrics?format=json"))
72+
assert r_json.status_code == HTTPStatus.OK
73+
parsed_json = json.loads(r_json.text)
74+
assert isinstance(parsed_json, list), "Expected JSON metrics array"
75+
76+
assert any(m.get("key") == "records_processed_total" for m in parsed_json), (
77+
"records_processed_total missing in JSON metrics"
78+
)
7579

7680
# Invalid
7781
r_bad = get(api_url(f"/pipelines/{pipeline_name}/metrics?format=does-not-exist"))
7882
assert r_bad.status_code == HTTPStatus.BAD_REQUEST
7983

80-
# Minimal checks
81-
assert "# TYPE records_processed_total counter" in text_default
82-
assert "# TYPE records_processed_total counter" in text_prom
83-
assert any(m.get("key") == "records_processed_total" for m in parsed_json), (
84-
"records_processed_total missing in JSON metrics"
85-
)
86-
8784

8885
@gen_pipeline_name
8986
@single_host_only

0 commit comments

Comments
 (0)