testing: fix test flake in dynamic host volume client tests (#24836)

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.
This commit is contained in:
Tim Gross
2025-01-10 14:48:05 -05:00
committed by GitHub
parent ffb34319d5
commit cca9a5320d

View File

@@ -9,6 +9,7 @@ import (
"errors"
"io"
"path/filepath"
"sort"
"testing"
"time"
@@ -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))