forked from cloudfoundry/bosh
-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
In bosh/go_agent's ip_resolver_test.go test, it iterates through NIC names and picks up the hard-coded NIC and assume that's the active one:
if _, err := gonet.InterfaceByName("en0"); err == nil {
return "en0"
} else if _, err := gonet.InterfaceByName("eth0"); err == nil {
return "eth0"
} else if _, err := gonet.InterfaceByName("venet0"); err == nil {
// Travis CI uses venet0 as primary network interface
return "venet0"
}
panic("Not sure which interface name to use: en0 and eth0 are not found")
Such an approach is error-prone and in-elegant, e.g. I may have a NIC named 'eth0', but my laptop is disconnected from ethernet cable, and use a wireless NIC named 'wlan0', in this case the test code picks up 'eth0', but the proper one should be used is 'wlan0' (the active one taking traffic), as a result, the test fails.
To address it, proposal is to introduce a environment "PRIMARY_NIC", if it is set, the test uses it, only when this environment is not set, it falls back to the current logic, that is, iterating through the hard-coded NIC's and pick up whatever available.
Metadata
Metadata
Assignees
Labels
No labels