What is Resilient Testing?
One type of Non Functional Testing.
Certifying one system ( web application, desktop application, mobile application etc.) is resilient to some extent.
This testing is very much needed for 24*7 service apps like ecommerce, healthcare apps etc.
What is microservice?
Microservices are tiny individual services written for a particular job to be performed.
They can talk with each other.
In our current technological era microservices have become the base for most of the web services.
Examples of Microservices
Netflix has a widespread architecture that has evolved from monolithic to SOA.¬† It receives more than one billion calls every day, from more than 800 different types of devices, to its streaming-video API.¬† Each API call then prompts around five additional calls to the backend service.
Amazon has also migrated to microservices.¬† They get countless calls from a variety of applications‚ÄĒincluding applications that manage the web service API as well as the website itself‚ÄĒwhich would have been simply impossible for their old, two-tiered architecture to handle.
The auction site eBay is yet another example that has gone through the same transition.¬† Their core application comprises several autonomous applications, with each one executing the business logic for different function areas.
What is Spring Boot?
A framework built on top of java spring framework. So it can be called a framework of framework.
By spring boot, java developer can create microservices with very ease by just using some simple annotations as shown below:
What is chaos monkey?
Chaos Monkey is a software tool that was developed by Netflix engineers to test the resiliency and recoverability of their Amazon Web Services
This has been made opensource to integrate with various microservice technologies like node js , java spring boot microservices, python etc.
In Simple words chaos monkey creates chaotic situation by killing or increasing latency of micro service instances so that user experience delay in the services‚Äô response.
The responsibility of tester is to check the performance of whole system while chaos monkey is doing these type of assaults to the microservices. That is the resilience of that system.
How does chaos monkey work?
It increases the response time of different microservices.
It kills the service instances.
By doing this type of assaults it tries to decrease the performance of whole system.
How to implement Chaos Monkey in Spring boot Microservice_Step1
Add this below lines in <dependencies> in pom.xml
How to implement Chaos Monkey in Spring boot Microservice_Step2
Add this in application.yml
¬†¬†¬† active: chaos-monkey
¬†¬† level: 5
¬†¬† latencyRangeStart: 100
¬†¬† latencyRangeEnd: 1000
¬†¬† exceptionsActive: true
¬†¬† killApplicationActive: false
¬†¬† restController: true
How to implement Chaos Monkey in Spring boot Microservice_Step3
Add this in application.properties√®
That‚Äôs it. The application looks like this :
How to implement Chaos Monkey in Spring boot Microservice_Step4
add these below dependency also in the pom.xml==>
This dependency is to activate the actuator endpoints of spring boot framework. Actuator endpoints actually gives privilege to handle any running service from outside of the code.
How to implement Chaos Monkey in Spring boot Microservice_Step5
And then in properties file add this below configurations ==>
This two lines are to activate the chaosmonkey actuator endpoints so that we can disable and enable the chaos monkey from outside the code ( by postman, ,browser etc.)
How to implement Chaos Monkey in Spring boot Microservice_Step6
Then from postman do this==>
if you are running your application on 8094 port.
How to implement Chaos Monkey in Spring boot Microservice_Step7
Now be sure that chaos monkey is running good by doing this==>
How to implement Chaos Monkey in Spring boot Microservice_Step8
Now run the jmeter and you will see that performance is very bad and also due to the chaos exceptions some responses are bad (400,500 etc) [deviation:106]
How to implement Chaos Monkey in Spring boot Microservice_Step9
Now disable the chaos monkey by below process==>
How to implement Chaos Monkey in Spring boot Microservice_Step10
Now again run jmeter, you will see the service is performing well enough ==>[deviation:18]
And all the responses are 200 ==>[everything green]
Enjoy doing resilient testing with Chaos Monkey. Happy Coding and Happy Testing!