Documentation
¶
Index ¶
- func BuildTraceTestResultsProto(e *Executor, results []TestResult, tests []Test) []*backend.TraceTestResult
- func ConvertRunnerResultToTraceTestResult(result TestResult, test Test) *backend.TraceTestResult
- func ConvertRunnerResultsToTraceTestResults(results []TestResult, tests []Test) []*backend.TraceTestResult
- func OutputResults(results []TestResult, tests []Test, format string, quiet bool) error
- func ParseBodyForComparison(decodedBytes []byte, decodedType DecodedType) (any, error)
- func UploadResultsAndFinalize(ctx context.Context, client *api.TuskClient, driftRunID string, ...) error
- func UploadSingleTestResult(ctx context.Context, client *api.TuskClient, driftRunID string, ...) error
- type DecodedType
- type Deviation
- type DynamicFieldMatcher
- type EncodingType
- type Executor
- func (e *Executor) GetConcurrency() int
- func (e *Executor) GetServiceLogPath() string
- func (e *Executor) LoadSpansForTrace(traceID string, filename string) ([]*core.Span, error)
- func (e *Executor) LoadTestsFromFolder(folder string) ([]Test, error)
- func (e *Executor) LoadTestsFromTraceFile(path string) ([]Test, error)
- func (e *Executor) RunSingleTest(test Test) (TestResult, error)
- func (e *Executor) RunTests(tests []Test) ([]TestResult, error)
- func (e *Executor) RunTestsConcurrently(tests []Test, maxConcurrency int) ([]TestResult, error)
- func (e *Executor) SetConcurrency(concurrency int)
- func (e *Executor) SetEnableServiceLogs(enable bool)
- func (e *Executor) SetOnTestCompleted(callback func(TestResult, Test))
- func (e *Executor) SetResultsOutput(dir string)
- func (e *Executor) SetSuiteSpans(spans []*core.Span)
- func (e *Executor) SetTestTimeout(timeout time.Duration)
- func (e *Executor) StartEnvironment() error
- func (e *Executor) StartServer() error
- func (e *Executor) StartService() error
- func (e *Executor) StopEnvironment() error
- func (e *Executor) StopServer() error
- func (e *Executor) StopService() error
- func (e *Executor) WaitForSDKAcknowledgement() error
- func (e *Executor) WaitForSpanData(traceID string, timeout time.Duration)
- func (e *Executor) WriteRunResultsToFile(tests []Test, results []TestResult) (string, error)
- type MatchEvent
- type MessageType
- type MockMatcher
- type MockMatcherRequestData
- type Request
- type RequestBodyMetadata
- type Response
- type SemVer
- type Server
- func (ms *Server) GetInboundReplaySpan(traceID string) *core.Span
- func (ms *Server) GetMatchEvents(traceID string) []MatchEvent
- func (ms *Server) GetRootSpanID(traceID string) string
- func (ms *Server) GetSDKVersion() string
- func (ms *Server) GetSocketPath() string
- func (ms *Server) GetSuiteSpans() []*core.Span
- func (ms *Server) LoadSpansForTrace(traceID string, spans []*core.Span)
- func (ms *Server) SetCurrentTestID(id string)
- func (ms *Server) SetSuiteSpans(spans []*core.Span)
- func (ms *Server) Start() error
- func (ms *Server) Stop() error
- func (ms *Server) WaitForInboundSpan(traceID string, timeout time.Duration)
- func (ms *Server) WaitForSDKConnection(timeout time.Duration) error
- func (ms *Server) WaitForSpanData(traceID string, timeout time.Duration)
- type Test
- type TestResult
- type Trace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildTraceTestResultsProto ¶
func BuildTraceTestResultsProto(e *Executor, results []TestResult, tests []Test) []*backend.TraceTestResult
func ConvertRunnerResultToTraceTestResult ¶
func ConvertRunnerResultToTraceTestResult(result TestResult, test Test) *backend.TraceTestResult
func ConvertRunnerResultsToTraceTestResults ¶
func ConvertRunnerResultsToTraceTestResults(results []TestResult, tests []Test) []*backend.TraceTestResult
ConvertRunnerResultsToTraceTestResults maps local results for upload to the backend
func OutputResults ¶
func OutputResults(results []TestResult, tests []Test, format string, quiet bool) error
func ParseBodyForComparison ¶
func ParseBodyForComparison(decodedBytes []byte, decodedType DecodedType) (any, error)
ParseBodyForComparison parses decoded body bytes for response comparison. For JSON, it unmarshals into a structured type; for text, returns string. For binary/media types, returns base64-encoded string for comparison.
func UploadResultsAndFinalize ¶
func UploadResultsAndFinalize( ctx context.Context, client *api.TuskClient, driftRunID string, authOptions api.AuthOptions, executor *Executor, results []TestResult, tests []Test, streamed bool, ) error
func UploadSingleTestResult ¶
func UploadSingleTestResult( ctx context.Context, client *api.TuskClient, driftRunID string, auth api.AuthOptions, e *Executor, res TestResult, test Test, ) error
Types ¶
type DecodedType ¶
type DecodedType string
DecodedType represents the type of decoded content. Must match the DecodedType enum in tusk-drift-sdk/src/core/tracing/JsonSchemaHelper.ts. TODO: use Protobuf to share this type across the CLI and SDK(s).
const ( DecodedTypeJSON DecodedType = "JSON" DecodedTypeHTML DecodedType = "HTML" DecodedTypeCSS DecodedType = "CSS" DecodedTypeJAVASCRIPT DecodedType = "JAVASCRIPT" DecodedTypeXML DecodedType = "XML" DecodedTypeYAML DecodedType = "YAML" DecodedTypeMARKDOWN DecodedType = "MARKDOWN" DecodedTypeCSV DecodedType = "CSV" DecodedTypeSQL DecodedType = "SQL" DecodedTypeGRAPHQL DecodedType = "GRAPHQL" DecodedTypePLAINTEXT DecodedType = "PLAIN_TEXT" DecodedTypeFORMDATA DecodedType = "FORM_DATA" DecodedTypeMULTIPARTFORM DecodedType = "MULTIPART_FORM" DecodedTypePDF DecodedType = "PDF" DecodedTypeAUDIO DecodedType = "AUDIO" DecodedTypeVIDEO DecodedType = "VIDEO" DecodedTypeGZIP DecodedType = "GZIP" DecodedTypeBINARY DecodedType = "BINARY" DecodedTypeJPEG DecodedType = "JPEG" DecodedTypePNG DecodedType = "PNG" DecodedTypeGIF DecodedType = "GIF" DecodedTypeWEBP DecodedType = "WEBP" DecodedTypeSVG DecodedType = "SVG" DecodedTypeZIP DecodedType = "ZIP" DecodedTypeUNSPECIFIED DecodedType = "UNSPECIFIED" )
func DecodeBody ¶
func DecodeBody(bodyValue any, metadata *RequestBodyMetadata) ([]byte, DecodedType, error)
DecodeBody decodes a body value using schema metadata Returns the decoded bytes and the type for further processing
type DynamicFieldMatcher ¶
type DynamicFieldMatcher struct {
// contains filtered or unexported fields
}
DynamicFieldMatcher defines patterns for identifying dynamic fields that should be ignored
func NewDynamicFieldMatcher ¶
func NewDynamicFieldMatcher() *DynamicFieldMatcher
NewDynamicFieldMatcher creates a new matcher with default patterns
func NewDynamicFieldMatcherWithConfig ¶
func NewDynamicFieldMatcherWithConfig(cfg *config.ComparisonConfig) *DynamicFieldMatcher
func (*DynamicFieldMatcher) ShouldIgnoreField ¶
func (m *DynamicFieldMatcher) ShouldIgnoreField(fieldName string, expectedValue, actualValue any, testID string) bool
ShouldIgnoreField determines if a field should be ignored during comparison
type EncodingType ¶
type EncodingType string
EncodingType represents how the body is encoded
const ( EncodingTypeBASE64 EncodingType = "BASE64" EncodingTypeNONE EncodingType = "NONE" )
type Executor ¶
type Executor struct {
ResultsFile string // Will be set by the run command if --save-results is true
// contains filtered or unexported fields
}
func NewExecutor ¶
func NewExecutor() *Executor
func (*Executor) GetConcurrency ¶
GetConcurrency returns the current concurrency setting
func (*Executor) GetServiceLogPath ¶
func (*Executor) LoadSpansForTrace ¶
func (*Executor) LoadTestsFromFolder ¶
func (*Executor) LoadTestsFromTraceFile ¶
LoadTestsFromTraceFile loads all tests from a trace file
func (*Executor) RunSingleTest ¶
func (e *Executor) RunSingleTest(test Test) (TestResult, error)
RunSingleTest replays a single trace on the service under test.
func (*Executor) RunTestsConcurrently ¶
func (e *Executor) RunTestsConcurrently(tests []Test, maxConcurrency int) ([]TestResult, error)
RunTestsConcurrently executes tests in parallel with the specified concurrency limit
func (*Executor) SetConcurrency ¶
SetConcurrency sets the maximum number of concurrent tests
func (*Executor) SetEnableServiceLogs ¶
SetDisableServiceLogs sets whether service logging should be disabled
func (*Executor) SetOnTestCompleted ¶
func (e *Executor) SetOnTestCompleted(callback func(TestResult, Test))
func (*Executor) SetResultsOutput ¶
func (*Executor) SetSuiteSpans ¶
func (*Executor) SetTestTimeout ¶
func (*Executor) StartEnvironment ¶
StartEnvironment starts the mock server and service, then waits for the SDK ack. It performs best-effort cleanup on failure.
func (*Executor) StartServer ¶
StartServer initializes and starts the mock server
func (*Executor) StartService ¶
func (*Executor) StopEnvironment ¶
StopEnvironment stops the service and mock server (best effort).
func (*Executor) StopServer ¶
func (*Executor) StopService ¶
func (*Executor) WaitForSDKAcknowledgement ¶
WaitForSDKAcknowledgement waits for the SDK to acknowledge the connection.
func (*Executor) WaitForSpanData ¶
WaitForSpanData blocks briefly until inbound or match events are recorded for a test
func (*Executor) WriteRunResultsToFile ¶
func (e *Executor) WriteRunResultsToFile(tests []Test, results []TestResult) (string, error)
type MatchEvent ¶
type MessageType ¶
type MessageType string
MessageType represents the type of message sent by the SDK
const ( MessageTypeSDKConnect MessageType = "sdk_connect" MessageTypeMockRequest MessageType = "mock_request" )
type MockMatcher ¶
type MockMatcher struct {
// contains filtered or unexported fields
}
func NewMockMatcher ¶
func NewMockMatcher(server *Server) *MockMatcher
func (*MockMatcher) FindBestMatchAcrossTraces ¶
func (mm *MockMatcher) FindBestMatchAcrossTraces(req *core.GetMockRequest, traceID string, spans []*core.Span) (*core.Span, *backend.MatchLevel, error)
FindBestMatchInSpans implements the priority matching algorithm for spans across a test suite
func (*MockMatcher) FindBestMatchInTrace ¶
func (mm *MockMatcher) FindBestMatchInTrace(req *core.GetMockRequest, traceID string) (*core.Span, *backend.MatchLevel, error)
FindBestMatch implements the priority matching algorithm for spans within a trace
type MockMatcherRequestData ¶
type RequestBodyMetadata ¶
type RequestBodyMetadata struct {
Encoding EncodingType
DecodedType DecodedType
}
RequestBodyMetadata contains encoding information from the schema
func ExtractRequestBodyMetadata ¶
func ExtractRequestBodyMetadata(schema *structpb.Struct, fieldPath string) *RequestBodyMetadata
ExtractBodyMetadata extracts encoding metadata from a schema for a specific field
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server handles Unix socket communication with the SDK
func (*Server) GetInboundReplaySpan ¶
func (*Server) GetMatchEvents ¶
func (ms *Server) GetMatchEvents(traceID string) []MatchEvent
func (*Server) GetRootSpanID ¶
func (*Server) GetSDKVersion ¶
func (*Server) GetSocketPath ¶
func (*Server) GetSuiteSpans ¶
func (*Server) LoadSpansForTrace ¶
LoadSpansForTrace loads all spans for matching
func (*Server) SetCurrentTestID ¶
func (*Server) SetSuiteSpans ¶
func (*Server) WaitForInboundSpan ¶
func (*Server) WaitForSDKConnection ¶
type Test ¶
type Test struct {
FileName string `json:"file_name"`
TraceID string `json:"trace_id"`
TraceTestID string `json:"trace_test_id,omitempty"`
Spans []*core.Span `json:"-"`
Type string `json:"type"` // Used for test execution
DisplayType string `json:"display_type"` // Used for CLI display
Timestamp string `json:"timestamp"`
Method string `json:"method"`
Path string `json:"path"` // Used for test execution
DisplayName string `json:"display_name"` // Used for CLI display
Status string `json:"status"`
Duration int `json:"duration"`
Metadata map[string]any `json:"metadata"`
Request Request `json:"request"`
Response Response `json:"response"`
}
func ConvertTraceTestToRunnerTest ¶
ConvertTraceTestToRunnerTest converts a single protobuf TraceTest to runner.Test
func ConvertTraceTestsToRunnerTests ¶
ConvertTraceTestsToRunnerTests converts protobuf TraceTests to runner.Tests