SlideShare a Scribd company logo
1
Testing a Service
Fabric solution and
live happy!!!
Massimo Bonanni
Paranormal Developer, with the head in the Cloud and all the
REST in microservices!
@massimobonanni
massimo.bonanni@microsoft.com
@cloudgen_verona
#CodeGen
#dotnetconf
3
Main sponsor
4
Community sponsors
5
6
Unit testing
8
Programming
Models
Dev & Ops
Tooling
Orchestration Lifecycle
Management
Health &
Monitoring
Always On
Availability
Auto
Scaling
AzureOn-premises infrastructureAny cloudDev machine
Service Fabric: Microservices platform
ExecutablesReliable Services (.NET, Java)
Reliable Actors (.NET, Java)ASP.NET Core
Containers
9
F5 is our friend….
It is the most used test tools
It's free and you can find it in all Visual
Studio versions
You don’t have to write any additional code
10
F5 is not useful …. with Service Fabric
Resources – you need a local cluster
Time – you need to publish the app
Code complete – you need all the
microservices you interact with
11
Why unit test…
A unit test is an automated piece
of code that invokes a unit of work
in the system and then checks a
single assumption about the
behavior of that unit of work.
Roy Osherove – The Art Of Unit Testing
Microservices are small, perform
single functionality and loosely
coupled.
Microservices Architecture
12
Why unit test…
A unit test is an automated piece
of code that invokes a unit of work
in the system and then checks a
single assumption about the
behavior of that unit of work.
Roy Osherove – The Art Of Unit Testing
Microservices are small, perform
single functionality and loosely
coupled.
Microservices Architecture
A microservice is
your Unit of
Work to test!!!
13
The three obstacles
Your
µService
Service Fabric Platform
Replicas Partitioning State Management……
File System Database Web Service
External Components Others µServices
14
Real case: Shopping Cart & Order
We model 3 typical shopping cart scenarios
• The cart can be created only if it is a new cart
Creating the shopping cart
• Need to check if the product is still available
Adding a product to the cart
• The order is created starting from the cart and only if the order is new
Creating an order from the cart
15
Scenario : Creating the shopping cart
We must "replace" the
Service Fabric platform, so
our tests doesn’t need the
cluster.
Service Fabric Platform
Replicas Partitioning
State
Management
……
16
Scenario : Creating the shopping cart
this.StateManager.TryGetStateAsync<State>(StateKeyName,
cancellationToken);
this.StateManager.SetStateAsync(StateKeyName,
state, cancellationToken);
this.RegisterReminderAsync(ExpiredReminderName, null,
CartExpiredTimeout, TimeSpan.FromMilliseconds(-1));
17
Scenario : Adding a product to the cart
We need to decouple our
microservice from external
components, so that our tests can
verify only the actor's logic.
File System Database Web Service
External Components
18
Scenario : Adding a product to the cart
private async Task<ProductData> GetProductFromStorageAsync(string productId,
double quantity, CancellationToken cancellationToken)
{
ProductData result = null;
try
{
using (SqlConnection conn = new SqlConnection(connectionString))
using (SqlCommand cmd = new SqlCommand("CheckProduct", conn))
{
// Database code
}
}
catch
{
result = null;
}
return result;
}
19
Scenario : Creating an order from the cart
We must to replace the static
classes ActorProxy and
ServiceProxy used in the
creation of communication
proxies.
Others µServices
20
Scenario : Creating an order from the cart
var orderProxy = ActorProxy.Create<IOrderActor>(this.Id,
new Uri("fabric:/TestingApp/OrderActor"));
Demo:
Unit test
22
The three obstacles….three solutions!
Your
µService
Service Fabric Platform
Replicas Partitioning
State
Management
……
File System Database Web Service
External Components Others µServices
Mock the platform
(ServiceFabric.Mocks)
Abstract the proxy
factories
Create a layer of
indirection
The CHAOS
24
Keep the stability!!!!
Solutions based on distributed architectures such as cloud infrastructures
must be:
This is why you need to be able to test the stability of your solutions when
complex state transitions due to errors occur in the underlying
infrastructure.
•able to withstand or recover quickly from difficult conditionsResilient
• its status does not get corrupted as a result of a problemReliable
25
What can go wrong in production?
Restarting a
node
Restarting a
distributed
code package
Removing a
replica
Restarting a
replica
Moving a
primary
replica
Moving a
secondary
replica
Remove a
node
Add a node
26
27
Start-ServiceFabricChaos
Chaos induces faults in the cluster based on the received input
parameters.
Chaos runs in multiple iterations: each iteration consists of faults
and cluster validation.
You can control:
• how long Chaos runs,
• how long it waits between
iterations,
• how many faults it can induce
during an iteration,
• how long it waits between faults.
• ….
Demo:
Chaos test
29
Take away….
Keep the microservices simple….they will be
testability simply!
When design a solution, keep in mind the
testability!
Mock, fake and shim are your best friends!
If car companies launch expensive cars
against a wall to test them, why should not
you do it with your code?
Grazie
massimobonanni @massimobonanni massimobonanni

More Related Content

What's hot (20)

PDF
Designing an effective hybrid apps automation framework
Andrea Tino
 
PDF
Tales of an open source library
Adam Klein
 
PDF
Mobx Internals
500Tech
 
PPTX
Spring boot
Shatrughna Singh
 
PPTX
Visualforce remoteobject
Karanraj Sankaranarayanan
 
PPTX
Progressive Web App Testing With Cypress.io
Knoldus Inc.
 
PPTX
End to end test automation with cypress
Kushan Shalindra Amarasiri - Technical QE Specialist
 
PPTX
What is Spring Boot and Why Spring Boot ?
narendrachinnu
 
PPTX
Why I am hooked on the future of React
Maurice De Beijer [MVP]
 
PDF
Cypress - Best Practices
Brian Mann
 
PPTX
Automated Testing for Websites With Selenium IDE
Robert Greiner
 
PPTX
Leveraging Azure for Performance Testing
Tarun Arora
 
PDF
Microservices with Spring Boot Tutorial | Edureka
Edureka!
 
PDF
Xmas Serverless Transformation: when the elf doesn’t scale!
Massimo Bonanni
 
PPTX
Angular Unit Testing
Shailendra Chauhan
 
PPTX
Windows Azure Acid Test
expanz
 
PPTX
Introduction to Integration Testing With Cypress
Erez Cohen
 
PPTX
Fullstack workshop
Assaf Gannon
 
PPTX
Protractor overview
Abhishek Yadav
 
PDF
KKBOX WWDC17 Performance and Testing - Hokila
Liyao Chen
 
Designing an effective hybrid apps automation framework
Andrea Tino
 
Tales of an open source library
Adam Klein
 
Mobx Internals
500Tech
 
Spring boot
Shatrughna Singh
 
Visualforce remoteobject
Karanraj Sankaranarayanan
 
Progressive Web App Testing With Cypress.io
Knoldus Inc.
 
End to end test automation with cypress
Kushan Shalindra Amarasiri - Technical QE Specialist
 
What is Spring Boot and Why Spring Boot ?
narendrachinnu
 
Why I am hooked on the future of React
Maurice De Beijer [MVP]
 
Cypress - Best Practices
Brian Mann
 
Automated Testing for Websites With Selenium IDE
Robert Greiner
 
Leveraging Azure for Performance Testing
Tarun Arora
 
Microservices with Spring Boot Tutorial | Edureka
Edureka!
 
Xmas Serverless Transformation: when the elf doesn’t scale!
Massimo Bonanni
 
Angular Unit Testing
Shailendra Chauhan
 
Windows Azure Acid Test
expanz
 
Introduction to Integration Testing With Cypress
Erez Cohen
 
Fullstack workshop
Assaf Gannon
 
Protractor overview
Abhishek Yadav
 
KKBOX WWDC17 Performance and Testing - Hokila
Liyao Chen
 

Similar to Testing a Service Fabric solution and live happy!! (20)

PPTX
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
MSDEVMTL
 
PPTX
Azure Service Fabric Overview
João Pedro Martins
 
PPTX
Service fabric overview
Himanshu Desai
 
PPTX
Stephane Lapointe & Alexandre Brisebois: Développer des microservices avec Se...
MSDEVMTL
 
PPTX
Devteach 2016: A practical overview of actors in service fabric
Brisebois
 
PDF
Serverless microservices: Test smarter, not harder
DiUS
 
PPTX
Tokyo Azure Meetup #5 - Microservices and Azure Service Fabric
Tokyo Azure Meetup
 
PPTX
Azure servicefabric
Abhishek Sur
 
PDF
Scaling mobile dev teams
Priyank Gupta
 
PPTX
Service Fabric – building tomorrows applications today
BizTalk360
 
PPTX
Designing Microservices
David Chou
 
PPTX
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Codit
 
PPTX
08 hopex v next service fabric
Michel Bruchet
 
PPTX
Implementation of Systems Based on Microservices Architecture of Microsoft Se...
GlobalLogic Ukraine
 
PPTX
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
João Pedro Martins
 
PPTX
Serhiy Kalinets "Embracing architectural challenges in the modern .NET world"
Fwdays
 
PPTX
Architecting Microservices in .Net
Richard Banks
 
PPTX
Azure service fabric
Fernando Mejía
 
PPTX
Reactive Micro Services with Java seminar
Gal Marder
 
PPTX
Micro services
Brian Perera
 
Stephane Lapointe, Frank Boucher & Alexandre Brisebois: Les micro-services et...
MSDEVMTL
 
Azure Service Fabric Overview
João Pedro Martins
 
Service fabric overview
Himanshu Desai
 
Stephane Lapointe & Alexandre Brisebois: Développer des microservices avec Se...
MSDEVMTL
 
Devteach 2016: A practical overview of actors in service fabric
Brisebois
 
Serverless microservices: Test smarter, not harder
DiUS
 
Tokyo Azure Meetup #5 - Microservices and Azure Service Fabric
Tokyo Azure Meetup
 
Azure servicefabric
Abhishek Sur
 
Scaling mobile dev teams
Priyank Gupta
 
Service Fabric – building tomorrows applications today
BizTalk360
 
Designing Microservices
David Chou
 
Azure Service Fabric: notes from the field (Sam Vanhoute @Integrate 2016)
Codit
 
08 hopex v next service fabric
Michel Bruchet
 
Implementation of Systems Based on Microservices Architecture of Microsoft Se...
GlobalLogic Ukraine
 
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
João Pedro Martins
 
Serhiy Kalinets "Embracing architectural challenges in the modern .NET world"
Fwdays
 
Architecting Microservices in .Net
Richard Banks
 
Azure service fabric
Fernando Mejía
 
Reactive Micro Services with Java seminar
Gal Marder
 
Micro services
Brian Perera
 
Ad

More from Massimo Bonanni (20)

PDF
Architetture Serverless con SQL Server e Azure Functions
Massimo Bonanni
 
PDF
IoT in salsa serverless
Massimo Bonanni
 
PDF
Tutto quello che avreste voluto sapere sull'API Management (e non avete mai o...
Massimo Bonanni
 
PDF
Empower every Azure Function to achieve more!!
Massimo Bonanni
 
PDF
Everything you always wanted to know about API Management (but were afraid to...
Massimo Bonanni
 
PPTX
Welcome Azure Functions 2. 0
Massimo Bonanni
 
PPTX
Discovering the Service Fabric's actor model
Massimo Bonanni
 
PPTX
Discovering the Service Fabric's actor model
Massimo Bonanni
 
PPTX
Soluzioni IoT con le tecnologie Microsoft
Massimo Bonanni
 
PPTX
Project Gesture & Real Sense: il potere nelle mani!!
Massimo Bonanni
 
PPTX
Project Gesture & RealSense: gestures in a simple way!!
Massimo Bonanni
 
PPTX
Project Prague & RealSense: il potere nelle mani!!
Massimo Bonanni
 
PPTX
L'approccio ai microservizi secondo Service Fabric
Massimo Bonanni
 
PPTX
The Microservices world in. NET Core and. NET framework
Massimo Bonanni
 
PPTX
Microservices architecture & Service Fabric
Massimo Bonanni
 
PPTX
Introduzione allo sviluppo UWP per xBox
Massimo Bonanni
 
PPTX
Cognitive Services & LUIS
Massimo Bonanni
 
PPTX
Service Fabric: la potenza dei micro servizi
Massimo Bonanni
 
PPTX
Automated UI testing for iOs and Android mobile apps
Massimo Bonanni
 
PPTX
Soluzioni IoT con le tecnologie Microsoft
Massimo Bonanni
 
Architetture Serverless con SQL Server e Azure Functions
Massimo Bonanni
 
IoT in salsa serverless
Massimo Bonanni
 
Tutto quello che avreste voluto sapere sull'API Management (e non avete mai o...
Massimo Bonanni
 
Empower every Azure Function to achieve more!!
Massimo Bonanni
 
Everything you always wanted to know about API Management (but were afraid to...
Massimo Bonanni
 
Welcome Azure Functions 2. 0
Massimo Bonanni
 
Discovering the Service Fabric's actor model
Massimo Bonanni
 
Discovering the Service Fabric's actor model
Massimo Bonanni
 
Soluzioni IoT con le tecnologie Microsoft
Massimo Bonanni
 
Project Gesture & Real Sense: il potere nelle mani!!
Massimo Bonanni
 
Project Gesture & RealSense: gestures in a simple way!!
Massimo Bonanni
 
Project Prague & RealSense: il potere nelle mani!!
Massimo Bonanni
 
L'approccio ai microservizi secondo Service Fabric
Massimo Bonanni
 
The Microservices world in. NET Core and. NET framework
Massimo Bonanni
 
Microservices architecture & Service Fabric
Massimo Bonanni
 
Introduzione allo sviluppo UWP per xBox
Massimo Bonanni
 
Cognitive Services & LUIS
Massimo Bonanni
 
Service Fabric: la potenza dei micro servizi
Massimo Bonanni
 
Automated UI testing for iOs and Android mobile apps
Massimo Bonanni
 
Soluzioni IoT con le tecnologie Microsoft
Massimo Bonanni
 
Ad

Recently uploaded (20)

PDF
UiPath vs Other Automation Tools Meeting Presentation.pdf
Tracy Dixon
 
PDF
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
PPTX
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
PDF
Generative AI in Healthcare: Benefits, Use Cases & Challenges
Lily Clark
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PDF
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
PDF
Novus Safe Lite- What is Novus Safe Lite.pdf
Novus Hi-Tech
 
PDF
Rethinking Security Operations - Modern SOC.pdf
Haris Chughtai
 
PDF
How Current Advanced Cyber Threats Transform Business Operation
Eryk Budi Pratama
 
PPTX
UI5Con 2025 - Beyond UI5 Controls with the Rise of Web Components
Wouter Lemaire
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
PDF
Julia Furst Morgado The Lazy Guide to Kubernetes with EKS Auto Mode + Karpenter
AWS Chicago
 
PDF
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
PDF
Productivity Management Software | Workstatus
Lovely Baghel
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
How a Code Plagiarism Checker Protects Originality in Programming
Code Quiry
 
PPTX
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
PDF
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
Fwdays
 
UiPath vs Other Automation Tools Meeting Presentation.pdf
Tracy Dixon
 
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
Generative AI in Healthcare: Benefits, Use Cases & Challenges
Lily Clark
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
Novus Safe Lite- What is Novus Safe Lite.pdf
Novus Hi-Tech
 
Rethinking Security Operations - Modern SOC.pdf
Haris Chughtai
 
How Current Advanced Cyber Threats Transform Business Operation
Eryk Budi Pratama
 
UI5Con 2025 - Beyond UI5 Controls with the Rise of Web Components
Wouter Lemaire
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
Julia Furst Morgado The Lazy Guide to Kubernetes with EKS Auto Mode + Karpenter
AWS Chicago
 
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
Productivity Management Software | Workstatus
Lovely Baghel
 
Top Managed Service Providers in Los Angeles
Captain IT
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
How a Code Plagiarism Checker Protects Originality in Programming
Code Quiry
 
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
Fwdays
 

Testing a Service Fabric solution and live happy!!

  • 1. 1 Testing a Service Fabric solution and live happy!!! Massimo Bonanni Paranormal Developer, with the head in the Cloud and all the REST in microservices! @massimobonanni [email protected]
  • 5. 5
  • 6. 6
  • 8. 8 Programming Models Dev & Ops Tooling Orchestration Lifecycle Management Health & Monitoring Always On Availability Auto Scaling AzureOn-premises infrastructureAny cloudDev machine Service Fabric: Microservices platform ExecutablesReliable Services (.NET, Java) Reliable Actors (.NET, Java)ASP.NET Core Containers
  • 9. 9 F5 is our friend…. It is the most used test tools It's free and you can find it in all Visual Studio versions You don’t have to write any additional code
  • 10. 10 F5 is not useful …. with Service Fabric Resources – you need a local cluster Time – you need to publish the app Code complete – you need all the microservices you interact with
  • 11. 11 Why unit test… A unit test is an automated piece of code that invokes a unit of work in the system and then checks a single assumption about the behavior of that unit of work. Roy Osherove – The Art Of Unit Testing Microservices are small, perform single functionality and loosely coupled. Microservices Architecture
  • 12. 12 Why unit test… A unit test is an automated piece of code that invokes a unit of work in the system and then checks a single assumption about the behavior of that unit of work. Roy Osherove – The Art Of Unit Testing Microservices are small, perform single functionality and loosely coupled. Microservices Architecture A microservice is your Unit of Work to test!!!
  • 13. 13 The three obstacles Your µService Service Fabric Platform Replicas Partitioning State Management…… File System Database Web Service External Components Others µServices
  • 14. 14 Real case: Shopping Cart & Order We model 3 typical shopping cart scenarios • The cart can be created only if it is a new cart Creating the shopping cart • Need to check if the product is still available Adding a product to the cart • The order is created starting from the cart and only if the order is new Creating an order from the cart
  • 15. 15 Scenario : Creating the shopping cart We must "replace" the Service Fabric platform, so our tests doesn’t need the cluster. Service Fabric Platform Replicas Partitioning State Management ……
  • 16. 16 Scenario : Creating the shopping cart this.StateManager.TryGetStateAsync<State>(StateKeyName, cancellationToken); this.StateManager.SetStateAsync(StateKeyName, state, cancellationToken); this.RegisterReminderAsync(ExpiredReminderName, null, CartExpiredTimeout, TimeSpan.FromMilliseconds(-1));
  • 17. 17 Scenario : Adding a product to the cart We need to decouple our microservice from external components, so that our tests can verify only the actor's logic. File System Database Web Service External Components
  • 18. 18 Scenario : Adding a product to the cart private async Task<ProductData> GetProductFromStorageAsync(string productId, double quantity, CancellationToken cancellationToken) { ProductData result = null; try { using (SqlConnection conn = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand("CheckProduct", conn)) { // Database code } } catch { result = null; } return result; }
  • 19. 19 Scenario : Creating an order from the cart We must to replace the static classes ActorProxy and ServiceProxy used in the creation of communication proxies. Others µServices
  • 20. 20 Scenario : Creating an order from the cart var orderProxy = ActorProxy.Create<IOrderActor>(this.Id, new Uri("fabric:/TestingApp/OrderActor"));
  • 22. 22 The three obstacles….three solutions! Your µService Service Fabric Platform Replicas Partitioning State Management …… File System Database Web Service External Components Others µServices Mock the platform (ServiceFabric.Mocks) Abstract the proxy factories Create a layer of indirection
  • 24. 24 Keep the stability!!!! Solutions based on distributed architectures such as cloud infrastructures must be: This is why you need to be able to test the stability of your solutions when complex state transitions due to errors occur in the underlying infrastructure. •able to withstand or recover quickly from difficult conditionsResilient • its status does not get corrupted as a result of a problemReliable
  • 25. 25 What can go wrong in production? Restarting a node Restarting a distributed code package Removing a replica Restarting a replica Moving a primary replica Moving a secondary replica Remove a node Add a node
  • 26. 26
  • 27. 27 Start-ServiceFabricChaos Chaos induces faults in the cluster based on the received input parameters. Chaos runs in multiple iterations: each iteration consists of faults and cluster validation. You can control: • how long Chaos runs, • how long it waits between iterations, • how many faults it can induce during an iteration, • how long it waits between faults. • ….
  • 29. 29 Take away…. Keep the microservices simple….they will be testability simply! When design a solution, keep in mind the testability! Mock, fake and shim are your best friends! If car companies launch expensive cars against a wall to test them, why should not you do it with your code?