From 2e2a4c496a29d7ae574f65e65d2584321cb5911a Mon Sep 17 00:00:00 2001 From: Alexey Perevalov Date: Tue, 26 May 2020 21:21:52 +0300 Subject: [PATCH] Fix test with different order of Topology's nodes GetTopology provides Nodes not in order of Node.Id. PR https://github.com/google/cadvisor/pull/2551 removed that check, as result test acidentially passed. Signed-off-by: Alexey Perevalov --- machine/topology_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/machine/topology_test.go b/machine/topology_test.go index e3e84480..e9403007 100644 --- a/machine/topology_test.go +++ b/machine/topology_test.go @@ -19,6 +19,7 @@ import ( "io/ioutil" "os" "reflect" + "sort" "testing" info "github.com/google/cadvisor/info/v1" @@ -263,6 +264,9 @@ func TestTopologyWithoutNodes(t *testing.T) { sysFs.SetPhysicalPackageIDs(physicalPackageIDs, nil) topology, numCores, err := GetTopology(sysFs) + sort.SliceStable(topology, func(i, j int) bool { + return topology[i].Id < topology[j].Id + }) assert.Nil(t, err) assert.Equal(t, 2, len(topology)) assert.Equal(t, 4, numCores)