Skip to content

Commit ef87405

Browse files
Fix flakiness in runIndexCleanerTest by filtering Jaeger indices (#7004)
RESOLVE #7002 **issue:** - The test `runIndexCleanerTest` was flaky because it included unrelated system indices (e.g., `top_queries-2025.04.08-51429`). ## Description of the changes - Added `strings` import to use `strings.HasPrefix`. - Filtered indices to only include those starting with `prefixWithSeparator + "jaeger-"`. - Updated the assertion to use `filteredIndices` instead of raw `indices`. **Impact:** Ensures the test only checks relevant Jaeger indices, improving reliability. ## Checklist - [✓]I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [✓] I have signed all commits - [ ] I have added unit tests for the new functionality - [✓]I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `npm run lint` and `npm run test` --------- Signed-off-by: Shubham Solanki <[email protected]> Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
1 parent 46d78ec commit ef87405

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

internal/storage/integration/es_index_cleaner_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"net/http"
1010
"os/exec"
11+
"strings"
1112
"testing"
1213

1314
elasticsearch8 "github.com/elastic/go-elasticsearch/v8"
@@ -154,16 +155,23 @@ func runIndexCleanerTest(t *testing.T, client *elastic.Client, v8Client *elastic
154155
require.NoError(t, err)
155156
err = runEsCleaner(0, envVars)
156157
require.NoError(t, err)
157-
indices, err := client.IndexNames()
158+
foundIndices, err := client.IndexNames()
158159
require.NoError(t, err)
159160
if prefix != "" {
160161
prefix += "-"
161162
}
163+
var actual []string
164+
for _, index := range foundIndices {
165+
// ignore system indices https://github.com/jaegertracing/jaeger/issues/7002
166+
if strings.HasPrefix(index, prefix+"jaeger") {
167+
actual = append(actual, index)
168+
}
169+
}
162170
var expected []string
163171
for _, index := range expectedIndices {
164172
expected = append(expected, prefix+index)
165173
}
166-
assert.ElementsMatch(t, indices, expected, "indices found: %v, expected: %v", indices, expected)
174+
assert.ElementsMatch(t, actual, expected, "indices found: %v, expected: %v", foundIndices, expected)
167175
}
168176

169177
func createAllIndices(client *elastic.Client, prefix string, adaptiveSampling bool) error {

0 commit comments

Comments
 (0)