Skip to content

Commit 5152c32

Browse files
zzylolclaude
andcommitted
Fix workspace conflicts and add missing test data for correctness CI
- Add [workspace] table to three standalone test Cargo.toml files (compare_patterns, compare_matched_tokens/rust_tests, rust_pattern_matching) to prevent "believes it's in a workspace" error on the root Cargo.toml - Add test_data/promql_queries.json with 10 PromQL test cases covering ONLY_TEMPORAL, ONLY_SPATIAL, and ONE_TEMPORAL_ONE_SPATIAL patterns, required by the cross-language master_test_runner - Unignore test_data/*.json in asap-common/.gitignore (tests/**/*.json was intended for generated result files, not fixture input data) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f3fdf53 commit 5152c32

5 files changed

Lines changed: 235 additions & 0 deletions

File tree

asap-common/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ dependencies/py/promql_utilities/promql_utilities.egg-info/
88
dependencies/rs/**/target/
99

1010
tests/**/*.json
11+
!tests/**/test_data/*.json
1112
tests/**/target/

asap-common/tests/compare_matched_tokens/rust_tests/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[workspace]
2+
13
[package]
24
name = "promql_cross_lang_tests"
35
version = "0.1.0"
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
{
2+
"test_cases": [
3+
{
4+
"id": "temporal_rate_basic",
5+
"description": "Basic rate function over a time range",
6+
"query": "rate(http_requests_total{job=\"api\"}[5m])",
7+
"expected_pattern_type": "ONLY_TEMPORAL",
8+
"expected_tokens": {
9+
"metric": {
10+
"name": "http_requests_total",
11+
"labels": {"job": "api"},
12+
"at_modifier": null
13+
},
14+
"function": {
15+
"name": "rate"
16+
},
17+
"range_vector": {
18+
"range": "5m"
19+
}
20+
}
21+
},
22+
{
23+
"id": "temporal_increase_basic",
24+
"description": "Increase function over a time range",
25+
"query": "increase(http_requests_total[1h])",
26+
"expected_pattern_type": "ONLY_TEMPORAL",
27+
"expected_tokens": {
28+
"metric": {
29+
"name": "http_requests_total",
30+
"labels": {},
31+
"at_modifier": null
32+
},
33+
"function": {
34+
"name": "increase"
35+
},
36+
"range_vector": {
37+
"range": "1h"
38+
}
39+
}
40+
},
41+
{
42+
"id": "temporal_quantile_over_time",
43+
"description": "Quantile over time function",
44+
"query": "quantile_over_time(0.95, cpu_usage{instance=\"host1\"}[10m])",
45+
"expected_pattern_type": "ONLY_TEMPORAL",
46+
"expected_tokens": {
47+
"metric": {
48+
"name": "cpu_usage",
49+
"labels": {"instance": "host1"},
50+
"at_modifier": null
51+
},
52+
"function": {
53+
"name": "quantile_over_time"
54+
},
55+
"range_vector": {
56+
"range": "10m"
57+
}
58+
}
59+
},
60+
{
61+
"id": "temporal_avg_over_time",
62+
"description": "Average over time function",
63+
"query": "avg_over_time(memory_bytes[30m])",
64+
"expected_pattern_type": "ONLY_TEMPORAL",
65+
"expected_tokens": {
66+
"metric": {
67+
"name": "memory_bytes",
68+
"labels": {},
69+
"at_modifier": null
70+
},
71+
"function": {
72+
"name": "avg_over_time"
73+
},
74+
"range_vector": {
75+
"range": "30m"
76+
}
77+
}
78+
},
79+
{
80+
"id": "spatial_sum_aggregation",
81+
"description": "Sum aggregation across all series",
82+
"query": "sum(http_requests_total{job=\"api\"})",
83+
"expected_pattern_type": "ONLY_SPATIAL",
84+
"expected_tokens": {
85+
"metric": {
86+
"name": "http_requests_total",
87+
"labels": {"job": "api"},
88+
"at_modifier": null
89+
},
90+
"aggregation": {
91+
"op": "sum",
92+
"modifier": null
93+
}
94+
}
95+
},
96+
{
97+
"id": "spatial_avg_aggregation",
98+
"description": "Average aggregation by label",
99+
"query": "avg by (instance) (cpu_usage)",
100+
"expected_pattern_type": "ONLY_SPATIAL",
101+
"expected_tokens": {
102+
"metric": {
103+
"name": "cpu_usage",
104+
"labels": {},
105+
"at_modifier": null
106+
},
107+
"aggregation": {
108+
"op": "avg",
109+
"modifier": null
110+
}
111+
}
112+
},
113+
{
114+
"id": "spatial_count_aggregation",
115+
"description": "Count aggregation",
116+
"query": "count(up{job=\"node\"})",
117+
"expected_pattern_type": "ONLY_SPATIAL",
118+
"expected_tokens": {
119+
"metric": {
120+
"name": "up",
121+
"labels": {"job": "node"},
122+
"at_modifier": null
123+
},
124+
"aggregation": {
125+
"op": "count",
126+
"modifier": null
127+
}
128+
}
129+
},
130+
{
131+
"id": "combined_sum_of_rate",
132+
"description": "Sum aggregation of rate (temporal + spatial)",
133+
"query": "sum(rate(http_requests_total{job=\"api\"}[5m]))",
134+
"expected_pattern_type": "ONE_TEMPORAL_ONE_SPATIAL",
135+
"expected_tokens": {
136+
"metric": {
137+
"name": "http_requests_total",
138+
"labels": {"job": "api"},
139+
"at_modifier": null
140+
},
141+
"function": {
142+
"name": "rate"
143+
},
144+
"aggregation": {
145+
"op": "sum",
146+
"modifier": null
147+
},
148+
"range_vector": {
149+
"range": "5m"
150+
}
151+
}
152+
},
153+
{
154+
"id": "combined_avg_of_quantile_over_time",
155+
"description": "Avg aggregation of quantile_over_time (temporal + spatial)",
156+
"query": "avg(quantile_over_time(0.99, response_time_seconds[15m]))",
157+
"expected_pattern_type": "ONE_TEMPORAL_ONE_SPATIAL",
158+
"expected_tokens": {
159+
"metric": {
160+
"name": "response_time_seconds",
161+
"labels": {},
162+
"at_modifier": null
163+
},
164+
"function": {
165+
"name": "quantile_over_time"
166+
},
167+
"aggregation": {
168+
"op": "avg",
169+
"modifier": null
170+
},
171+
"range_vector": {
172+
"range": "15m"
173+
}
174+
}
175+
},
176+
{
177+
"id": "combined_sum_of_avg_over_time",
178+
"description": "Sum aggregation of avg_over_time",
179+
"query": "sum by (job) (avg_over_time(memory_bytes{env=\"prod\"}[1h]))",
180+
"expected_pattern_type": "ONE_TEMPORAL_ONE_SPATIAL",
181+
"expected_tokens": {
182+
"metric": {
183+
"name": "memory_bytes",
184+
"labels": {"env": "prod"},
185+
"at_modifier": null
186+
},
187+
"function": {
188+
"name": "avg_over_time"
189+
},
190+
"aggregation": {
191+
"op": "sum",
192+
"modifier": null
193+
},
194+
"range_vector": {
195+
"range": "1h"
196+
}
197+
}
198+
}
199+
],
200+
"pattern_builder_tests": [
201+
{
202+
"id": "builder_metric_no_labels",
203+
"description": "Build a simple metric selector with no labels",
204+
"builder_call": "metric",
205+
"parameters": {
206+
"collect_as": "metric"
207+
},
208+
"expected_pattern": {
209+
"type": "metric",
210+
"collect_as": "metric"
211+
}
212+
},
213+
{
214+
"id": "builder_function_rate",
215+
"description": "Build a rate function pattern",
216+
"builder_call": "function",
217+
"parameters": {
218+
"names": ["rate", "increase"],
219+
"collect_as": "function"
220+
},
221+
"expected_pattern": {
222+
"type": "function",
223+
"names": ["rate", "increase"],
224+
"collect_as": "function"
225+
}
226+
}
227+
]
228+
}

asap-common/tests/compare_patterns/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[workspace]
2+
13
[package]
24
name = "compare_patterns_runner"
35
version = "0.1.0"

asap-common/tests/rust_pattern_matching/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[workspace]
2+
13
[package]
24
name = "promql_cross_lang_tests"
35
version = "0.1.0"

0 commit comments

Comments
 (0)