Skip to content

Commit

Permalink
Tests: Fix flaky Add_new_labels test (#1511)
Browse files Browse the repository at this point in the history
This should fix flakyness of the test:
TestUpdateAllManagedClusterLabelNames/Add_new_labels

Which would flake due to non-deterministic order of labels. Fixed by
sorting the slice in the test.

Introduced by:
448fe48

Signed-off-by: Jacob Baungard Hansen <[email protected]>
  • Loading branch information
jacobbaungard authored Jun 25, 2024
1 parent faae62f commit 0fbe0e0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions proxy/pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"reflect"
"regexp"
"slices"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -747,6 +748,9 @@ func TestUpdateAllManagedClusterLabelNames(t *testing.T) {
}
}

// The label list does not appear to be deterministically sorted
// Sorting here in order to ensure the test can pass reliably.
slices.Sort(syncLabelList.RegexLabelList)
if !reflect.DeepEqual(syncLabelList.RegexLabelList, expectedRegexList) {
t.Errorf("syncLabelList.RegexLabelList = %v, want %v", syncLabelList.RegexLabelList, expectedRegexList)
}
Expand Down

0 comments on commit 0fbe0e0

Please sign in to comment.