## Summary - **Fixed** `Not Known / Other` → `Unknown / Other` (grammar error) - **Removed** `Data Sources` — no dedicated page exists in the codebase, fully covered by `Ingestion` - **Renamed** `Landing Page` → `Home` — matches route name, component name, and enterprise template - **Renamed** `Cosmetic` → `UI / Styling` — clearer and more descriptive 17 checkboxes (down from 18). ## Test plan - [ ] Verify template renders correctly in GitHub issue form: `https://github.com/openobserve/openobserve/issues/new?template=bug-report-template-latest.yaml` - [ ] Confirm all 17 checkboxes appear and are selectable 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| tests | ||
| .gitignore | ||
| README.md | ||
| pyproject.toml | ||
README.md
Database Validation Tests
This directory contains database validation tests for OpenObserve. These tests ingest data via the API and then validate the database state by directly querying the metadata database.
Purpose
These tests are separate from:
- Rust integration tests (
tests/integration_test.rs) - To avoid increasing PR CI time - API tests (
tests/api-testing/) - Different concern: DB state validation vs API endpoint testing
Structure
tests/db-testing/
├── README.md # This file
├── pyproject.toml # Python project configuration (auto-generated in CI)
├── requirements.lock # Locked dependencies (managed by rye)
└── tests/
├── conftest.py # Pytest fixtures and configuration
└── test_*.py # Test files
Dependencies
pytest- Test frameworkrequests- HTTP client for API callspsycopg2-binary- PostgreSQL database driverpython-dotenv- Environment variable management
Running Tests Locally
Prerequisites
-
Install rye:
curl -sSf https://rye.astral.sh/get | bash -
Build OpenObserve:
cargo build --features mimalloc -
Start a PostgreSQL instance:
docker run -d \ --name postgres-test \ -e POSTGRES_PASSWORD=password \ -p 5432:5432 \ postgres:17.5-alpine3.22
Run Tests
-
Start OpenObserve with Postgres backend:
export ZO_META_STORE=postgres export ZO_META_POSTGRES_DSN=postgres://postgres:password@localhost:5432/postgres export ZO_ROOT_USER_EMAIL=root@example.com export ZO_ROOT_USER_PASSWORD=Complexpass#123 target/debug/openobserve -
In another terminal, run the tests:
cd tests/db-testing rye sync # Install dependencies rye run pytest -v
Writing Tests
Test Structure
Each test should follow this pattern:
- Ingest data via the OpenObserve API
- Query the database directly to validate state
- Assert that the database state matches expectations
Example Test
def test_my_validation(ingest_test_data, db_cursor, test_org, test_stream):
"""Test description."""
# 1. Ingest test data
test_data = [{"timestamp": "...", "field": "value"}]
ingest_test_data(test_data)
# 2. Query database
db_cursor.execute("""
SELECT * FROM meta
WHERE org_id = %s
AND key2 = %s
""", (test_org, test_stream))
results = db_cursor.fetchall()
# 3. Validate
assert len(results) > 0, "Expected data not found"
Available Fixtures
db_connection- PostgreSQL connection (session-scoped)db_cursor- Database cursor for queriesingest_test_data- Function to ingest data via APIquery_api- Function to query OpenObserve search APIopenobserve_base_url- OpenObserve API base URLauth_credentials- Authentication credentials tupletest_org- Test organization name (default: "default")test_stream- Test stream name (default: "db_test_stream")
CI Integration
Tests run automatically in the db-testing.yml GitHub Actions workflow on:
- Push to
mainbranch - Pull requests to any branch
The workflow:
- Starts a PostgreSQL service
- Builds OpenObserve
- Configures OpenObserve to use Postgres
- Runs pytest tests
- Uploads logs on failure
Database Schema Reference
The meta table structure (adjust based on your actual schema):
CREATE TABLE meta (
id SERIAL PRIMARY KEY,
org_id VARCHAR(100),
module VARCHAR(100),
key1 VARCHAR(256),
key2 VARCHAR(256),
start_dt BIGINT,
value TEXT,
-- ... other columns
);
Common modules:
schema- Stream schemasstream_settings- Stream configurationfile_list- File metadataorganization- Organization settingsuser- User data
Tips
- Use transactions in tests when you need to clean up (though fixtures handle most cleanup)
- Wait for ingestion - Data ingestion is async, use
wait_for_ingestion()helper - Print debug info - Use
print()statements to debug queries during development - Test isolation - Each test should be independent and not rely on other tests
- Database state - Tests query a shared database; use unique stream names if needed
Troubleshooting
Tests fail with "connection refused"
- Ensure PostgreSQL is running and accessible
- Check
ZO_META_POSTGRES_DSNenvironment variable
Tests fail with "table not found"
- OpenObserve may not have initialized the database schema
- Check OpenObserve logs for migration errors
Tests timeout
- Increase wait times in
wait_for_ingestion() - Check if OpenObserve is running and healthy
Future Enhancements
- Add SQLite backend testing
- Add tests for data compaction
- Add tests for schema evolution
- Add tests for multi-tenancy
- Add performance/load tests
- Add tests for backup/restore operations