Test Updates to Align with Header Removal from APIcast Midstream#1029
Test Updates to Align with Header Removal from APIcast Midstream#1029cathal-bailey wants to merge 2 commits into
Conversation
…m APIcast midstream
9a1e120 to
33fc4ad
Compare
…n.py to align with header removal in APIcast midstream
|
are there any upstream changes or jira issue that shows this is expected change? |
|
| @backoff.on_predicate( | ||
| backoff.fibo, | ||
| lambda response: response.headers.get("server") not in ("openresty", "envoy"), | ||
| lambda response: response.status_code not in (200, 503, 500), |
There was a problem hiding this comment.
There is bug. In the test where you are waiting for the 503, it can pass when it gets 200, then the test will fail on the wrong status code, but the only issue is that the test didn't wait enough time to load the configuration.
I also don't like that the range of the status codes is hardcoded. If there isn't other way how to detect that configuration is loaded, I would at least test the backoff against fixture status_code and set it to something, that doesn't collide with standard status codes (e.g 418) .
There was a problem hiding this comment.
I could set a global variable expected_code returned from fixture status_code, then retry while response.status_code != expected_code? Then when retry passes, the response code will be the correct one
There was a problem hiding this comment.
I'm not sure how do you want set the global variable, but test response.status_code against expected_code seems like good approach to me. I would personally refactor make_request function, so it accepts status code as parameter, wrap return api_client.get("/") by a nested function and anotate that nested function by backoff with the correct condition.
test_do_not_send_openresty_version.pyalso affected by midstream change.