Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion traffic_ops/traffic_ops_golang/monitoring/monitoring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,12 @@ func TestGetMonitoringJSON(t *testing.T) {
if err != nil {
t.Errorf("GetMonitoringJSON expected: nil error, actual: %v", err)
}

for _, cache := range resp.Response.TrafficServers {
cache.Interfaces = sortInterfaces(cache.Interfaces)
}
for _, cache := range sqlResp.TrafficServers {
cache.Interfaces = sortInterfaces(cache.Interfaces)
}
resp.Response.TrafficServers = sortCaches(resp.Response.TrafficServers)
sqlResp.TrafficServers = sortCaches(sqlResp.TrafficServers)
resp.Response.TrafficMonitors = sortMonitors(resp.Response.TrafficMonitors)
Expand Down Expand Up @@ -606,6 +611,23 @@ func (s SortableCaches) Less(i, j int) bool {
return s[i].HostName < s[j].HostName
}

type SortableInterfaces []tc.ServerInterfaceInfo

func (s SortableInterfaces) Len() int {
return len(s)
}
func (s SortableInterfaces) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s SortableInterfaces) Less(i, j int) bool {
return s[i].Name < s[j].Name
}

func sortInterfaces(i []tc.ServerInterfaceInfo) []tc.ServerInterfaceInfo {
sort.Sort(SortableInterfaces(i))
return i
}

func sortCaches(p []Cache) []Cache {
sort.Sort(SortableCaches(p))
return p
Expand Down