Merge lp:~dooferlad/juju-ci-tools/addressable-containers-assess into lp:juju-ci-tools
| Status: | Merged |
|---|---|
| Merged at revision: | 1173 |
| Proposed branch: | lp:~dooferlad/juju-ci-tools/addressable-containers-assess |
| Merge into: | lp:juju-ci-tools |
| Prerequisite: | lp:~dooferlad/juju-ci-tools/addressable-containers-tools |
| Diff against target: |
575 lines (+497/-7) 3 files modified
assess_container_networking.py (+342/-5) substrate.py (+2/-2) test_assess_container_networking.py (+153/-0) |
| To merge this branch: | bzr merge lp:~dooferlad/juju-ci-tools/addressable-containers-assess |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Aaron Bentley (community) | 2015-09-21 | Approve on 2015-12-08 | |
| James Tunnicliffe (community) | Resubmit on 2015-11-26 | ||
|
Review via email:
|
|||
Description of the Change
https:/
This adds tests that check container networking as set up by the Juju addressable containers feature.
| James Tunnicliffe (dooferlad) wrote : | # |
Thanks Aaron,
Yes, your patch seems entirely reasonable. What I had evolved into
something much more complicated than was needed! Thanks for calling me out
on it.
On Tue, Sep 22, 2015 at 8:02 PM, Aaron Bentley <email address hidden>
wrote:
> Review: Needs Information
>
> Thanks.
>
> The file for testing assess_
> test_assess_
>
> You are treating args.juju_bin as if it's the path to the directory, but
> it's the path to the binary.
>
> I'm still having trouble understanding why we need something as
> complicated as MachineGetter. Here's a patch that I think could remove the
> need for it:
> https:/
>
> Does that seem sane? Just make a bunch of machines and containers and
> then use them?
>
> See also inline comments.
>
> Diff comments:
>
> > === modified file 'assess_
> > --- assess_
> > +++ assess_
> > @@ -148,3 +218,210 @@
> > self.requested_
> > if self._new_
> > return
> > +
> > +
> > +def find_network(
> > + """Find a connected subnet containing the given address.
> > +
> > + When using this to find the subnet of a container, don't use the
> container
> > + as the machine to run the ip route show command on ("machine"), use
> a real
> > + box because lxc will just send everything to its host machine, so
> it is on
> > + a subnet containing itself. Not much use.
> > + :param client: A Juju client
> > + :param machine: ID of the machine on which to run a command
> > + :param addr: find the connected subnet containing this address
> > + :return: CIDR containing the address if found, else, None
> > + """
> > + ip_cmd = ' '.join(['ip', 'route', 'show', 'to', 'match', addr])
> > + routes = ssh(client, machine, ip_cmd)
> > +
> > + for route in re.findall(
> re.MULTILINE):
> > + if route != 'default':
> > + return route
> > +
> > + raise ValueError("Unable to find route to %r" % addr)
> > +
> > +
> > +def assess_
> > + """Test that all containers in target can talk to target[0]
> > + :param client: Juju client
> > + :param targets: machine IDs of machines to test
> > + :return: None;
> > + """
> > + status = client.
> > + source = targets[0]
> > + dests = targets[1:]
> > +
> > + with tempfile.
> > + f.write('tmux new-session -d -s test "nc -l 6778 >
> nc_listen.out"')
> > + client.juju('scp', (f.name, source + ':/home/
> > + os.remove(f.name)
> > +
> > + # Containers are named 'x/type/y' where x is the host of the
> container. We
> > + host = source.
> > + address = status[
> > +
> > + for dest in dests:
> > + ssh(client, source, 'rm nc_listen.out; bash ./listen.sh')
> > + ssh(client...
- 1094. By James Tunnicliffe on 2015-09-24
-
retry ssh commands if they fail with code 255, which seems to happen on heavily loaded machines.
- 1095. By James Tunnicliffe on 2015-09-24
-
Fixed missing import
- 1096. By James Tunnicliffe on 2015-09-25
-
SSH wrapper now trying even harder to retry on connection errors.
clean_environment is more able to cope with Juju getting confused and retrying.
Use random data in assess_network_ traffic to avoid stale data triggering false positive in tests.
Not using asserts.
Clean out machines from the environment again (accidental check in of debug code).
Fixed dumping logs at the end of the test.
Better fix for EnvJujuClient.get_status. - 1097. By James Tunnicliffe on 2015-09-25
-
Merge from addressable-
containers- tools - 1098. By James Tunnicliffe on 2015-11-10
-
A bit more reliability hacking around ssh and reboots.
Find a private address to ping for testing rather than 8.8.8.8.
Generate the correct exit code on failure.
join URLs using urljoin, not string concatination (copes with if a / is needed or not). This may need to be expanded to more areas of the code. - 1099. By James Tunnicliffe on 2015-11-10
-
merge upstream changes
- 1100. By James Tunnicliffe on 2015-11-11
-
Merged upstream
| Aaron Bentley (abentley) wrote : | # |
This looks pretty good.
There are bunch of files that you've removed the execute bit from. Please don't do that.
See other comments inline.
- 1101. By James Tunnicliffe on 2015-11-13
-
Merge latest addressable-
containers- tools - 1102. By James Tunnicliffe on 2015-11-13
-
Fixed up tests.
- 1103. By James Tunnicliffe on 2015-11-13
-
Removed unused imports
- 1104. By James Tunnicliffe on 2015-11-13
-
Removed unused variable
- 1105. By James Tunnicliffe on 2015-11-16
-
Fixed up tests.
Use wait_for_port instead of a simple delay where possible.
| Aaron Bentley (abentley) wrote : | # |
You haven't addressed these comments from 2015-11-13:
+ for host in hosts:
280 + ssh(client, host, 'sudo reboot')
281 +
282 + # If wait_for_started is called too early the machines still appear to be
283 + # up, so we wait a few seconds for the reboot.
284 + time.sleep(10)
Aaron Bentley (abentley) wrote on 2015-11-13:
I think it would be more reliable to use wait_for_port(22, closed=True) here.
365 --- substrate.py 2015-09-17 20:39:25 +0000
366 +++ substrate.py 2015-11-11 19:51:39 +0000
367 @@ -1,3 +1,4 @@
368 +__metaclass__ = type
Aaron Bentley (abentley) wrote on 2015-11-13:
Assigning metaclass must go below any imports or it will break lint on wily.
372 @@ -6,7 +7,7 @@
373 import os
374 import subprocess
375 from time import sleep
376 -
377 +import urlparse
378 from utility import temp_dir
Aaron Bentley (abentley) wrote on 2015-11-13:
There should be a blank line between standard library imports and local application imports.
- 1106. By James Tunnicliffe on 2015-11-26
-
Fixed subnets/
<ver>/? op=reserved_ ip_ranges when no IP addresses had been explicitly added.
| James Tunnicliffe (dooferlad) wrote : | # |
Sorry, tried wait_for_
- should have commented on the merge proposal. Of course today when I
try again it has worked perfectly three times in a row and failed with
a DNS error once, which I am not going to blame it for. Whatever I am
doing differently today seems to be fine.
On Mon, Nov 23, 2015 at 5:15 PM, Aaron Bentley
<email address hidden> wrote:
> You haven't addressed these comments from 2015-11-13:
> + for host in hosts:
> 280 + ssh(client, host, 'sudo reboot')
> 281 +
> 282 + # If wait_for_started is called too early the machines still appear to be
> 283 + # up, so we wait a few seconds for the reboot.
> 284 + time.sleep(10)
> Aaron Bentley (abentley) wrote on 2015-11-13:
> I think it would be more reliable to use wait_for_port(22, closed=True) here.
>
> 365 --- substrate.py 2015-09-17 20:39:25 +0000
> 366 +++ substrate.py 2015-11-11 19:51:39 +0000
> 367 @@ -1,3 +1,4 @@
> 368 +__metaclass__ = type
> Aaron Bentley (abentley) wrote on 2015-11-13:
> Assigning metaclass must go below any imports or it will break lint on wily.
>
>
> 372 @@ -6,7 +7,7 @@
> 373 import os
> 374 import subprocess
> 375 from time import sleep
> 376 -
> 377 +import urlparse
> 378 from utility import temp_dir
> Aaron Bentley (abentley) wrote on 2015-11-13:
> There should be a blank line between standard library imports and local application imports.
> --
> https:/
> You are the owner of lp:~dooferlad/juju-ci-tools/addressable-containers-assess.
- 1107. By James Tunnicliffe on 2015-11-26
-
Doh!
- 1108. By James Tunnicliffe on 2015-11-26
-
Fixed up reboot ordering and waits.
| Aaron Bentley (abentley) wrote : | # |
Thanks for your changes. You haven't addressed this comment yet:
372 @@ -6,7 +7,7 @@
373 import os
374 import subprocess
375 from time import sleep
376 -
377 +import urlparse
378 from utility import temp_dir
Aaron Bentley (abentley) wrote on 2015-11-13:
There should be a blank line between standard library imports and local application imports.
- 1109. By James Tunnicliffe on 2015-11-27
-
Fixed import spacing
| James Tunnicliffe (dooferlad) wrote : | # |
Bother. Sorry. Fix on its way.
On Fri, Nov 27, 2015 at 3:06 PM, Aaron Bentley
<email address hidden> wrote:
> Thanks for your changes. You haven't addressed this comment yet:
>
> 372 @@ -6,7 +7,7 @@
> 373 import os
> 374 import subprocess
> 375 from time import sleep
> 376 -
> 377 +import urlparse
> 378 from utility import temp_dir
> Aaron Bentley (abentley) wrote on 2015-11-13:
> There should be a blank line between standard library imports and local application imports.
> --
> https:/
> You are the owner of lp:~dooferlad/juju-ci-tools/addressable-containers-assess.
| James Tunnicliffe (dooferlad) wrote : | # |
Fix pushed.
| Aaron Bentley (abentley) wrote : | # |
You have added a blank line between "standard library imports" and "local application imports", but you have also removed the blank line between "related third party imports" and "local application imports". I will fix this, but in the future, please try to follow PEP8 style more closely for imports.

Thanks.
The file for testing assess_ container_ networking should be named test_assess_ container_ networking.
You are treating args.juju_bin as if it's the path to the directory, but it's the path to the binary.
I'm still having trouble understanding why we need something as complicated as MachineGetter. Here's a patch that I think could remove the need for it: /pastebin. canonical. com/140360/
https:/
Does that seem sane? Just make a bunch of machines and containers and then use them?
See also inline comments.