Merge lp:~sinzui/juju-ci-tools/xenial-network into lp:juju-ci-tools

Proposed by Curtis Hovey
Status: Merged
Merged at revision: 1791
Proposed branch: lp:~sinzui/juju-ci-tools/xenial-network
Merge into: lp:juju-ci-tools
Diff against target: 40 lines (+19/-1)
2 files modified
assess_container_networking.py (+3/-1)
tests/test_assess_container_networking.py (+16/-0)
To merge this branch: bzr merge lp:~sinzui/juju-ci-tools/xenial-network
Reviewer Review Type Date Requested Status
Martin Packman (community) Approve
Review via email: mp+312507@code.launchpad.net

Description of the change

allow container networking tests of xenial

The container networking tests fail on xenial because the rules parse the device of the private IP fail. The rules assume the device is the last word in the output and we have a test for this case. But xenial's ip will include the next hop flag ("onlink") after the device. A better way to find the device is to look for the word after "dev", which clearly indicats which words is the device.

Container networking was broken by a bad lxd package The fix has arrived in xenial and we want to test it. I plan to keep the maas 1.9 test using trusty, the maas 2.x tests will switch to xenial.

To post a comment you must log in.
1789. By Curtis Hovey

Fix comment.

Revision history for this message
Martin Packman (gz) wrote :

Looks good, thanks for test with real input values. Do we maybe want to run it past Andy tomorrow in case we're missing other corner cases?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'assess_container_networking.py'
2--- assess_container_networking.py 2016-11-21 20:33:15 +0000
3+++ assess_container_networking.py 2016-12-05 21:25:31 +0000
4@@ -252,7 +252,9 @@
5 def private_address(client, host):
6 default_route = ssh(client, host, 'ip -4 -o route list 0/0')
7 log.info("Default route from {}: {}".format(host, default_route))
8- route_match = re.search(r'([\w-]+)\s*$', default_route)
9+ # Match the device that is the word after 'dev'. eg.
10+ # default via 10.0.30.1 dev br-eth1 onlink'
11+ route_match = re.search(r'\sdev\s([\w-]+)', default_route)
12 if route_match is None:
13 raise JujuAssertionError(
14 "Failed to find device in {}".format(default_route))
15
16=== modified file 'tests/test_assess_container_networking.py'
17--- tests/test_assess_container_networking.py 2016-11-21 20:33:15 +0000
18+++ tests/test_assess_container_networking.py 2016-12-05 21:25:31 +0000
19@@ -355,6 +355,22 @@
20 call(fake_client, "machine.test",
21 "ip -4 -o addr show br-eth1")])
22
23+ def test_private_address_with_next_hop_flag(self):
24+ ssh_results = ["default via 10.0.30.1 dev br-eth1 onlink",
25+ "5: br-eth1 inet 10.0.30.24/24 brd "
26+ "10.0.30.255 scope global br-eth1 "
27+ "valid_lft forever preferred_lft forever"]
28+ fake_client = fake_juju_client()
29+ with patch("assess_container_networking.ssh",
30+ autospec=True, side_effect=ssh_results) as mock_ssh:
31+ result = jcnet.private_address(fake_client, "machine.test")
32+ self.assertEqual(result, "10.0.30.24")
33+ self.assertEqual(mock_ssh.mock_calls,
34+ [call(fake_client, "machine.test",
35+ "ip -4 -o route list 0/0"),
36+ call(fake_client, "machine.test",
37+ "ip -4 -o addr show br-eth1")])
38+
39
40 class TestMain(FakeHomeTestCase):
41

Subscribers

People subscribed via source and target branches