[ADP-606] CloudEvents Testing Marker
Overview
This ADP defines a method for marking test events using CloudEvents context attributes, facilitating event testing, debugging, and validation.
Guidelines
MUST use the CloudEvents context attribute mechanism to add a test marker attribute.
The test marker attribute MUST be named
test
.The
test
attribute MUST be a string value in the format ofscope.type
, where:scope
identifies the testing scope (e.g., "order", "product", "user")type
specifies the type of test (e.g., "perf", "e2e")
Event consumers SHOULD check the
test
attribute and handle test events accordingly.Test events SHOULD NOT trigger critical operations or state changes in production systems.
Event producers SHOULD provide a mechanism to control the generation of test events.
Implementation Recommendations
Implement a switch in the event production environment to control the generation of events with the
test
attribute.Implement logic in event consumers to identify and appropriately handle test events.
Differentiate between test and production events in logging and monitoring systems.
Consider implementing a cleanup mechanism to periodically delete or archive test events.
Example
Here's an example of a CloudEvent with the test
attribute:
{
"specversion" : "1.0",
"type" : "com.example.someevent",
"source" : "/mycontext",
"id" : "C234-1234-1234",
"time" : "2023-06-01T10:30:00Z",
"test" : "integration.automated",
"data" : {
"message" : "This is a test event"
}
}
Test Scenarios
Test Event Generation: Verify that event producers can correctly generate events with the
test
attribute.Test Event Handling: Ensure that event consumers can identify test events and take appropriate actions.
Mixed Event Stream: Validate system behavior in a mixed stream of test and production events.
Test Mode Switching: Verify the ability to dynamically enable and disable test event generation.
Scope and Type Validation: Ensure that different
scope.type
combinations are correctly generated and handled.
Security Considerations
Ensure that test events do not inadvertently expose sensitive information.
Implement appropriate access controls to prevent unauthorized users from generating test events.
Monitor the use of test events to detect potential misuse or anomalous behavior.