Merge lp:~rackspace-titan/nova/test_004_metadata_retry into lp:~hudson-openstack/nova/trunk

Proposed by Dan Prince
Status: Merged
Approved by: Brian Waldon
Approved revision: 1392
Merged at revision: 1399
Proposed branch: lp:~rackspace-titan/nova/test_004_metadata_retry
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 18 lines (+5/-2)
1 file modified
smoketests/test_netadmin.py (+5/-2)
To merge this branch: bzr merge lp:~rackspace-titan/nova/test_004_metadata_retry
Reviewer Review Type Date Requested Status
Brian Waldon (community) Approve
Devin Carlen (community) Approve
John Tran (community) Approve
William Wolf (community) Approve
Review via email: mp+70663@code.launchpad.net

Description of the change

Update the curl command in the __public_instance_is_accessible function of test_netadmin to return an error code which we can then check for and handle properly. This should allow calling functions to properly retry and timeout if an actual test failure happens.

To post a comment you must log in.
Revision history for this message
William Wolf (throughnothing) wrote :

looks good

review: Approve
Revision history for this message
Alex Meade (alex-meade) wrote :

What does adding -f do?

Revision history for this message
Alex Meade (alex-meade) wrote :

nvm, spose I skipped over it in the man pages

Revision history for this message
Dan Prince (dan-prince) wrote :

> What does adding -f do?

Without using -f curl returns an exit status of 0 when an HTTP 4xx error occurs (which typically means the command ran successfully). Using the -f option makes curl a bit more script friendly... From the curl man page:

       -f/--fail
              (HTTP) Fail silently (no output at all) on server errors. This
              is mostly done to better enable scripts etc to better deal with
              failed attempts. In normal cases when a HTTP server fails to
              deliver a document, it returns an HTML document stating so
              (which often also describes why and more). This flag will pre‐
              vent curl from outputting that and return error 22.

              This method is not fail-safe and there are occasions where non-
              successful response codes will slip through, especially when
              authentication is involved (response codes 401 and 407).

Revision history for this message
John Tran (jtran) wrote :

lgtm

review: Approve
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
Brian Waldon (bcwaldon) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'smoketests/test_netadmin.py'
2--- smoketests/test_netadmin.py 2011-08-05 15:17:05 +0000
3+++ smoketests/test_netadmin.py 2011-08-07 03:07:21 +0000
4@@ -109,9 +109,12 @@
5
6 def __public_instance_is_accessible(self):
7 id_url = "latest/meta-data/instance-id"
8- options = "-s --max-time 1"
9+ options = "-f -s --max-time 1"
10 command = "curl %s %s/%s" % (options, self.data['public_ip'], id_url)
11- instance_id = commands.getoutput(command).strip()
12+ status, output = commands.getstatusoutput(command)
13+ instance_id = output.strip()
14+ if status > 0:
15+ return False
16 if not instance_id:
17 return False
18 if instance_id != self.data['instance'].id: