Skip to content

Commit

Permalink
test: fix openstack unit-test stability
Browse files Browse the repository at this point in the history
Put interfaces in sorted order to avoid mismatch on expected results,
also makes machine config reproducible.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Oct 25, 2021
1 parent 72f62ac commit 0a964d9
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"log"
"net"
"path/filepath"
"sort"
"strconv"
"strings"

Expand Down Expand Up @@ -223,8 +224,16 @@ func (o *Openstack) ConfigurationNetwork(metadataNetworkConfig []byte, metadataC
}
}

for _, iface := range ifaces {
machineConfig.MachineConfig.MachineNetwork.NetworkInterfaces = append(machineConfig.MachineConfig.MachineNetwork.NetworkInterfaces, iface)
ifaceNames := make([]string, 0, len(ifaces))

for ifaceName := range ifaces {
ifaceNames = append(ifaceNames, ifaceName)
}

sort.Strings(ifaceNames)

for _, ifaceName := range ifaceNames {
machineConfig.MachineConfig.MachineNetwork.NetworkInterfaces = append(machineConfig.MachineConfig.MachineNetwork.NetworkInterfaces, ifaces[ifaceName])
}

if machineConfig.MachineConfig.MachineNetwork.NameServers == nil && len(nameServers) > 0 {
Expand Down

0 comments on commit 0a964d9

Please sign in to comment.