diff --git a/pkg/test/integration/cluster/cluster.go b/pkg/test/integration/cluster/cluster.go index 5c991aaa61..55bed62f3f 100644 --- a/pkg/test/integration/cluster/cluster.go +++ b/pkg/test/integration/cluster/cluster.go @@ -88,19 +88,20 @@ func (t *testTransport) RoundTrip(req *http.Request) (*http.Response, error) { func (t *testTransport) DialContext(ctx context.Context, network, addr string) (net.Conn, error) { var err error - switch addr { - case "push:80": - addr, err = t.c.pickHealthyComponent("distributor") - if err != nil { - return nil, err + if t.c.microservices { + switch addr { + case "push:80": + addr, err = t.c.pickHealthyComponent("distributor") + case "querier:80": + addr, err = t.c.pickHealthyComponent("query-frontend", "querier") + default: + return nil, fmt.Errorf("unknown addr %s", addr) } - case "querier:80": - addr, err = t.c.pickHealthyComponent("query-frontend", "querier") - if err != nil { - return nil, err - } - default: - return nil, fmt.Errorf("unknown addr %s", addr) + } else { + addr, err = t.c.pickHealthyComponent("all") + } + if err != nil { + return nil, err } return t.defaultDialContext(ctx, network, addr) @@ -135,6 +136,7 @@ type Cluster struct { v2 bool // is this a v2 cluster debuginfodURL string // debuginfod URL for symbolization expectedComponents []string // number of expected components + microservices bool tmpDir string httpClient *http.Client diff --git a/pkg/test/integration/cluster/cluster_v1.go b/pkg/test/integration/cluster/cluster_v1.go index 78b5acc93f..86986fbe39 100644 --- a/pkg/test/integration/cluster/cluster_v1.go +++ b/pkg/test/integration/cluster/cluster_v1.go @@ -7,9 +7,20 @@ import ( "path/filepath" ) +func WithV1SingleTarget() ClusterOption { + return func(c *Cluster) { + c.v2 = false + c.microservices = false + c.expectedComponents = []string{ + "all", + } + } +} + func WithV1() ClusterOption { return func(c *Cluster) { c.v2 = false + c.microservices = true c.expectedComponents = []string{ "distributor", "distributor", @@ -58,8 +69,6 @@ func (c *Cluster) v1Prepare(_ context.Context, memberlistJoin []string) error { fmt.Sprintf("-blocks-storage.bucket-store.sync-dir=%s", syncDir), fmt.Sprintf("-compactor.data-dir=%s", compactorDir), fmt.Sprintf("-pyroscopedb.data-path=%s", dataDir), - "-distributor.replication-factor=3", - "-store-gateway.sharding-ring.replication-factor=3", "-query-scheduler.ring.instance-id="+comp.nodeName(), "-query-scheduler.ring.instance-addr="+listenAddr, "-store-gateway.sharding-ring.instance-id="+comp.nodeName(), @@ -70,6 +79,12 @@ func (c *Cluster) v1Prepare(_ context.Context, memberlistJoin []string) error { "-ingester.lifecycler.ID="+comp.nodeName(), "-ingester.min-ready-duration=0", ) + if c.microservices { + comp.flags = append(comp.flags, + "-distributor.replication-factor=3", + "-store-gateway.sharding-ring.replication-factor=3", + ) + } // handle memberlist join for _, m := range memberlistJoin { diff --git a/pkg/test/integration/cluster/cluster_v2.go b/pkg/test/integration/cluster/cluster_v2.go index 31b83a4c4d..4c921c3795 100644 --- a/pkg/test/integration/cluster/cluster_v2.go +++ b/pkg/test/integration/cluster/cluster_v2.go @@ -15,6 +15,7 @@ import ( func WithV2() ClusterOption { return func(c *Cluster) { c.v2 = true + c.microservices = true c.expectedComponents = []string{ "distributor", "distributor", diff --git a/pkg/test/integration/microservices_test.go b/pkg/test/integration/microservices_test.go index a2248a5dbe..3a7d5d7218 100644 --- a/pkg/test/integration/microservices_test.go +++ b/pkg/test/integration/microservices_test.go @@ -32,7 +32,28 @@ import ( // of the services and runs the same queries again to check if the cluster is still // able to respond to queries. func TestMicroServicesIntegrationV1(t *testing.T) { - c := cluster.NewMicroServiceCluster() + tests := []struct { + name string + opts []cluster.ClusterOption + }{ + { + name: "v1-microservices", + opts: []cluster.ClusterOption{cluster.WithV1()}, + }, + { + name: "v1-single-tareget", + opts: []cluster.ClusterOption{cluster.WithV1SingleTarget()}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + testMicroServicesIntegrationV1(t, tt.opts) + }) + } +} + +func testMicroServicesIntegrationV1(t *testing.T, opts []cluster.ClusterOption) { + c := cluster.NewMicroServiceCluster(opts...) ctx := context.Background() require.NoError(t, c.Prepare(ctx))