Skip to content

Commit a1505de

Browse files
authored
[issues-7892] add e2e test to verify a new tenant would be queryable (#100)
2 parents 3756f5c + e7b2072 commit a1505de

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

test/e2e/receive_test.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,3 +1215,74 @@ func TestReceiveCpnp(t *testing.T) {
12151215
}, v)
12161216

12171217
}
1218+
1219+
func TestNewTenant(t *testing.T) {
1220+
e, err := e2e.NewDockerEnvironment("new-tenant")
1221+
testutil.Ok(t, err)
1222+
t.Cleanup(e2ethanos.CleanScenario(t, e))
1223+
1224+
// Setup 3 ingestors.
1225+
i1 := e2ethanos.NewReceiveBuilder(e, "i1").WithIngestionEnabled().Init()
1226+
i2 := e2ethanos.NewReceiveBuilder(e, "i2").WithIngestionEnabled().Init()
1227+
i3 := e2ethanos.NewReceiveBuilder(e, "i3").WithIngestionEnabled().Init()
1228+
1229+
h := receive.HashringConfig{
1230+
Endpoints: []receive.Endpoint{
1231+
{Address: i1.InternalEndpoint("grpc")},
1232+
{Address: i2.InternalEndpoint("grpc")},
1233+
{Address: i3.InternalEndpoint("grpc")},
1234+
},
1235+
}
1236+
1237+
// Setup 1 distributor with double replication
1238+
r1 := e2ethanos.NewReceiveBuilder(e, "r1").WithRouting(2, h).Init()
1239+
testutil.Ok(t, e2e.StartAndWaitReady(i1, i2, i3, r1))
1240+
1241+
q := e2ethanos.NewQuerierBuilder(e, "1", i1.InternalEndpoint("grpc"), i2.InternalEndpoint("grpc"), i3.InternalEndpoint("grpc")).Init()
1242+
testutil.Ok(t, e2e.StartAndWaitReady(q))
1243+
testutil.Ok(t, q.WaitSumMetricsWithOptions(e2emon.Equals(3), []string{"thanos_store_nodes_grpc_connections"}, e2emon.WaitMissingMetrics()))
1244+
1245+
rp1 := e2ethanos.NewReverseProxy(e, "1", "tenant-1", "http://"+r1.InternalEndpoint("remote-write"))
1246+
prom1 := e2ethanos.NewPrometheus(e, "1", e2ethanos.DefaultPromConfig("prom1", 0, "http://"+rp1.InternalEndpoint("http")+"/api/v1/receive", "", e2ethanos.LocalPrometheusTarget), "", e2ethanos.DefaultPrometheusImage())
1247+
testutil.Ok(t, e2e.StartAndWaitReady(rp1, prom1))
1248+
1249+
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
1250+
t.Cleanup(cancel)
1251+
1252+
expectedReplicationFactor := 2.0
1253+
1254+
queryAndAssert(t, ctx, q.Endpoint("http"), func() string { return "count(up) by (prometheus, tenant_id)" }, time.Now, promclient.QueryOptions{
1255+
Deduplicate: false,
1256+
}, model.Vector{
1257+
&model.Sample{
1258+
Metric: model.Metric{
1259+
"prometheus": "prom1",
1260+
"tenant_id": "tenant-1",
1261+
},
1262+
Value: model.SampleValue(expectedReplicationFactor),
1263+
},
1264+
})
1265+
1266+
rp2 := e2ethanos.NewReverseProxy(e, "2", "tenant-2", "http://"+r1.InternalEndpoint("remote-write"))
1267+
prom2 := e2ethanos.NewPrometheus(e, "2", e2ethanos.DefaultPromConfig("prom2", 0, "http://"+rp2.InternalEndpoint("http")+"/api/v1/receive", "", e2ethanos.LocalPrometheusTarget), "", e2ethanos.DefaultPrometheusImage())
1268+
testutil.Ok(t, e2e.StartAndWaitReady(rp2, prom2))
1269+
1270+
queryAndAssert(t, ctx, q.Endpoint("http"), func() string { return "count(up) by (prometheus, tenant_id)" }, time.Now, promclient.QueryOptions{
1271+
Deduplicate: false,
1272+
}, model.Vector{
1273+
&model.Sample{
1274+
Metric: model.Metric{
1275+
"prometheus": "prom1",
1276+
"tenant_id": "tenant-1",
1277+
},
1278+
Value: model.SampleValue(expectedReplicationFactor),
1279+
},
1280+
&model.Sample{
1281+
Metric: model.Metric{
1282+
"prometheus": "prom2",
1283+
"tenant_id": "tenant-2",
1284+
},
1285+
Value: model.SampleValue(expectedReplicationFactor),
1286+
},
1287+
})
1288+
}

0 commit comments

Comments
 (0)