SlideShare a Scribd company logo
1 of 28
Event Driven
Architecture Testing
Aditya Kumar Singh (Sofware Consultant)
Test Automation Competency
Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
 Punctuality
Join the session 5 minutes prior to the session start time. We start on
time and conclude on time!
 Feedback
Make sure to submit a constructive feedback for all sessions as it is very
helpful for the presenter.
 Silent Mode
Keep your mobile devices in silent mode, feel free to move out of session
in case you need to attend an urgent call.
 Avoid Disturbance
Avoid unwanted chit chat during the session.
1. Event Driven Architecture
2. Test Automation in Event Driven Architecture
o Identify Test Scenarios
o Testing Framework
o Design Reusable Components
o Parameterize Test Data
o Handling Asynchronous Behavior
o Implement Mocking Strategy
o Implement Idempotency
3. Strategies for Testing Event Driven Architecture
4. Key Challenges in Testing Event Driven Architecture
5. Quality Assurance Tools and Frameworks for
Event Driven Architecture
6. Q&A
Event Driven Architecture
 According to IBM, Event Driven Architecture is an integration model built around the publication, capture,
processing, and storage (or persistence) of events. When an application or service performs an action or
undergoes a change that another application or service might want to know about, it publishes an event—a
record of that action or change—that another application or service can consume and process to perform
actions in turn.
 What is an "Event" in context of Event Driven Architecture - An event within the context of a system refers to
a state change or any observable occurrence that an application or device can detect, record, and
communicate to other applications or devices.
o Events are completely asynchronous in nature,
o Events are immutable, cannot be changed or destroyed,
o Events help in achieving loose coupling between different components or services.
Example
Typical Components of Event Driven Architecture
 Event Producers - are components or entities responsible for generating and emitting events when a
significant change or occurrence takes place within the system.
 Event Brokers - serve as intermediaries that facilitate the communication between event producers
and event consumers. They receive events from producers and route them to the appropriate
consumers based on predefined rules.
 Event Consumers - are components or services that subscribe to and process events. They react to the
occurrence of specific events by performing predetermined actions or processes.
 Event Mesh - is an advanced concept that extends the idea of event brokers. It provides a networked
communication layer that allows events to flow seamlessly between various components and services.
02
01
03
Identify Test
Scenarios
04
Testing
Framework
Design Reusable
Components
Parameterize
Test Data
05
Handling
Asynchronous Behavior
06
Implement
Mocking Strategy
Test Automation In Event Driven Architecture
Identify Test Scenarios
• Clearly define the various scenarios and use cases for testing in our event-driven architecture.
o Positive Scenarios: Events are produced and consumed successfully.
o Negative Scenarios: Handling of errors, retries, and edge cases.
o Scalability: Testing the system's ability to handle a large number of events.
o Ordering: Verify the correct order of events.
• Identify edge cases, error conditions, and boundary conditions for comprehensive coverage.
• For Example:
public void testOrderProcessingEvent() {
OrderEvent orderEvent = new OrderEvent("placeOrder", orderId, items);
// Trigger the event
eventBus.publish(orderEvent);
assertTrue(orderProcessingService.isOrderProcessed(orderId));
}
Testing Framework
• The choice of a testing framework often depends on the programming language, technologies, and specific
requirements of your project.
• Popular frameworks for event-driven architectures include tools like JUnit, TestNG, and specialized event-driven
testing frameworks.
• For Example:
@Test
public void testAsynchronousEvent() {
CompletableFuture<String> futureResult = new CompletableFuture<>();
// Subscribe to an asynchronous event
eventBus.subscribe("asyncEvent", payload -> futureResult.complete(payload));
// Trigger the event
eventBus.publishAsync("asyncEvent", "TestPayload");
// Verify the asynchronous result
assertEquals("TestPayload", futureResult.join());
}
Design Reusable Components
• Create modular test components that can be reused across different test scenarios.
• Design functions or methods for common tasks such as event generation, verification, and state validation.
• For Example:
public class BaseEvent {
protected String eventId;
public BaseEvent(String eventId) {
this.eventId = eventId;
}
public String getEventId() {
return eventId;
}
}
OrderEvent orderEvent = new OrderEvent("123");
// Access common properties
String eventId = orderEvent.getEventId();
Parameterize Test Data
• Use parameterization to vary test data and cover a wide range of scenarios.
• Ensure that test data is easily maintainable and can be updated without modifying the entire test script.
• For Example:
@DataProvider(name = "orderData")
public Object[][] orderData() {
return new Object[][] {
{ "orderId1", Arrays.asList(item1, item2) },
{ "orderId2", Arrays.asList(item3, item4) },
// Additional test data
};
}
@Test(dataProvider = "orderData")
public void testOrderProcessingEvent(String orderId, List<Item> items) {
OrderEvent orderEvent = EventUtils.createOrderEvent(orderId, items);
}
Handling Asynchronous Behavior
• Implement mechanisms to handle the asynchronous nature of events.
• Use proper synchronization techniques to wait for events or signals before proceeding with verification.
• For Example:
@Test
public void testAsyncEventHandling() throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
eventBus.subscribe("asyncEvent", payload -> {
latch.countDown();
});
// Trigger the asynchronous event
eventBus.publishAsync("asyncEvent", "TestPayload");
// Wait for the event to be processed
latch.await();
}
Implement Mocking Strategy
• Create mock objects or stubs for external dependencies or services that emit events.
• Simulate different scenarios by configuring mock behaviors.
• Ensure that mocks are easily configurable for different test cases.
• For Example:
@Test
public void testEventHandlingWithMock() {
ExternalService mockService = mock(ExternalService.class);
// Inject the mock service into the event handler
eventHandler.setExternalService(mockService);
// Trigger the event
eventBus.publish(new SampleEvent("test"));
verify(mockService).processEvent(any());
}
Event Generation Testing :
• Validation Logic:
o Review the conditional statements and rules triggering
events.
o Ensure that the logic is comprehensive, covering all
relevant scenarios.
• Timing Analysis:
o Evaluate the system's responsiveness in generating
events promptly after the triggering conditions are met.
o Assess the impact of system load on the timing of event
generation.
Strategies for Testing Event Driven Architecture
Event Consumption Testing :
• Subscription Verification:
o Validate that subscription mechanisms correctly register
components for relevant events.
o Confirm that Un-subscription is handled appropriately.
• Order of Processing:
o Test scenarios where events arrive out of order to assess
the system's ability to reorder and process them correctly.
o Evaluate the impact of event processing delays on the
overall system state.
Event Payload Testing :
• Schema Validation:
o Perform exhaustive testing against the event payload
schema, including edge cases.
o Check for backward compatibility with older event versions.
• Completeness Check:
o Verify that all required information for downstream
processes is present in the payload.
o Consider scenarios where optional fields are missing.
Event Routing Testing :
• Destination Mapping:
o Assess the mapping between events and their intended destinations or subscribers.
o Verify that updates to destination mappings do not disrupt the routing mechanism.
• Filtering Mechanism:
o Test scenarios where events contain additional information, ensuring that the filtering mechanism
correctly identifies relevant data.
Concurrency and Parallelism Testing :
 Simultaneous Event Handling:
o Assess the system's behavior when multiple components attempt to process events concurrently.
o Verify that locks and synchronization mechanisms prevent data corruption.
 Resource Utilization:
o Monitor resource usage during peak event loads to identify potential resource exhaustion or
contention.
Event Orchestration Testing :
 Sequence Validation:
o Test scenarios where events trigger complex
sequences of actions across multiple components.
o Verify that dependencies are satisfied before
executing orchestrated actions.
 Dependency Testing:
o Evaluate the handling of dependencies between
events and their impact on the overall system flow.
Asynchronous Communication
 Challenge: Asynchronous event-driven
systems operate without a direct request-
response mechanism, making it challenging
to trace and monitor the flow of events.
 Details:
o Traditional testing methodologies
relying on synchronous interactions
may not be directly applicable.
o It's difficult to predict the exact order
of events and their impact on the
system, requiring specialized testing
approaches.
Distributed Systems Complexity
 Challenge: Event-driven systems often involve
multiple distributed components, making it
complex to test interactions and dependencies
across these components accurately.
 Details:
o Coordinating testing efforts across
distributed systems requires specialized
tools and frameworks.
o Issues such as network latency and varying
processing times can impact the reliability
of event propagation.
Fault Tolerance and Resilience
 Challenge: Testing the system's ability to handle
faults, failures, and unexpected events is critical
for ensuring resilience. However, replicating
real-world failure scenarios can be complex.
 Details:
o Simulating network failures, component
crashes, or transient errors requires
specialized testing environments.
o Ensuring that the system can recover
gracefully without data loss poses
additional challenges.
Dynamic Event Subscriptions
 Challenge: Dynamic changes in event
subscriptions, where components subscribe or
unsubscribe from events at runtime, introduce
challenges in maintaining a consistent system
state.
 Details:
o Testing scenarios where subscription
changes occur concurrently with event
generation and consumption is challenging.
o Coordinating dynamic subscription changes
without disrupting ongoing processes is
critical.
Security in Event Driven Systems
 Challenge: Ensuring the security of event data
during transmission and processing poses unique
challenges in the decentralized and distributed
nature of event-driven architectures.
 Details:
o Testing for vulnerabilities such as
eavesdropping, unauthorized event
injection, and ensuring secure
authentication and authorization is
essential.
o Coordinating security testing across multiple
components and communication channels
requires a comprehensive approach.
 Pact is a contract testing tool that
helps ensure interactions between
services are as expected.
 It's beneficial for testing contracts
between Event Producers and
Event Consumers in event-
driven systems.
Tools and Framework For Event Driven Architecture
 Karate is a testing framework that
enables behavior-
driven development (BDD) for
API testing. It can be used to
test APIs and event-driven
systems effectively.
 Gatling is a powerful open-source
load testing tool. It can be used to
simulate realistic user scenarios and
stress test event-driven systems
for performance and scalability.
 Prometheus is an open-
source monitoring and alerting
toolkit designed for reliability. It
can be integrated into event-driven
architectures to collect metrics and
monitor system health.
 Grafana is an open-source platform
for monitoring and observability. It
can be used in conjunction with
Prometheus to create
customizable dashboards and
visualize data from event-driven
systems.
 New Relic is a
comprehensive observability
platform that provides monitoring,
alerting, and visualization tools.
It supports monitoring of event-
driven architectures for performance
and reliability.
Testing Event Driven Architecture Presentation
Testing Event Driven Architecture Presentation

More Related Content

Similar to Testing Event Driven Architecture Presentation

Qtp Training
Qtp TrainingQtp Training
Qtp Training
mehramit
 
Cerberus_Presentation1
Cerberus_Presentation1Cerberus_Presentation1
Cerberus_Presentation1
CIVEL Benoit
 
Shravyashree Selenium Automation 3+yrs exp
Shravyashree Selenium Automation 3+yrs expShravyashree Selenium Automation 3+yrs exp
Shravyashree Selenium Automation 3+yrs exp
Shravyashree Achar M
 
谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability
drewz lin
 

Similar to Testing Event Driven Architecture Presentation (20)

Qtp Training
Qtp TrainingQtp Training
Qtp Training
 
Testing in a distributed world
Testing in a distributed worldTesting in a distributed world
Testing in a distributed world
 
Chamundeswari_Resume
Chamundeswari_ResumeChamundeswari_Resume
Chamundeswari_Resume
 
Regulated Reactive - Security Considerations for Building Reactive Systems in...
Regulated Reactive - Security Considerations for Building Reactive Systems in...Regulated Reactive - Security Considerations for Building Reactive Systems in...
Regulated Reactive - Security Considerations for Building Reactive Systems in...
 
Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)Cerberus : Framework for Manual and Automated Testing (Web Application)
Cerberus : Framework for Manual and Automated Testing (Web Application)
 
Cerberus_Presentation1
Cerberus_Presentation1Cerberus_Presentation1
Cerberus_Presentation1
 
Shravyashree Selenium Automation 3+yrs exp
Shravyashree Selenium Automation 3+yrs expShravyashree Selenium Automation 3+yrs exp
Shravyashree Selenium Automation 3+yrs exp
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Role+Of+Testing+In+Sdlc
Role+Of+Testing+In+SdlcRole+Of+Testing+In+Sdlc
Role+Of+Testing+In+Sdlc
 
system verilog
system verilogsystem verilog
system verilog
 
Automated testing-whitepaper
Automated testing-whitepaperAutomated testing-whitepaper
Automated testing-whitepaper
 
Openstack Cloud Management and Automation Using Red Hat Cloudforms 4.0
Openstack Cloud  Management and Automation Using Red Hat Cloudforms 4.0Openstack Cloud  Management and Automation Using Red Hat Cloudforms 4.0
Openstack Cloud Management and Automation Using Red Hat Cloudforms 4.0
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Software Testing 1198102207476437 4
Software Testing 1198102207476437 4Software Testing 1198102207476437 4
Software Testing 1198102207476437 4
 
Introduction to DevSecOps
Introduction to DevSecOpsIntroduction to DevSecOps
Introduction to DevSecOps
 
谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability
 
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web TestingThe Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
 
Testing Event Driven Architectures: How to Broker the Complexity | Frank Kilc...
Testing Event Driven Architectures: How to Broker the Complexity | Frank Kilc...Testing Event Driven Architectures: How to Broker the Complexity | Frank Kilc...
Testing Event Driven Architectures: How to Broker the Complexity | Frank Kilc...
 
Creating Test Scenarios Demystified_ Your Ultimate How-To Guide.pdf
Creating Test Scenarios Demystified_ Your Ultimate How-To Guide.pdfCreating Test Scenarios Demystified_ Your Ultimate How-To Guide.pdf
Creating Test Scenarios Demystified_ Your Ultimate How-To Guide.pdf
 
Effective Software Test Case Design Approach
Effective Software Test Case Design ApproachEffective Software Test Case Design Approach
Effective Software Test Case Design Approach
 

More from Knoldus Inc.

More from Knoldus Inc. (20)

Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptx
 
GraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdfGraphQL with .NET Core Microservices.pdf
GraphQL with .NET Core Microservices.pdf
 
NuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptxNuGet Packages Presentation (DoT NeT).pptx
NuGet Packages Presentation (DoT NeT).pptx
 
Data Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable TestingData Quality in Test Automation Navigating the Path to Reliable Testing
Data Quality in Test Automation Navigating the Path to Reliable Testing
 
K8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose KubernetesK8sGPTThe AI​ way to diagnose Kubernetes
K8sGPTThe AI​ way to diagnose Kubernetes
 
Introduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptxIntroduction to Circle Ci Presentation.pptx
Introduction to Circle Ci Presentation.pptx
 
Robusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptxRobusta -Tool Presentation (DevOps).pptx
Robusta -Tool Presentation (DevOps).pptx
 
Optimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptxOptimizing Kubernetes using GOLDILOCKS.pptx
Optimizing Kubernetes using GOLDILOCKS.pptx
 
Azure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptxAzure Function App Exception Handling.pptx
Azure Function App Exception Handling.pptx
 
CQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptxCQRS Design Pattern Presentation (Java).pptx
CQRS Design Pattern Presentation (Java).pptx
 
ETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake PresentationETL Observability: Azure to Snowflake Presentation
ETL Observability: Azure to Snowflake Presentation
 
Scripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics PresentationScripting with K6 - Beyond the Basics Presentation
Scripting with K6 - Beyond the Basics Presentation
 
Getting started with dotnet core Web APIs
Getting started with dotnet core Web APIsGetting started with dotnet core Web APIs
Getting started with dotnet core Web APIs
 
Introduction To Rust part II Presentation
Introduction To Rust part II PresentationIntroduction To Rust part II Presentation
Introduction To Rust part II Presentation
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Configuring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRAConfiguring Workflows & Validators in JIRA
Configuring Workflows & Validators in JIRA
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Testing Event Driven Architecture Presentation

  • 1. Event Driven Architecture Testing Aditya Kumar Singh (Sofware Consultant) Test Automation Competency
  • 2. Lack of etiquette and manners is a huge turn off. KnolX Etiquettes  Punctuality Join the session 5 minutes prior to the session start time. We start on time and conclude on time!  Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter.  Silent Mode Keep your mobile devices in silent mode, feel free to move out of session in case you need to attend an urgent call.  Avoid Disturbance Avoid unwanted chit chat during the session.
  • 3. 1. Event Driven Architecture 2. Test Automation in Event Driven Architecture o Identify Test Scenarios o Testing Framework o Design Reusable Components o Parameterize Test Data o Handling Asynchronous Behavior o Implement Mocking Strategy o Implement Idempotency 3. Strategies for Testing Event Driven Architecture 4. Key Challenges in Testing Event Driven Architecture 5. Quality Assurance Tools and Frameworks for Event Driven Architecture 6. Q&A
  • 4. Event Driven Architecture  According to IBM, Event Driven Architecture is an integration model built around the publication, capture, processing, and storage (or persistence) of events. When an application or service performs an action or undergoes a change that another application or service might want to know about, it publishes an event—a record of that action or change—that another application or service can consume and process to perform actions in turn.  What is an "Event" in context of Event Driven Architecture - An event within the context of a system refers to a state change or any observable occurrence that an application or device can detect, record, and communicate to other applications or devices. o Events are completely asynchronous in nature, o Events are immutable, cannot be changed or destroyed, o Events help in achieving loose coupling between different components or services.
  • 6. Typical Components of Event Driven Architecture  Event Producers - are components or entities responsible for generating and emitting events when a significant change or occurrence takes place within the system.  Event Brokers - serve as intermediaries that facilitate the communication between event producers and event consumers. They receive events from producers and route them to the appropriate consumers based on predefined rules.  Event Consumers - are components or services that subscribe to and process events. They react to the occurrence of specific events by performing predetermined actions or processes.  Event Mesh - is an advanced concept that extends the idea of event brokers. It provides a networked communication layer that allows events to flow seamlessly between various components and services.
  • 7. 02 01 03 Identify Test Scenarios 04 Testing Framework Design Reusable Components Parameterize Test Data 05 Handling Asynchronous Behavior 06 Implement Mocking Strategy Test Automation In Event Driven Architecture
  • 8. Identify Test Scenarios • Clearly define the various scenarios and use cases for testing in our event-driven architecture. o Positive Scenarios: Events are produced and consumed successfully. o Negative Scenarios: Handling of errors, retries, and edge cases. o Scalability: Testing the system's ability to handle a large number of events. o Ordering: Verify the correct order of events. • Identify edge cases, error conditions, and boundary conditions for comprehensive coverage. • For Example: public void testOrderProcessingEvent() { OrderEvent orderEvent = new OrderEvent("placeOrder", orderId, items); // Trigger the event eventBus.publish(orderEvent); assertTrue(orderProcessingService.isOrderProcessed(orderId)); }
  • 9. Testing Framework • The choice of a testing framework often depends on the programming language, technologies, and specific requirements of your project. • Popular frameworks for event-driven architectures include tools like JUnit, TestNG, and specialized event-driven testing frameworks. • For Example: @Test public void testAsynchronousEvent() { CompletableFuture<String> futureResult = new CompletableFuture<>(); // Subscribe to an asynchronous event eventBus.subscribe("asyncEvent", payload -> futureResult.complete(payload)); // Trigger the event eventBus.publishAsync("asyncEvent", "TestPayload"); // Verify the asynchronous result assertEquals("TestPayload", futureResult.join()); }
  • 10. Design Reusable Components • Create modular test components that can be reused across different test scenarios. • Design functions or methods for common tasks such as event generation, verification, and state validation. • For Example: public class BaseEvent { protected String eventId; public BaseEvent(String eventId) { this.eventId = eventId; } public String getEventId() { return eventId; } } OrderEvent orderEvent = new OrderEvent("123"); // Access common properties String eventId = orderEvent.getEventId();
  • 11. Parameterize Test Data • Use parameterization to vary test data and cover a wide range of scenarios. • Ensure that test data is easily maintainable and can be updated without modifying the entire test script. • For Example: @DataProvider(name = "orderData") public Object[][] orderData() { return new Object[][] { { "orderId1", Arrays.asList(item1, item2) }, { "orderId2", Arrays.asList(item3, item4) }, // Additional test data }; } @Test(dataProvider = "orderData") public void testOrderProcessingEvent(String orderId, List<Item> items) { OrderEvent orderEvent = EventUtils.createOrderEvent(orderId, items); }
  • 12. Handling Asynchronous Behavior • Implement mechanisms to handle the asynchronous nature of events. • Use proper synchronization techniques to wait for events or signals before proceeding with verification. • For Example: @Test public void testAsyncEventHandling() throws InterruptedException { CountDownLatch latch = new CountDownLatch(1); eventBus.subscribe("asyncEvent", payload -> { latch.countDown(); }); // Trigger the asynchronous event eventBus.publishAsync("asyncEvent", "TestPayload"); // Wait for the event to be processed latch.await(); }
  • 13. Implement Mocking Strategy • Create mock objects or stubs for external dependencies or services that emit events. • Simulate different scenarios by configuring mock behaviors. • Ensure that mocks are easily configurable for different test cases. • For Example: @Test public void testEventHandlingWithMock() { ExternalService mockService = mock(ExternalService.class); // Inject the mock service into the event handler eventHandler.setExternalService(mockService); // Trigger the event eventBus.publish(new SampleEvent("test")); verify(mockService).processEvent(any()); }
  • 14. Event Generation Testing : • Validation Logic: o Review the conditional statements and rules triggering events. o Ensure that the logic is comprehensive, covering all relevant scenarios. • Timing Analysis: o Evaluate the system's responsiveness in generating events promptly after the triggering conditions are met. o Assess the impact of system load on the timing of event generation. Strategies for Testing Event Driven Architecture
  • 15. Event Consumption Testing : • Subscription Verification: o Validate that subscription mechanisms correctly register components for relevant events. o Confirm that Un-subscription is handled appropriately. • Order of Processing: o Test scenarios where events arrive out of order to assess the system's ability to reorder and process them correctly. o Evaluate the impact of event processing delays on the overall system state.
  • 16. Event Payload Testing : • Schema Validation: o Perform exhaustive testing against the event payload schema, including edge cases. o Check for backward compatibility with older event versions. • Completeness Check: o Verify that all required information for downstream processes is present in the payload. o Consider scenarios where optional fields are missing.
  • 17. Event Routing Testing : • Destination Mapping: o Assess the mapping between events and their intended destinations or subscribers. o Verify that updates to destination mappings do not disrupt the routing mechanism. • Filtering Mechanism: o Test scenarios where events contain additional information, ensuring that the filtering mechanism correctly identifies relevant data.
  • 18. Concurrency and Parallelism Testing :  Simultaneous Event Handling: o Assess the system's behavior when multiple components attempt to process events concurrently. o Verify that locks and synchronization mechanisms prevent data corruption.  Resource Utilization: o Monitor resource usage during peak event loads to identify potential resource exhaustion or contention.
  • 19. Event Orchestration Testing :  Sequence Validation: o Test scenarios where events trigger complex sequences of actions across multiple components. o Verify that dependencies are satisfied before executing orchestrated actions.  Dependency Testing: o Evaluate the handling of dependencies between events and their impact on the overall system flow.
  • 20.
  • 21. Asynchronous Communication  Challenge: Asynchronous event-driven systems operate without a direct request- response mechanism, making it challenging to trace and monitor the flow of events.  Details: o Traditional testing methodologies relying on synchronous interactions may not be directly applicable. o It's difficult to predict the exact order of events and their impact on the system, requiring specialized testing approaches.
  • 22. Distributed Systems Complexity  Challenge: Event-driven systems often involve multiple distributed components, making it complex to test interactions and dependencies across these components accurately.  Details: o Coordinating testing efforts across distributed systems requires specialized tools and frameworks. o Issues such as network latency and varying processing times can impact the reliability of event propagation.
  • 23. Fault Tolerance and Resilience  Challenge: Testing the system's ability to handle faults, failures, and unexpected events is critical for ensuring resilience. However, replicating real-world failure scenarios can be complex.  Details: o Simulating network failures, component crashes, or transient errors requires specialized testing environments. o Ensuring that the system can recover gracefully without data loss poses additional challenges.
  • 24. Dynamic Event Subscriptions  Challenge: Dynamic changes in event subscriptions, where components subscribe or unsubscribe from events at runtime, introduce challenges in maintaining a consistent system state.  Details: o Testing scenarios where subscription changes occur concurrently with event generation and consumption is challenging. o Coordinating dynamic subscription changes without disrupting ongoing processes is critical.
  • 25. Security in Event Driven Systems  Challenge: Ensuring the security of event data during transmission and processing poses unique challenges in the decentralized and distributed nature of event-driven architectures.  Details: o Testing for vulnerabilities such as eavesdropping, unauthorized event injection, and ensuring secure authentication and authorization is essential. o Coordinating security testing across multiple components and communication channels requires a comprehensive approach.
  • 26.  Pact is a contract testing tool that helps ensure interactions between services are as expected.  It's beneficial for testing contracts between Event Producers and Event Consumers in event- driven systems. Tools and Framework For Event Driven Architecture  Karate is a testing framework that enables behavior- driven development (BDD) for API testing. It can be used to test APIs and event-driven systems effectively.  Gatling is a powerful open-source load testing tool. It can be used to simulate realistic user scenarios and stress test event-driven systems for performance and scalability.  Prometheus is an open- source monitoring and alerting toolkit designed for reliability. It can be integrated into event-driven architectures to collect metrics and monitor system health.  Grafana is an open-source platform for monitoring and observability. It can be used in conjunction with Prometheus to create customizable dashboards and visualize data from event-driven systems.  New Relic is a comprehensive observability platform that provides monitoring, alerting, and visualization tools. It supports monitoring of event- driven architectures for performance and reliability.