test(BA-7836): add scenario tests for the prometheus query preset adapter - #14518
Draft
jopemachine wants to merge 11 commits into
Draft
test(BA-7836): add scenario tests for the prometheus query preset adapter#14518jopemachine wants to merge 11 commits into
jopemachine wants to merge 11 commits into
Conversation
jopemachine
added a commit
that referenced
this pull request
Sep 11, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sm7zNnhABQq1BSebraixh5
This was referenced Sep 11, 2026
jopemachine
added a commit
that referenced
this pull request
Sep 11, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sm7zNnhABQq1BSebraixh5
jopemachine
force-pushed
the
test/BA-7836-preset-scenarios
branch
from
September 11, 2026 03:59
a27e021 to
6e6c77b
Compare
jopemachine
added a commit
that referenced
this pull request
Sep 11, 2026
Split from the CI run of #14518 after the stand-in began echoing the query, where all 54 preset rows passed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sm7zNnhABQq1BSebraixh5
…pter Replace the TODO stub in the preset adapter's KNOWLEDGE.md with the 55 rows the adapter guarantees (8 calls), transcribe 45 of them into tests/scenario/bai_scenario/manager/prometheus_query_preset/, and add the report.md split from the CI run of #14508, where every row passed. Add SeedPreset and SeedPresetIn, which lay rows through the creator alone so a template the renderer would refuse can still be stored, and FakePrometheusClient, which answers one sample for every query and keeps what it was asked. The rows that read what the stand-in received, or need it to answer an error, wait for the runner to hand fakes to `then` (BA-7830). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sm7zNnhABQq1BSebraixh5
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sm7zNnhABQq1BSebraixh5
The stand-in now answers every query with one sample whose value is the PromQL it was asked, a matrix for a range query and a vector for an instant one, and refuses an empty query as Prometheus does. That lets the rows on the window fallback, the range, the labels reaching the query and Prometheus refusing a query run against the answer, so the preset table covers every row of its document (54 over 8 modules). Also list the scenarios at module level as the other tables do, and say in the document that lending a preset into a scope by a share is not this table's concern. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sm7zNnhABQq1BSebraixh5
Split from the CI run of #14518 after the stand-in began echoing the query, where all 54 preset rows passed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sm7zNnhABQq1BSebraixh5
The preset table laid its categories and its caller through the category table's seed and helper, which stacked this branch on #14514. It now carries a category seed and the caller helper of its own, so the two land independently; whichever merges second can drop its copy. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sm7zNnhABQq1BSebraixh5
jopemachine
force-pushed
the
test/BA-7836-preset-scenarios
branch
from
September 11, 2026 04:15
2dc9d33 to
d3ff86e
Compare
jopemachine
changed the base branch from
test/BA-7835-preset-category-scenarios
to
main
September 11, 2026 04:15
The preset has no soft delete, only a purge, so the module the domain and deployment tables call retiring is purging here. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sm7zNnhABQq1BSebraixh5
… user Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sm7zNnhABQq1BSebraixh5
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sm7zNnhABQq1BSebraixh5
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013qjgCzggSejnvDrLt4tG3a
…set scenarios for readability The knowledge document, the component docstrings and every scenario sentence used a terse, metaphorical style (문, 줄, 훑기, 심다, 실리다, 대역, 창, 묶음) that did not read at a glance. Rewrite them in plain technical Korean: 프리셋/카테고리 for the entities, 모의 서버 for the fake Prometheus, 시간 창 and 그룹 라벨 for the window and group labels, 생성/조회/검색/수정/삭제 for the operations, 권한 검사 for enforcement, 미리 만들어 둔 for seeded data, and 역할 부족으로 거부 for the role refusals. report.md follows from the CI run in the next commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NQiEEB2mfJtFWnMnHLDFnT
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013qjgCzggSejnvDrLt4tG3a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves BA-7836
Summary
api/adapters/prometheus_query_preset/KNOWLEDGE.mdwith the scenarios the adapter guarantees — 8 calls / 54 rows — in the shapeapi/adapters/domain/KNOWLEDGE.mdandapi/adapters/deployment/KNOWLEDGE.md(test(BA-7806): add scenario tests for the deployment adapter's own calls #14501) set.tests/scenario/bai_scenario/manager/prometheus_query_preset/(8 modules) and add thereport.mdsplit from the CI run. Every public call of the adapter is called by at least one row.SeedPreset/SeedPresetIn(rows laid through the creator alone, so a template the renderer would refuse can still be stored),FakePrometheusClient, and aSeedCategoryof its own for the rows that file a preset under a category. The category seed and the caller helper (lay_someone) are duplicated in test(BA-7835): add scenario tests for the prometheus query preset category adapter #14514 so the two PRs land independently; whichever merges second can drop its copy.How the Prometheus rows are verified without a runner change: the stand-in answers every query with one sample whose value is the PromQL it was asked, a matrix for a range query and a vector for an instant one, and refuses an empty query the way Prometheus does (
parse error: no expression found). A row therefore states the exact query that reached Prometheus —avg by () (rate(container_cpu_seconds_total{}[1h]))— and the "Prometheus refuses" rows run a template that renders to an empty query when no label is given.What the rows pin, worth a reviewer's eye:
global_search_container_metrics,public_search_container_metric_metadata,search_user_container_metrics) have no adapter and are consumed by legacy GraphQL only, so they are named in the document and kept out of the tables.Judgment calls
Decisions a reviewer may want to overturn; none of them is settled by a rule I could find.
fakes/prometheus.pythencan read what reached Prometheus off the answer. It also runs the real renderer, so a template the client could not render is refused in the fake as in the client.then).fakes/prometheus.pyFailedToGetMetric, modelled on Prometheus's own 400 for an empty query; the "Prometheus refuses" rows lean on it.test_creating.pytest_creating.py,test_editing.pyForeignKeyViolationError, because nothing maps it to a domain error.test_executing.pyPrometheusQueryPresetNotFound(the service reads the preset itself) while update / purge expectEntityNotFoundError(the ops path); the asymmetry is pinned as is.test_creating.py,test_previewing.pytest_reading.py,test_searching.pyUserNotFound).test_editing.py,test_executing.py,test_retiring.pycomponents/prometheus_query_preset.pynode_of), which mirrors the adapter's_data_to_dtofield list in test code.Split out of #14508. Independent of #14514 (prometheus_query_preset_category), which covers the sibling entity.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Sm7zNnhABQq1BSebraixh5