Skip to content

Commit 296c063

Browse files
authored
fix(metrics-layer): Add xfailing metrics layer sort test (#54712)
- This adds a test that's failing where sort order isn't being maintained consistently in the metrics layer
1 parent b990231 commit 296c063

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

tests/snuba/api/endpoints/test_organization_events_mep.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,6 +2391,64 @@ def test_title_and_transaction_alias(self):
23912391
assert field_meta["transaction"] == "string"
23922392
assert field_meta["p75()"] == "duration"
23932393

2394+
def test_maintain_sort_order_across_datasets(self):
2395+
self.store_transaction_metric(
2396+
1,
2397+
tags={"transaction": "foo_transaction"},
2398+
timestamp=self.min_ago,
2399+
)
2400+
self.store_transaction_metric(
2401+
1,
2402+
metric="user",
2403+
tags={"transaction": "bar_transaction"},
2404+
timestamp=self.min_ago,
2405+
)
2406+
self.store_transaction_metric(
2407+
5,
2408+
tags={"transaction": "bar_transaction"},
2409+
timestamp=self.min_ago,
2410+
)
2411+
self.store_transaction_metric(
2412+
5,
2413+
tags={"transaction": "bar_transaction"},
2414+
timestamp=self.min_ago,
2415+
)
2416+
2417+
response = self.do_request(
2418+
{
2419+
"field": [
2420+
"title",
2421+
"project",
2422+
"count()",
2423+
"count_unique(user)",
2424+
],
2425+
"query": "event.type:transaction",
2426+
"orderby": "count()",
2427+
"dataset": "metrics",
2428+
"project": self.project.id,
2429+
"per_page": 50,
2430+
}
2431+
)
2432+
assert response.status_code == 200, response.content
2433+
data = response.data["data"]
2434+
meta = response.data["meta"]
2435+
field_meta = meta["fields"]
2436+
2437+
assert len(data) == 2
2438+
2439+
assert data[0]["title"] == "foo_transaction"
2440+
assert data[0]["count()"] == 1
2441+
assert data[0]["count_unique(user)"] == 0
2442+
2443+
assert data[1]["title"] == "bar_transaction"
2444+
assert data[1]["count()"] == 2
2445+
assert data[1]["count_unique(user)"] == 1
2446+
2447+
assert meta["isMetricsData"]
2448+
assert field_meta["title"] == "string"
2449+
assert field_meta["count()"] == "integer"
2450+
assert field_meta["count_unique(user)"] == "integer"
2451+
23942452

23952453
class OrganizationEventsMetricsEnhancedPerformanceEndpointTestWithMetricLayer(
23962454
OrganizationEventsMetricsEnhancedPerformanceEndpointTest
@@ -2426,3 +2484,8 @@ def test_http_error_rate(self):
24262484
@pytest.mark.xfail(reason="Multiple aliases to same column not supported")
24272485
def test_title_and_transaction_alias(self):
24282486
super().test_title_and_transaction_alias()
2487+
2488+
@pytest.mark.xfail(reason="Sort order is flaking when querying multiple datasets")
2489+
def test_maintain_sort_order_across_datasets(self):
2490+
"""You may need to run this test a few times to get it to fail"""
2491+
super().test_maintain_sort_order_across_datasets()

0 commit comments

Comments
 (0)