mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-04 00:08:55 +00:00
## Alert Library A curated catalog at `/alert-library`: browse packs of ready-made alerts, see which ones can actually run against the streams this org already receives, preview a verdict against real data, and install one or many. The library is a **peer page** of Alerts / Notification Destinations / Templates — flat routing, presented as tabs via a shared `AlertSectionTabs` in `OPageLayout #header-tabs` (the pattern `PipelineSectionTabs` already ships). ### What landed, by phase | Phase | What | | --- | --- | | Data layer | S3 manifest fetch, cache, readiness resolution (`useAlertLibrary`, `constants/alertLibrary`, `types/alertLibrary`) | | Gallery | Rail (packs / categories, multi-select, segmented switch), stat-strip availability facets, cards | | Drawer | Detail view with query preview and customizable tunables | | Install | Bulk-install wizard — destination selection, per-alert tunables, stale-session hardening | | Prefill | Carry a library alert (query, trigger, threshold, severity) into the alert editor | ### Design decisions worth knowing - **Rail navigates, strip filters.** Availability is deliberately not in the rail — carrying both overflowed it and pushed a facet group below the fold. - **Colour marks the exception only.** No "Ready" pill (it would describe ~75 of 86 cards and signal nothing); only unusable cards carry a label. - **A failed `/streams` call leaves readiness unknown**, rather than claiming "none of your data matches" — that claim would be about the request, not the org, and it is the most alarming thing this page can say. Counts read `—` until there is an answer, and a failed *refresh* keeps the verdict it already had. - **No "Installed" tile** — installed detection doesn't exist yet, and a tile reading a permanent zero is dishonest UI. - **`severity: warning` renders as `medium`** — the badge group's scale is critical/high/medium/low/info, and medium is the amber it also gives P3, which is exactly the priority a warning alert installs as. - Pack and category names come from the manifest, so they render as `raw()` data — a pack added upstream needs no frontend release. ### Design-system changes (used by the library, applied app-wide) - **`warning-quiet` badge tone** — one variant whose values differ by theme: the soft amber wash in light, a neutral chip in dark. Neither the filled amber chip nor the neutral one was right in both, because the two ramps aren't symmetric. - **Border tokens now meet WCAG 2.1 SC 1.4.11.** Every border token measured under 3:1 (`border-strong` was 2.52:1). `border-default` firms to grey-300 and controls get a token that clears 3:1. - Nav: Reliability's flyout groups its four alerting entries under one **Alerts** header, declared in the same order as the tab strip those pages carry. Flyout levels are sized by depth. - `sensors-off` icon added to the `OIcon` registry. ### Fixes that rode along - **metrics**: a shared URL whose `metrics_data` blob omits panel query fields no longer blanks the whole metrics page — blob queries are filled out to the panel schema before being laid over. - **dashboards**: a PromQL series with no legend template was named `JSON.stringify(metric)`, so fifty series read identically for the width of the chip. Series are now named by the labels that actually differ, preferring the ones that say *which workload* it is (namespace / service / pod / host). Correlation's semantic groups refine that when loaded, but nothing is fetched to render a chart — that endpoint is enterprise-only and a chart must render the same on OSS. - **alerts**: preview evaluates against the alert's real trigger; deleting a row no longer reloads the list behind it; peer tabs no longer shift when switching alerting pages. - **ui**: badge-only select options no longer render bold. ### Tests - `test(search)`: pins the streaming-aggregate **wire contract** at the HTTP boundary. Under streaming aggregates each partition carries the cumulative merged state (last frame is the answer) while ordinary partitions are disjoint and must be summed. No pytest had ever received `streaming_aggs: true` — the emitter could have flipped to per-partition deltas with the whole suite green while dashboards, Logs and the alert preview all silently over-counted. - `test(e2e)`: four helpers that passed only while an org stayed small — an assertion reading past a 20-row page, an unfiltered `OSelect` that virtualises past 50 entries, a tab click landing on the rename pencil, and two builder tests asserting on whichever metric sorted first. - New unit specs across the library components, composable, facets, tunables and install path. ### Notes - **i18n**: en-US only; CI generates the other 14 locales. - **No backend changes** — this branch is entirely `web/` plus test helpers.
OpenObserve API Tests
End-to-end pytest suite against the OpenObserve REST API. Runs in CI on every
PR (.github/workflows/api-testing.yml); also runnable locally.
Quick start
# one-time setup
brew install rye # or: curl -sSf https://rye.astral.sh/get | bash
rye sync # install Python + deps from requirements.lock
cargo build # build the OO debug binary (~10 min first time)
# every run
ZO_ROOT_USER_EMAIL=root@example.com \
ZO_ROOT_USER_PASSWORD='Complexpass#123' \
ZO_BASE_URL=http://localhost:5080/ \
WS_ZO_BASE_URL=ws://localhost:5080/ \
target/debug/openobserve &
rye run pytest # full suite
rye run pytest -m framework # just the new-framework self-tests
rye run pytest tests/test_kvstore.py -v # one file
Layout
tests/api-testing/
├── pyproject.toml # pytest + ruff config
├── conftest.py # legacy session-wide fixtures (do not extend)
├── support/ # NEW FRAMEWORK — write new tests against this
│ ├── client.py # OpenObserveClient: HTTP entry point
│ ├── endpoints/ # one wrapper class per resource group
│ │ ├── search.py # client.search.sql(...), .hits(...), .count(...)
│ │ ├── streams.py # client.streams.list(), .delete(...), .ingest_json(...)
│ │ ├── users.py
│ │ ├── dashboards.py
│ │ ├── alerts.py
│ │ ├── folders.py
│ │ └── kvstore.py
│ ├── factories.py # payload builders (user_payload, dashboard_payload, …)
│ ├── wait.py # wait_until(predicate, timeout, ...) — REPLACES time.sleep
│ └── fixtures.py # client, temp_stream_name, temp_user_email, …
├── tests/ # test files
│ ├── conftest.py
│ ├── test_framework_selfcheck.py # 14 tests that prove support/ works
│ └── test_*.py # 40+ legacy test files (in revamp progress)
├── helpers/ # non-test shared code
│ ├── sourcemap_helpers.py
│ └── workflow/ # workflow chain helpers (with embedded pages/)
├── fixtures/ # static test data
│ └── rum/ # RUM ingest scripts
└── README.md # this file
Writing a new test — the rules
Use the new framework. Don't copy-paste from old test_*.py files; they
are scheduled for rewrite (see revamp plan).
# tests/<area>/test_my_feature.py
from support.client import OpenObserveClient
from support.factories import user_payload
from support.fixtures import client, temp_user_email # noqa: F401
from support.wait import wait_until
def test_create_user_returns_complete_record(client: OpenObserveClient, temp_user_email: str):
"""Create a user — verify the response has the email AND role we sent."""
payload = user_payload(email=temp_user_email, role="admin")
resp = client.users.create(payload)
assert resp.status_code == 200, resp.text
body = resp.json()
# VALIDATE THE BODY, not just status_code
assert body.get("data", {}).get("email") == temp_user_email
assert body.get("data", {}).get("role") == "admin"
# cleanup happens automatically via temp_user_email fixture
Mandatory patterns
| ✅ Do | ❌ Don't |
|---|---|
from support.fixtures import client |
session = create_session; url = base_url; org_id = "default" (307 occurrences in legacy code) |
client.streams.list() |
session.get(f"{url}api/{org_id}/streams") |
body = resp.json(); assert body["foo"] == ... |
assert resp.status_code == 200 and stop |
wait_until(lambda: client.search.count(sql) >= N, timeout=30) |
time.sleep(5) |
unique_email("user") / temp_user_email fixture |
hardcoded pytests@gmail.com |
logger.debug("got %s", resp.status_code) |
print(resp.content) |
start, end = time_window(minutes=15) |
hardcoded start_time = 1700629279639000 |
Anti-patterns that fail review
assert resp.status_code in [200, 400, 404, 500]— pick one. If the API behaves wrongly, file a bug; don't paper over it.pytest.skip(...)when the test discovers the bug it's meant to catch — use@pytest.mark.xfail(strict=True).- Commented-out test functions — delete them.
pages.*direct imports — that subtree is legacy. New tests usesupport.client.
Lint
rye run ruff check support/ tests/test_framework_selfcheck.py # strict mode
rye run ruff check --fix support/ # autofix
Existing legacy tests have a per-file ruff-ignore (so print etc. don't fail
the whole suite); new tests under support/ and any new well-formed test
file should pass strict ruff.
Test markers
| Marker | Meaning |
|---|---|
framework |
Self-tests for support/ framework. Run with -m framework. |
order(N) |
Run order pin (legacy — avoid in new tests). |
Troubleshooting
KeyError: 'ZO_BASE_URL'on collection —conftest.pyreads env vars at import. Export them before running pytest (even--collect-only).test_workflow.pyfails with SMTP error —ZO_SMTP_ENABLED=truenot set. CI does this; locally you'd need to wire an SMTP env.- Test_organisations.py warning about
yield—test_create_organizationuses pre-pytest-4 yield-style and is silently ignored. Scheduled for rewrite in Phase 4.
Revamp in progress
This suite is being incrementally reworked. See:
../../tests/ui-testing/MD_Files/api tests revamp/API_TESTS_REVAMP.md— the plan../../tests/ui-testing/MD_Files/api tests revamp/oss_rework_progress/— phase-by-phase progress