Skip to content

Commit

Permalink
Updated query_frontend_test and query_test
Browse files Browse the repository at this point in the history
    -- 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 <[email protected]>
  • Loading branch information
pawarpranav83 committed Dec 24, 2023
1 parent d5651b0 commit 2d1a9fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions test/e2e/query_frontend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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()))

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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",
},
})

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2d1a9fe

Please sign in to comment.