Skip to content
ADP
API Design PrincipleBETA

[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

  1. MUST use the CloudEvents context attribute mechanism to add a test marker attribute.

  2. The test marker attribute MUST be named test.

  3. The test attribute MUST be a string value in the format of scope.type, where:

    • scope identifies the testing scope (e.g., "order", "product", "user")
    • type specifies the type of test (e.g., "perf", "e2e")
  4. Event consumers SHOULD check the test attribute and handle test events accordingly.

  5. Test events SHOULD NOT trigger critical operations or state changes in production systems.

  6. Event producers SHOULD provide a mechanism to control the generation of test events.

Implementation Recommendations

  1. Implement a switch in the event production environment to control the generation of events with the test attribute.

  2. Implement logic in event consumers to identify and appropriately handle test events.

  3. Differentiate between test and production events in logging and monitoring systems.

  4. Consider implementing a cleanup mechanism to periodically delete or archive test events.

Example

Here's an example of a CloudEvent with the test attribute:

json
{
  "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

  1. Test Event Generation: Verify that event producers can correctly generate events with the test attribute.

  2. Test Event Handling: Ensure that event consumers can identify test events and take appropriate actions.

  3. Mixed Event Stream: Validate system behavior in a mixed stream of test and production events.

  4. Test Mode Switching: Verify the ability to dynamically enable and disable test event generation.

  5. Scope and Type Validation: Ensure that different scope.type combinations are correctly generated and handled.

Security Considerations

  1. Ensure that test events do not inadvertently expose sensitive information.

  2. Implement appropriate access controls to prevent unauthorized users from generating test events.

  3. Monitor the use of test events to detect potential misuse or anomalous behavior.

References