Skip to content

Commit

Permalink
fmt: format load strings and promql in tests
Browse files Browse the repository at this point in the history
* added small tool to automatically format tests
* reformatted all tests

Signed-off-by: Michael Hoffmann <mhoffm@posteo.de>
  • Loading branch information
MichaHoffmann committed Jun 8, 2024
1 parent b1c0214 commit 12d908c
Show file tree
Hide file tree
Showing 8 changed files with 1,272 additions and 1,094 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ check-docs: $(MDOX)
format: $(GOIMPORTS)
@echo ">> formatting go code"
@gofmt -s -w $(FILES_TO_FMT)
@echo ">> formatting promql tests"
@go run scripts/testvet/main.go -json -fix ./...
@echo ">> formatting imports"
@$(GOIMPORTS) -w $(FILES_TO_FMT)

.PHONY:lint
Expand Down
16 changes: 8 additions & 8 deletions engine/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ func BenchmarkRangeQuery(b *testing.B) {
},
{
name: "topk",
query: "topk(2,http_requests_total)",
query: `topk(2, http_requests_total)`,
storage: sixHourDataset,
},
{
name: "bottomk",
query: "bottomk(2,http_requests_total)",
query: `bottomk(2, http_requests_total)`,
storage: sixHourDataset,
},
{
Expand Down Expand Up @@ -204,12 +204,12 @@ func BenchmarkRangeQuery(b *testing.B) {
},
{
name: "binary operation with one to one",
query: `http_requests_total{container="c1"} / ignoring(container) http_responses_total`,
query: `http_requests_total{container="c1"} / ignoring (container) http_responses_total`,
storage: sixHourDataset,
},
{
name: "binary operation with many to one",
query: `http_requests_total / on (pod) group_left http_responses_total`,
query: `http_requests_total / on (pod) group_left () http_responses_total`,
storage: sixHourDataset,
},
{
Expand All @@ -234,12 +234,12 @@ func BenchmarkRangeQuery(b *testing.B) {
},
{
name: "at modifier ",
query: "http_requests_total @ 600",
query: `http_requests_total @ 600.000`,
storage: sixHourDataset,
},
{
name: "at modifier with positive offset vector",
query: "http_requests_total @ 600 offset 5m",
query: `http_requests_total @ 600.000 offset 5m`,
storage: sixHourDataset,
},
{
Expand Down Expand Up @@ -457,7 +457,7 @@ func BenchmarkInstantQuery(b *testing.B) {
},
{
name: "count_values",
query: "count_values('val', http_requests_total)",
query: `count_values("val", http_requests_total)`,
},
{
name: "round",
Expand Down Expand Up @@ -493,7 +493,7 @@ func BenchmarkInstantQuery(b *testing.B) {
},
{
name: "binary operation with many to one",
query: `http_requests_total / on (pod) group_left http_responses_total`,
query: `http_requests_total / on (pod) group_left () http_responses_total`,
},
{
name: "unary negation",
Expand Down
4 changes: 2 additions & 2 deletions engine/distributed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ func TestDistributedAggregations(t *testing.T) {
rangeStart: time.Unix(7, 0),
query: `max_over_time(min_over_time(sum(bar)[15s:15s])[15s:15s])`,
},
{name: "subquery over distributed binary expression", query: `max_over_time((bar/bar)[30s:15s])`},
{name: "subquery over distributed binary expression", query: `max_over_time((bar / bar)[30s:15s])`},
{name: "timestamp", query: `timestamp(bar)`},
{name: "timestamp - step invariant", query: `timestamp(bar @ 6000)`},
{name: "timestamp - step invariant", query: `timestamp(bar @ 6000.000)`},
}

lookbackDeltas := []time.Duration{0, 30 * time.Second, 5 * time.Minute}
Expand Down
Loading

0 comments on commit 12d908c

Please sign in to comment.