From 2d1a9fe959323e420289a32a9f04836f95766c46 Mon Sep 17 00:00:00 2001 From: pawarpranav83 Date: Sun, 24 Dec 2023 15:48:31 +0530 Subject: [PATCH] Updated query_frontend_test and query_test -- Made remoteWrite function non-public -- Removed tenant_id and receive labels from the Timeseries samplesrw -- Removed prometheus instance from TestQueryFrontendMemcachedCache test -- Added a receiver instance -- now - predefined timestamp -- tempfn - returns now, used in instant query function -- Updated model.Metric labels to match the sample label Signed-off-by: pawarpranav83 --- test/e2e/query_frontend_test.go | 17 +++++++++-------- test/e2e/query_test.go | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/test/e2e/query_frontend_test.go b/test/e2e/query_frontend_test.go index 01605c06ae8..57d94d02f1f 100644 --- a/test/e2e/query_frontend_test.go +++ b/test/e2e/query_frontend_test.go @@ -60,9 +60,7 @@ func TestQueryFrontend(t *testing.T) { {Name: "instance", Value: "localhost:9090"}, {Name: "job", Value: "myself"}, {Name: "prometheus", Value: "test"}, - {Name: "receive", Value: "receive-ingestor-rw"}, {Name: "replica", Value: "0"}, - {Name: "tenant_id", Value: "default-tenant"}, } samplesrw = append(samplesrw, prompb.TimeSeries{ @@ -87,7 +85,7 @@ func TestQueryFrontend(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) t.Cleanup(cancel) - testutil.Ok(t, RemoteWrite(ctx, samplesrw, i.Endpoint("remote-write"))) + testutil.Ok(t, remoteWrite(ctx, samplesrw, i.Endpoint("remote-write"))) testutil.Ok(t, q.WaitSumMetricsWithOptions(e2emon.Equals(1), []string{"thanos_store_nodes_grpc_connections"}, e2emon.WaitMissingMetrics())) @@ -442,12 +440,13 @@ func TestQueryFrontendMemcachedCache(t *testing.T) { testutil.Ok(t, err) t.Cleanup(e2ethanos.CleanScenario(t, e)) - now := time.Now() + now := time.Date(2023, time.December, 22, 12, 0, 0, 0, time.UTC) + tempfn := func() time.Time { return now } - prom, sidecar := e2ethanos.NewPrometheusWithSidecar(e, "1", e2ethanos.DefaultPromConfig("test", 0, "", "", e2ethanos.LocalPrometheusTarget), "", e2ethanos.DefaultPrometheusImage(), "") - testutil.Ok(t, e2e.StartAndWaitReady(prom, sidecar)) + i := e2ethanos.NewReceiveBuilder(e, "ingestor-rw").WithIngestionEnabled().Init() + testutil.Ok(t, e2e.StartAndWaitReady(i)) - q := e2ethanos.NewQuerierBuilder(e, "1", sidecar.InternalEndpoint("grpc")).Init() + q := e2ethanos.NewQuerierBuilder(e, "1", i.InternalEndpoint("grpc")).Init() testutil.Ok(t, e2e.StartAndWaitReady(q)) memcached := e2ethanos.NewMemcached(e, "1") @@ -482,13 +481,15 @@ func TestQueryFrontendMemcachedCache(t *testing.T) { // Ensure we can get the result from Querier first so that it // doesn't need to retry when we send queries to the frontend later. - queryAndAssertSeries(t, ctx, q.Endpoint("http"), e2ethanos.QueryUpWithoutInstance, time.Now, promclient.QueryOptions{ + queryAndAssertSeries(t, ctx, q.Endpoint("http"), e2ethanos.QueryUpWithoutInstance, tempfn, promclient.QueryOptions{ Deduplicate: false, }, []model.Metric{ { "job": "myself", "prometheus": "test", + "receive": "receive-ingestor-rw", "replica": "0", + "tenant_id": "default-tenant", }, }) diff --git a/test/e2e/query_test.go b/test/e2e/query_test.go index 20fbbaa9a6d..300ca8549ce 100644 --- a/test/e2e/query_test.go +++ b/test/e2e/query_test.go @@ -1721,7 +1721,7 @@ func rangeQuery(t *testing.T, ctx context.Context, addr string, q func() string, return retExplanation } -func RemoteWrite(ctx context.Context, timeseries []prompb.TimeSeries, addr string) error { +func remoteWrite(ctx context.Context, timeseries []prompb.TimeSeries, addr string) error { // Create write request data, err := proto.Marshal(&prompb.WriteRequest{Timeseries: timeseries}) if err != nil {