SlideShare a Scribd company logo
1 of 36
Download to read offline
Stateful mock servers to the
rescue on REST ecosystems
netponto - 2018-04-07
Nuno Caneco
Nuno Caneco
/@nuno.caneco
/nunocaneco
nuno.caneco@gmail.com
Engineering Manager / Cluster Lead
@nunocaneco
Raise your hands
The Monolith
A monolith is a geological feature consisting of a single massive stone or rock, such as some
mountains, or a single large piece of rock placed as, or within, a monument or building.
https://en.wikipedia.org/wiki/Monolith
A software system is called "monolithic" if it has a monolithic architecture, in which functionally
distinguishable aspects (for example data input and output, data processing, error handling, and the
user interface) are all interwoven, rather than containing architecturally separate components.
https://en.wikipedia.org/wiki/Monolithic_system
Monolithic architecture
Storefront
UI
Backoffice
UI
Catalog Service
User Service
Order Service
(...)
Database
Mobile
Web API
Microservices architecture
Storefront
UI
Backoffice
UI
User
Service
Mobile
Web API
Catalog
Service
Order
Service
REST
REST has become the default technology to support Microservices Architecture
● It's HTTP(S)
● Use HTTP Verbs for actions: GET, PUT, POST, DELETE, PATCH, ...
● Use HTTP Status Codes to provide meaningful and normalized responses to
clients
● Easily extensible using HTTP Headers
● Support multiple authentication mechanisms
● JSON is more simple and less verbose than XML
The growth of a
Microservice
Application
Ecosystem
User interfacePublic API
Backend Services
Publish / Subscribe
Databases
BLOB Storage
3rd party systems
Component Dependency
System Complexity ~= Business Complexity
Loose coupling ; High dependency
Dependency
level = 0
Dependency
level = 10
Dependency
level = 7
Teams & Components
Combine dependency level with
● Development environment
○ Setup
○ Maintain
● Keep services up to date
● Keep database schema and data
● Test
○ Time it takes to finish tests
○ Dependency from data
● CI/CD
○ Keep a stable environment for end-to-end tests
● Contract stability
● Communication between maintainers
Fakes to the
rescue
Terminology
Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists.
Fake objects actually have working implementations, but usually take some shortcut which makes them not
suitable for production (an in memory database is a good example).
Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside
what's programmed in for the test.
Spies are stubs that also record some information based on how they were called. One form of this might be an
email service that records how many messages it was sent.
Mocks are objects pre-programmed with expectations which form a specification of the calls they are expected to
receive.
https://martinfowler.com/articles/mocksArentStubs.html
Mock your dependencies
Dependencies with real implementations are
replaced by mocked implementations that
provide similar behavior at the interface level.
Example
Example
Fake Techniques - Client Fake
Client App
XptoAPIClient
Xpto Web API
HTTP
FakeXptoAPI
Client
IXptoApiClient
Quick to implement and simple to use
No new components on the system
Using a Mock framework allows control of
results on automated tests
Doesn't test the HTTP layer
Requires coding to implement statefulness
The Production Code is not stimulated
Potential risk to "Go Live" with the Fake
instead of Real implementation
Fake Techniques - Proxy
Client App
XptoAPIClient
Xpto Web API
HTTP
Quick to implement and simple to use
Saved responses are similar to the real API
No coding necessary (although possible)
Easy to implement with containers
Very flexible: easy to modify responses
Contract changes invalidate previous saved
responses
Requires coding to implement statefulness
Difficult to implement Expectations
mechanism to integrated with automated tests
Store
and
Forward
Proxy
HTTP
Responses
Fake Techniques - Fake Server
Client App
XptoAPIClient
Xpto Web API
HTTP Not so flexible to change responses
Requires coding
Need to implement Expectations to integrate
with automated tests
Code generation accelerates development
Easy support for contract changes:
(just regenerate the code and change implementation)
Easy to create and share containers
Easy to implement statefulness
Fake Xpto Web
API
Production&Integration
Development&Tests
HTTP
Demo I
Proxy
Demo - Proxy
Movie Rating UI
MovieRating
APIClient
Movie Rating Web API
HTTP
Store
and
Forward
Proxy
Responses
Omdb API
Demo II
Fake Server
Demo - Fake Server
Movie Rating UI
MovieRating
APIClient
Movie Rating Web
API
Fake Xpto Web
API
Omdb API
Wrapping up
Integrating with docker
Using docker to launch every 1st dependency allows easy
setup of the project.
$> git clone <repo>
$> docker-compose up deps
Open solution in Visual Studio and hit F5
No expensive setup of databases, messaging systems or other services
Docker images can be versioned alongside with the versions of the API
Can be used to run component tests (not integration tests)
Summary
● Fake the 1st level dependencies to avoid having the entire dependency tree
● Choose your strategy: Client Fake, Proxy, Stateful Fake or any other that suits
● Consider generating as much code as possible
● Potentially high upfront investment - big gains in the long run
● Make it easy for the developers to
○ Run the project
○ Manage the versions of the dependencies they are using
○ Write automated tests
● Make components tests running against Fakes instead
ANY QUESTIONS?
/@nuno.caneco
/nunocaneco
nuno.caneco@gmail.com
THANK YOU
@nunocaneco
Patrocinadores “GOLD”
Twitter: @PTMicrosoft http://www.microsoft.com/portugal
Patrocinadores “GOLD”
Twitter: @FindmoreC http://www.findmore.pt/pt
Patrocinadores “Silver”
Patrocinadores “Bronze”
http://bit.ly/netponto-aval-76
* Para quem não puder preencher durante a reunião,
iremos enviar um email com o link à tarde
Próximas reuniões presenciais
07/04/2018 – Lisboa
23/06/2018 – Lisboa
15/09/2018 – Lisboa
24/11/2018 – Lisboa
Reserva estes dias na agenda! :)

More Related Content

What's hot

A simplest way to reconstruct .Net Framework - CRB Tech
A simplest way to reconstruct .Net Framework - CRB TechA simplest way to reconstruct .Net Framework - CRB Tech
A simplest way to reconstruct .Net Framework - CRB TechPooja Gaikwad
 
PHP Symfony MicroServices Migration @MeeticTech
PHP Symfony MicroServices Migration @MeeticTechPHP Symfony MicroServices Migration @MeeticTech
PHP Symfony MicroServices Migration @MeeticTechmeeticTech
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterJamshid Hashimi
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.netsuraj pandey
 
Implementing application security using the .net framework
Implementing application security using the .net frameworkImplementing application security using the .net framework
Implementing application security using the .net frameworkLalit Kale
 
dotMemory 4 - What's inside?
dotMemory 4 - What's inside?dotMemory 4 - What's inside?
dotMemory 4 - What's inside?Maarten Balliauw
 
Lap around .net 4
Lap around .net 4Lap around .net 4
Lap around .net 4Abdul Khan
 
Robot framework Gowthami Goli
Robot framework Gowthami GoliRobot framework Gowthami Goli
Robot framework Gowthami GoliGowthami Buddi
 
Continuous Integration and development environment approach
Continuous Integration and development environment approachContinuous Integration and development environment approach
Continuous Integration and development environment approachAleksandr Tsertkov
 
Use React tools for better Angular apps
Use React tools for better Angular appsUse React tools for better Angular apps
Use React tools for better Angular appsMartin Hochel
 
Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)
Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)
Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)Johannes Geppert
 
Testing with Spring 4.x
Testing with Spring 4.xTesting with Spring 4.x
Testing with Spring 4.xSam Brannen
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsVirtual Nuggets
 
12 factor app - Core Guidelines To Cloud Ready Solutions
12 factor app - Core Guidelines To Cloud Ready Solutions12 factor app - Core Guidelines To Cloud Ready Solutions
12 factor app - Core Guidelines To Cloud Ready SolutionsKashif Ali Siddiqui
 
Talking architecture shop - Exploring open source success at scale
Talking architecture shop - Exploring open source success at scaleTalking architecture shop - Exploring open source success at scale
Talking architecture shop - Exploring open source success at scaleEric D. Schabell
 
Appium & Robot Framework
Appium & Robot FrameworkAppium & Robot Framework
Appium & Robot FrameworkFurkan Ertürk
 

What's hot (19)

A simplest way to reconstruct .Net Framework - CRB Tech
A simplest way to reconstruct .Net Framework - CRB TechA simplest way to reconstruct .Net Framework - CRB Tech
A simplest way to reconstruct .Net Framework - CRB Tech
 
PHP Symfony MicroServices Migration @MeeticTech
PHP Symfony MicroServices Migration @MeeticTechPHP Symfony MicroServices Migration @MeeticTech
PHP Symfony MicroServices Migration @MeeticTech
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniter
 
Introduction to vb.net
Introduction to vb.netIntroduction to vb.net
Introduction to vb.net
 
Implementing application security using the .net framework
Implementing application security using the .net frameworkImplementing application security using the .net framework
Implementing application security using the .net framework
 
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan PeshovJavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
 
dotMemory 4 - What's inside?
dotMemory 4 - What's inside?dotMemory 4 - What's inside?
dotMemory 4 - What's inside?
 
Lap around .net 4
Lap around .net 4Lap around .net 4
Lap around .net 4
 
Robot framework Gowthami Goli
Robot framework Gowthami GoliRobot framework Gowthami Goli
Robot framework Gowthami Goli
 
Continuous Integration and development environment approach
Continuous Integration and development environment approachContinuous Integration and development environment approach
Continuous Integration and development environment approach
 
Practice of AppSec .NET
Practice of AppSec .NETPractice of AppSec .NET
Practice of AppSec .NET
 
Use React tools for better Angular apps
Use React tools for better Angular appsUse React tools for better Angular apps
Use React tools for better Angular apps
 
Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)
Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)
Java web applications based on new Struts 2.5 and AngularJS (ApacheCon NA 2016)
 
Testing with Spring 4.x
Testing with Spring 4.xTesting with Spring 4.x
Testing with Spring 4.x
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggets
 
Javantura v4 - Spring Boot and JavaFX - can they play together - Josip Kovaček
Javantura v4 - Spring Boot and JavaFX - can they play together - Josip KovačekJavantura v4 - Spring Boot and JavaFX - can they play together - Josip Kovaček
Javantura v4 - Spring Boot and JavaFX - can they play together - Josip Kovaček
 
12 factor app - Core Guidelines To Cloud Ready Solutions
12 factor app - Core Guidelines To Cloud Ready Solutions12 factor app - Core Guidelines To Cloud Ready Solutions
12 factor app - Core Guidelines To Cloud Ready Solutions
 
Talking architecture shop - Exploring open source success at scale
Talking architecture shop - Exploring open source success at scaleTalking architecture shop - Exploring open source success at scale
Talking architecture shop - Exploring open source success at scale
 
Appium & Robot Framework
Appium & Robot FrameworkAppium & Robot Framework
Appium & Robot Framework
 

Similar to Stateful mock servers to the rescue on REST ecosystems

Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Steve Lange
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksSunil Patil
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworksSunil Patil
 
Widgets - the Wookie project
Widgets - the Wookie projectWidgets - the Wookie project
Widgets - the Wookie projectscottw
 
Actively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net DeveloperActively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net DeveloperKarthik Reddy
 
Actively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net DeveloperActively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net DeveloperKarthik Reddy
 
Best practices for creating modular Web applications
Best practices for creating modular Web applicationsBest practices for creating modular Web applications
Best practices for creating modular Web applicationspeychevi
 
Paremus service fabric
Paremus service fabricParemus service fabric
Paremus service fabricpjhInovex
 
Pentesting With Web Services in 2012
Pentesting With Web Services in 2012Pentesting With Web Services in 2012
Pentesting With Web Services in 2012Ishan Girdhar
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - TalkMatthias Noback
 
Online lg prodect
Online lg prodectOnline lg prodect
Online lg prodectYesu Raj
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstEnea Gabriel
 
COMPRO- WEB ALBUM & MOTION ANALYZER
COMPRO- WEB ALBUM  & MOTION ANALYZERCOMPRO- WEB ALBUM  & MOTION ANALYZER
COMPRO- WEB ALBUM & MOTION ANALYZERAshish Tanwer
 
DWX2015 - Von Bayern in die Cloud
DWX2015 - Von Bayern in die CloudDWX2015 - Von Bayern in die Cloud
DWX2015 - Von Bayern in die Cloudphilippgarbe
 
The Twelve Factor Apps
The Twelve Factor AppsThe Twelve Factor Apps
The Twelve Factor Appstomi vanek
 

Similar to Stateful mock servers to the rescue on REST ecosystems (20)

Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)
 
D22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source FrameworksD22 Portlet Development With Open Source Frameworks
D22 Portlet Development With Open Source Frameworks
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworks
 
Widgets - the Wookie project
Widgets - the Wookie projectWidgets - the Wookie project
Widgets - the Wookie project
 
Actively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net DeveloperActively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net Developer
 
Actively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net DeveloperActively looking for an opportunity to work as a challenging Dot Net Developer
Actively looking for an opportunity to work as a challenging Dot Net Developer
 
Best practices for creating modular Web applications
Best practices for creating modular Web applicationsBest practices for creating modular Web applications
Best practices for creating modular Web applications
 
Techdays 2011 - Things I will remember
Techdays 2011 - Things I will rememberTechdays 2011 - Things I will remember
Techdays 2011 - Things I will remember
 
Paremus service fabric
Paremus service fabricParemus service fabric
Paremus service fabric
 
Pentesting With Web Services in 2012
Pentesting With Web Services in 2012Pentesting With Web Services in 2012
Pentesting With Web Services in 2012
 
What's New in InTouch Machine Edition (ITME)
What's New in InTouch Machine Edition (ITME)What's New in InTouch Machine Edition (ITME)
What's New in InTouch Machine Edition (ITME)
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
 
Online lg prodect
Online lg prodectOnline lg prodect
Online lg prodect
 
soa1.ppt
soa1.pptsoa1.ppt
soa1.ppt
 
Path to continuous delivery
Path to continuous deliveryPath to continuous delivery
Path to continuous delivery
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
 
COMPRO- WEB ALBUM & MOTION ANALYZER
COMPRO- WEB ALBUM  & MOTION ANALYZERCOMPRO- WEB ALBUM  & MOTION ANALYZER
COMPRO- WEB ALBUM & MOTION ANALYZER
 
Von Bayern in die Cloud
Von Bayern in die CloudVon Bayern in die Cloud
Von Bayern in die Cloud
 
DWX2015 - Von Bayern in die Cloud
DWX2015 - Von Bayern in die CloudDWX2015 - Von Bayern in die Cloud
DWX2015 - Von Bayern in die Cloud
 
The Twelve Factor Apps
The Twelve Factor AppsThe Twelve Factor Apps
The Twelve Factor Apps
 

More from Nuno Caneco

Building resilient applications
Building resilient applicationsBuilding resilient applications
Building resilient applicationsNuno Caneco
 
Git from the trenches
Git from the trenchesGit from the trenches
Git from the trenchesNuno Caneco
 
Tuga IT 2017 - Redis
Tuga IT 2017 - RedisTuga IT 2017 - Redis
Tuga IT 2017 - RedisNuno Caneco
 
Tuga it 2017 - Event processing with Apache Storm
Tuga it 2017 - Event processing with Apache StormTuga it 2017 - Event processing with Apache Storm
Tuga it 2017 - Event processing with Apache StormNuno Caneco
 
Fullstack LX - Improving your application performance
Fullstack LX - Improving your application performanceFullstack LX - Improving your application performance
Fullstack LX - Improving your application performanceNuno Caneco
 
Running agile on a non-agile environment
Running agile on a non-agile environmentRunning agile on a non-agile environment
Running agile on a non-agile environmentNuno Caneco
 
Introducing redis
Introducing redisIntroducing redis
Introducing redisNuno Caneco
 
Tuga it 2016 improving your application performance
Tuga it 2016   improving your application performanceTuga it 2016   improving your application performance
Tuga it 2016 improving your application performanceNuno Caneco
 

More from Nuno Caneco (8)

Building resilient applications
Building resilient applicationsBuilding resilient applications
Building resilient applications
 
Git from the trenches
Git from the trenchesGit from the trenches
Git from the trenches
 
Tuga IT 2017 - Redis
Tuga IT 2017 - RedisTuga IT 2017 - Redis
Tuga IT 2017 - Redis
 
Tuga it 2017 - Event processing with Apache Storm
Tuga it 2017 - Event processing with Apache StormTuga it 2017 - Event processing with Apache Storm
Tuga it 2017 - Event processing with Apache Storm
 
Fullstack LX - Improving your application performance
Fullstack LX - Improving your application performanceFullstack LX - Improving your application performance
Fullstack LX - Improving your application performance
 
Running agile on a non-agile environment
Running agile on a non-agile environmentRunning agile on a non-agile environment
Running agile on a non-agile environment
 
Introducing redis
Introducing redisIntroducing redis
Introducing redis
 
Tuga it 2016 improving your application performance
Tuga it 2016   improving your application performanceTuga it 2016   improving your application performance
Tuga it 2016 improving your application performance
 

Recently uploaded

Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 

Stateful mock servers to the rescue on REST ecosystems

  • 1. Stateful mock servers to the rescue on REST ecosystems netponto - 2018-04-07 Nuno Caneco
  • 4.
  • 5. The Monolith A monolith is a geological feature consisting of a single massive stone or rock, such as some mountains, or a single large piece of rock placed as, or within, a monument or building. https://en.wikipedia.org/wiki/Monolith A software system is called "monolithic" if it has a monolithic architecture, in which functionally distinguishable aspects (for example data input and output, data processing, error handling, and the user interface) are all interwoven, rather than containing architecturally separate components. https://en.wikipedia.org/wiki/Monolithic_system
  • 6. Monolithic architecture Storefront UI Backoffice UI Catalog Service User Service Order Service (...) Database Mobile Web API
  • 8. REST REST has become the default technology to support Microservices Architecture ● It's HTTP(S) ● Use HTTP Verbs for actions: GET, PUT, POST, DELETE, PATCH, ... ● Use HTTP Status Codes to provide meaningful and normalized responses to clients ● Easily extensible using HTTP Headers ● Support multiple authentication mechanisms ● JSON is more simple and less verbose than XML
  • 9. The growth of a Microservice Application
  • 10. Ecosystem User interfacePublic API Backend Services Publish / Subscribe Databases BLOB Storage 3rd party systems
  • 11. Component Dependency System Complexity ~= Business Complexity Loose coupling ; High dependency
  • 12. Dependency level = 0 Dependency level = 10 Dependency level = 7 Teams & Components
  • 13. Combine dependency level with ● Development environment ○ Setup ○ Maintain ● Keep services up to date ● Keep database schema and data ● Test ○ Time it takes to finish tests ○ Dependency from data ● CI/CD ○ Keep a stable environment for end-to-end tests ● Contract stability ● Communication between maintainers
  • 15. Terminology Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists. Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production (an in memory database is a good example). Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test. Spies are stubs that also record some information based on how they were called. One form of this might be an email service that records how many messages it was sent. Mocks are objects pre-programmed with expectations which form a specification of the calls they are expected to receive. https://martinfowler.com/articles/mocksArentStubs.html
  • 16. Mock your dependencies Dependencies with real implementations are replaced by mocked implementations that provide similar behavior at the interface level.
  • 19. Fake Techniques - Client Fake Client App XptoAPIClient Xpto Web API HTTP FakeXptoAPI Client IXptoApiClient Quick to implement and simple to use No new components on the system Using a Mock framework allows control of results on automated tests Doesn't test the HTTP layer Requires coding to implement statefulness The Production Code is not stimulated Potential risk to "Go Live" with the Fake instead of Real implementation
  • 20. Fake Techniques - Proxy Client App XptoAPIClient Xpto Web API HTTP Quick to implement and simple to use Saved responses are similar to the real API No coding necessary (although possible) Easy to implement with containers Very flexible: easy to modify responses Contract changes invalidate previous saved responses Requires coding to implement statefulness Difficult to implement Expectations mechanism to integrated with automated tests Store and Forward Proxy HTTP Responses
  • 21. Fake Techniques - Fake Server Client App XptoAPIClient Xpto Web API HTTP Not so flexible to change responses Requires coding Need to implement Expectations to integrate with automated tests Code generation accelerates development Easy support for contract changes: (just regenerate the code and change implementation) Easy to create and share containers Easy to implement statefulness Fake Xpto Web API Production&Integration Development&Tests HTTP
  • 23. Demo - Proxy Movie Rating UI MovieRating APIClient Movie Rating Web API HTTP Store and Forward Proxy Responses Omdb API
  • 25. Demo - Fake Server Movie Rating UI MovieRating APIClient Movie Rating Web API Fake Xpto Web API Omdb API
  • 27. Integrating with docker Using docker to launch every 1st dependency allows easy setup of the project. $> git clone <repo> $> docker-compose up deps Open solution in Visual Studio and hit F5 No expensive setup of databases, messaging systems or other services Docker images can be versioned alongside with the versions of the API Can be used to run component tests (not integration tests)
  • 28. Summary ● Fake the 1st level dependencies to avoid having the entire dependency tree ● Choose your strategy: Client Fake, Proxy, Stateful Fake or any other that suits ● Consider generating as much code as possible ● Potentially high upfront investment - big gains in the long run ● Make it easy for the developers to ○ Run the project ○ Manage the versions of the dependencies they are using ○ Write automated tests ● Make components tests running against Fakes instead
  • 31. Patrocinadores “GOLD” Twitter: @PTMicrosoft http://www.microsoft.com/portugal
  • 35. http://bit.ly/netponto-aval-76 * Para quem não puder preencher durante a reunião, iremos enviar um email com o link à tarde
  • 36. Próximas reuniões presenciais 07/04/2018 – Lisboa 23/06/2018 – Lisboa 15/09/2018 – Lisboa 24/11/2018 – Lisboa Reserva estes dias na agenda! :)