Documentation
¶
Overview ¶
Package integration provides end-to-end Lambda function testing utilities and test case management.
Index ¶
- func AssertColdStartTime(t *testing.T, duration time.Duration, maxAllowed time.Duration)
- func AssertLambdaResponse(t *testing.T, response interface{}, expectedStatus int, ...)
- func AssertWarmStartTime(t *testing.T, duration time.Duration, maxAllowed time.Duration)
- func BuildAPIGatewayEvent(method, path string, body interface{}, headers map[string]string) events.APIGatewayV2HTTPRequest
- func BuildDynamoDBStreamEvent(eventName string, newImage, oldImage map[string]interface{}) events.DynamoDBEvent
- func BuildEventBridgeEvent(source, detailType string, detail interface{}) events.CloudWatchEvent
- func BuildS3Event(bucket, key, eventName string) events.S3Event
- func BuildSQSEvent(messages ...string) events.SQSEvent
- func RunBatchStreamTest(t *testing.T, handler func(context.Context, events.DynamoDBEvent) error, ...)
- func RunConcurrencyTest(t *testing.T, handler lambda.Handler, test LambdaConcurrencyTest)
- func RunStreamReplay(t *testing.T, test StreamReplayTest, records []events.DynamoDBEventRecord)
- func TestStreamErrorScenarios(t *testing.T, handler func(context.Context, events.DynamoDBEvent) error)
- func TestStreamIdempotency(t *testing.T, handler func(context.Context, events.DynamoDBEvent) error)
- func TestStreamOrdering(t *testing.T, handler func(context.Context, events.DynamoDBEvent) error)
- type BatchStreamTest
- type LagMeasurement
- type LambdaConcurrencyTest
- type LambdaTestCase
- type LambdaTestSuite
- type MemoryProfiler
- type StreamEvent
- type StreamEventCollector
- type StreamLagMonitor
- type StreamMetrics
- type StreamReplayTest
- type StreamTestCase
- type StreamTestResult
- type StreamTestSuite
- type TestMetrics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertColdStartTime ¶
AssertColdStartTime verifies cold start performance
func AssertLambdaResponse ¶
func AssertLambdaResponse(t *testing.T, response interface{}, expectedStatus int, expectedBody interface{})
AssertLambdaResponse validates Lambda response structure
func AssertWarmStartTime ¶
AssertWarmStartTime verifies warm start performance
func BuildAPIGatewayEvent ¶
func BuildAPIGatewayEvent(method, path string, body interface{}, headers map[string]string) events.APIGatewayV2HTTPRequest
BuildAPIGatewayEvent creates an API Gateway event for testing
func BuildDynamoDBStreamEvent ¶
func BuildDynamoDBStreamEvent(eventName string, newImage, oldImage map[string]interface{}) events.DynamoDBEvent
BuildDynamoDBStreamEvent creates a DynamoDB stream event for testing
func BuildEventBridgeEvent ¶
func BuildEventBridgeEvent(source, detailType string, detail interface{}) events.CloudWatchEvent
BuildEventBridgeEvent creates an EventBridge event for testing
func BuildS3Event ¶
BuildS3Event creates an S3 event for testing
func BuildSQSEvent ¶
BuildSQSEvent creates an SQS event for testing
func RunBatchStreamTest ¶
func RunBatchStreamTest(t *testing.T, handler func(context.Context, events.DynamoDBEvent) error, test BatchStreamTest)
RunBatchStreamTest executes batch stream processing test
func RunConcurrencyTest ¶
func RunConcurrencyTest(t *testing.T, handler lambda.Handler, test LambdaConcurrencyTest)
RunConcurrencyTest executes Lambda concurrency test
func RunStreamReplay ¶
func RunStreamReplay(t *testing.T, test StreamReplayTest, records []events.DynamoDBEventRecord)
RunStreamReplay executes stream replay test
func TestStreamErrorScenarios ¶
func TestStreamErrorScenarios(t *testing.T, handler func(context.Context, events.DynamoDBEvent) error)
TestStreamErrorScenarios tests error handling in stream processing
func TestStreamIdempotency ¶
TestStreamIdempotency tests idempotent stream processing
func TestStreamOrdering ¶
TestStreamOrdering tests stream record ordering
Types ¶
type BatchStreamTest ¶
type BatchStreamTest struct {
BatchSize int
Records []events.DynamoDBEventRecord
MaxConcurrency int
Timeout time.Duration
}
BatchStreamTest tests batch stream processing
type LagMeasurement ¶
LagMeasurement represents a lag measurement
type LambdaConcurrencyTest ¶
type LambdaConcurrencyTest struct {
Name string
ConcurrentRequests int
RequestBuilder func(int) interface{}
ValidateResponse func(*testing.T, interface{}, error)
MaxDuration time.Duration
}
LambdaConcurrencyTest tests Lambda under concurrent load
type LambdaTestCase ¶
type LambdaTestCase struct {
Name string
Event interface{}
SetupFunc func() error
CleanupFunc func() error
ValidateFunc func(*testing.T, interface{}, error)
ExpectedError bool
Timeout time.Duration
}
LambdaTestCase defines an end-to-end Lambda test case
type LambdaTestSuite ¶
type LambdaTestSuite struct {
// contains filtered or unexported fields
}
LambdaTestSuite provides utilities for end-to-end Lambda testing
func NewLambdaTestSuite ¶
func NewLambdaTestSuite(t *testing.T, handler lambda.Handler) *LambdaTestSuite
NewLambdaTestSuite creates a new Lambda test suite
func (*LambdaTestSuite) PrintMetrics ¶
func (s *LambdaTestSuite) PrintMetrics()
PrintMetrics prints test metrics summary
func (*LambdaTestSuite) RunTest ¶
func (s *LambdaTestSuite) RunTest(tc LambdaTestCase)
RunTest executes a single Lambda test case
func (*LambdaTestSuite) RunTests ¶
func (s *LambdaTestSuite) RunTests(testCases []LambdaTestCase)
RunTests executes multiple Lambda test cases
type MemoryProfiler ¶
type MemoryProfiler struct {
// contains filtered or unexported fields
}
MemoryProfiler tracks Lambda memory usage
func NewMemoryProfiler ¶
func NewMemoryProfiler() *MemoryProfiler
NewMemoryProfiler creates a memory profiler
func (*MemoryProfiler) GetPeakMemory ¶
func (m *MemoryProfiler) GetPeakMemory() int
GetPeakMemory returns peak memory usage
func (*MemoryProfiler) Sample ¶
func (m *MemoryProfiler) Sample()
Sample records current memory usage
type StreamEvent ¶
type StreamEvent struct {
Type string
Timestamp time.Time
Data interface{}
Metadata map[string]interface{}
}
StreamEvent represents a processed stream event
type StreamEventCollector ¶
type StreamEventCollector struct {
// contains filtered or unexported fields
}
StreamEventCollector collects events for validation
func (*StreamEventCollector) AddEvent ¶
func (c *StreamEventCollector) AddEvent(eventType string, data interface{})
AddEvent adds an event to the collector
func (*StreamEventCollector) GetEvents ¶
func (c *StreamEventCollector) GetEvents() []StreamEvent
GetEvents returns collected events
type StreamLagMonitor ¶
type StreamLagMonitor struct {
// contains filtered or unexported fields
}
StreamLagMonitor monitors stream processing lag
func NewStreamLagMonitor ¶
func NewStreamLagMonitor(alertThreshold time.Duration) *StreamLagMonitor
NewStreamLagMonitor creates a lag monitor
func (*StreamLagMonitor) GetHighLagRecords ¶
func (m *StreamLagMonitor) GetHighLagRecords() []LagMeasurement
GetHighLagRecords returns records with high lag
func (*StreamLagMonitor) RecordLag ¶
func (m *StreamLagMonitor) RecordLag(record events.DynamoDBEventRecord)
RecordLag records stream lag
type StreamMetrics ¶
type StreamMetrics struct {
TotalRecords int
ProcessedRecords int
FailedRecords int
RetryCount int
ProcessingTime map[string]time.Duration
RecordLag []time.Duration
BatchSizes []int
// contains filtered or unexported fields
}
StreamMetrics tracks stream processing metrics
type StreamReplayTest ¶
type StreamReplayTest struct {
Name string
StartTime time.Time
EndTime time.Time
RecordFilter func(events.DynamoDBEventRecord) bool
ProcessRecord func(events.DynamoDBEventRecord) error
}
StreamReplayTest replays historical stream records
type StreamTestCase ¶
type StreamTestCase struct {
Name string
Operation string // INSERT, MODIFY, REMOVE
OldImage interface{}
NewImage interface{}
SetupFunc func() error
ValidateFunc func(*testing.T, *StreamTestResult)
ExpectedEvents []string
Timeout time.Duration
}
StreamTestCase defines a DynamoDB stream test case
type StreamTestResult ¶
type StreamTestResult struct {
ProcessedRecords int
FailedRecords int
Events []StreamEvent
Duration time.Duration
Errors []error
}
StreamTestResult captures stream processing results
type StreamTestSuite ¶
type StreamTestSuite struct {
// contains filtered or unexported fields
}
StreamTestSuite provides utilities for testing DynamoDB streams
func NewStreamTestSuite ¶
func NewStreamTestSuite(t *testing.T, handler func(context.Context, events.DynamoDBEvent) error) *StreamTestSuite
NewStreamTestSuite creates a new stream test suite
func (*StreamTestSuite) PrintMetrics ¶
func (s *StreamTestSuite) PrintMetrics()
PrintMetrics prints stream processing metrics
func (*StreamTestSuite) RunTest ¶
func (s *StreamTestSuite) RunTest(tc StreamTestCase)
RunTest executes a stream test case