Documentation
¶
Index ¶
- func ModelsForMigration() []interface{}
- func RunStartEventToTestRun(req *events.ReportRunStartEventRequest) (*TestRun, []*Suite)
- type ActiveTestStepsDocument
- type Attachment
- type LiveStepBufferDocument
- type OutputDocument
- type RawMessagesRunDocument
- type RawMessagesRunSummary
- type RetainedMessage
- type RunShard
- type Step
- type StepDocument
- type Suite
- type Test
- type TestAttempt
- type TestErrorDocument
- type TestFailureDocument
- type TestRun
- type TestRunDocument
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ModelsForMigration ¶ added in v0.2.0
func ModelsForMigration() []interface{}
ModelsForMigration lists models in schema creation order.
func RunStartEventToTestRun ¶ added in v0.2.0
func RunStartEventToTestRun(req *events.ReportRunStartEventRequest) (*TestRun, []*Suite)
RunStartEventToTestRun maps a ReportRunStartEventRequest to a TestRun row. The returned value is ready for an idempotent upsert into the runs table.
Types ¶
type ActiveTestStepsDocument ¶ added in v0.2.0
type ActiveTestStepsDocument struct {
TestID string `bson:"test_id" json:"testId"`
RetryIndex int32 `bson:"retry_index" json:"retryIndex"`
Status string `bson:"status,omitempty" json:"status,omitempty"`
Steps []*StepDocument `bson:"steps,omitempty" json:"steps,omitempty"`
FirstEventAt *time.Time `bson:"first_event_at,omitempty" json:"firstEventAt,omitempty"`
LastEventAt *time.Time `bson:"last_event_at,omitempty" json:"lastEventAt,omitempty"`
FlushStartedAt *time.Time `bson:"flush_started_at,omitempty" json:"flushStartedAt,omitempty"`
TTLAt *time.Time `bson:"ttl_at,omitempty" json:"ttlAt,omitempty"`
CreatedAt time.Time `bson:"created_at" json:"createdAt"`
UpdatedAt time.Time `bson:"updated_at" json:"updatedAt"`
}
ActiveTestStepsDocument stores transient in-flight steps for a single active test attempt. The owning TestRunDocument keys this object by test id in ActiveTestSteps.
type Attachment ¶ added in v0.2.0
type Attachment struct {
ID string `gorm:"column:id;type:text;primaryKey" json:"id"`
RunID string `gorm:"column:run_id;type:text;not null;index:idx_attachments_run" json:"runId"`
TestID string `gorm:"column:test_id;type:text;not null;index:idx_attachments_test" json:"testId"`
TestAttemptID string `gorm:"column:test_attempt_id;type:text;not null;index:idx_attachments_attempt" json:"testAttemptId"`
StepID *string `gorm:"column:step_id;type:text" json:"stepId,omitempty"`
Kind string `gorm:"column:kind;type:text" json:"kind,omitempty"`
Name string `gorm:"column:name;type:text" json:"name,omitempty"`
ContentType string `gorm:"column:content_type;type:text" json:"contentType,omitempty"`
SizeBytes int64 `gorm:"column:size_bytes" json:"sizeBytes,omitempty"`
StorageKey string `gorm:"column:storage_key;type:text" json:"storageKey,omitempty"`
Checksum string `gorm:"column:checksum;type:text" json:"checksum,omitempty"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime;index:idx_attachments_created_at" json:"createdAt"`
DeletedAt *time.Time `gorm:"column:deleted_at" json:"deletedAt,omitempty"`
}
Attachment maps to PostgreSQL attachments metadata.
func (Attachment) TableName ¶ added in v0.2.0
func (Attachment) TableName() string
type LiveStepBufferDocument ¶ added in v0.2.0
type LiveStepBufferDocument struct {
ID string `bson:"_id" json:"id"`
RunID string `bson:"run_id" json:"runId"`
TestID string `bson:"test_id" json:"testId"`
AttemptIndex int32 `bson:"attempt_index" json:"attemptIndex"`
Status string `bson:"status,omitempty" json:"status,omitempty"`
Steps []*StepDocument `bson:"steps,omitempty" json:"steps,omitempty"`
FirstEventAt *time.Time `bson:"first_event_at,omitempty" json:"firstEventAt,omitempty"`
LastEventAt *time.Time `bson:"last_event_at,omitempty" json:"lastEventAt,omitempty"`
FlushStartedAt *time.Time `bson:"flush_started_at,omitempty" json:"flushStartedAt,omitempty"`
TTLAt *time.Time `bson:"ttl_at,omitempty" json:"ttlAt,omitempty"`
CreatedAt time.Time `bson:"created_at" json:"createdAt"`
UpdatedAt time.Time `bson:"updated_at" json:"updatedAt"`
}
LiveStepBufferDocument is the standalone collection representation of an active step buffer. The collection is initialized separately so later phases can cut over from the embedded run-document buffer without another schema hop.
type OutputDocument ¶
type OutputDocument struct {
Message string `bson:"message,omitempty" json:"message,omitempty"`
Timestamp *time.Time `bson:"timestamp,omitempty" json:"timestamp,omitempty"`
}
OutputDocument represents stdout or stderr output
type RawMessagesRunDocument ¶ added in v0.1.1
type RawMessagesRunDocument struct {
// RunID is the test run identifier; used as the MongoDB _id.
RunID string `bson:"_id" json:"runId"`
// Messages is the ordered list of raw messages received for this run.
Messages []RetainedMessage `bson:"messages" json:"messages"`
// CreatedAt is the time the document was first created (first message for the run).
CreatedAt time.Time `bson:"created_at" json:"createdAt"`
// UpdatedAt is the time the last message was appended to this document.
UpdatedAt time.Time `bson:"updated_at" json:"updatedAt"`
}
RawMessagesRunDocument groups all retained NATS messages that belong to a single test run. The document _id is the run_id, so every message for a run is co-located in one document, making replay and audit straightforward.
type RawMessagesRunSummary ¶ added in v0.1.1
type RawMessagesRunSummary struct {
// RunID is the retained run identifier (_id in MongoDB).
RunID string `bson:"_id" json:"runId"`
// MessageCount is the number of retained messages for this run.
MessageCount int `bson:"message_count" json:"messageCount"`
// CreatedAt is when the retention document was first created.
CreatedAt time.Time `bson:"created_at" json:"createdAt"`
// UpdatedAt is when the retention document was last appended to.
UpdatedAt time.Time `bson:"updated_at" json:"updatedAt"`
}
RawMessagesRunSummary is a lightweight listing item for runs that have retained raw messages.
type RetainedMessage ¶ added in v0.1.1
type RetainedMessage struct {
// Subject is the NATS subject on which the message was received.
Subject string `bson:"subject" json:"subject"`
// EventType is the decoded event type from the message envelope.
EventType string `bson:"event_type" json:"eventType"`
// Payload contains the parsed JSON of the full NATS message (event envelope).
Payload map[string]interface{} `bson:"payload" json:"payload"`
// Sequence is the JetStream sequence number of the message within the stream.
Sequence uint64 `bson:"sequence,omitempty" json:"sequence,omitempty"`
// Stream is the name of the JetStream stream this message was consumed from.
Stream string `bson:"stream,omitempty" json:"stream,omitempty"`
// ReceivedAt is the time the message was received and stored.
ReceivedAt time.Time `bson:"received_at" json:"receivedAt"`
}
RetainedMessage is a single NATS message captured within a run's retention log. Multiple RetainedMessages are embedded in a RawMessagesRunDocument.
type RunShard ¶ added in v0.2.0
type RunShard struct {
ID string `gorm:"column:id;type:text;primaryKey" json:"id"`
RunID string `` /* 151-byte string literal not displayed */
ShardIndex *int32 `gorm:"column:shard_index;uniqueIndex:ux_run_shards_run_id_shard_index,priority:2" json:"shardIndex,omitempty"`
ShardCountExpected *int32 `gorm:"column:shard_count_expected" json:"shardCountExpected,omitempty"`
Status string `gorm:"column:status;type:text;index:idx_run_shards_run_status,priority:2" json:"status,omitempty"`
StartTime *time.Time `gorm:"column:started_at" json:"startTime,omitempty"`
EndTime *time.Time `gorm:"column:finished_at" json:"endTime,omitempty"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updatedAt"`
}
RunShard maps to the PostgreSQL run_shards table.
func RunEndEventToRunShard ¶ added in v0.2.0
func RunEndEventToRunShard(req *events.TestRunEndEventRequest) *RunShard
RunEndEventToRunShard maps run-level shard metadata in a terminal event to a RunShard row. Returns nil when the run is not sharded or shard metadata is incomplete.
func RunStartEventToRunShard ¶ added in v0.2.0
func RunStartEventToRunShard(req *events.ReportRunStartEventRequest) *RunShard
RunStartEventToRunShard maps run-level shard metadata to a RunShard row. Returns nil when the run is not sharded or shard metadata is incomplete.
type Step ¶ added in v0.2.4
type Step json.RawMessage
func StepFromDocuments ¶ added in v0.2.4
func StepFromDocuments(steps []*StepDocument) (*Step, error)
func (Step) MarshalJSON ¶ added in v0.2.4
func (*Step) UnmarshalJSON ¶ added in v0.2.4
type StepDocument ¶
type StepDocument struct {
ID string `bson:"id" json:"id"`
RunID string `bson:"run_id,omitempty" json:"runId,omitempty"`
TestCaseRunID string `bson:"test_case_run_id,omitempty" json:"testCaseRunId,omitempty"`
ParentStepID string `bson:"parent_step_id,omitempty" json:"parentStepId,omitempty"`
Title string `bson:"title,omitempty" json:"title,omitempty"`
Description string `bson:"description,omitempty" json:"description,omitempty"`
StartTime *time.Time `bson:"start_time,omitempty" json:"startTime,omitempty"`
Duration *int64 `bson:"duration,omitempty" json:"duration,omitempty"`
Type string `bson:"type,omitempty" json:"type,omitempty"`
Metadata map[string]interface{} `bson:"metadata,omitempty" json:"metadata,omitempty"`
Tags []string `bson:"tags,omitempty" json:"tags,omitempty"`
WorkerIndex string `bson:"worker_index,omitempty" json:"workerIndex,omitempty"`
Status string `bson:"status,omitempty" json:"status,omitempty"`
Category string `bson:"category,omitempty" json:"category,omitempty"`
Location string `bson:"location,omitempty" json:"location,omitempty"`
RetryIndex int32 `bson:"retry_index,omitempty" json:"retryIndex,omitempty"`
// Error fields
Error string `bson:"error,omitempty" json:"error,omitempty"` // Single error message
Errors []string `bson:"errors,omitempty" json:"errors,omitempty"` // Array of error messages
CreatedAt time.Time `bson:"created_at" json:"createdAt"`
UpdatedAt time.Time `bson:"updated_at" json:"updatedAt"`
// Nested steps (for step hierarchies)
Steps []*StepDocument `bson:"steps,omitempty" json:"steps,omitempty"`
}
StepDocument represents a test step embedded within a test or parent step.
func StepDocumentsFromStep ¶ added in v0.2.4
func StepDocumentsFromStep(step *Step) ([]*StepDocument, error)
type Suite ¶ added in v0.2.0
type Suite struct {
ID string `gorm:"column:id;type:text;primaryKey" json:"id"`
RunID string `gorm:"column:run_id;type:text;not null;index:idx_suites_run_id;index:idx_suites_run_status,priority:1" json:"runId,omitempty"`
ExternalSuiteID string `gorm:"column:external_suite_id;type:text;index:idx_suites_run_external_suite_id,priority:2" json:"externalSuiteId,omitempty"`
ParentSuiteID *string `gorm:"column:parent_suite_id;type:text" json:"parentSuiteId,omitempty"`
Name string `gorm:"column:name;type:text" json:"name,omitempty"`
Description string `gorm:"column:description;type:text" json:"description,omitempty"`
Status string `gorm:"column:status;type:text;index:idx_suites_run_status,priority:2" json:"status,omitempty"`
Metadata map[string]interface{} `gorm:"column:metadata;type:jsonb;serializer:json" json:"metadata,omitempty"`
Duration *int64 `gorm:"column:duration" json:"duration,omitempty"`
Location string `gorm:"column:location;type:text" json:"location,omitempty"`
Type string `gorm:"column:type;type:text" json:"type,omitempty"`
TestSuiteSpecID string `gorm:"column:test_suite_spec_id;type:text" json:"testSuiteSpecId,omitempty"`
InitiatedBy string `gorm:"column:initiated_by;type:text" json:"initiatedBy,omitempty"`
ProjectName string `gorm:"column:project_name;type:text" json:"projectName,omitempty"`
Author string `gorm:"column:author;type:text" json:"author,omitempty"`
Owner string `gorm:"column:owner;type:text" json:"owner,omitempty"`
TestCaseIDs []string `gorm:"column:test_case_ids;type:jsonb;serializer:json" json:"testCaseIds,omitempty"`
SubSuiteIDs []string `gorm:"column:sub_suite_ids;type:jsonb;serializer:json" json:"subSuiteIds,omitempty"`
Tags []string `gorm:"column:tags;type:jsonb;serializer:json" json:"tags,omitempty"`
StartTime *time.Time `gorm:"column:started_at" json:"startTime,omitempty"`
EndTime *time.Time `gorm:"column:finished_at" json:"endTime,omitempty"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updatedAt"`
Suites []*Suite `gorm:"foreignKey:ParentSuiteID;references:ID" json:"suites,omitempty"`
Tests []*Test `gorm:"foreignKey:SuiteID;references:ID" json:"tests,omitempty"`
}
Suite maps to the PostgreSQL suites table.
type Test ¶ added in v0.2.0
type Test struct {
ID string `gorm:"column:id;type:text;primaryKey" json:"id"`
RunID string `gorm:"column:run_id;type:text;not null;index:idx_tests_run_id" json:"runId,omitempty"`
ExternalTestID string `` /* 170-byte string literal not displayed */
SuiteID *string `gorm:"column:suite_id;type:text;not null;index:idx_tests_suite_status,priority:1" json:"suiteId,omitempty"`
Name string `gorm:"column:name;type:text" json:"name,omitempty"`
Title string `gorm:"column:title;type:text" json:"title,omitempty"`
Description string `gorm:"column:description;type:text" json:"description,omitempty"`
Status string `gorm:"column:status;type:text;index:idx_tests_suite_status,priority:2" json:"status,omitempty"`
StartTime *time.Time `gorm:"column:started_at" json:"startTime,omitempty"`
EndTime *time.Time `gorm:"column:finished_at" json:"endTime,omitempty"`
Duration *int64 `gorm:"column:duration" json:"duration,omitempty"`
Metadata map[string]interface{} `gorm:"column:metadata;type:jsonb;serializer:json" json:"metadata,omitempty"`
Tags []string `gorm:"column:tags;type:jsonb;serializer:json" json:"tags,omitempty"`
Location string `gorm:"column:location;type:text" json:"location,omitempty"`
RetryCount *int32 `gorm:"column:retry_count" json:"retryCount,omitempty"`
RetryIndex *int32 `gorm:"column:retry_index" json:"retryIndex,omitempty"`
Timeout *int32 `gorm:"column:timeout" json:"timeout,omitempty"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updatedAt"`
Attempts []TestAttempt `gorm:"foreignKey:TestID;references:ID" json:"attempts,omitempty"`
}
Test maps to the PostgreSQL tests table.
func RunStartEventToTests ¶ added in v0.2.0
func RunStartEventToTests(req *events.ReportRunStartEventRequest) []*Test
RunStartEventToTests maps embedded test cases in a run-start payload to relational test rows.
func TestCaseRunToRelationalTest ¶ added in v0.2.0
func TestCaseRunToRelationalTest(protoTest *entities.TestCaseRun) *Test
TestCaseRunToRelationalTest maps a TestCaseRun payload to the relational tests row.
type TestAttempt ¶ added in v0.2.0
type TestAttempt struct {
ID string `gorm:"column:id;type:text;primaryKey" json:"id"`
RunID string `gorm:"column:run_id;type:text;not null;index:idx_attempts_run_id" json:"runId,omitempty"`
TestID string `` /* 151-byte string literal not displayed */
AttemptIndex int32 `` /* 153-byte string literal not displayed */
Status string `gorm:"column:status;type:text;index:idx_attempts_status_finished_at,priority:1" json:"status,omitempty"`
StartTime *time.Time `gorm:"column:started_at" json:"startTime,omitempty"`
EndTime *time.Time `gorm:"column:finished_at;index:idx_attempts_status_finished_at,priority:2" json:"endTime,omitempty"`
Duration *int64 `gorm:"column:duration" json:"duration,omitempty"`
// Steps holds the step array containing step trees serialized as jsonb.
// Go type is json.RawMessage (provisional — concrete typed decode at read time).
Steps *Step `gorm:"column:steps;type:jsonb" json:"steps,omitempty"`
StepsCount int32 `gorm:"column:steps_count" json:"stepsCount,omitempty"`
Attachments []map[string]interface{} `gorm:"column:attachments;type:jsonb;serializer:json" json:"attachments,omitempty"`
ErrorMessage string `gorm:"column:error_message;type:text" json:"errorMessage,omitempty"`
StackTrace string `gorm:"column:stack_trace;type:text" json:"stackTrace,omitempty"`
ErrorList []string `gorm:"column:error_list;type:jsonb;serializer:json" json:"errorList,omitempty"`
Failures []*TestFailureDocument `gorm:"column:failures;type:jsonb;serializer:json" json:"failures,omitempty"`
Errors []*TestErrorDocument `gorm:"column:errors;type:jsonb;serializer:json" json:"errors,omitempty"`
StdOut []*OutputDocument `gorm:"column:stdout;type:jsonb;serializer:json" json:"stdout,omitempty"`
StdErr []*OutputDocument `gorm:"column:stderr;type:jsonb;serializer:json" json:"stderr,omitempty"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updatedAt"`
AttachmentsRows []Attachment `gorm:"foreignKey:TestAttemptID;references:ID" json:"attachmentsRows,omitempty"`
}
TestAttempt maps to PostgreSQL test_attempts. Steps are stored on the attempt row as requested.
func TestCaseRunToRelationalAttempt ¶ added in v0.2.0
func TestCaseRunToRelationalAttempt(protoTest *entities.TestCaseRun, attachments []map[string]interface{}) *TestAttempt
TestCaseRunToRelationalAttempt maps a TestCaseRun payload to the relational test_attempts row.
func (TestAttempt) TableName ¶ added in v0.2.0
func (TestAttempt) TableName() string
type TestErrorDocument ¶
type TestErrorDocument struct {
ErrorMessage string `bson:"error_message,omitempty" json:"errorMessage,omitempty"`
StackTrace string `bson:"stack_trace,omitempty" json:"stackTrace,omitempty"`
Timestamp *time.Time `bson:"timestamp,omitempty" json:"timestamp,omitempty"`
Attachments []map[string]interface{} `bson:"attachments,omitempty" json:"attachments,omitempty"`
}
TestErrorDocument represents a test error with details
type TestFailureDocument ¶
type TestFailureDocument struct {
FailureMessage string `bson:"failure_message,omitempty" json:"failureMessage,omitempty"`
StackTrace string `bson:"stack_trace,omitempty" json:"stackTrace,omitempty"`
Timestamp *time.Time `bson:"timestamp,omitempty" json:"timestamp,omitempty"`
Attachments []map[string]interface{} `bson:"attachments,omitempty" json:"attachments,omitempty"`
}
TestFailureDocument represents a test failure with details
type TestRun ¶ added in v0.2.0
type TestRun struct {
ID string `gorm:"column:id;type:text;primaryKey" json:"id"`
Name string `gorm:"column:name;type:text" json:"name,omitempty"`
Description string `gorm:"column:description;type:text" json:"description,omitempty"`
Status string `gorm:"column:status;type:text;index:idx_runs_status_started_at,priority:1" json:"status,omitempty"`
Metadata map[string]interface{} `gorm:"column:metadata;type:jsonb;serializer:json" json:"metadata,omitempty"`
Duration *int64 `gorm:"column:duration" json:"duration,omitempty"`
TotalTests int32 `gorm:"column:total_tests" json:"totalTests,omitempty"`
InitiatedBy string `gorm:"column:initiated_by;type:text" json:"initiatedBy,omitempty"`
ProjectName string `gorm:"column:project_name;type:text" json:"projectName,omitempty"`
StartTime *time.Time `gorm:"column:started_at;index:idx_runs_status_started_at,priority:2;index:idx_runs_started_at" json:"startTime,omitempty"`
EndTime *time.Time `gorm:"column:finished_at" json:"endTime,omitempty"`
CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at;autoUpdateTime" json:"updatedAt"`
Shards []*RunShard `gorm:"foreignKey:RunID;references:ID" json:"shards,omitempty"`
Suites []*Suite `gorm:"foreignKey:RunID;references:ID" json:"suites,omitempty"`
Tests []*Test `gorm:"foreignKey:RunID;references:ID" json:"tests,omitempty"`
}
TestRun maps to the PostgreSQL runs table. It intentionally mirrors TestRunDocument fields where practical.
func RunEndEventToTestRun ¶ added in v0.2.0
func RunEndEventToTestRun(req *events.TestRunEndEventRequest) TestRun
RunEndEventToTestRun maps a TestRunEndEventRequest to TestRun. The returned fields are intended for a partial update to finalize the run's terminal state.
type TestRunDocument ¶
type TestRunDocument struct {
ID string `bson:"_id" json:"id"`
// ActiveTestSteps buffers in-flight step trees by test id while the attempt is running.
ActiveTestSteps map[string]*ActiveTestStepsDocument `bson:"active_test_steps,omitempty" json:"activeTestSteps,omitempty"`
}
TestRunDocument represents the MongoDB document structure for a test run, including active test steps buffering.