tests — observability

Module: tests-observability Cohesion: 0.80 Members: 0

tests — observability

This document describes the run-store.test.ts module, which is the test suite for the RunStore class located in src/observability/run-store.ts.

RunStore Test Suite Documentation

Introduction

The run-store.test.ts module provides comprehensive unit and integration tests for the RunStore class. RunStore is a critical component responsible for managing the lifecycle, events, metrics, and artifacts of individual execution runs within the system. This test suite ensures the reliability, data integrity, and correct behavior of RunStore's persistence and retrieval mechanisms.

Purpose of the Test Suite

The primary purpose of this test suite is to:

  1. Verify Core Functionality: Ensure that RunStore correctly creates, updates, and retrieves run data, including events, metrics, and artifacts.
  2. Validate Data Integrity: Confirm that data written to disk (e.g., events.jsonl, metrics.json, artifacts) is correctly stored and can be accurately read back.
  3. Test Edge Cases: Cover scenarios like unknown run IDs, concurrent operations (implicitly through rapid run creation), and data retention limits.
  4. Ensure Resource Management: Verify that temporary files and directories are created and cleaned up properly, and that write streams are handled correctly.
  5. Confirm Singleton Behavior: Validate that RunStore adheres to its singleton pattern.

Core Functionality Under Test

The test suite is structured around the key public methods and behaviors of the RunStore class.

1. Run Lifecycle Management (startRun, endRun)

2. Event Logging (emit, getEvents)

3. Artifact Management (saveArtifact, getArtifact)

4. Run Retrieval and Listing (getRun, listRuns)

5. Metrics Updates (updateMetrics)

6. Data Retention and Pruning

7. Singleton Pattern Enforcement

Test Environment and Utilities

The test suite employs several helper functions and jest hooks to manage the test environment effectively.

Dependencies

This test module directly depends on:

How to Run Tests

Assuming jest or a compatible test runner is configured, these tests can typically be executed from the project root using:

npm test tests/observability/run-store.test.ts
# or
yarn test tests/observability/run-store.test.ts

Or, to run all tests:

npm test