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
test: add integration tests for preferences and add --with-web flag (#9821)
Pandeybb4d6117acec
diff --git a/.github/workflows/integrationci.yaml b/.github/workflows/integrationci.yamlindex f4eb203d0a..8b4add9f14 100644--- a/.github/workflows/integrationci.yaml+++ b/.github/workflows/integrationci.yaml@@ -9,6 +9,29 @@ on:- labeledjobs:+ fmtlint:+ if: |+ ((github.event_name == 'pull_request' && ! github.event.pull_request.head.repo.fork && github.event.pull_request.user.login != 'dependabot[bot]' && ! contains(github.event.pull_request.labels.*.name, 'safe-to-test')) ||+ (github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'safe-to-test'))) && contains(github.event.pull_request.labels.*.name, 'safe-to-integrate')+ runs-on: ubuntu-latest+ steps:+ - name: checkout+ uses: actions/checkout@v4+ - name: python+ uses: actions/setup-python@v5+ with:+ python-version: 3.13+ - name: poetry+ run: |+ python -m pip install poetry==2.1.2+ python -m poetry config virtualenvs.in-project true+ cd tests/integration && poetry install --no-root+ - name: fmt+ run: |+ make py-fmt+ - name: lint+ run: |+ make py-linttest:strategy:fail-fast: false@@ -21,6 +44,7 @@ jobs:- dashboard- querier- ttl+ - preferencesqlstore-provider:- postgres- sqlitediff --git a/cmd/enterprise/Dockerfile.integration b/cmd/enterprise/Dockerfile.integrationindex 7e3b19e9d1..02bae33aaa 100644--- a/cmd/enterprise/Dockerfile.integration+++ b/cmd/enterprise/Dockerfile.integration@@ -1,11 +1,3 @@-FROM node:18-bullseye AS build--WORKDIR /opt/-COPY ./frontend/ ./-ENV NODE_OPTIONS=--max-old-space-size=8192-RUN CI=1 yarn install-RUN CI=1 yarn build-FROM golang:1.24-bullseyeARG OS="linux"@@ -40,8 +32,6 @@ COPY Makefile MakefileRUN TARGET_DIR=/root ARCHS=${TARGETARCH} ZEUS_URL=${ZEUSURL} LICENSE_URL=${ZEUSURL}/api/v1 make go-build-enterprise-raceRUN mv /root/linux-${TARGETARCH}/signoz /root/signoz-COPY --from=build /opt/build ./web/-RUN chmod 755 /root /root/signozENTRYPOINT ["/root/signoz", "server"]diff --git a/cmd/enterprise/Dockerfile.with-web.integration b/cmd/enterprise/Dockerfile.with-web.integrationnew file mode 100644index 0000000000..7e3b19e9d1--- /dev/null+++ b/cmd/enterprise/Dockerfile.with-web.integration@@ -0,0 +1,47 @@+FROM node:18-bullseye AS build++WORKDIR /opt/+COPY ./frontend/ ./+ENV NODE_OPTIONS=--max-old-space-size=8192+RUN CI=1 yarn install+RUN CI=1 yarn build++FROM golang:1.24-bullseye++ARG OS="linux"+ARG TARGETARCH+ARG ZEUSURL++# This path is important for stacktraces+WORKDIR $GOPATH/src/github.com/signoz/signoz+WORKDIR /root++RUN set -eux; \+ apt-get update; \+ apt-get install -y --no-install-recommends \+ g++ \+ gcc \+ libc6-dev \+ make \+ pkg-config \+ ; \+ rm -rf /var/lib/apt/lists/*++COPY go.mod go.sum ./++RUN go mod download++COPY ./cmd/ ./cmd/+COPY ./ee/ ./ee/+COPY ./pkg/ ./pkg/+COPY ./templates/email /root/templates++COPY Makefile Makefile+RUN TARGET_DIR=/root ARCHS=${TARGETARCH} ZEUS_URL=${ZEUSURL} LICENSE_URL=${ZEUSURL}/api/v1 make go-build-enterprise-race+RUN mv /root/linux-${TARGETARCH}/signoz /root/signoz++COPY --from=build /opt/build ./web/++RUN chmod 755 /root /root/signoz++ENTRYPOINT ["/root/signoz", "server"]diff --git a/docs/contributing/go/handler.md b/docs/contributing/go/handler.mdnew file mode 100644index 0000000000..9853430ac5--- /dev/null+++ b/docs/contributing/go/handler.md@@ -0,0 +1,179 @@+# Handler++Handlers in SigNoz are responsible for exposing module functionality over HTTP. They are thin adapters that:++- Decode incoming HTTP requests+- Call the appropriate module layer+- Return structured responses (or errors) in a consistent format+- Describe themselves for OpenAPI generation++They are **not** the place for complex business logic; that belongs in modules (for example, `pkg/modules/user`, `pkg/modules/session`, etc).++## How are handlers structured?++At a high level, a typical flow looks like this:++1. A `Handler` interface is defined in the module (for example, `user.Handler`, `session.Handler`, `organization.Handler`).+2. The `apiserver` provider wires those handlers into HTTP routes using Gorilla `mux.Router`.++Each route wraps a module handler method with the following:+- Authorization middleware (from `pkg/http/middleware`)+- A generic HTTP `handler.Handler` (from `pkg/http/handler`)+- An `OpenAPIDef` that describes the operation for OpenAPI generation++For example, in `pkg/apiserver/signozapiserver`:++```go+if err := router.Handle("/api/v1/invite", handler.New(+ provider.authZ.AdminAccess(provider.userHandler.CreateInvite),+ handler.OpenAPIDef{+ ID: "CreateInvite",+ Tags: []string{"users"},+ Summary: "Create invite",+ Description: "This endpoint creates an invite for a user",+ Request: new(types.PostableInvite),+ RequestContentType: "application/json",+ Response: new(types.Invite),+ ResponseContentType: "application/json",+ SuccessStatusCode: http.StatusCreated,+ ErrorStatusCodes: []int{http.StatusBadRequest, http.StatusConflict},+ Deprecated: false,+ SecuritySchemes: newSecuritySchemes(types.RoleAdmin),+ },+)).Methods(http.MethodPost).GetError(); err != nil {+ return err+}+```++In this pattern:++- `provider.userHandler.CreateInvite` is a handler method.+- `provider.authZ.AdminAccess(...)` wraps that method with authorization checks and context setup.+- `handler.New` converts it into an HTTP handler and wires it to OpenAPI via the `OpenAPIDef`.++## How to write a new handler method?++When adding a new endpoint:++1. Add a method to the appropriate module `Handler` interface.+2. Implement that method in the module.+3. Register the method in `signozapiserver` with the correct route, HTTP method, auth, and `OpenAPIDef`.++### 1. Extend an existing `Handler` interface or create a new one++Find the module in `pkg/modules/<name>` and extend its `Handler` interface with a new method that receives an `http.ResponseWriter` and `*http.Request`. For example:++```go+type Handler interface {+ // existing methods...+ CreateThing(rw http.ResponseWriter, req *http.Request)+}+```++Keep the method focused on HTTP concerns and delegate business logic to the module.++### 2. Implement the handler method++In the module implementation, implement the new method. A typical implementation:++- Extracts authentication and organization context from `req.Context()`+- Decodes the request body into a `types.*` struct using the `binding` package+- Calls module functions+- Uses the `render` package to write responses or errors++```go+func (h *handler) CreateThing(rw http.ResponseWriter, req *http.Request) {+ // Extract authentication and organization context from req.Context()+ claims, err := authtypes.ClaimsFromContext(req.Context())+ if err != nil {+ render.Error(rw, err)+ return+ }++ // Decode the request body into a `types.*` struct using the `binding` package+ var in types.PostableThing+ if err := binding.JSON.BindBody(req.Body, &in); err != nil {+ render.Error(rw, err)+ return+ }++ // Call module functions+ out, err := h.module.CreateThing(req.Context(), claims.OrgID, &in)+ if err != nil {+ render.Error(rw, err)+ return+ }++ // Use the `render` package to write responses or errors+ render.Success(rw, http.StatusCreated, out)+}+```++### 3. Register the handler in `signozapiserver`++In `pkg/apiserver/signozapiserver`, add a route in the appropriate `add*Routes` function (`addUserRoutes`, `addSessionRoutes`, `addOrgRoutes`, etc.). The pattern is:++```go+if err := router.Handle("/api/v1/things", handler.New(+ provider.authZ.AdminAccess(provider.thingHandler.CreateThing),+ handler.OpenAPIDef{+ ID: "CreateThing",+ Tags: []string{"things"},+ Summary: "Create thing",+ Description: "This endpoint creates a thing",+ Request: new(types.PostableThing),+ RequestContentType: "application/json",+ Response: new(types.GettableThing),+ ResponseContentType: "application/json",+ SuccessStatusCode: http.StatusCreated,+ ErrorStatusCodes: []int{http.StatusBadRequest, http.StatusConflict},+ Deprecated: false,+ SecuritySchemes: newSecuritySchemes(types.RoleAdmin),+ },+)).Methods(http.MethodPost).GetError(); err != nil {+ return err+}+```++### 4. Update the OpenAPI spec++Run the following command to update the OpenAPI spec:++```bash+go run cmd/enterprise/*.go generate openapi+```++This will update the OpenAPI spec in `docs/api/openapi.yml` to reflect the new endpoint.++## How does OpenAPI integration work?++The `handler.New` function ties the HTTP handler to OpenAPI metadata via `OpenAPIDef`. This drives the generated OpenAPI document.++- **ID**: A unique identifier for the operation (used as the `operationId`).+- **Tags**: Logical grouping for the operation (for example, `"users"`, `"sessions"`, `"orgs"`).+- **Summary / Description**: Human-friendly documentation.+- **Request / RequestContentType**:+ - `Request` is a Go type that describes the request body or form.+ - `RequestContentType` is usually `"application/json"` or `"application/x-www-form-urlencoded"` (for callbacks like SAML).+- **Response / ResponseContentType**:+ - `Response` is the Go type for the successful response payload.+ - `ResponseContentType` is usually `"application/json"`; use `""` for responses without a body.+- **SuccessStatusCode**: The HTTP status for successful responses (for example, `http.StatusOK`, `http.StatusCreated`, `http.StatusNoContent`).+- **ErrorStatusCodes**: Additional error status codes beyond the standard ones automatically added by `handler.New`.+- **SecuritySchemes**: Auth mechanisms and scopes required by the operation.++The generic handler:++- Automatically appends `401`, `403`, and `500` to `ErrorStatusCodes` when appropriate.+- Registers request and response schemas with the OpenAPI reflector so they appear in `docs/api/openapi.yml`.++See existing examples in:++- `addUserRoutes` (for typical JSON request/response)+- `addSessionRoutes` (for form-encoded and redirect flows)++## What should I remember?++- **Keep handlers thin**: focus on HTTP concerns and delegate logic to modules/services.+- **Always register routes through `signozapiserver`** using `handler.New` and a complete `OpenAPIDef`.+- **Choose accurate request/response types** from the `types` packages so OpenAPI schemas are correct.diff --git a/tests/integration/conftest.py b/tests/integration/conftest.pyindex 524fd40b92..f0a6772bba 100644--- a/tests/integration/conftest.py+++ b/tests/integration/conftest.py@@ -33,6 +33,12 @@ def pytest_addoption(parser: pytest.Parser):default=False,help="Teardown environment. Run pytest --basetemp=./tmp/ -vv --teardown src/bootstrap/setup::test_teardown to teardown your local dev environment.",)+ parser.addoption(+ "--with-web",+ action="store_true",+ default=False,+ help="Build and run with web. Run pytest --basetemp=./tmp/ -vv --with-web src/bootstrap/setup::test_setup to setup your local dev environment with web.",+ )parser.addoption("--sqlstore-provider",action="store",diff --git a/tests/integration/fixtures/auth.py b/tests/integration/fixtures/auth.pyindex a345a58fe4..762f4c6ee9 100644--- a/tests/integration/fixtures/auth.py+++ b/tests/integration/fixtures/auth.py@@ -1,6 +1,5 @@-from typing import Tuplefrom http import HTTPStatus-from typing import Callable, List+from typing import Callable, List, Tupleimport pytestimport requests@@ -134,9 +133,9 @@ def get_tokens(signoz: types.SigNoz) -> Callable[[str, str], Tuple[str, str]]:)assert response.status_code == HTTPStatus.OK- accessToken = response.json()["data"]["accessToken"]- refreshToken = response.json()["data"]["refreshToken"]- return accessToken, refreshToken+ access_token = response.json()["data"]["accessToken"]+ refresh_token = response.json()["data"]["refreshToken"]+ return access_token, refresh_tokenreturn _get_tokensdiff --git a/tests/integration/fixtures/idputils.py b/tests/integration/fixtures/idputils.pyindex 221e757006..818860f40d 100644--- a/tests/integration/fixtures/idputils.py+++ b/tests/integration/fixtures/idputils.py@@ -1,4 +1,4 @@-from typing import Callable, Dict, Any+from typing import Any, Callable, Dictfrom urllib.parse import urljoinfrom xml.etree import ElementTree@@ -71,7 +71,9 @@ def create_saml_client("saml_signature_canonicalization_method": "http://www.w3.org/2001/10/xml-exc-c14n#","saml.onetimeuse.condition": "false","saml.server.signature.keyinfo.xmlSigKeyInfoKeyNameTransformer": "NONE",- "saml_assertion_consumer_url_post": urljoin(f"{signoz.self.host_configs['8080'].base()}", callback_path)+ "saml_assertion_consumer_url_post": urljoin(+ f"{signoz.self.host_configs['8080'].base()}", callback_path+ ),},"authenticationFlowBindingOverrides": {},"fullScopeAllowed": True,@@ -124,9 +126,11 @@ def create_saml_client(@pytest.fixture(name="update_saml_client_attributes", scope="function")def update_saml_client_attributes(- idp: types.TestContainerIDP+ idp: types.TestContainerIDP,) -> Callable[[str, Dict[str, Any]], None]:- def _update_saml_client_attributes(client_id: str, attributes: Dict[str, Any]) -> None:+ def _update_saml_client_attributes(+ client_id: str, attributes: Dict[str, Any]+ ) -> None:client = KeycloakAdmin(server_url=idp.container.host_configs["6060"].base(),username=IDP_ROOT_USERNAME,diff --git a/tests/integration/fixtures/logs.py b/tests/integration/fixtures/logs.pyindex 1d7477cbe9..7e974c8e12 100644--- a/tests/integration/fixtures/logs.py+++ b/tests/integration/fixtures/logs.py@@ -429,7 +429,11 @@ def ttl_legacy_logs_v2_table_setup(request, signoz: types.SigNoz):).result_rowsassert result is not None# Add cleanup to restore original table- request.addfinalizer(lambda: signoz.telemetrystore.conn.query("RENAME TABLE signoz_logs.logs_v2_backup TO signoz_logs.logs_v2;"))+ request.addfinalizer(+ lambda: signoz.telemetrystore.conn.query(+ "RENAME TABLE signoz_logs.logs_v2_backup TO signoz_logs.logs_v2;"+ )+ )# Create new test tablesresult = signoz.telemetrystore.conn.query(@@ -445,10 +449,15 @@ def ttl_legacy_logs_v2_table_setup(request, signoz: types.SigNoz):assert result is not None# Add cleanup to drop test table- request.addfinalizer(lambda: signoz.telemetrystore.conn.query("DROP TABLE IF EXISTS signoz_logs.logs_v2;"))+ request.addfinalizer(+ lambda: signoz.telemetrystore.conn.query(+ "DROP TABLE IF EXISTS signoz_logs.logs_v2;"+ )+ )yield # Test runs here+@pytest.fixture(name="ttl_legacy_logs_v2_resource_table_setup", scope="function")def ttl_legacy_logs_v2_resource_table_setup(request, signoz: types.SigNoz):"""@@ -463,7 +472,11 @@ def ttl_legacy_logs_v2_resource_table_setup(request, signoz: types.SigNoz):).result_rowsassert result is not None# Add cleanup to restore original table- request.addfinalizer(lambda: signoz.telemetrystore.conn.query("RENAME TABLE signoz_logs.logs_v2_resource_backup TO signoz_logs.logs_v2_resource;"))+ request.addfinalizer(+ lambda: signoz.telemetrystore.conn.query(+ "RENAME TABLE signoz_logs.logs_v2_resource_backup TO signoz_logs.logs_v2_resource;"+ )+ )# Create new test tablesresult = signoz.telemetrystore.conn.query(@@ -478,6 +491,10 @@ def ttl_legacy_logs_v2_resource_table_setup(request, signoz: types.SigNoz):assert result is not None# Add cleanup to drop test table- request.addfinalizer(lambda: signoz.telemetrystore.conn.query("DROP TABLE IF EXISTS signoz_logs.logs_v2_resource;"))+ request.addfinalizer(+ lambda: signoz.telemetrystore.conn.query(+ "DROP TABLE IF EXISTS signoz_logs.logs_v2_resource;"+ )+ )- yield # Test runs here\ No newline at end of file+ yield # Test runs herediff --git a/tests/integration/fixtures/signoz.py b/tests/integration/fixtures/signoz.pyindex 8f3c6aa40b..6b396eb9f2 100644--- a/tests/integration/fixtures/signoz.py+++ b/tests/integration/fixtures/signoz.py@@ -1,7 +1,7 @@-from os import pathimport platformimport timefrom http import HTTPStatus+from os import pathimport dockerimport docker.errors@@ -34,14 +34,21 @@ def signoz( # pylint: disable=too-many-arguments,too-many-positional-arguments# Run the migrations for clickhouserequest.getfixturevalue("migrator")+ # Get the no-web flag+ with_web = pytestconfig.getoption("--with-web")+arch = platform.machine()if arch == "x86_64":arch = "amd64"# Build the image+ dockerfile_path = "cmd/enterprise/Dockerfile.integration"+ if with_web:+ dockerfile_path = "cmd/enterprise/Dockerfile.with-web.integration"+self = DockerImage(path="../../",- dockerfile_path="cmd/enterprise/Dockerfile.integration",+ dockerfile_path=dockerfile_path,tag="signoz:integration",buildargs={"TARGETARCH": arch,@@ -53,7 +60,7 @@ def signoz( # pylint: disable=too-many-arguments,too-many-positional-argumentsenv = ({- "SIGNOZ_WEB_ENABLED": True,+ "SIGNOZ_WEB_ENABLED": False,"SIGNOZ_WEB_DIRECTORY": "/root/web","SIGNOZ_INSTRUMENTATION_LOGS_LEVEL": "debug","SIGNOZ_PROMETHEUS_ACTIVE__QUERY__TRACKER_ENABLED": False,@@ -63,6 +70,9 @@ def signoz( # pylint: disable=too-many-arguments,too-many-positional-arguments| clickhouse.env)+ if with_web:+ env["SIGNOZ_WEB_ENABLED"] = True+container = DockerContainer("signoz:integration")for k, v in env.items():container.with_env(k, v)@@ -71,7 +81,7 @@ def signoz( # pylint: disable=too-many-arguments,too-many-positional-argumentsprovider = request.config.getoption("--sqlstore-provider")if provider == "sqlite":- dir_path = path.dirname(sqlstore.env["SIGNOZ_SQLSTORE_SQLITE_PATH"])+ dir_path = path.dirname(sqlstore.env["SIGNOZ_SQLSTORE_SQLITE_PATH"])container.with_volume_mapping(dir_path,dir_path,diff --git a/tests/integration/fixtures/sqlite.py b/tests/integration/fixtures/sqlite.pyindex 1ad33e3da8..b22202af5d 100644--- a/tests/integration/fixtures/sqlite.py+++ b/tests/integration/fixtures/sqlite.py@@ -27,7 +27,6 @@ def sqlite(with engine.connect() as conn:result = conn.execute(sql.text("SELECT 1"))assert result.fetchone()[0] == 1-return types.TestContainerSQL(container=types.TestContainerDocker(@@ -53,7 +52,6 @@ def sqlite(result = conn.execute(sql.text("SELECT 1"))assert result.fetchone()[0] == 1-return types.TestContainerSQL(container=types.TestContainerDocker(id="",diff --git a/tests/integration/src/callbackauthn/b_saml.py b/tests/integration/src/callbackauthn/b_saml.pyindex 3d09b2ca24..c2999bff33 100644--- a/tests/integration/src/callbackauthn/b_saml.py+++ b/tests/integration/src/callbackauthn/b_saml.py@@ -1,5 +1,5 @@from http import HTTPStatus-from typing import Callable, List, Dict, Any+from typing import Any, Callable, Dict, Listimport requestsfrom selenium import webdriver@@ -93,10 +93,11 @@ def test_create_auth_domain(f"{signoz.self.host_configs['8080'].address}:{signoz.self.host_configs['8080'].port}",{"saml_idp_initiated_sso_url_name": "idp-initiated-saml-test",- "saml_idp_initiated_sso_relay_state": relay_state_url- }+ "saml_idp_initiated_sso_relay_state": relay_state_url,+ },)+def test_saml_authn(signoz: SigNoz,idp: TestContainerIDP, # pylint: disable=unused-argument@@ -163,7 +164,10 @@ def test_idp_initiated_saml_authn(assert len(session_context["orgs"]) == 1assert len(session_context["orgs"][0]["authNSupport"]["callback"]) == 1- idp_initiated_login_url = idp.container.host_configs["6060"].base() + "/realms/master/protocol/saml/clients/idp-initiated-saml-test"+ idp_initiated_login_url = (+ idp.container.host_configs["6060"].base()+ + "/realms/master/protocol/saml/clients/idp-initiated-saml-test"+ )driver.get(idp_initiated_login_url)idp_login("[email protected]", "password")diff --git a/tests/integration/src/cloudintegrations/a_get_connection_params.py b/tests/integration/src/cloudintegrations/a_get_connection_params.pyindex 64c2a523da..8516038b4b 100644--- a/tests/integration/src/cloudintegrations/a_get_connection_params.py+++ b/tests/integration/src/cloudintegrations/a_get_connection_params.py@@ -146,16 +146,16 @@ def test_generate_connection_params(data = response_data["data"]# ingestion_key is created by the mocked gateway and should match- assert data["ingestion_key"] == "test-ingestion-key-123456", (- "ingestion_key should match the mocked ingestion key"- )+ assert (+ data["ingestion_key"] == "test-ingestion-key-123456"+ ), "ingestion_key should match the mocked ingestion key"# ingestion_url should be https://ingest.test.signoz.cloud based on the mocked deployment DNS- assert data["ingestion_url"] == "https://ingest.test.signoz.cloud", (- "ingestion_url should be https://ingest.test.signoz.cloud"- )+ assert (+ data["ingestion_url"] == "https://ingest.test.signoz.cloud"+ ), "ingestion_url should be https://ingest.test.signoz.cloud"# signoz_api_url should be https://test-deployment.test.signoz.cloud based on the mocked deployment name and DNS- assert data["signoz_api_url"] == "https://test-deployment.test.signoz.cloud", (- "signoz_api_url should be https://test-deployment.test.signoz.cloud"- )+ assert (+ data["signoz_api_url"] == "https://test-deployment.test.signoz.cloud"+ ), "signoz_api_url should be https://test-deployment.test.signoz.cloud"diff --git a/tests/integration/src/dashboard/a_public_dashboard.py b/tests/integration/src/dashboard/a_public_dashboard.pyindex 1752956e54..e505573e3e 100644--- a/tests/integration/src/dashboard/a_public_dashboard.py+++ b/tests/integration/src/dashboard/a_public_dashboard.py@@ -1,11 +1,12 @@from http import HTTPStatusfrom typing import Callable, List-from wiremock.resources.mappings import Mapping+import requestsfrom sqlalchemy import sql+from wiremock.resources.mappings import Mapping-from fixtures.auth import USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD,add_license-from fixtures.types import Operation, SigNoz,TestContainerDocker+from fixtures.auth import USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD, add_license+from fixtures.types import Operation, SigNoz, TestContainerDockerdef test_apply_license(@@ -19,6 +20,7 @@ def test_apply_license("""add_license(signoz, make_http_mocks, get_token)+def test_create_and_get_public_dashboard(signoz: SigNoz,create_user_admin: Operation, # pylint: disable=unused-argument@@ -28,11 +30,7 @@ def test_create_and_get_public_dashboard(response = requests.post(signoz.self.host_configs["8080"].get("/api/v1/dashboards"),- json={- "title": "Sample Title",- "uploadedGrafana": False,- "version": "v5"- },+ json={"title": "Sample Title", "uploadedGrafana": False, "version": "v5"},headers={"Authorization": f"Bearer {admin_token}"},timeout=2,)@@ -40,10 +38,12 @@ def test_create_and_get_public_dashboard(assert response.status_code == HTTPStatus.CREATEDassert response.json()["status"] == "success"data = response.json()["data"]- id = data["id"]+ dashboard_id = data["id"]response = requests.post(- signoz.self.host_configs["8080"].get(f"/api/v1/dashboards/{id}/public"),+ signoz.self.host_configs["8080"].get(+ f"/api/v1/dashboards/{dashboard_id}/public"+ ),json={"timeRangeEnabled": True,"defaultTimeRange": "10s",@@ -56,25 +56,27 @@ def test_create_and_get_public_dashboard(assert "id" in response.json()["data"]response = requests.get(- signoz.self.host_configs["8080"].get(f"/api/v1/dashboards/{id}/public"),+ signoz.self.host_configs["8080"].get(+ f"/api/v1/dashboards/{dashboard_id}/public"+ ),headers={"Authorization": f"Bearer {admin_token}"},timeout=2,)assert response.status_code == HTTPStatus.OKassert response.json()["status"] == "success"- assert response.json()["data"]["timeRangeEnabled"] == True+ assert response.json()["data"]["timeRangeEnabled"] is Trueassert response.json()["data"]["defaultTimeRange"] == "10s"public_path = response.json()["data"]["publicPath"]assert public_path.startswith("/public/dashboard/")public_dashboard_id = public_path.split("/public/dashboard/")[-1]- row = None+ row = Nonewith signoz.sqlstore.conn.connect() as conn:# verify the role creationresult = conn.execute(sql.text("SELECT * FROM role WHERE name = :role"),- {"role": "signoz-anonymous"}+ {"role": "signoz-anonymous"},)row = result.mappings().fetchone()assert row is not None@@ -84,18 +86,18 @@ def test_create_and_get_public_dashboard(tuple_object_id = f"organization/{row["org_id"]}/role/{row["id"]}"tuple_result = conn.execute(sql.text("SELECT * FROM tuple WHERE object_id = :object_id"),- {"object_id": tuple_object_id}+ {"object_id": tuple_object_id},)tuple_row = tuple_result.fetchone()assert tuple_row is not None# verify the tuple creation for public-dashboard- tuple_object_id = f"organization/{row["org_id"]}/public-dashboard/{public_dashboard_id}"+ tuple_object_id = (+ f"organization/{row["org_id"]}/public-dashboard/{public_dashboard_id}"+ )tuple_result = conn.execute(sql.text("SELECT * FROM tuple WHERE object_id = :object_id"),- {"object_id": tuple_object_id}+ {"object_id": tuple_object_id},)tuple_row = tuple_result.fetchone()assert tuple_row is not None--\ No newline at end of filediff --git a/tests/integration/src/passwordauthn/b_license.py b/tests/integration/src/passwordauthn/b_license.pyindex d5d850c619..fd3929a9f2 100644--- a/tests/integration/src/passwordauthn/b_license.py+++ b/tests/integration/src/passwordauthn/b_license.py@@ -1,9 +1,7 @@import http-import jsonfrom typing import Callable, Listimport requests-from sqlalchemy import sqlfrom wiremock.client import (HttpMethods,Mapping,@@ -138,7 +136,7 @@ def test_refresh_license()assert response.status_code == http.HTTPStatus.OKassert response.json()["data"]["valid_from"] == 1732146922-+response = requests.post(url=signoz.zeus.host_configs["8080"].get("/__admin/requests/count"),json={"method": "GET", "url": "/v2/licenses/me"},diff --git a/tests/integration/src/passwordauthn/d_password.py b/tests/integration/src/passwordauthn/d_password.pyindex 1779c5f717..1b87b235ad 100644--- a/tests/integration/src/passwordauthn/d_password.py+++ b/tests/integration/src/passwordauthn/d_password.py@@ -185,7 +185,6 @@ def test_reset_password(assert token is not None-def test_reset_password_with_no_password(signoz: types.SigNoz, get_token: Callable[[str, str], str]) -> None:diff --git a/tests/integration/src/passwordauthn/e_role.py b/tests/integration/src/passwordauthn/e_role.pyindex a15334bb5f..ce52a1f647 100644--- a/tests/integration/src/passwordauthn/e_role.py+++ b/tests/integration/src/passwordauthn/e_role.py@@ -1,11 +1,16 @@-from typing import Tuple-import requestsfrom http import HTTPStatus+from typing import Callable, Tuple+import requests-from typing import Callable+from fixtures import types-def test_change_role(signoz: types.SigNoz, get_token: Callable[[str, str], str], get_tokens: Callable[[str, str], Tuple[str, str]]):++def test_change_role(+ signoz: types.SigNoz,+ get_token: Callable[[str, str], str],+ get_tokens: Callable[[str, str], Tuple[str, str]],+):admin_token = get_token("[email protected]", "password123Z$")# Create a new user as VIEWER@@ -34,7 +39,9 @@ def test_change_role(signoz: types.SigNoz, get_token: Callable[[str, str], str],assert response.status_code == HTTPStatus.CREATED# Make some API calls as new user- new_user_token, new_user_refresh_token = get_tokens("[email protected]", "password123Z$")+ new_user_token, new_user_refresh_token = get_tokens(+ "[email protected]", "password123Z$"+ )response = requests.get(signoz.self.host_configs["8080"].get("/api/v1/user/me"),@@ -54,7 +61,7 @@ def test_change_role(signoz: types.SigNoz, get_token: Callable[[str, str], str],)assert response.status_code == HTTPStatus.FORBIDDEN-+# Change the new user's role - move to ADMINresponse = requests.put(signoz.self.host_configs["8080"].get(f"/api/v1/user/{new_user_id}"),@@ -91,7 +98,10 @@ def test_change_role(signoz: types.SigNoz, get_token: Callable[[str, str], str],# Make some API call again which is protectedrotate_response = response.json()["data"]- new_user_token, new_user_refresh_token = rotate_response["accessToken"], rotate_response["refreshToken"]+ new_user_token, new_user_refresh_token = (+ rotate_response["accessToken"],+ rotate_response["refreshToken"],+ )response = requests.get(signoz.self.host_configs["8080"].get("/api/v1/org/preferences"),diff --git a/tests/integration/src/preference/a_user.py b/tests/integration/src/preference/a_user.pynew file mode 100644index 0000000000..ba37da8941--- /dev/null+++ b/tests/integration/src/preference/a_user.py@@ -0,0 +1,71 @@+from http import HTTPStatus+from typing import Callable++import requests++from fixtures import types+from fixtures.logger import setup_logger++logger = setup_logger(__name__)+++def test_get_user_preference(+ signoz: types.SigNoz,+ create_user_admin: types.Operation, # pylint: disable=unused-argument+ get_token: Callable[[str, str], str],+):+ admin_token = get_token("[email protected]", "password123Z$")++ response = requests.get(+ signoz.self.host_configs["8080"].get("/api/v1/user/preferences"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )++ assert response.status_code == HTTPStatus.OK+ assert response.json()["data"] is not None+++def test_get_set_user_preference_by_name(+ signoz: types.SigNoz,+ create_user_admin: types.Operation, # pylint: disable=unused-argument+ get_token: Callable[[str, str], str],+):+ admin_token = get_token("[email protected]", "password123Z$")++ # preference does not exist+ response = requests.get(+ signoz.self.host_configs["8080"].get(+ "/api/v1/user/preferences/somenonexistentpreference"+ ),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )++ # This should be NOT_FOUND+ assert response.status_code == HTTPStatus.BAD_REQUEST++ # play with welcome_checklist_do_later preference+ response = requests.put(+ signoz.self.host_configs["8080"].get(+ "/api/v1/user/preferences/welcome_checklist_do_later"+ ),+ headers={"Authorization": f"Bearer {admin_token}"},+ json={"value": True},+ timeout=2,+ )++ assert response.status_code == HTTPStatus.NO_CONTENT++ # get preference by name+ response = requests.get(+ signoz.self.host_configs["8080"].get(+ "/api/v1/user/preferences/welcome_checklist_do_later"+ ),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )++ assert response.status_code == HTTPStatus.OK+ assert response.json()["data"] is not None+ assert response.json()["data"]["value"] is Truediff --git a/tests/integration/src/ttl/a_ttl.py b/tests/integration/src/ttl/a_ttl.pyindex eab9f322c9..57b574c319 100644--- a/tests/integration/src/ttl/a_ttl.py+++ b/tests/integration/src/ttl/a_ttl.py@@ -83,7 +83,9 @@ def test_set_ttl_traces_success(assert all("toIntervalSecond(12960000)" in ttl_part for ttl_part in ttl_parts)-def test_set_ttl_traces_with_cold_storage(signoz: types.SigNoz, get_token: Callable[[str, str], str]):+def test_set_ttl_traces_with_cold_storage(+ signoz: types.SigNoz, get_token: Callable[[str, str], str]+):"""Test setting TTL for traces with cold storage configuration."""payload = {"type": "traces",@@ -292,10 +294,7 @@ def test_set_custom_retention_ttl_basic(retention_col[3] == "100"), f"Expected default value of _retention_days to be 100 in table {table}, but got {retention_col[3]}"- tables_to_check = [- "logs_attribute_keys",- "logs_resource_keys"- ]+ tables_to_check = ["logs_attribute_keys", "logs_resource_keys"]# Query to get table engine info which includes TTLtable_list = "', '".join(tables_to_check)@@ -316,8 +315,8 @@ def test_set_custom_retention_ttl_basic(def test_set_custom_retention_ttl_basic_fallback(signoz: types.SigNoz,get_token,- ttl_legacy_logs_v2_table_setup, # pylint: disable=unused-argument- ttl_legacy_logs_v2_resource_table_setup, # pylint: disable=unused-argument+ ttl_legacy_logs_v2_table_setup, # pylint: disable=unused-argument+ ttl_legacy_logs_v2_resource_table_setup, # pylint: disable=unused-argument):"""Test setting TTL for logs using the new setTTLLogs method."""@@ -354,7 +353,7 @@ def test_set_custom_retention_ttl_basic_fallback("logs_v2","logs_v2_resource","logs_attribute_keys",- "logs_resource_keys"+ "logs_resource_keys",]# Query to get table engine info which includes TTL@@ -678,8 +677,8 @@ def test_get_custom_retention_ttl(def test_set_ttl_logs_success(signoz: types.SigNoz,get_token,- ttl_legacy_logs_v2_table_setup,# pylint: disable=unused-argument- ttl_legacy_logs_v2_resource_table_setup,# pylint: disable=unused-argument+ ttl_legacy_logs_v2_table_setup, # pylint: disable=unused-argument+ ttl_legacy_logs_v2_resource_table_setup, # pylint: disable=unused-argument):"""Test setting TTL for logs using the new setTTLLogs method."""