Skip to content

Commit 571c882

Browse files
committed
Creating Test
Signed-off-by: alanprot <[email protected]>
1 parent c46aec6 commit 571c882

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

pkg/ingester/ingester_test.go

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5085,12 +5085,16 @@ func TestExpendedPostingsCacheIsolation(t *testing.T) {
50855085
cfg.BlocksStorageConfig.TSDB.BlockRanges = []time.Duration{2 * time.Hour}
50865086
cfg.LifecyclerConfig.JoinAfter = 0
50875087
cfg.BlocksStorageConfig.TSDB.PostingsCache = cortex_tsdb.TSDBPostingsCacheConfig{
5088-
SeedSize: 1, // lets make sure all metric names collide
5088+
SeedSize: 3, // lets make sure all metric names collide
50895089
Head: cortex_tsdb.PostingsCacheConfig{
5090-
Enabled: true,
5090+
Enabled: true,
5091+
Ttl: time.Hour,
5092+
MaxBytes: 1024 * 1024 * 1024,
50915093
},
50925094
Blocks: cortex_tsdb.PostingsCacheConfig{
5093-
Enabled: true,
5095+
Enabled: true,
5096+
Ttl: time.Hour,
5097+
MaxBytes: 1024 * 1024 * 1024,
50945098
},
50955099
}
50965100

@@ -5102,21 +5106,22 @@ func TestExpendedPostingsCacheIsolation(t *testing.T) {
51025106

51035107
numberOfTenants := 100
51045108
wg := sync.WaitGroup{}
5105-
wg.Add(numberOfTenants)
51065109

5107-
for j := 0; j < numberOfTenants; j++ {
5108-
go func() {
5109-
defer wg.Done()
5110-
userId := fmt.Sprintf("user%v", j)
5111-
ctx := user.InjectOrgID(context.Background(), userId)
5112-
_, err = i.Push(ctx, cortexpb.ToWriteRequest(
5113-
[]labels.Labels{labels.FromStrings(labels.MetricName, "foo", "userId", userId)}, []cortexpb.Sample{{Value: 2, TimestampMs: 4 * 60 * 60 * 1000}}, nil, nil, cortexpb.API))
5114-
require.NoError(t, err)
5115-
}()
5110+
for k := 0; k < 10; k++ {
5111+
wg.Add(numberOfTenants)
5112+
for j := 0; j < numberOfTenants; j++ {
5113+
go func() {
5114+
defer wg.Done()
5115+
userId := fmt.Sprintf("user%v", j)
5116+
ctx := user.InjectOrgID(context.Background(), userId)
5117+
_, err := i.Push(ctx, cortexpb.ToWriteRequest(
5118+
[]labels.Labels{labels.FromStrings(labels.MetricName, "foo", "userId", userId, "k", strconv.Itoa(k))}, []cortexpb.Sample{{Value: 2, TimestampMs: 4 * 60 * 60 * 1000}}, nil, nil, cortexpb.API))
5119+
require.NoError(t, err)
5120+
}()
5121+
}
5122+
wg.Wait()
51165123
}
51175124

5118-
wg.Wait()
5119-
51205125
wg.Add(numberOfTenants)
51215126
for j := 0; j < numberOfTenants; j++ {
51225127
go func() {
@@ -5131,8 +5136,8 @@ func TestExpendedPostingsCacheIsolation(t *testing.T) {
51315136
Matchers: []*client.LabelMatcher{{Type: client.EQUAL, Name: labels.MetricName, Value: "foo"}},
51325137
}, s)
51335138
require.NoError(t, err)
5134-
require.Len(t, s.series, 1)
5135-
require.Len(t, s.series[0].Labels, 2)
5139+
require.Len(t, s.series, 10)
5140+
require.Len(t, s.series[0].Labels, 3)
51365141
require.Equal(t, userId, cortexpb.FromLabelAdaptersToLabels(s.series[0].Labels).Get("userId"))
51375142
}()
51385143
}

0 commit comments

Comments
 (0)