Skip to content

Commit

Permalink
Remove functional tests for opentelemetry instrumentation
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
lubosmj committed Oct 31, 2024
1 parent c5509f5 commit 59ab3c2
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 312 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ if [ "$TEST" = "azure" ]; then
command: "azurite-blob --blobHost 0.0.0.0"' vars/main.yaml
sed -i -e '$a azure_test: true\
pulp_scenario_settings: {"api_root_rewrite_header": "X-API-Root", "domain_enabled": true, "rest_framework__default_permission_classes": ["pulpcore.plugin.access_policy.DefaultAccessPolicy"]}\
pulp_scenario_env: {"otel_bsp_max_export_batch_size": 1, "otel_bsp_max_queue_size": 1, "otel_exporter_otlp_endpoint": "http://localhost:4318", "otel_exporter_otlp_protocol": "http/protobuf", "otel_metric_export_interval": 800, "pulp_otel_enabled": "true"}\
pulp_scenario_env: {}\
' vars/main.yaml
fi

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/scripts/pre_before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ if [ "$TEST" = "azure" ]; then
cmd_stdin_prefix bash -c "cat > /etc/nginx/pulp/api_root_rewrite.conf" < pulpcore/tests/functional/assets/api_root_rewrite.conf
cmd_prefix bash -c "s6-rc -d change nginx"
cmd_prefix bash -c "s6-rc -u change nginx"
cmd_stdin_prefix bash -c "cat > /var/lib/pulp/scripts/otel_server.py" < pulpcore/tests/functional/assets/otel_server.py
cmd_user_prefix nohup python3 /var/lib/pulp/scripts/otel_server.py &
fi
41 changes: 0 additions & 41 deletions pulp_file/tests/functional/api/test_telemetry_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def test_get_requests(
file_content_unit_with_name_factory,
gen_object_with_cleanup,
monitor_task,
received_otel_span,
test_path,
):
"""Test if content-app correctly returns mime-types based on filenames."""
Expand Down Expand Up @@ -49,43 +48,3 @@ def test_get_requests(
status_code = 302
else:
status_code = 200

s.get(url, allow_redirects=False)
assert received_otel_span(
{
"http.method": "GET",
"http.target": content_path,
"http.status_code": status_code,
"http.user_agent": test_path,
}
)

s.get(url + "fail")
assert received_otel_span(
{
"http.method": "GET",
"http.target": content_path + "fail",
"http.status_code": 404,
"http.user_agent": test_path,
}
)

s.post(url, data={})
assert received_otel_span(
{
"http.method": "POST",
"http.target": content_path,
"http.status_code": 405,
"http.user_agent": test_path,
}
)

s.head(url, allow_redirects=False)
assert received_otel_span(
{
"http.method": "HEAD",
"http.target": content_path,
"http.status_code": status_code,
"http.user_agent": test_path,
}
)
62 changes: 0 additions & 62 deletions pulpcore/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,68 +210,6 @@ def make_url(self, path):
return f"{protocol_handler}{self.host}:{self.port}{path}"


@pytest.fixture(scope="session")
def received_otel_span():
"""A fixture for checking the presence of specific spans on the otel collector server.
Ensure the collector server is up and running before executing tests with this fixture. To do
so, please, run the server as follows: python3 pulpcore/tests/functional/assets/otel_server.py
"""

def _received_otel_span(data, retries=3):
if os.environ.get("PULP_OTEL_ENABLED") != "true":
# pretend everything is working as expected if tests are run from
# a non-configured runner
return True

async def _send_request():
async with aiohttp.ClientSession(raise_for_status=False) as session:
otel_server_url = os.environ.get("OTEL_EXPORTER_OTLP_ENDPOINT")
async with session.post(f"{otel_server_url}/test", json=data) as response:
return response.status

while retries:
status = asyncio.run(_send_request())
if status == 200:
return True
sleep(2)
retries -= 1
return False

return _received_otel_span


@pytest.fixture(scope="session")
def received_otel_metrics():
"""A fixture for checking the presence of specific metrics on the otel collector server.
Ensure the collector server is up and running before executing tests with this fixture. To do
so, please, run the server as follows: python3 pulpcore/tests/functional/assets/otel_server.py
"""

def _received_otel_metric(data, retries=3):
if os.environ.get("PULP_OTEL_ENABLED") != "true":
# pretend everything is working as expected if tests are run from
# a non-configured runner
return True

async def _send_request():
async with aiohttp.ClientSession(raise_for_status=False) as session:
otel_server_url = os.environ.get("OTEL_EXPORTER_OTLP_ENDPOINT")
async with session.post(f"{otel_server_url}/metrics_test", json=data) as response:
return response.status

while retries:
status = asyncio.run(_send_request())
if status == 200:
return True
sleep(2)
retries -= 1
return False

return _received_otel_metric


@pytest.fixture
def test_path():
return os.getenv("PYTEST_CURRENT_TEST").split()[0]
Expand Down
29 changes: 2 additions & 27 deletions pulpcore/tests/functional/api/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,40 +59,24 @@


@pytest.mark.parallel
def test_get_authenticated(test_path, pulpcore_bindings, received_otel_span):
def test_get_authenticated(test_path, pulpcore_bindings):
"""GET the status path with valid credentials.
Verify the response with :meth:`verify_get_response`.
"""
response = pulpcore_bindings.StatusApi.status_read()
verify_get_response(response.to_dict(), STATUS)
assert received_otel_span(
{
"http.method": "GET",
"http.target": "/pulp/api/v3/status/",
"http.status_code": 200,
"http.user_agent": test_path,
}
)


@pytest.mark.parallel
def test_get_unauthenticated(test_path, pulpcore_bindings, anonymous_user, received_otel_span):
def test_get_unauthenticated(test_path, pulpcore_bindings, anonymous_user):
"""GET the status path with no credentials.
Verify the response with :meth:`verify_get_response`.
"""
with anonymous_user:
response = pulpcore_bindings.StatusApi.status_read()
verify_get_response(response.to_dict(), STATUS)
assert received_otel_span(
{
"http.method": "GET",
"http.target": "/pulp/api/v3/status/",
"http.status_code": 200,
"http.user_agent": test_path,
}
)


@pytest.mark.parallel
Expand All @@ -101,7 +85,6 @@ def test_post_authenticated(
pulp_api_v3_path,
pulp_api_v3_url,
pulpcore_bindings,
received_otel_span,
):
"""POST the status path with valid credentials.
Expand All @@ -117,14 +100,6 @@ def test_post_authenticated(
pulpcore_bindings.client.request("POST", status_url, headers={"User-Agent": test_path})

assert e.value.status == 405
assert received_otel_span(
{
"http.method": "POST",
"http.target": f"{pulp_api_v3_path}status/",
"http.status_code": 405,
"http.user_agent": test_path,
}
)


@pytest.mark.parallel
Expand Down
21 changes: 1 addition & 20 deletions pulpcore/tests/functional/api/test_tasking.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,7 @@ def test_task_version_prevent_pickup(dispatch_task, pulpcore_bindings):
pulpcore_bindings.TasksApi.tasks_cancel(task_href, {"state": "canceled"})


def test_emmiting_unblocked_task_telemetry(
dispatch_task, pulpcore_bindings, pulp_settings, received_otel_metrics
):
def test_emmiting_unblocked_task_telemetry(dispatch_task, pulpcore_bindings, pulp_settings):
if os.getenv("PULP_OTEL_ENABLED").lower() != "true":
pytest.skip("Need PULP_OTEL_ENABLED to run this test.")

Expand All @@ -356,23 +354,6 @@ def test_emmiting_unblocked_task_telemetry(
task = pulpcore_bindings.TasksApi.read(task_href)
assert task.state == "waiting"

# And trigger the metrics
assert received_otel_metrics(
{
"name": "tasks_unblocked_queue",
"description": "Number of unblocked tasks waiting in the queue.",
"unit": "tasks",
}
)

assert received_otel_metrics(
{
"name": "tasks_longest_unblocked_time",
"description": "The age of the longest waiting task.",
"unit": "seconds",
}
)

[
pulpcore_bindings.TasksApi.tasks_cancel(task_href, {"state": "canceled"})
for task_href in resident_task_hrefs
Expand Down
152 changes: 0 additions & 152 deletions pulpcore/tests/functional/assets/otel_server.py

This file was deleted.

Loading

0 comments on commit 59ab3c2

Please sign in to comment.