[openstack-dev] [api] [gabbi] gabbi can poll now

Chris Dent chdent at redhat.com
Fri Jun 12 10:44:30 UTC 2015


In various discussion with some of the projects, on this list and at
summit, one of the holdups on people being able to adopt gabbi[1] as a
tool for HTTP API testing in their own stuff was because they had
request handlers that return 202 in response to a POST and the created
resource would not be immediately available (for further testing).
Or similarly time-ambiguous situations.

The latest release of gabbi has a way to handle this. A 'poll' key
has been added to the test language. Here's an example of how it
might be used:

     - name: create something async
       url: /async_creator
       method: POST
       request_headers:
           content-type: application/json
       data:
           name: jones
           abode: bungalow
       status: 202

     - name: poll for created resource
       url: $LOCATION
       poll:
           count: 10 # try up to ten times
           delay: .5 # wait .5 seconds between each try
       response_json_paths:
           $.name: jones
           $.abode: bungalow

The second request will repeat itself every .5 seconds until either
one of the following is true:

* It has tried ten times. In this case, the most recent test
   assertion failure will be raised.
* The test passes.

This is rope that can hang your tests. Be cautious and conservative
in use.

This just went up on pypi as the somewhat bizarrely numbered[2] version
0.100.0[3].

As always if you're thinking of using it and want some help, have
questions, etc please feel free to find me (or jasonamyers).

[1] http://gabbi.readthedocs.org/
[2] I was in a feature freeze at 0.99.x and the need for this feature beat
     the race to get to version 1.0 and I want 1.0 to be the _actual_
     public and frozen API.
[3] https://pypi.python.org/pypi/gabbi

-- 
Chris Dent tw:@anticdent freenode:cdent
https://tank.peermore.com/tanks/cdent



More information about the OpenStack-dev mailing list