Skip to content

Commit

Permalink
ci: move suites that use httpbin_local to gitlab from circleci (#10601)
Browse files Browse the repository at this point in the history
This change moves test suites that use the `httpbin_local` service from
circleci to gitlab for billing purposes.

## 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
emmettbutler authored Sep 11, 2024
1 parent 49711ec commit 72f4032
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 56 deletions.
36 changes: 0 additions & 36 deletions .circleci/config.templ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -589,15 +589,6 @@ jobs:
snapshot: true
docker_services: 'postgres'

aiohttp:
<<: *machine_executor
parallelism: 3
steps:
- run_test:
pattern: 'aiohttp' # includes aiohttp_jinja2
snapshot: true
docker_services: 'httpbin_local'

cassandra:
<<: *contrib_job
docker:
Expand Down Expand Up @@ -652,23 +643,6 @@ jobs:
snapshot: true
docker_services: "memcached redis postgres"

httplib:
<<: *machine_executor
steps:
- run_test:
pattern: "httplib"
snapshot: true
docker_services: 'httpbin_local'

httpx:
<<: *machine_executor
parallelism: 2
steps:
- run_test:
pattern: 'httpx'
snapshot: true
docker_services: 'httpbin_local'

mariadb:
<<: *machine_executor
parallelism: 4
Expand Down Expand Up @@ -727,16 +701,6 @@ jobs:
snapshot: true
docker_services: 'mongo'

requests:
<<: *contrib_job
docker:
- image: *ddtrace_dev_image
- *testagent
- *httpbin_local
steps:
- run_test:
pattern: "requests"

sqlalchemy:
<<: *contrib_job_small
docker:
Expand Down
34 changes: 34 additions & 0 deletions .gitlab/tests/contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,40 @@ unittest:
variables:
SUITE_NAME: "unittest"

aiohttp:
extends: .test_base_riot_snapshot
parallel: 3
variables:
SUITE_NAME: "aiohttp"
services:
- !reference [.test_base_riot_snapshot, services]
- !reference [.services, httpbin_local]

requests:
extends: .test_base_riot_snapshot
variables:
SUITE_NAME: "requests"
services:
- !reference [.test_base_riot_snapshot, services]
- !reference [.services, httpbin_local]

httplib:
extends: .test_base_riot_snapshot
variables:
SUITE_NAME: "httplib"
services:
- !reference [.test_base_riot_snapshot, services]
- !reference [.services, httpbin_local]

httpx:
extends: .test_base_riot_snapshot
variables:
SUITE_NAME: "httpx"
services:
- !reference [.test_base_riot_snapshot, services]
- !reference [.services, httpbin_local]
parallel: 2

urllib3:
extends: .test_base_riot_snapshot
services:
Expand Down
4 changes: 2 additions & 2 deletions tests/contrib/aiohttp/test_aiohttp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def test_200_request_post(snapshot_context):

@pytest.mark.asyncio
async def test_500_request(snapshot_context):
with snapshot_context():
with snapshot_context(ignores=["meta.http.status_msg"]):
async with aiohttp.ClientSession() as session:
async with session.get(URL_500) as resp:
assert resp.status == 500
Expand Down Expand Up @@ -220,7 +220,7 @@ async def test_trace_query_string(snapshot_context):
The query string is included as a tag on the span
"""
with override_http_config("aiohttp_client", {"trace_query_string": True}):
with snapshot_context():
with snapshot_context(ignores=["meta.http.status_msg"]):
async with aiohttp.ClientSession() as session:
async with session.get(
"%s/?k1=v1&k2=v2" % URL_200,
Expand Down
35 changes: 17 additions & 18 deletions tests/contrib/requests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
from tests.utils import override_global_tracer


# socket name comes from https://english.stackexchange.com/a/44048
SOCKET = "httpbin.org"
URL_200 = "http://{}/status/200".format(SOCKET)
URL_500 = "http://{}/status/500".format(SOCKET)
URL_AUTH_200 = "http://user:pass@{}/status/200".format(SOCKET)
HOST_AND_PORT = "httpbin-local: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)
URL_AUTH_200 = "http://user:pass@{}/status/200".format(HOST_AND_PORT)


class BaseRequestTestCase(object):
Expand Down Expand Up @@ -213,7 +213,7 @@ def test_requests_module_200(self):
def test_post_500(self):
out = self.session.post(URL_500)
# validation
assert out.status_code == 500
assert out.status_code >= 500
spans = self.pop_spans()
assert len(spans) == 1
s = spans[0]
Expand Down Expand Up @@ -252,7 +252,7 @@ def test_non_existant_url(self):

def test_500(self):
out = self.session.get(URL_500)
assert out.status_code == 500
assert out.status_code >= 500

spans = self.pop_spans()
assert len(spans) == 1
Expand Down Expand Up @@ -363,7 +363,7 @@ def test_split_by_domain_with_ampersat(self):
s = spans[0]

assert s.get_tag("out.host") == SOCKET
assert s.service == "httpbin.org"
assert s.service == HOST_AND_PORT

def test_split_by_domain(self):
# ensure a service name is generated by the domain name
Expand All @@ -378,7 +378,7 @@ def test_split_by_domain(self):
s = spans[0]

assert s.get_tag("out.host") == SOCKET
assert s.service == "httpbin.org"
assert s.service == HOST_AND_PORT
assert s.resource == "GET /status/200"

def test_split_by_domain_precedence(self):
Expand All @@ -394,7 +394,7 @@ def test_split_by_domain_precedence(self):
s = spans[0]

assert s.get_tag("out.host") == SOCKET
assert s.service == "httpbin.org"
assert s.service == HOST_AND_PORT
assert s.resource == "GET /status/200"

def test_split_by_domain_wrong(self):
Expand All @@ -413,43 +413,43 @@ def test_split_by_domain_remove_auth_in_url(self):
# ensure that auth details are stripped from URL
cfg = config.get_from(self.session)
cfg["split_by_domain"] = True
out = self.session.get("http://user:pass@httpbin.org")
out = self.session.get(f"http://user:pass@{HOST_AND_PORT}")
assert out.status_code == 200

spans = self.pop_spans()
assert len(spans) == 1
s = spans[0]

assert s.get_tag("out.host") == SOCKET
assert s.service == "httpbin.org"
assert s.service == HOST_AND_PORT

def test_split_by_domain_includes_port(self):
# ensure that port is included if present in URL
cfg = config.get_from(self.session)
cfg["split_by_domain"] = True
out = self.session.get("http://httpbin.org:80")
out = self.session.get(f"http://{HOST_AND_PORT}")
assert out.status_code == 200

spans = self.pop_spans()
assert len(spans) == 1
s = spans[0]

assert s.get_tag("out.host") == SOCKET
assert s.service == "httpbin.org:80"
assert s.service == HOST_AND_PORT

def test_split_by_domain_includes_port_path(self):
# ensure that port is included if present in URL but not path
cfg = config.get_from(self.session)
cfg["split_by_domain"] = True
out = self.session.get("http://httpbin.org:80/anything/v1/foo")
out = self.session.get(f"http://{HOST_AND_PORT}/anything/v1/foo")
assert out.status_code == 200

spans = self.pop_spans()
assert len(spans) == 1
s = spans[0]

assert s.get_tag("out.host") == SOCKET
assert s.service == "httpbin.org:80"
assert s.service == HOST_AND_PORT

@TracerTestCase.run_in_subprocess(env_overrides=dict(DD_REQUESTS_SERVICE="override"))
def test_global_config_service_env_precedence(self):
Expand Down Expand Up @@ -575,13 +575,12 @@ def test_request_and_response_headers(self):

# Enabled when explicitly configured
with self.override_config("requests", {}):
config.requests.http.trace_headers(["my-header", "access-control-allow-origin"])
config.requests.http.trace_headers(["my-header"])
self.session.get(URL_200, headers={"my-header": "my_value"})
spans = self.pop_spans()
assert len(spans) == 1
s = spans[0]
assert s.get_tag("http.request.headers.my-header") == "my_value"
assert s.get_tag("http.response.headers.access-control-allow-origin") == "*"

def test_analytics_integration_default(self):
"""
Expand Down

0 comments on commit 72f4032

Please sign in to comment.