Skip to content

Commit 96f6f2f

Browse files
committed
e2e: basic utf8 tests
Signed-off-by: Michael Hoffmann <[email protected]>
1 parent 68844d4 commit 96f6f2f

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

test/e2e/query_test.go

+44
Original file line numberDiff line numberDiff line change
@@ -2468,3 +2468,47 @@ func TestChainDeduplication(t *testing.T) {
24682468
},
24692469
)
24702470
}
2471+
2472+
func TestSidecarUTF8Labels(t *testing.T) {
2473+
t.Parallel()
2474+
2475+
e, err := e2e.NewDockerEnvironment("sidecar-utf8")
2476+
testutil.Ok(t, err)
2477+
t.Cleanup(e2ethanos.CleanScenario(t, e))
2478+
2479+
promCfg := e2ethanos.DefaultPromConfig("prom", 0, "", "", e2ethanos.LocalPrometheusTarget)
2480+
prom, sidecar := e2ethanos.NewPrometheusWithSidecar(e, "p1", promCfg, "", e2ethanos.DefaultPrometheusImage(), "")
2481+
testutil.Ok(t, e2e.StartAndWaitReady(prom, sidecar))
2482+
2483+
endpoints := []string{
2484+
sidecar.InternalEndpoint("grpc"),
2485+
}
2486+
querier := e2ethanos.
2487+
NewQuerierBuilder(e, "1", endpoints...).
2488+
Init()
2489+
testutil.Ok(t, e2e.StartAndWaitReady(querier))
2490+
2491+
now := time.Now()
2492+
ctx := context.Background()
2493+
m := model.Sample{
2494+
Metric: map[model.LabelName]model.LabelValue{
2495+
"__name__": "🔥",
2496+
},
2497+
Value: model.SampleValue(2),
2498+
Timestamp: model.TimeFromUnixNano(now.Add(time.Minute).UnixNano()),
2499+
}
2500+
testutil.Ok(t, synthesizeSamples(ctx, prom, []model.Sample{m}))
2501+
2502+
retv := instantQuery(t, context.Background(), querier.Endpoint("http"), func() string {
2503+
return `{"🔥"}`
2504+
}, func() time.Time { return now.Add(time.Minute) }, promclient.QueryOptions{Deduplicate: true}, 1)
2505+
2506+
testutil.Equals(t, model.Vector{&model.Sample{
2507+
Metric: model.Metric{
2508+
"__name__": "🔥",
2509+
"prometheus": "prom",
2510+
},
2511+
Value: model.SampleValue(2),
2512+
Timestamp: model.TimeFromUnixNano(now.Add(time.Minute).UnixNano()),
2513+
}}, retv)
2514+
}

test/e2e/store_gateway_test.go

+35
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,41 @@ func TestStoreGatewayNoCacheFile(t *testing.T) {
620620
)
621621
testutil.Ok(t, s1.WaitSumMetrics(e2emon.Equals(7+2), "thanos_bucket_store_series_blocks_queried"))
622622
})
623+
t.Run("upload block id6 with utf8 labels", func(t *testing.T) {
624+
series := []labels.Labels{labels.FromStrings("a", "1", "🚀", "🔥")}
625+
extLset := labels.FromStrings("ext1", "value1", "replica", "1")
626+
id6, err := e2eutil.CreateBlockWithBlockDelay(ctx, dir, series, 10, timestamp.FromTime(now), timestamp.FromTime(now.Add(2*time.Hour)), 30*time.Minute, extLset, 0, metadata.NoneFunc, nil)
627+
testutil.Ok(t, err)
628+
testutil.Ok(t, objstore.UploadDir(ctx, l, bkt, path.Join(dir, id6.String()), id6.String()))
629+
630+
// Wait for store to sync blocks.
631+
// thanos_blocks_meta_synced: 2x loadedMeta 1x labelExcludedMeta 1x TooFreshMeta 1x noMeta.
632+
testutil.Ok(t, s1.WaitSumMetrics(e2emon.Equals(5), "thanos_blocks_meta_synced"))
633+
testutil.Ok(t, s1.WaitSumMetrics(e2emon.Equals(0), "thanos_blocks_meta_sync_failures_total"))
634+
635+
testutil.Ok(t, s1.WaitSumMetrics(e2emon.Equals(2), "thanos_bucket_store_blocks_loaded"))
636+
testutil.Ok(t, s1.WaitSumMetrics(e2emon.Equals(2), "thanos_bucket_store_block_drops_total"))
637+
testutil.Ok(t, s1.WaitSumMetrics(e2emon.Equals(0), "thanos_bucket_store_block_load_failures_total"))
638+
639+
queryAndAssertSeries(t, ctx, q.Endpoint("http"), func() string { return testQuery },
640+
time.Now, promclient.QueryOptions{
641+
Deduplicate: true,
642+
},
643+
[]model.Metric{
644+
{
645+
"a": "1",
646+
"b": "2",
647+
"ext1": "value1",
648+
},
649+
{
650+
"a": "1",
651+
"🚀": "🔥",
652+
"ext1": "value1",
653+
},
654+
},
655+
)
656+
testutil.Ok(t, s1.WaitSumMetrics(e2emon.Equals(9+2), "thanos_bucket_store_series_blocks_queried"))
657+
})
623658
}
624659

625660
func TestStoreGatewayMemcachedCache(t *testing.T) {

0 commit comments

Comments
 (0)