Skip to content

test(o11ylogsdb): unit test suite (82 tests, 8 files)#182

Merged
strawgate merged 2 commits into
mainfrom
o11ylogsdb-tests
Apr 26, 2026
Merged

test(o11ylogsdb): unit test suite (82 tests, 8 files)#182
strawgate merged 2 commits into
mainfrom
o11ylogsdb-tests

Conversation

@strawgate
Copy link
Copy Markdown
Owner

Summary

Locks down the engine's invariants before the codec stack starts swapping in Rust/WASM behind it. All TS-only against the existing `src/`. 82 tests across 8 files; full repo suite goes from 479 → 561 tests.

  • chunk.test.ts — ChunkBuilder semantics, wire-format round-trip, `chunkWireSize` matches `serializeChunk(c).length`, `ChunkPolicy` hooks (preEncode/postDecode + encodePayload/decodePayload).
  • stream.test.ts — StreamRegistry interning + chunk-list ordering.
  • drain.test.ts — tokenize / similarity / mergeTemplate, Drain matchOrAdd / matchTemplate / reconstruct, whitespace normalization contract.
  • engine.test.ts — LogStore append/flush/iterRecords, row-cap chunking, stats(), per-stream policyFactory.
  • policy-roundtrip.test.ts — every shipped `ChunkPolicy` (Default, ColumnarRaw, ColumnarDrain, DrainChunk, TypedColumnar) round-trips records. Adds typed-slot detector cases (PREFIXED_INT64, UUID, SIGNED_INT, sub-threshold STRING fallback).
  • query.test.ts — time range, severity zone-map pruning, resourceEquals, bodyContains, bodyLeafEquals dot-paths, limit; chunksPruned / streamsPruned stats.
  • compact.test.ts — compactChunk re-encodes payload, preserves records, no-ops on same codec, doesn't mutate input.
  • public-api.test.ts — smoke check on the index.ts export surface.

Why now

Next milestone is M0 (codec workspace migration) and M1/M2 (Rust crates for FSST, binary fuse, Drain). Each one swaps in a new implementation behind the same interface. Tests give a regression net before that work starts.

Test plan

  • `npx vitest run packages/o11ylogsdb/test/` — 82 passed
  • `npx vitest run --coverage` — 561 passed across 40 files (no regressions)
  • `npm run typecheck:packages` — passes
  • `npx biome check packages/o11ylogsdb` — 0 warnings

🤖 Generated with Claude Code

Locks down the engine's invariants before the codec stack starts
swapping in Rust/WASM behind it. All tests are TS-only against the
existing `src/` implementation.

Files and what they cover:

- chunk.test.ts: ChunkBuilder freeze semantics (empty chunk, time
  range, severity zone-map, resource/scope hoisting); wire-format
  serialize/deserialize round-trip; chunkWireSize == serializeChunk
  length; ChunkPolicy hooks (preEncode/postDecode meta blob,
  encodePayload/decodePayload bypass).
- stream.test.ts: StreamRegistry interns same id for ref-equal and
  structurally-equal (resource, scope) tuples, separates by service
  or scope, preserves chunk insertion order, throws on unknown id.
- drain.test.ts: tokenize, similarity, mergeTemplate; Drain
  matchOrAdd / matchTemplate / reconstruct; whitespace
  normalization; default config matches the published reference.
- engine.test.ts: LogStore append/flush/iterRecords; rowsPerChunk
  cap closes chunks; stats() bytes/log; policyFactory creates one
  policy per stream and reuses across chunks.
- policy-roundtrip.test.ts: every shipped ChunkPolicy
  (Default/ColumnarRaw/ColumnarDrain/Drain/TypedColumnar) round-
  trips records on templated, single-record, and empty chunks.
  Adds slot-detector cases for TypedColumnar (PREFIXED_INT64, UUID,
  SIGNED_INT, sub-threshold STRING fallback).
- query.test.ts: time range, severity zone-map pruning,
  resourceEquals, bodyContains, bodyLeafEquals dot-paths, limit;
  chunksPruned / streamsPruned stats accuracy.
- compact.test.ts: compactChunk re-encodes payload, preserves
  records, no-ops when target == current, doesn't mutate input.
- public-api.test.ts: smoke check that the index.ts surface exports
  every documented symbol; catches accidental drops on refactor.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 26, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 26, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 58b85296-f7d2-42e1-b121-570124187c6a

📥 Commits

Reviewing files that changed from the base of the PR and between fae1e75 and dde70ff.

📒 Files selected for processing (1)
  • packages/o11ylogsdb/test/query.test.ts

Walkthrough

This PR adds comprehensive test coverage to the o11ylogsdb package via seven new Vitest modules. Tests cover chunk creation/serialization, compaction and codec conversion, Drain template clustering, LogStore engine behaviors (append, chunking, iteration, stats), chunk policy encode/decode round-trips, public API exports, query filtering/pruning, and StreamRegistry internment. All changes are test-only; no exported or public entity declarations were modified.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@dosubot dosubot Bot added the javascript Pull requests that update javascript code label Apr 26, 2026
@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented Apr 26, 2026

Note

Your trial team has used its Gitar budget, so automatic reviews are paused. Upgrade now to unlock full capacity. Comment "Gitar review" to trigger a review manually.
Learn more about usage limits

Code Review 👍 Approved with suggestions 0 resolved / 1 findings

Comprehensive unit test suite for o11ylogsdb coverage. Update the checkout comment on line 23 to accurately reflect the seven records appended.

Auto-approved: The PR adds a comprehensive unit test suite with 82 tests across 8 files for existing functionality, ensuring robust coverage without modifying production code logic.

💡 Quality: Comment says "8 records" but only 7 are appended for checkout

📄 packages/o11ylogsdb/test/query.test.ts:23

The comment on line 23 says // checkout: 8 records spanning t=1000-7000 but only 7 store.append(resA, …) calls follow (t=1000, 2000, 3000, 4000, 5000, 6000, 7000). The test assertions themselves are consistent with 7 records (e.g., recordsScanned = 11 = 7 + 4), so the tests pass correctly — only the comment is misleading.

Suggested fix
- // checkout: 8 records spanning t=1000-7000, mixed severities
+ // checkout: 7 records spanning t=1000-7000, mixed severities
🤖 Prompt for agents
Code Review: Comprehensive unit test suite for o11ylogsdb coverage. Update the checkout comment on line 23 to accurately reflect the seven records appended.

1. 💡 Quality: Comment says "8 records" but only 7 are appended for checkout
   Files: packages/o11ylogsdb/test/query.test.ts:23

   The comment on line 23 says `// checkout: 8 records spanning t=1000-7000` but only 7 `store.append(resA, …)` calls follow (t=1000, 2000, 3000, 4000, 5000, 6000, 7000). The test assertions themselves are consistent with 7 records (e.g., `recordsScanned` = 11 = 7 + 4), so the tests pass correctly — only the comment is misleading.

   Suggested fix:
   - // checkout: 8 records spanning t=1000-7000, mixed severities
   + // checkout: 7 records spanning t=1000-7000, mixed severities

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Important

Your trial ends in 6 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more.

Was this helpful? React with 👍 / 👎 | Gitar

Comment thread packages/o11ylogsdb/test/query.test.ts Outdated
const resA: Resource = { attributes: [{ key: "service.name", value: "checkout" }] };
const resB: Resource = { attributes: [{ key: "service.name", value: "payments" }] };
const store = new LogStore({ rowsPerChunk: 4 });
// checkout: 8 records spanning t=1000-7000, mixed severities
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Quality: Comment says "8 records" but only 7 are appended for checkout

The comment on line 23 says // checkout: 8 records spanning t=1000-7000 but only 7 store.append(resA, …) calls follow (t=1000, 2000, 3000, 4000, 5000, 6000, 7000). The test assertions themselves are consistent with 7 records (e.g., recordsScanned = 11 = 7 + 4), so the tests pass correctly — only the comment is misleading.

Suggested fix:

- // checkout: 8 records spanning t=1000-7000, mixed severities
+ // checkout: 7 records spanning t=1000-7000, mixed severities

Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion

Copy link
Copy Markdown

@gitar-bot gitar-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitar has auto-approved this PR (configure)

Comment said 8 records but only 7 appends follow. Test math
(recordsScanned = 7 + 4 = 11) was already correct; just the
comment was wrong. Bot-flagged on PR #182.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@strawgate strawgate merged commit 273aaf3 into main Apr 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant