APIs - Test Status Response
|
07-17-2019, 06:58 AM
Post: #1
|
|||
|
|||
APIs - Test Status Response
I've written a script that kicks off a test, polls to wait for results, grabs the results and puts them into a python dataframe. At least that's what it's supposed to do.
My code is pretty messy so I apologies in advance, please feel free to suggest improvements if you have time but my priority is to get the script working. When I send a GET to /testStatus.php, I am expecting a 1XX response as per the documentation, but it seems to return a 200 when the test is at the front of the queue and started. I'm now not sure how I can wait for the test to complete . As a side note, I'm also having trouble with knowing how long to poll for since I've experienced being behind 78 tests this week. Any good strategies to deal with this are welcome! Code: import requests |
|||
07-22-2019, 06:32 PM
Post: #2
|
|||
|
|||
RE: APIs - Test Status Response
You want the code from the test, not the HTTP response code for the API call so think this line
statusResponseCode = testStatus_Response.status_code should be statusResponseCode = resp_dict_status['data']['statusCode'] As far as polling goes, I'd suggest an incremental back off based on the number of testing being run, and when the last check was made but put an upper cap on it e.g. 1 hour Andy Using WebPageTest - http://usingwpt.com/ |
|||
07-23-2019, 10:54 PM
Post: #3
|
|||
|
|||
RE: APIs - Test Status Response
Hi Andy,
Thank-you very much for pointing out and correcting the fact that I using the wrong response. I've used your suggestion now and it's working great. For the polling, I've changed the logic to now grab the number of tests I'm behind and wait that many seconds (plus an arbitrary 5 seconds) which works nicely. Thanks again for your support. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)