SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix(tests): fix flaky rootuser integration tests (#10660)
Pandeydfe2a6a9e5fe
diff --git a/.github/workflows/integrationci.yaml b/.github/workflows/integrationci.yamlindex 4d48141b3e..5046aa796f 100644--- a/.github/workflows/integrationci.yaml+++ b/.github/workflows/integrationci.yaml@@ -29,6 +29,7 @@ jobs:- name: fmtrun: |make py-fmt+ git diff --exit-code -- tests/integration/- name: lintrun: |make py-lintdiff --git a/tests/integration/src/rootuser/01_rootuser.py b/tests/integration/src/rootuser/01_rootuser.pyindex 7fc2d5570d..3dbaf4bc7f 100644--- a/tests/integration/src/rootuser/01_rootuser.py+++ b/tests/integration/src/rootuser/01_rootuser.py@@ -12,8 +12,12 @@ logger = setup_logger(__name__)def test_root_user_created(signoz: types.SigNoz) -> None:"""The root user service reconciles asynchronously after startup.- Wait until the root user is available by polling /api/v1/version.++ Phase 1: Poll /api/v1/version until setupCompleted=true.+ Phase 2: Poll /api/v1/user until it returns 200, confirming the root+ user actually exists and the impersonation provider works."""+ # Phase 1: wait for setupCompletedfor attempt in range(15):response = requests.get(signoz.self.host_configs["8080"].get("/api/v1/version"),@@ -21,11 +25,30 @@ def test_root_user_created(signoz: types.SigNoz) -> None:)assert response.status_code == HTTPStatus.OKif response.json().get("setupCompleted") is True:- return+ breaklogger.info("Attempt %s: setupCompleted is not yet true, retrying ...",attempt + 1,)time.sleep(2)+ else:+ raise AssertionError(+ "setupCompleted did not become true within the expected time"+ )++ # Phase 2: wait for root user to be fully resolved+ for attempt in range(15):+ response = requests.get(+ signoz.self.host_configs["8080"].get("/api/v1/user"),+ timeout=2,+ )+ if response.status_code == HTTPStatus.OK:+ return+ logger.info(+ "Attempt %s: /api/v1/user returned %s, retrying ...",+ attempt + 1,+ response.status_code,+ )+ time.sleep(2)raise AssertionError("root user was not created within the expected time")diff --git a/tests/integration/src/rootuser/02_impersonation.py b/tests/integration/src/rootuser/02_impersonation.pyindex 2076596695..a9127f4aae 100644--- a/tests/integration/src/rootuser/02_impersonation.py+++ b/tests/integration/src/rootuser/02_impersonation.py@@ -26,19 +26,6 @@ def test_global_config_returns_impersonation_enabled(signoz: types.SigNoz) -> Noassert data["identN"]["apikey"]["enabled"] is False-def test_unauthenticated_request_succeeds(signoz: types.SigNoz) -> None:- """- With impersonation enabled, requests without any auth header- should succeed as the root user (admin).- """- response = requests.get(- signoz.self.host_configs["8080"].get("/api/v1/dashboards"),- timeout=2,- )-- assert response.status_code == HTTPStatus.OK--def test_impersonated_user_is_admin(signoz: types.SigNoz) -> None:"""The impersonated identity should have admin privileges.