Skip to content

Commit

Permalink
testing: fix test flake in dynamic host volume client tests
Browse files Browse the repository at this point in the history
The output of `GetDynamicHostVolumes` is a slice but that slice is constructed
from iterating over a map and isn't sorted. Sort the output in the test to
eliminate a test flake.
  • Loading branch information
tgross committed Jan 10, 2025
1 parent a7b5970 commit fe19f80
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/hostvolumemanager/host_volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"errors"
"io"
"path/filepath"
"sort"
"testing"
"time"

Expand Down Expand Up @@ -131,6 +132,7 @@ func TestHostVolumeManager(t *testing.T) {
stateDBs, err := memDB.GetDynamicHostVolumes()
must.NoError(t, err)
must.Len(t, 2, stateDBs)
sort.Slice(stateDBs, func(i, j int) bool { return stateDBs[i].ID < stateDBs[j].ID })
must.Eq(t, "vol-id-2", stateDBs[1].ID)
must.Eq(t, "vol-id-2", stateDBs[1].CreateReq.ID)
must.MapContainsKey(t, node.vols, name, must.Sprintf("no %q in %+v", name, node.vols))
Expand Down

0 comments on commit fe19f80

Please sign in to comment.