Merge lp://staging/~ev/ubuntu-ci-services-itself/pythonise-integration-test-runner into lp://staging/ubuntu-ci-services-itself

Proposed by Evan
Status: Merged
Approved by: Evan
Approved revision: 156
Merged at revision: 147
Proposed branch: lp://staging/~ev/ubuntu-ci-services-itself/pythonise-integration-test-runner
Merge into: lp://staging/ubuntu-ci-services-itself
Diff against target: 813 lines (+646/-153)
3 files modified
tests/run (+0/-153)
tests/run.py (+502/-0)
tests/test_run.py (+144/-0)
To merge this branch: bzr merge lp://staging/~ev/ubuntu-ci-services-itself/pythonise-integration-test-runner
Reviewer Review Type Date Requested Status
Andy Doan (community) Approve
Evan (community) Needs Resubmitting
Review via email: mp+202153@code.staging.launchpad.net

Commit message

Pythonise the integration test runner.

Description of the change

Pythonise the integration test runner. Use juju terminate-machine # --force and juju destroy-service rather than juju destroy-environment, which should be much quicker. Use python-novaclient instead of relying on the external nova binary. Tests, which were nonexistent in the shell version.

To post a comment you must log in.
132. By Evan

Forgot to actually call assert_no_deployed_services. Oops

Revision history for this message
Evan (ev) wrote :

Note to self: this needs a little bit of work to check the machine still exists before attempting to destroy it:

ERROR no machines were destroyed: machine 11 does not exist
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File /usr/lib/python2.7/atexit.py, line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File ./tests/run.py, line 60, in destroy_services
    _destroy_machine(machine)
  File ./tests/run.py, line 32, in _destroy_machine
    subprocess.check_output(['juju', 'destroy-machine', machine, '--force'])
  File /usr/lib/python2.7/subprocess.py, line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
CalledProcessError: Command '['juju', 'destroy-machine', '11', '--force']' returned non-zero exit status 1

We should find a way to use python-jujuclient for this instead of calling juju directly.

133. By Evan

We will still have a bootstrap node after destroying services and machines.

134. By Evan

Add a method to wait for any dying nodes to turn to dust.

135. By Evan

Optimisation. We definitely need to bootstrap if we have no instances.

136. By Evan

Fix a test broken by the needs_bootstrap optimisation.

137. By Evan

Fix another broken test by moving the wait_for_death call to when it's expected that everything is dead or dying.

138. By Evan

Back out that optimisation. It was no good.

Revision history for this message
Evan (ev) wrote :

I think this is ready to merge. I sorted out the destroy-machine failing by waiting for the nodes that were dying to die, rather than bringing in jujuclient (which doesn't have a destroy_machine command, as it turns out).

review: Needs Resubmitting
139. By Evan

Explicitly handle the case where the node could disappear between calling status and terminate-machine.

Revision history for this message
Evan (ev) wrote :

I've now explicitly handled the case where the instance disappears between calling status and terminate-machine.

Revision history for this message
Andy Doan (doanac) wrote :

can you chmod +x ./tests/run.py so its executable by default?

Revision history for this message
Andy Doan (doanac) wrote :

423 + with open(SUDOERS_FILE) as fp:
424 + contents = fp.read()
425 + if not contents.strip('\n').endswith(SUDOERS):
426 + return False

non-root users can't read this file so the script fails.

Revision history for this message
Andy Doan (doanac) wrote :

now that this thing is python, we are missing some of the output the shell version used to cause. its hard to see what the runner is attempting. You think you could add a few status messages for each of the major steps in the process (ie destroying, bootstrapping, installing, etc).

140. By Evan

Make tests/run.py executable.

Revision history for this message
Evan (ev) wrote :

On 23 January 2014 16:36, Andy Doan <email address hidden> wrote:
> can you chmod +x ./tests/run.py so its executable by default?

Fixed as r140.

141. By Evan

Handle permission denied on sudoers file, with a test.

Revision history for this message
Evan (ev) wrote :

On 23 January 2014 16:58, Andy Doan <email address hidden> wrote:
> 423 + with open(SUDOERS_FILE) as fp:
> 424 + contents = fp.read()
> 425 + if not contents.strip('\n').endswith(SUDOERS):
> 426 + return False
>
> non-root users can't read this file so the script fails.

Mine is 0644. Fixed as r141.

142. By Evan

Correct error message.

143. By Evan

Use the logging module rather than print. Be more verbose in what's going on.

144. By Evan

Disable logging in tests.

Revision history for this message
Evan (ev) wrote :

On 23 January 2014 17:06, Andy Doan <email address hidden> wrote:
> now that this thing is python, we are missing some of the output the shell version used to cause. its hard to see what the runner is attempting. You think you could add a few status messages for each of the major steps in the process (ie destroying, bootstrapping, installing, etc).

Fixed as r143 and r144.

145. By Evan

pep8

146. By Evan

Check to make sure we have a new enough version of juju installed.

147. By Evan

Add a test for check_juju_version

148. By Evan

Dump the log from any services with failed relations. WIP.

Revision history for this message
Andy Doan (doanac) wrote :

missing the import for "re" now.

149. By Evan

Missing import.

Revision history for this message
Evan (ev) wrote :

D'oh. Fixed as r149.

Revision history for this message
Andy Doan (doanac) wrote :

i also see:

Traceback (most recent call last):
  File "./tests/run.py", line 403, in <module>
    sys.exit(main())
  File "./tests/run.py", line 393, in main
    units = find_failed_units(e.output)
  File "./tests/run.py", line 160, in find_failed_units
    return set(re.findall('unit: (.*): machine: .* error details:', body))
  File "/usr/lib/python2.7/re.py", line 177, in findall
    return _compile(pattern, flags).findall(string)
TypeError: expected string or buffer

Revision history for this message
Evan (ev) wrote :

On 23 January 2014 20:37, Andy Doan <email address hidden> wrote:
> i also see:
>
> Traceback (most recent call last):
> File "./tests/run.py", line 403, in <module>
> sys.exit(main())
> File "./tests/run.py", line 393, in main
> units = find_failed_units(e.output)
> File "./tests/run.py", line 160, in find_failed_units
> return set(re.findall('unit: (.*): machine: .* error details:', body))
> File "/usr/lib/python2.7/re.py", line 177, in findall
> return _compile(pattern, flags).findall(string)
> TypeError: expected string or buffer

Fixing by using juju status for this instead. I'll ping you when it's ready.

Revision history for this message
Andy Doan (doanac) wrote :

I'm also seeing:

535 + needed = needs_bootstrap()

fail if I have nodes available but no tunnel set up. I have to run "juju destroy-environment" by hand before I can run the script.

150. By Evan

Get the units with errors from juju status rather than trying to parse the output of the test runs.

151. By Evan

Tests for find_failed_units.

Revision history for this message
Evan (ev) wrote :

On 23 January 2014 22:05, Andy Doan <email address hidden> wrote:
> I'm also seeing:
>
> 535 + needed = needs_bootstrap()
>
> fail if I have nodes available but no tunnel set up. I have to run "juju destroy-environment" by hand before I can run the script.

What's the output of juju status in that instance? I am unable to
reproduce this by running juju bootstrap, not setting up a tunnel, and
then running python tests/run.py.

Revision history for this message
Andy Doan (doanac) wrote :

On 01/23/2014 05:30 PM, Evan Dandrea wrote:
>> fail if I have nodes available but no tunnel set up. I have to run "juju destroy-environment" by hand before I can run the script.
> What's the output of juju status in that instance? I am unable to
> reproduce this by running juju bootstrap, not setting up a tunnel, and
> then running python tests/run.py.

bad wording on my part. "juju status" just hangs. You can't run
juju-staus without a tunnel setup. And we don't have a tunnel set up at
this part of the script.

Revision history for this message
Evan (ev) wrote :

On 23 January 2014 23:54, Andy Doan <email address hidden> wrote:
> bad wording on my part. "juju status" just hangs. You can't run
> juju-staus without a tunnel setup. And we don't have a tunnel set up at
> this part of the script.

It will eventually time out and succeed. I'll see if I can find a more
expedient check tomorrow.

152. By Evan

Completely rework how we check to see if we need to bootstrap or tunnel. This solves the long timeouts seen when the environment is bootstrapped but no tunnel exists.

153. By Evan

Typo.

154. By Evan

Cover all needs_bootstrap cases in the tests.

155. By Evan

pep8

156. By Evan

Document functions.

Revision history for this message
Evan (ev) wrote :

Okay, I think we're ready to go again. This version should handle whatever crazy broken juju environment you throw at it.

review: Needs Resubmitting
Revision history for this message
Andy Doan (doanac) wrote :

things seem to be working smooth for me now. lets merge it.

review: Approve
Revision history for this message
Evan (ev) wrote :

Woohoo!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: