mirror of
https://github.com/SigNoz/signoz.git
synced 2026-06-25 09:30:31 +01:00
* chore(frontend): remove stale e2e scaffold
frontend/e2e/ held an unused settings-only test-plan scaffold from Oct 2025.
Active Playwright specs live at tests/e2e/. Drop the directory, the orphan
playwright.config.ts, the @playwright/test dependency, and the tsconfig
references that pinned them.
* chore(e2e): migrate formatter from prettier to oxfmt
Swap tests/e2e/ onto oxfmt — same tool the frontend adopted in #11057. Style
matches frontend/.oxfmtrc.json (tabs, tabWidth:1) so the two TS trees stay
visually consistent. Drops .prettierrc.json and .prettierignore, adds the
fmt/fmt:check yarn scripts, and reformats the existing specs.
* chore(e2e): migrate linter from eslint to oxlint
Drop eslint + @typescript-eslint plugins in favour of oxlint 1.59 + tsgolint
— same toolchain the frontend adopted in #10176. The .oxlintrc.json mirrors
frontend/.oxlintrc.json with plugins scoped to a Playwright TS codebase
(eslint, typescript, unicorn, import, promise).
Divergence: eslint-plugin-playwright is not ported. Its rules depend on
ESLint APIs (context.getAncestors) that oxlint's JS plugin shim does not
implement, so the five playwright/* rules are dropped in this migration.
* ci(e2e): add fmtlint job
Mirror integrationci.yaml's fmtlint job for e2e. Runs oxfmt --check and
oxlint on tests/e2e/ under the same safe-to-e2e label gating as the
existing test job.
* chore(integration): migrate python tooling from black/pylint/isort/autoflake to ruff
Replace the four-tool stack with ruff — same motivation as the oxfmt/oxlint
swap on the TS side. One tool covers formatting (ruff format), import
sorting (I), unused-import/variable cleanup (F401/F841), and the pylint
rules we actually care about (E/W/F/UP/B/PL).
Rule set mirrors the intent of the prior pylint config: too-many-* checks
and magic-value-comparison stay disabled, dangerous-default-value (now
B006) stays muted. A handful of newly-surfaced codes (B011/B024/B905/E741/
UP047/PLC0206/PLW2901) are also muted to keep this a pure tool swap — each
deserves its own review before enabling.
Divergence: ruff caps line-length at 320, so the prior pylint value of 400
drops to 320. Nothing in tree exceeds 320, so no lines wrap.
No changes to integrationci.yaml — both fmt/lint steps still call
make py-fmt / make py-lint, which now dispatch to ruff.
* chore(e2e): restore playwright lint rules via oxlint jsPlugin
eslint-plugin-playwright@2.x was rewritten against ESLint 8's
context.sourceCode.getAncestors() API, which oxlint's JS plugin shim
exposes. The 0.16.x version previously ruled out by context.getAncestors()
missing is no longer a blocker. Bump to 2.10.2, re-add it as a jsPlugin,
and restore the five rules dropped in the initial oxlint migration:
expect-expect, no-conditional-in-test, no-page-pause, no-wait-for-timeout,
prefer-web-first-assertions.
Rule count: 104 → 109.
* chore(frontend): remove stale e2e prompt
frontend/prompts/generate-e2e-test.md is leftover from the same Oct 2025
scaffold removed in ebf735dcc. It references frontend/e2e/utils/login.util.ts,
which no longer exists, and is not wired into anything.
* chore(e2e): make .env.local write layout explicit
The single f-string with inline \n escapes read as a wall of text after
ruff's line-length allowance collapsed it onto one line. Switch to a
triple-quoted f-string so the generated .env.local structure is visible
in source. Byte-for-byte identical output.
* chore(e2e): write .env.local one key per line
Open the file with a context manager and emit each key with its own
f.write call. Same output as before, but each key-value pair is a
discrete statement.
103 lines
3.8 KiB
Python
103 lines
3.8 KiB
Python
import docker
|
|
import docker.errors
|
|
import pytest
|
|
from sqlalchemy import create_engine, sql
|
|
from testcontainers.core.container import Network
|
|
from testcontainers.postgres import PostgresContainer
|
|
|
|
from fixtures import reuse, types
|
|
from fixtures.logger import setup_logger
|
|
|
|
logger = setup_logger(__name__)
|
|
|
|
|
|
@pytest.fixture(name="postgres", scope="package")
|
|
def postgres(network: Network, request: pytest.FixtureRequest, pytestconfig: pytest.Config) -> types.TestContainerSQL:
|
|
"""
|
|
Package-scoped fixture for PostgreSQL TestContainer.
|
|
"""
|
|
|
|
def create() -> types.TestContainerSQL:
|
|
version = request.config.getoption("--postgres-version")
|
|
|
|
container = PostgresContainer(
|
|
image=f"postgres:{version}",
|
|
port=5432,
|
|
username="signoz",
|
|
password="password",
|
|
dbname="signoz",
|
|
driver="psycopg2",
|
|
)
|
|
container.with_network(network)
|
|
container.start()
|
|
|
|
engine = create_engine(f"postgresql+psycopg2://{container.username}:{container.password}@{container.get_container_host_ip()}:{container.get_exposed_port(5432)}/{container.dbname}")
|
|
|
|
with engine.connect() as conn:
|
|
result = conn.execute(sql.text("SELECT 1"))
|
|
assert result.fetchone()[0] == 1
|
|
|
|
return types.TestContainerSQL(
|
|
container=types.TestContainerDocker(
|
|
id=container.get_wrapped_container().id,
|
|
host_configs={
|
|
"5432": types.TestContainerUrlConfig(
|
|
"postgresql",
|
|
container.get_container_host_ip(),
|
|
container.get_exposed_port(5432),
|
|
)
|
|
},
|
|
container_configs={"5432": types.TestContainerUrlConfig("postgresql", container.get_wrapped_container().name, 5432)},
|
|
),
|
|
conn=engine,
|
|
env={
|
|
"SIGNOZ_SQLSTORE_PROVIDER": "postgres",
|
|
"SIGNOZ_SQLSTORE_POSTGRES_DSN": f"postgresql://{container.username}:{container.password}@{container.get_wrapped_container().name}:{5432}/{container.dbname}",
|
|
"SIGNOZ_SQLSTORE_POSTGRES_DBNAME": container.dbname,
|
|
"SIGNOZ_SQLSTORE_POSTGRES_USER": container.username,
|
|
"SIGNOZ_SQLSTORE_POSTGRES_PASSWORD": container.password,
|
|
},
|
|
)
|
|
|
|
def delete(container: types.TestContainerSQL):
|
|
client = docker.from_env()
|
|
try:
|
|
client.containers.get(container_id=container.container.id).stop()
|
|
client.containers.get(container_id=container.container.id).remove(v=True)
|
|
except docker.errors.NotFound:
|
|
logger.info(
|
|
"Skipping removal of Postgres, Postgres(%s) not found. Maybe it was manually removed?",
|
|
{"id": container.container.id},
|
|
)
|
|
|
|
def restore(cache: dict) -> types.TestContainerSQL:
|
|
container = types.TestContainerDocker.from_cache(cache["container"])
|
|
host_config = container.host_configs["5432"]
|
|
env = cache["env"]
|
|
|
|
engine = create_engine(f"postgresql+psycopg2://{env['SIGNOZ_SQLSTORE_POSTGRES_USER']}:{env['SIGNOZ_SQLSTORE_POSTGRES_PASSWORD']}@{host_config.address}:{host_config.port}/{env['SIGNOZ_SQLSTORE_POSTGRES_DBNAME']}")
|
|
|
|
with engine.connect() as conn:
|
|
result = conn.execute(sql.text("SELECT 1"))
|
|
assert result.fetchone()[0] == 1
|
|
|
|
return types.TestContainerSQL(
|
|
container=container,
|
|
conn=engine,
|
|
env=env,
|
|
)
|
|
|
|
return reuse.wrap(
|
|
request,
|
|
pytestconfig,
|
|
"postgres",
|
|
lambda: types.TestContainerSQL(
|
|
container=types.TestContainerDocker(id="", host_configs={}, container_configs={}),
|
|
conn=None,
|
|
env={},
|
|
),
|
|
create,
|
|
delete,
|
|
restore,
|
|
)
|