Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go_agent unit test uses hard-coded NIC names #6

Open
weilanwu opened this issue Jul 2, 2014 · 0 comments
Open

go_agent unit test uses hard-coded NIC names #6

weilanwu opened this issue Jul 2, 2014 · 0 comments

Comments

@weilanwu
Copy link

weilanwu commented Jul 2, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant