(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func TestIngesterSharding(t *testing.T) { |
| 22 | const numSeriesToPush = 1000 |
| 23 | |
| 24 | tests := map[string]struct { |
| 25 | shardingStrategy string |
| 26 | tenantShardSize int |
| 27 | expectedIngestersWithSeries int |
| 28 | }{ |
| 29 | //Default Sharding Strategy |
| 30 | "default sharding strategy should be ignored and spread across all ingesters": { |
| 31 | shardingStrategy: "default", |
| 32 | tenantShardSize: 2, // Ignored by default strategy. |
| 33 | expectedIngestersWithSeries: 3, |
| 34 | }, |
| 35 | "default sharding strategy should spread series across all ingesters": { |
| 36 | shardingStrategy: "default", |
| 37 | tenantShardSize: 0, // Ignored by default strategy. |
| 38 | expectedIngestersWithSeries: 3, |
| 39 | }, |
| 40 | //Shuffle Sharding Strategy |
| 41 | "shuffle-sharding strategy should spread series across the configured shard size number of ingesters": { |
| 42 | shardingStrategy: "shuffle-sharding", |
| 43 | tenantShardSize: 2, |
| 44 | expectedIngestersWithSeries: 2, |
| 45 | }, |
| 46 | "Tenant Shard Size of 0 should leverage all ingesters": { |
| 47 | shardingStrategy: "shuffle-sharding", |
| 48 | tenantShardSize: 0, |
| 49 | expectedIngestersWithSeries: 3, |
| 50 | }, |
| 51 | } |
| 52 | |
| 53 | for testName, testData := range tests { |
| 54 | t.Run(testName, func(t *testing.T) { |
| 55 | s, err := e2e.NewScenario(networkName) |
| 56 | require.NoError(t, err) |
| 57 | defer s.Close() |
| 58 | |
| 59 | flags := BlocksStorageFlags() |
| 60 | flags["-distributor.shard-by-all-labels"] = "true" |
| 61 | flags["-distributor.sharding-strategy"] = testData.shardingStrategy |
| 62 | flags["-distributor.ingestion-tenant-shard-size"] = strconv.Itoa(testData.tenantShardSize) |
| 63 | |
| 64 | if testData.shardingStrategy == "shuffle-sharding" { |
| 65 | // Enable shuffle sharding on read path but not lookback, otherwise all ingesters would be |
| 66 | // queried being just registered. |
| 67 | flags["-querier.shuffle-sharding-ingesters-lookback-period"] = "1ns" |
| 68 | } |
| 69 | |
| 70 | // Start dependencies. |
| 71 | consul := e2edb.NewConsul() |
| 72 | minio := e2edb.NewMinio(9000, flags["-blocks-storage.s3.bucket-name"]) |
| 73 | require.NoError(t, s.StartAndWaitReady(consul, minio)) |
| 74 | |
| 75 | // Start Cortex components. |
| 76 | distributor := e2ecortex.NewDistributor("distributor", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), flags, "") |
| 77 | ingester1 := e2ecortex.NewIngester("ingester-1", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), flags, "") |
| 78 | ingester2 := e2ecortex.NewIngester("ingester-2", e2ecortex.RingStoreConsul, consul.NetworkHTTPEndpoint(), flags, "") |
nothing calls this directly
no test coverage detected