Skip to content

Commit

Permalink
chore(requests): fix local test runs (#10769)
Browse files Browse the repository at this point in the history
Running requests tests locally results in httpbin connection errors.
This regression was introduced in
72f4032#diff-9885ff9747de8410ef5d9849c7c0950e34f9a2b86bf340d5a05fa2d1514854bb.
This PR ensures the service alias used in gitlab is consistent with the
service name used in docker-compose. This change ensures requests tests
pass both in gitlab and locally.

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
  • Loading branch information
mabdinur authored Sep 25, 2024
1 parent f73437b commit 057bb26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ services:
- "${TMPDIR:-/var/lib/localstack}:/var/lib/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"

httpbin_local:
httpbin-local:
image: kennethreitz/httpbin@sha256:2c7abc4803080c22928265744410173b6fea3b898872c01c5fd0f0f9df4a59fb
platform: linux/amd64
ports:
Expand Down
10 changes: 6 additions & 4 deletions tests/contrib/requests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from tests.utils import override_global_tracer


HOST_AND_PORT = "httpbin-local:8001"
HOST_AND_PORT = "localhost:8001"
SOCKET = HOST_AND_PORT.split(":")[0]
URL_200 = "http://{}/status/200".format(HOST_AND_PORT)
URL_500 = "http://{}/status/500".format(HOST_AND_PORT)
Expand Down Expand Up @@ -243,9 +243,11 @@ def test_non_existant_url(self):
assert s.get_tag("span.kind") == "client"
assert s.get_tag("out.host") == "doesnotexist.google.com"
assert s.error == 1
assert "Name or service not known" in s.get_tag(ERROR_MSG)
assert "Name or service not known" in s.get_tag(ERROR_STACK)
assert "Traceback (most recent call last)" in s.get_tag(ERROR_STACK)
assert (
"HTTPConnectionPool(host='doesnotexist.google.com', port=80): Max retries exceeded with url: /"
in s.get_tag(ERROR_MSG)
)
assert s.get_tag(ERROR_STACK)
assert "requests.exception" in s.get_tag(ERROR_TYPE)

def test_500(self):
Expand Down

0 comments on commit 057bb26

Please sign in to comment.