-
Notifications
You must be signed in to change notification settings - Fork 6
test(metrics): migrate e2e coverage to unified metrics #1820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -206,37 +206,18 @@ def dbt_runner(ch_migrations_applied: SessionConfig): | |||||||||||||||||||||||||||||||||||||||||||||||||||
| runner.cleanup() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _collect_metrics(proc: AnalyticsProcess) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Run `lib/collect_metrics.py` (a script — NOT a test) against the | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| live API, primary worker only. Snapshots the metric catalog into `.artifacts/` | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| so the metric-coverage gate analyses a file with no second app boot. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Best-effort: a failure just means the gate finds no artifact and fails loudly — | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| never abort the session for it. Must run while the API is up (called from | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| analytics teardown, before proc.stop()).""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _collect_metrics(cfg: SessionConfig) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if not _IS_PRIMARY: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import subprocess | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from lib.collect_metric_definitions import collect | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| script = Path(__file__).parent / "lib" / "collect_metrics.py" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| out_dir = Path(__file__).parent / ".artifacts" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| result = subprocess.run( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| sys.executable, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| str(script), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "--url", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| proc.base_url, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "--out-dir", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| str(out_dir), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "--tenant", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| str(TEST_TENANT_ID), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| check=False, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if result.returncode != 0: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| collect(cfg, out_dir) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| except Exception as error: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG.warning( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "coverage-artifact collection failed (rc=%d); gate jobs may lack inputs", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| result.returncode, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "coverage-artifact collection failed: %s; gate jobs may lack inputs", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
214
to
+220
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Fail when coverage artifacts cannot be refreshed. Suppressing this error can leave an old Proposed fix out_dir = Path(__file__).parent / ".artifacts"
- try:
- collect(cfg, out_dir)
- except Exception as error:
- LOG.warning(
- "coverage-artifact collection failed: %s; gate jobs may lack inputs",
- error,
- )
+ collect(cfg, out_dir)📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.15.21)[warning] 217-217: Do not catch blind exception: (BLE001) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -258,7 +239,12 @@ def identity_stub(): | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| @pytest.fixture(scope="session") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| def analytics(ch_migrations_applied: SessionConfig, identity_stub: IdentityStub): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| def analytics( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ch_migrations_applied: SessionConfig, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| dbt_runner: DbtRunner, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| worker_ctx: WorkerContext, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| identity_stub: IdentityStub, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Spawn the analytics binary baked into the runner image. Its SeaORM | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| migrations run on startup; we then upsert test-specific metrics from | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| seed/metrics.yaml. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -270,6 +256,7 @@ def analytics(ch_migrations_applied: SessionConfig, identity_stub: IdentityStub) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| bronze→API tests cannot run, so the only honest result is red. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| cfg = ch_migrations_applied | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| dbt_runner.run("tag:gold", worker_ctx=worker_ctx) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from lib.analytics import ApiSpawnError # local import to keep top clean | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| binary = locate_binary(cfg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -280,11 +267,8 @@ def analytics(ch_migrations_applied: SessionConfig, identity_stub: IdentityStub) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| proc.start() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| seed_test_metrics(cfg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield proc | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Snapshot the metric catalog while the API is still up (a script, run via | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # subprocess — see _collect_metrics). Always | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # stop the process afterward, even if collection raised. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| _collect_metrics(proc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| _collect_metrics(cfg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| finally: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| proc.stop() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Remove the remaining legacy coverage instructions.
The following Lines 110-115 are now stale: the ad-hoc command omits required
--universe-file, and the “44/96 skip-listed” statement contradicts this section’s registry-driven, no-skip-list gate.🧰 Tools
🪛 LanguageTool
[grammar] ~97-~97: Ensure spelling is correct
Context: ...Bronze to API** workflow checks enabled builtin product definitions. The metrics lane s...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~97-~97: Ensure spelling is correct
Context: ...ons.json`; the gate then verifies every builtin has period, peer, and timeseries assert...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🤖 Prompt for AI Agents