Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_replays_response_from_cassette fails because of X-Amzn-Trace-Id #184

Open
FelixSchwarz opened this issue Apr 11, 2020 · 1 comment
Open

Comments

@FelixSchwarz
Copy link

$ pytest tests/integration/test_record_modes.py
.F......                                                                [100%]
================================== FAILURES ===================================
_____________ TestRecordOnce.test_replays_response_from_cassette ______________

            assert r0_headers == r1_headers
>           assert r0.content == r1.content
E           assert b'{\n  "args"...org/get"\n}\n' == b'{\n  "args"...org/get"\n}\n'
E             At index 208 diff: b'd' != b'e'
E             Full diff:
E               (
E                b'{\n  "args": {}, \n  "headers": {\n    "Accept": "*/*", \n    "Accept-Encodi'
E                b'ng": "gzip, deflate", \n    "Host": "httpbin.org", \n    "User-Agent": "py'
E             -  b'thon-requests/2.23.0", \n    "X-Amzn-Trace-Id": "Root=1-5e91e8b3-e94687be'
E             ?                                                                     ^^^^ ^^^...
E             
E             ...Full output truncated (9 lines hidden), use '-vv' to show

tests/integration/test_record_modes.py:43: AssertionError

The test code already removes some headers which may differ between requests but the difference shown above is in r1.content and I don't know what the best way is to ignore X-Amzn-Trace-Id there.

It seems as if httpbin.org uses Amazon's Elastic Load Balancing which adds a unique X-Amzn-Trace-Id header. That header is different for each request.

@sigmavirus24
Copy link
Collaborator

This is because httpbin has moved hosting providers.

It makes sense to me for us to either:

  • Strip it or
  • Start using pytest-httpbin

Either way, contributions will be necessary for this as I'm not able to spend a significant amount of time on this.

jhatler added a commit to jhatler/betamax that referenced this issue Dec 23, 2023
The httbin.org service returns a X-Amzn-Trace-Id header in its
responses, which is different for each request. This causes the
tests to fail. This clears the header before comparing responses.

Refs: betamaxpy#184, betamaxpy#190
Signed-off-by: Jaremy Hatler <[email protected]>
jhatler added a commit to jhatler/betamax that referenced this issue Dec 23, 2023
The httbin.org service returns a X-Amzn-Trace-Id header in its
responses, which is different for each request. This causes the
tests to fail. This clears the header before comparing responses.

Refs: betamaxpy#184, betamaxpy#190
Signed-off-by: Jaremy Hatler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants