Compare commits

...

1 Commits

Author SHA1 Message Date
Tushar Vats
5a2f0ffa1a test(querier): lock one enabled query for logs and traces heatmaps
A logs or traces heatmap or distribution rejects two enabled queries,
and an enabled query with an enabled formula over it. Add integration
tests for both so the behaviour from SigNoz/signoz#13796 stays put.

Assisted-by: Claude Opus 5.5
2026-12-02 15:02:41 +05:30
2 changed files with 76 additions and 0 deletions

View File

@@ -257,6 +257,44 @@ def test_disabled_query_without_formula(
assert [column["values"] for column in get_heatmap_columns(data, "A")] == [column["values"] for column in get_heatmap_columns(alone.json(), "A")]
@pytest.mark.parametrize("request_type", [RequestType.HEATMAP, RequestType.DISTRIBUTION], ids=["heatmap", "distribution"])
@pytest.mark.parametrize(
"queries,expected_message",
[
pytest.param(
[build_heatmap_query("A", "logs", "response_bytes"), build_heatmap_query("B", "logs", "response_bytes")],
"{request_type} requests take one enabled query, but 2 are enabled",
id="two_enabled_queries",
),
pytest.param(
[build_heatmap_query("A", "logs", "response_bytes"), build_formula_query("F1", "A * 2")],
'formula "F1" reads logs or traces query "A", but logs and traces heatmaps do not support formulas',
id="enabled_query_and_formula",
),
],
)
def test_more_than_one_enabled_query(
signoz: types.SigNoz,
create_user_admin: None, # pylint: disable=unused-argument
get_token: Callable[[str, str], str],
queries: list[dict],
expected_message: str,
request_type: str,
) -> None:
now = datetime.now(tz=UTC).replace(second=0, microsecond=0)
token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)
response = make_query_request(
signoz,
token,
int((now - timedelta(minutes=5)).timestamp() * 1000),
int(now.timestamp() * 1000),
queries,
request_type=request_type,
)
assert response.status_code == HTTPStatus.BAD_REQUEST, response.text
assert expected_message.format(request_type=request_type) in get_error_message(response.json())
@pytest.mark.parametrize("request_type", [RequestType.HEATMAP, RequestType.DISTRIBUTION], ids=["heatmap", "distribution"])
@pytest.mark.parametrize("expression", ["response_bytes", "avg(response_bytes)"], ids=["bare_field", "aggregation"])
def test_formula_over_logs_query(

View File

@@ -159,6 +159,44 @@ def test_disabled_query_without_formula(
assert [column["values"] for column in get_heatmap_columns(data, "A")] == [column["values"] for column in get_heatmap_columns(alone.json(), "A")]
@pytest.mark.parametrize("request_type", [RequestType.HEATMAP, RequestType.DISTRIBUTION], ids=["heatmap", "distribution"])
@pytest.mark.parametrize(
"queries,expected_message",
[
pytest.param(
[build_heatmap_query("A", "traces", "duration_nano"), build_heatmap_query("B", "traces", "duration_nano")],
"{request_type} requests take one enabled query, but 2 are enabled",
id="two_enabled_queries",
),
pytest.param(
[build_heatmap_query("A", "traces", "duration_nano"), build_formula_query("F1", "A * 2")],
'formula "F1" reads logs or traces query "A", but logs and traces heatmaps do not support formulas',
id="enabled_query_and_formula",
),
],
)
def test_more_than_one_enabled_query(
signoz: types.SigNoz,
create_user_admin: None, # pylint: disable=unused-argument
get_token: Callable[[str, str], str],
queries: list[dict],
expected_message: str,
request_type: str,
) -> None:
now = datetime.now(tz=UTC).replace(second=0, microsecond=0)
token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)
response = make_query_request(
signoz,
token,
int((now - timedelta(minutes=5)).timestamp() * 1000),
int(now.timestamp() * 1000),
queries,
request_type=request_type,
)
assert response.status_code == HTTPStatus.BAD_REQUEST, response.text
assert expected_message.format(request_type=request_type) in get_error_message(response.json())
@pytest.mark.parametrize("request_type", [RequestType.HEATMAP, RequestType.DISTRIBUTION], ids=["heatmap", "distribution"])
@pytest.mark.parametrize("expression", ["duration_nano", "avg(duration_nano)"], ids=["bare_field", "aggregation"])
def test_formula_over_traces_query(