Documentation
¶
Index ¶
- func ValidateRunID(runID string) error
- type MarkerInfo
- type MongoRepository
- func (r *MongoRepository) AppendStdError(ctx context.Context, runID, testID string, output interface{}) error
- func (r *MongoRepository) AppendStdOutput(ctx context.Context, runID, testID string, output interface{}) error
- func (r *MongoRepository) AppendTestAttachments(ctx context.Context, runID, testID string, retryIndex int32, ...) error
- func (r *MongoRepository) AppendTestError(ctx context.Context, runID, testID string, retryIndex int32, ...) error
- func (r *MongoRepository) AppendTestFailure(ctx context.Context, runID, testID string, retryIndex int32, ...) error
- func (r *MongoRepository) DeleteTestRun(ctx context.Context, runID string) error
- func (r *MongoRepository) DeleteTestRuns(ctx context.Context, runIDs []string) (int64, error)
- func (r *MongoRepository) GetTestFromRun(ctx context.Context, testID string) (*m.TestDocument, error)
- func (r *MongoRepository) GetTestRun(ctx context.Context, id string) (*m.TestRunDocument, error)
- func (r *MongoRepository) GetTestTrends(ctx context.Context, testID string, limit int64) ([]*TestTrendItem, error)
- func (r *MongoRepository) GetUniqueMarkers(ctx context.Context) ([]*MarkerInfo, error)
- func (r *MongoRepository) ListTestRuns(ctx context.Context, filter bson.M, limit, offset int64) ([]*m.TestRunDocument, int64, error)
- func (r *MongoRepository) MapSuites(ctx context.Context, runID string, name string, ...) error
- func (r *MongoRepository) MarkRunStarts(ctx context.Context, runID string) error
- func (r *MongoRepository) MarkRunningTestsAsTimedOut(ctx context.Context, runID string) error
- func (r *MongoRepository) RemoveRunMarker(ctx context.Context, runID string) error
- func (r *MongoRepository) RemoveRunsMarker(ctx context.Context, runIDs []string) (int64, error)
- func (r *MongoRepository) StepExists(ctx context.Context, stepID string) (bool, error)
- func (r *MongoRepository) SuiteExists(ctx context.Context, suiteID string) (bool, error)
- func (r *MongoRepository) TestExists(ctx context.Context, testID string) (bool, error)
- func (r *MongoRepository) TestRunExists(ctx context.Context, runID string) (bool, error)
- func (r *MongoRepository) UpdateRunMarker(ctx context.Context, runID string, markerValue string) error
- func (r *MongoRepository) UpdateRunsMarker(ctx context.Context, runIDs []string, markerValue string) (int64, error)
- func (r *MongoRepository) UpdateTestRunEnd(ctx context.Context, runID string, status string, startTime *time.Time, ...) error
- func (r *MongoRepository) UpdateTestStatus(ctx context.Context, runID string, testID string, status string) error
- func (r *MongoRepository) UpsertStepBegin(ctx context.Context, runID string, step *m.StepDocument, testID string, ...) error
- func (r *MongoRepository) UpsertStepEnd(ctx context.Context, runID string, stepID string, testID string, ...) error
- func (r *MongoRepository) UpsertSuiteBegin(ctx context.Context, runID string, suite *m.SuiteDocument, ...) error
- func (r *MongoRepository) UpsertSuiteEnd(ctx context.Context, runID string, suiteID string, status string, ...) error
- func (r *MongoRepository) UpsertTestBegin(ctx context.Context, runID string, test *m.TestDocument, suiteID string) error
- func (r *MongoRepository) UpsertTestEnd(ctx context.Context, runID string, testID string, status string, ...) error
- type RawMessageRepository
- func (r *RawMessageRepository) AppendMessage(ctx context.Context, runID string, msg m.RetainedMessage) error
- func (r *RawMessageRepository) CollectionName() string
- func (r *RawMessageRepository) DatabaseName() string
- func (r *RawMessageRepository) GetByRunID(ctx context.Context, runID string) (*m.RawMessagesRunDocument, error)
- func (r *RawMessageRepository) ListRunSummaries(ctx context.Context, limit, offset int64) ([]m.RawMessagesRunSummary, int64, error)
- type TestTrendItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateRunID ¶
validateRunID checks if runID is provided and returns an error if not
Types ¶
type MarkerInfo ¶
type MarkerInfo struct {
Marker string `json:"marker" bson:"_id"`
Count int64 `json:"count" bson:"count"`
}
MarkerInfo represents a unique marker value with its run count
type MongoRepository ¶
type MongoRepository struct {
// contains filtered or unexported fields
}
MongoRepository handles MongoDB operations for test runs
func NewMongoRepository ¶
func NewMongoRepository(collection *mongo.Collection, logger *slog.Logger) *MongoRepository
NewMongoRepository creates a new MongoDB repository
func (*MongoRepository) AppendStdError ¶
func (r *MongoRepository) AppendStdError(ctx context.Context, runID, testID string, output interface{}) error
AppendStdError adds stderr output to a test document
func (*MongoRepository) AppendStdOutput ¶
func (r *MongoRepository) AppendStdOutput(ctx context.Context, runID, testID string, output interface{}) error
AppendStdOutput adds stdout output to a test document
func (*MongoRepository) AppendTestAttachments ¶
func (r *MongoRepository) AppendTestAttachments(ctx context.Context, runID, testID string, retryIndex int32, attachments []map[string]interface{}) error
AppendTestAttachments adds attachments to a test attempt and legacy test-level attachments array.
func (*MongoRepository) AppendTestError ¶
func (r *MongoRepository) AppendTestError(ctx context.Context, runID, testID string, retryIndex int32, errorDoc interface{}) error
AppendTestError adds an error to a test document's attempt array
func (*MongoRepository) AppendTestFailure ¶
func (r *MongoRepository) AppendTestFailure(ctx context.Context, runID, testID string, retryIndex int32, failure interface{}) error
AppendTestFailure adds a failure to a test document's attempt array
func (*MongoRepository) DeleteTestRun ¶
func (r *MongoRepository) DeleteTestRun(ctx context.Context, runID string) error
DeleteTestRun deletes a test run document by ID
func (*MongoRepository) DeleteTestRuns ¶
DeleteTestRuns deletes multiple test run documents by IDs
func (*MongoRepository) GetTestFromRun ¶
func (r *MongoRepository) GetTestFromRun(ctx context.Context, testID string) (*m.TestDocument, error)
GetTestFromRun retrieves a specific test from within a test run document
func (*MongoRepository) GetTestRun ¶
func (r *MongoRepository) GetTestRun(ctx context.Context, id string) (*m.TestRunDocument, error)
GetTestRun retrieves a complete test run document by ID
func (*MongoRepository) GetTestTrends ¶
func (r *MongoRepository) GetTestTrends(ctx context.Context, testID string, limit int64) ([]*TestTrendItem, error)
GetTestTrends retrieves historical test execution data for a specific test ID across multiple runs Returns test executions sorted by created_at in descending order (most recent first)
func (*MongoRepository) GetUniqueMarkers ¶
func (r *MongoRepository) GetUniqueMarkers(ctx context.Context) ([]*MarkerInfo, error)
GetUniqueMarkers retrieves all unique MARKER metadata values and their run counts
func (*MongoRepository) ListTestRuns ¶
func (r *MongoRepository) ListTestRuns(ctx context.Context, filter bson.M, limit, offset int64) ([]*m.TestRunDocument, int64, error)
ListTestRuns retrieves test runs with pagination and optional filters
func (*MongoRepository) MapSuites ¶
func (r *MongoRepository) MapSuites(ctx context.Context, runID string, name string, metadata map[string]interface{}, totalTests int32, suites []m.SuiteDocument) error
MapSuites adds or updates test suites for a test run. For sharded test runs (detected by shard.total and shard.current in metadata): - Metadata is merged to preserve shard info from multiple shards - total_tests is accumulated across shards using $inc For non-sharded runs: - Metadata is replaced entirely - total_tests is set directly
func (*MongoRepository) MarkRunStarts ¶
func (r *MongoRepository) MarkRunStarts(ctx context.Context, runID string) error
func (*MongoRepository) MarkRunningTestsAsTimedOut ¶
func (r *MongoRepository) MarkRunningTestsAsTimedOut(ctx context.Context, runID string) error
func (*MongoRepository) RemoveRunMarker ¶
func (r *MongoRepository) RemoveRunMarker(ctx context.Context, runID string) error
RemoveRunMarker removes the MARKER metadata field from a test run
func (*MongoRepository) RemoveRunsMarker ¶
RemoveRunsMarker removes the MARKER metadata field from multiple test runs
func (*MongoRepository) StepExists ¶
StepExists checks if a step exists within a test It checks both root-level and nested suite tests
func (*MongoRepository) SuiteExists ¶
SuiteExists checks if a suite exists in the repository For nested suites, it extracts the root document ID and checks if the suite exists in the document hierarchy
func (*MongoRepository) TestExists ¶
TestExists checks if a test exists in the repository It checks both root-level tests array and nested suite tests arrays
func (*MongoRepository) TestRunExists ¶
TestRunExists checks if a test run document exists by ID
func (*MongoRepository) UpdateRunMarker ¶
func (r *MongoRepository) UpdateRunMarker(ctx context.Context, runID string, markerValue string) error
UpdateRunMarker updates or sets the MARKER metadata field for a test run
func (*MongoRepository) UpdateRunsMarker ¶
func (r *MongoRepository) UpdateRunsMarker(ctx context.Context, runIDs []string, markerValue string) (int64, error)
UpdateRunsMarker updates or sets the MARKER metadata field for multiple test runs
func (*MongoRepository) UpdateTestRunEnd ¶
func (r *MongoRepository) UpdateTestRunEnd(ctx context.Context, runID string, status string, startTime *time.Time, duration *int64) error
UpdateTestRunEnd updates a test run document with final status, times, and duration
func (*MongoRepository) UpdateTestStatus ¶
func (r *MongoRepository) UpdateTestStatus(ctx context.Context, runID string, testID string, status string) error
UpdateTestStatus updates the status of a test case run
func (*MongoRepository) UpsertStepBegin ¶
func (r *MongoRepository) UpsertStepBegin(ctx context.Context, runID string, step *m.StepDocument, testID string, retry_index int32) error
UpsertStepBegin creates or updates a step within the document identified by runID. With attempt-based retries: steps are stored in attempts[retry_index].steps instead of tests.steps. - runID: Required. Identifies the document (_id). - step: The step to create/update (step.ID identifies the step). - testID: Required. ID of parent test containing this step. - retry_index: Required. Retry attempt index to target for step storage. Returns error if runID is empty or parent test not found.
func (*MongoRepository) UpsertStepEnd ¶
func (r *MongoRepository) UpsertStepEnd(ctx context.Context, runID string, stepID string, testID string, retry_index int32, status string, metadata map[string]interface{}, errorMsg string, errors []string, duration *int64) error
UpsertStepEnd updates step end fields (status, metadata, error fields, duration). With attempt-based retries: steps are stored in attempts[retry_index].steps. - runID: Required. Identifies the document (_id). - stepID: Required. Identifies the step to update. - testID: Required. ID of test containing the step. - retry_index: Required. Retry attempt index containing the step. - status: Step status (e.g., PASSED, FAILED). - metadata: Step metadata including error details (error_stack, error_value, error_snippet, error_location). - errorMsg: Single error message. - errors: Array of error messages. - duration: Step duration in nanoseconds. Returns error if runID is empty or step not found.
func (*MongoRepository) UpsertSuiteBegin ¶
func (r *MongoRepository) UpsertSuiteBegin(ctx context.Context, runID string, suite *m.SuiteDocument, parentSuiteID string) error
UpsertSuiteBegin creates or updates a suite within the document identified by runID. - runID: Required. Identifies the document (_id). - suite: The suite to create/update (suite.ID identifies the suite). - parentSuiteID: Empty for root-level suite, or ID of parent suite for nested suites. Returns error if runID is empty or document not found.
func (*MongoRepository) UpsertSuiteEnd ¶
func (r *MongoRepository) UpsertSuiteEnd(ctx context.Context, runID string, suiteID string, status string, endTime *time.Time, duration *int64) error
UpsertSuiteEnd updates suite end fields (status, endTime, duration). - runID: Required. Identifies the document (_id). - suiteID: Required. Identifies the suite to update. Returns error if runID is empty or suite not found.
func (*MongoRepository) UpsertTestBegin ¶
func (r *MongoRepository) UpsertTestBegin(ctx context.Context, runID string, test *m.TestDocument, suiteID string) error
UpsertTestBegin creates or updates a test within the document identified by runID. - runID: Required. Identifies the document (_id). - test: The test to create/update (test.ID identifies the test). - suiteID: Required. ID of parent suite containing this test. Returns error if runID is empty.
func (*MongoRepository) UpsertTestEnd ¶
func (r *MongoRepository) UpsertTestEnd(ctx context.Context, runID string, testID string, status string, retryIndex int32, endTime *time.Time, duration *int64, attachments []map[string]interface{}) error
UpsertTestEnd updates test end fields (status, duration, attachments) and corresponding attempt fields. With attempt-based retries: updates both test-level status and attempts[retry_index] status/end_time/duration. - runID: Required. Identifies the document (_id). - testID: Required. Identifies the test to update. - retryIndex: Required. Identifies the test attempt to update. - status: New status to set (optional). - endTime: End time for the attempt (optional). - duration: New duration to set (optional). - attachments: Attachments for this attempt (optional). Returns error if runID is empty or test not found.
type RawMessageRepository ¶ added in v0.1.1
type RawMessageRepository struct {
// contains filtered or unexported fields
}
RawMessageRepository handles persistence of raw NATS messages for auditing and debugging. All messages for a given run are stored in a single document identified by the run_id.
func NewRawMessageRepository ¶ added in v0.1.1
func NewRawMessageRepository(collection *mongo.Collection, logger *slog.Logger) *RawMessageRepository
NewRawMessageRepository creates a new RawMessageRepository backed by the given collection.
func (*RawMessageRepository) AppendMessage ¶ added in v0.1.1
func (r *RawMessageRepository) AppendMessage(ctx context.Context, runID string, msg m.RetainedMessage) error
AppendMessage appends a single retained message to the run document identified by runID. If the document does not yet exist it is created (upsert). All messages belonging to the same run are therefore stored in one document.
func (*RawMessageRepository) CollectionName ¶ added in v0.1.1
func (r *RawMessageRepository) CollectionName() string
CollectionName returns the MongoDB collection name that raw messages are inserted into.
func (*RawMessageRepository) DatabaseName ¶ added in v0.1.1
func (r *RawMessageRepository) DatabaseName() string
DatabaseName returns the MongoDB database name that raw messages are inserted into.
func (*RawMessageRepository) GetByRunID ¶ added in v0.1.1
func (r *RawMessageRepository) GetByRunID(ctx context.Context, runID string) (*m.RawMessagesRunDocument, error)
GetByRunID retrieves the full raw messages document for the given run ID. Returns nil, nil if no document exists for that run (retention not enabled or run predates retention being turned on).
func (*RawMessageRepository) ListRunSummaries ¶ added in v0.1.1
func (r *RawMessageRepository) ListRunSummaries(ctx context.Context, limit, offset int64) ([]m.RawMessagesRunSummary, int64, error)
ListRunSummaries returns paginated summaries for all runs that have retained raw messages, newest first by updated_at.
type TestTrendItem ¶
type TestTrendItem struct {
TestID string `json:"testId"`
RunID string `json:"runId"`
Status string `json:"status"`
Duration *int64 `json:"duration,omitempty"`
StartTime *time.Time `json:"startTime,omitempty"`
EndTime *time.Time `json:"endTime,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
TestTrendItem represents a single test execution in the history