Skip to content

Commit

Permalink
Update nginx config to prevent restarts.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimf5 committed Dec 7, 2024
1 parent d73374f commit d9bba30
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def testdir(tmp_path_factory):
@pytest.fixture(scope="module")
def nginx_config(request, pytestconfig, testdir, logger):
tmpl = jinja2.Environment().from_string(request.module.NGINX_CONFIG)
params = request.param
params = request.param if hasattr(request, "param") else {}
params["globals"] = (
f"pid {testdir}/nginx.pid;\n"
+ f"error_log {testdir}/error.log notice;\n"
Expand Down Expand Up @@ -105,7 +105,7 @@ def nginx(testdir, pytestconfig, nginx_config, _certs, logger):
if pytestconfig.option.showlog:
with pytest.module_capsys.disabled():
print((testdir / "error.log").read_text())
(testdir / "error.log").unlink()
(testdir / "error.log").unlink()


@pytest.fixture(scope="module")
Expand Down
22 changes: 13 additions & 9 deletions tests/test_otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,21 @@
}
otel_trace on;
otel_service_name {{ name }};
otel_service_name test_service;
add_header "X-Otel-Trace-Id" $otel_trace_id;
add_header "X-Otel-Span-Id" $otel_span_id;
add_header "X-Otel-Parent-Id" $otel_parent_id;
add_header "X-Otel-Parent-Sampled" $otel_parent_sampled;
server {
listen 127.0.0.1:18443 {{ mode }};
listen 127.0.0.1:18443 ssl;
listen 127.0.0.1:18443 quic;
listen 127.0.0.1:18080;
http2 on;
http3 on;
server_name localhost;
location / {
Expand Down Expand Up @@ -217,14 +222,13 @@ def response(logger, http_ver, scheme, path, headers):

@pytest.mark.usefixtures("trace_service", "_otelcol", "nginx")
@pytest.mark.parametrize(
("nginx_config", "http_ver", "scheme"),
("http_ver", "scheme"),
[
({"name": "test_http0", "mode": ""}, 0, "http"),
({"name": "test_http1", "mode": ""}, 1, "http"),
({"name": "test_http2", "mode": "ssl http2"}, 2, "https"),
({"name": "test_http3", "mode": "quic"}, 3, "https"),
(0, "http"),
(1, "http"),
(2, "https"),
(3, "https"),
],
indirect=["nginx_config"],
ids=["http 0.9", "http 1.1", "http 2.0 ssl", "http 3.0 quic"],
scope="module",
)
Expand Down Expand Up @@ -308,7 +312,7 @@ def test_batch_size(self, http_ver, batches, idx, value):
def test_service_name(self, http_ver, batches, idx):
assert (
span_attr(batches[idx][0].resource, "service.name", "string_value")
) == f"test_http{http_ver}"
) == "test_service"

@pytest.mark.parametrize(
("idx", "value"),
Expand Down

0 comments on commit d9bba30

Please sign in to comment.