SlideShare a Scribd company logo
Testing Scenarios
Lynn Langit
Types of Tests
from: "https://martinfowler.com/articles/microservice-testing"
Testing Microservices
Function/ Method
Service REST
Services Package
Deploy Kubernetes
End-to-endLogs
Unit
Observability
updated from: "https://martinfowler.com/articles/microservice-testing"
Demo 1 - Unit tests: sayHello
Unit Test
import ballerina/test;
@test:Config
function testSayHelloTDD() {
string actual = sayHello(greetingAct);
test:assertEquals(actual,greetingExp,msg="string test failed");
}
Test Annotations
import ballerina/test;
@test:Config {
before: "beforeTestBar",
after: "afterTestBar",
dependsOn: ["testFunctionPre1", "testFuncctionPre2"],
groups: ["group1"]
}
function testBar() {
// test logic for function bar()
}
More Test Annotations & Assertions
import ballerina/test;
@test:BeforeSuite {...} | @test:BeforeEach {...} | @test:AfterSuite
{...}
function testBar() {
// test logic for function bar()
test:assertEquals(actual,greetingExp,msg="string test failed");
test:assertTrue(value,msg="Assert True failed");
test:assertFail("Expected an exception");
}
Running Tests
ballerina init
ballerina test [packageName] | [fileName.bal]
--list-groups tests
--groups group_a tests
--disable-groups group_b tests
--config myConf.conf
Testing Microservices
Function/ Method
Service REST
Services Package
Deploy Kubernetes
End-to-endLogs
Unit
Observability
updated from: "https://martinfowler.com/articles/microservice-testing"
caller hello
GET
Hello World
Demo 2 - Service tests: Ballerina Service
Unit Test with Mock
@test:Mock { packageName: ".", functionName: "intAdd" }
function mockIntAdd(int a, int b)returns int)... { return (a - b); }
@test:Config
function testIntAdd() {
int answer = 0;
answer = intAdd(5, 3);
test:assertEquals(actual,2,msg="mock failed");
}
function intAdd(int a, int b)returns int)... { return (a + b); }
Service Test Setup
function startService(){
serviceStarted=test:startServices("hello-service");
}
@test:Config { before: "startService",after: "stopService" }
function testFunc() {
//...
}
function stopService() {
test:stopServices("hello-service");
}
Service Test Body
@test:Config { before: "startService",after: "stopService" }
function testFunc() {
endpoint http:Client httpEndpoint { url: "http://localhost:9090" };
test:assertTrue(serviceStarted, msg = "Unable to start the service");
...
match response {
...
test:assertEquals(res, response1);
}
error err => test:assertFail(msg = "Failed to call the endpoint:");
}
}
Testing Microservices
Function/ Method
Service REST
Services Package
Deploy Kubernetes
End-to-endLogs
Unit
Observability
updated from: "https://martinfowler.com/articles/microservice-testing"
caller hello
response
Simpson quotes
GET
quote
twitter
tweet (quote)
response
Demo 3 - Services (composition) Tests
Services Test Setup
Testing Microservices
Function/ Method
Service REST
Services Package
Deploy Kubernetes
End-to-endLogs
Unit
Observability
updated from: "https://martinfowler.com/articles/microservice-testing"
Demo 4 - Deployment Tests
Service Deployment - Docker
import ballerinax/docker;
@docker:Config {
registry:"ballerina.guides.io",
name:"travel_agency_service",
tag:"v1.0"
}
@docker:Expose{}
# Auto Generated Dockerfile
FROM ballerina/ballerina:0.975.1
LABEL maintainer="dev@ballerina.io"
COPY travel_agency.balx
/home/ballerina
EXPOSE 9090
CMD ballerina run travel_agency.balx
OSS Tools for Testing Containers
Sysdig - Falco for k8
● Uses rules
● Alerts on drift
● Includes container best practices
● Highly configurable
Google - Container Structure Tests
● Unit Tests
○ for Docker Images
● Command Tests
○ verifies output of running a
command inside container
● File Existence Tests
○ verifies existence of file at a
location
● File Content Tests
○ verifies file contents
● Metadata Test
○ verifies container configuration
Testing Microservices
Function/ Method
Service REST
Services Package
Deploy Kubernetes
End-to-endLogs
Unit
Observability
updated from: "https://martinfowler.com/articles/microservice-testing"
Modern Approaches to Testing Microservices
from "https://opensource.com/article/18/6/five-microservice-testing-strategies-startups"
Documentation First
AWS Testing
(own-account)
Full stack
in-a-box
(local)
Shared
Testing
Instance
Stubbed
services Lorem ipsum congue
tempus
Lorem ipsum
tempus
Lorem ipsum
congue tempus
Lorem
ipsum
tempus
Documentation First
AWS
own-account
Full stack
in-a-box
local
Shared
Testing
Instances
Stubbed
Services
Breaking Things on Purpose
○ Inject something harmful
○ in order to build immunity
○ Chaos engineering
○ "thoughtful, planned experiments
designed to reveal the weakness in our
systems"
○ Testing proactively
○ instead of waiting for an outage
○ "Engineering Chaos" = better name
image from: https://www.anshulpatel.in/post/chaos_engg_exprmnt_dsgn/
Microservice Testing Reality
Unit Tests
Test functions
Test methods
Test services
Integration Tests
Test interactions within groups
Test interactions between groups
Test interactions outside groups
Deployment Tests
Test Container Configuration
Test Container Management
Configuration
Test Endpoints
Observability
Events, logs and alerts
Test in Production
Engineering Chaos
Modern Tests
Test Documentation
Full stack in-a-box
AWS own-account
Stubbed Services
05
01
02 03
04
exercism.io
How to get involved
Learn more
Open source
Get support
http://ballerina.io
http://github.com/ballerina-platform/
Stack Overflow #ballerina tag
Practice http://exercism.io/tracks/ballerina

More Related Content

What's hot

Android Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan KustAndroid Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Infinum
 
Open stack qa and tempest
Open stack qa and tempestOpen stack qa and tempest
Open stack qa and tempest
Kamesh Pemmaraju
 
Testing with Spring: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An Introduction
Sam Brannen
 
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - Testing your Android applications by Ivan KustInfinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum
 
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web Applications
Sam Brannen
 
Jenkins vs. AWS CodePipeline (AWS User Group Berlin)
Jenkins vs. AWS CodePipeline (AWS User Group Berlin)Jenkins vs. AWS CodePipeline (AWS User Group Berlin)
Jenkins vs. AWS CodePipeline (AWS User Group Berlin)
Steffen Gebert
 
Tempest scenariotests 20140512
Tempest scenariotests 20140512Tempest scenariotests 20140512
Tempest scenariotests 20140512Masayuki Igawa
 
Adding unit tests to the database deployment pipeline
Adding unit tests to the database deployment pipelineAdding unit tests to the database deployment pipeline
Adding unit tests to the database deployment pipeline
Eduardo Piairo
 
Pipeline based deployments on Jenkins
Pipeline based deployments  on JenkinsPipeline based deployments  on Jenkins
Pipeline based deployments on Jenkins
Knoldus Inc.
 
DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020
Lohika_Odessa_TechTalks
 
JavaOne 2016 - Pipeline as code
JavaOne 2016 - Pipeline as codeJavaOne 2016 - Pipeline as code
JavaOne 2016 - Pipeline as code
Bert Jan Schrijver
 
Adding unit tests to the database deployment pipeline
Adding unit tests to the database deployment pipelineAdding unit tests to the database deployment pipeline
Adding unit tests to the database deployment pipeline
Eduardo Piairo
 
Adding unit tests with tSQLt to the database deployment pipeline
 Adding unit tests with tSQLt to the database deployment pipeline Adding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipeline
Eduardo Piairo
 
Akmal Khaleeq Waheed - Challenge 3 p2
Akmal Khaleeq Waheed - Challenge 3 p2Akmal Khaleeq Waheed - Challenge 3 p2
Akmal Khaleeq Waheed - Challenge 3 p2
tovmug
 
Whatthestack using Tempest for testing your OpenStack deployment
Whatthestack using Tempest for testing your OpenStack deploymentWhatthestack using Tempest for testing your OpenStack deployment
Whatthestack using Tempest for testing your OpenStack deploymentChristian Schwede
 
Seven perilous pitfalls to avoid with Java | DevNation Tech Talk
Seven perilous pitfalls to avoid with Java | DevNation Tech TalkSeven perilous pitfalls to avoid with Java | DevNation Tech Talk
Seven perilous pitfalls to avoid with Java | DevNation Tech Talk
Red Hat Developers
 
API Testing following the Test Pyramid
API Testing following the Test PyramidAPI Testing following the Test Pyramid
API Testing following the Test Pyramid
Elias Nogueira
 
Load Testing with k6 framework
Load Testing with k6 frameworkLoad Testing with k6 framework
Load Testing with k6 framework
Svetlin Nakov
 
Integration testing for salt states using aws ec2 container service
Integration testing for salt states using aws ec2 container serviceIntegration testing for salt states using aws ec2 container service
Integration testing for salt states using aws ec2 container service
SaltStack
 
Pester & PSScriptAnalyser - Power Test your PowerShell with PowerShell - Futu...
Pester & PSScriptAnalyser - Power Test your PowerShell with PowerShell - Futu...Pester & PSScriptAnalyser - Power Test your PowerShell with PowerShell - Futu...
Pester & PSScriptAnalyser - Power Test your PowerShell with PowerShell - Futu...
DevOpsGroup
 

What's hot (20)

Android Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan KustAndroid Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
 
Open stack qa and tempest
Open stack qa and tempestOpen stack qa and tempest
Open stack qa and tempest
 
Testing with Spring: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An Introduction
 
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - Testing your Android applications by Ivan KustInfinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
 
Testing Spring MVC and REST Web Applications
Testing Spring MVC and REST Web ApplicationsTesting Spring MVC and REST Web Applications
Testing Spring MVC and REST Web Applications
 
Jenkins vs. AWS CodePipeline (AWS User Group Berlin)
Jenkins vs. AWS CodePipeline (AWS User Group Berlin)Jenkins vs. AWS CodePipeline (AWS User Group Berlin)
Jenkins vs. AWS CodePipeline (AWS User Group Berlin)
 
Tempest scenariotests 20140512
Tempest scenariotests 20140512Tempest scenariotests 20140512
Tempest scenariotests 20140512
 
Adding unit tests to the database deployment pipeline
Adding unit tests to the database deployment pipelineAdding unit tests to the database deployment pipeline
Adding unit tests to the database deployment pipeline
 
Pipeline based deployments on Jenkins
Pipeline based deployments  on JenkinsPipeline based deployments  on Jenkins
Pipeline based deployments on Jenkins
 
DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020
 
JavaOne 2016 - Pipeline as code
JavaOne 2016 - Pipeline as codeJavaOne 2016 - Pipeline as code
JavaOne 2016 - Pipeline as code
 
Adding unit tests to the database deployment pipeline
Adding unit tests to the database deployment pipelineAdding unit tests to the database deployment pipeline
Adding unit tests to the database deployment pipeline
 
Adding unit tests with tSQLt to the database deployment pipeline
 Adding unit tests with tSQLt to the database deployment pipeline Adding unit tests with tSQLt to the database deployment pipeline
Adding unit tests with tSQLt to the database deployment pipeline
 
Akmal Khaleeq Waheed - Challenge 3 p2
Akmal Khaleeq Waheed - Challenge 3 p2Akmal Khaleeq Waheed - Challenge 3 p2
Akmal Khaleeq Waheed - Challenge 3 p2
 
Whatthestack using Tempest for testing your OpenStack deployment
Whatthestack using Tempest for testing your OpenStack deploymentWhatthestack using Tempest for testing your OpenStack deployment
Whatthestack using Tempest for testing your OpenStack deployment
 
Seven perilous pitfalls to avoid with Java | DevNation Tech Talk
Seven perilous pitfalls to avoid with Java | DevNation Tech TalkSeven perilous pitfalls to avoid with Java | DevNation Tech Talk
Seven perilous pitfalls to avoid with Java | DevNation Tech Talk
 
API Testing following the Test Pyramid
API Testing following the Test PyramidAPI Testing following the Test Pyramid
API Testing following the Test Pyramid
 
Load Testing with k6 framework
Load Testing with k6 frameworkLoad Testing with k6 framework
Load Testing with k6 framework
 
Integration testing for salt states using aws ec2 container service
Integration testing for salt states using aws ec2 container serviceIntegration testing for salt states using aws ec2 container service
Integration testing for salt states using aws ec2 container service
 
Pester & PSScriptAnalyser - Power Test your PowerShell with PowerShell - Futu...
Pester & PSScriptAnalyser - Power Test your PowerShell with PowerShell - Futu...Pester & PSScriptAnalyser - Power Test your PowerShell with PowerShell - Futu...
Pester & PSScriptAnalyser - Power Test your PowerShell with PowerShell - Futu...
 

Similar to Test Driven Development for Microservices

How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
Yevgeniy Brikman
 
Testing Your Application On Google App Engine
Testing Your Application On Google App EngineTesting Your Application On Google App Engine
Testing Your Application On Google App Engine
IndicThreads
 
Testing your application on Google App Engine
Testing your application on Google App EngineTesting your application on Google App Engine
Testing your application on Google App Engine
Inphina Technologies
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
Roberto Franchini
 
Containerised Testing at Demonware : PyCon Ireland 2016
Containerised Testing at Demonware : PyCon Ireland 2016Containerised Testing at Demonware : PyCon Ireland 2016
Containerised Testing at Demonware : PyCon Ireland 2016
Thomas Shaw
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
Visual Engineering
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
Antons Kranga
 
AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Containe...
AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Containe...AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Containe...
AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Containe...
Amazon Web Services
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
John Congdon
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
Suman Sourav
 
Spring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSpring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing Support
Sam Brannen
 
JUnit5 and TestContainers
JUnit5 and TestContainersJUnit5 and TestContainers
JUnit5 and TestContainers
Sunghyouk Bae
 
Turner js
Turner jsTurner js
Turner js
Carmel Cohen
 
Dependency injection in scala
Dependency injection in scalaDependency injection in scala
Dependency injection in scala
Michal Bigos
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
Knoldus Inc.
 
In-Cluster Continuous Testing Framework for Docker Containers
In-Cluster Continuous Testing Framework for Docker ContainersIn-Cluster Continuous Testing Framework for Docker Containers
In-Cluster Continuous Testing Framework for Docker Containers
Neil Gehani
 
Javascript tdd byandreapaciolla
Javascript tdd byandreapaciollaJavascript tdd byandreapaciolla
Javascript tdd byandreapaciolla
Andrea Paciolla
 
Code Kata: String Calculator in Flex
Code Kata: String Calculator in FlexCode Kata: String Calculator in Flex
Code Kata: String Calculator in FlexChris Farrell
 
Anatomy of a Build Pipeline
Anatomy of a Build PipelineAnatomy of a Build Pipeline
Anatomy of a Build Pipeline
Samuel Brown
 

Similar to Test Driven Development for Microservices (20)

How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...How to test infrastructure code: automated testing for Terraform, Kubernetes,...
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
 
Testing Your Application On Google App Engine
Testing Your Application On Google App EngineTesting Your Application On Google App Engine
Testing Your Application On Google App Engine
 
Testing your application on Google App Engine
Testing your application on Google App EngineTesting your application on Google App Engine
Testing your application on Google App Engine
 
Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!Integration tests: use the containers, Luke!
Integration tests: use the containers, Luke!
 
Containerised Testing at Demonware : PyCon Ireland 2016
Containerised Testing at Demonware : PyCon Ireland 2016Containerised Testing at Demonware : PyCon Ireland 2016
Containerised Testing at Demonware : PyCon Ireland 2016
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
 
AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Containe...
AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Containe...AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Containe...
AWS December 2015 Webinar Series - Continuous Delivery to Amazon EC2 Containe...
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 
Spring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSpring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing Support
 
JUnit5 and TestContainers
JUnit5 and TestContainersJUnit5 and TestContainers
JUnit5 and TestContainers
 
Turner js
Turner jsTurner js
Turner js
 
Dependency injection in scala
Dependency injection in scalaDependency injection in scala
Dependency injection in scala
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
 
In-Cluster Continuous Testing Framework for Docker Containers
In-Cluster Continuous Testing Framework for Docker ContainersIn-Cluster Continuous Testing Framework for Docker Containers
In-Cluster Continuous Testing Framework for Docker Containers
 
Javascript tdd byandreapaciolla
Javascript tdd byandreapaciollaJavascript tdd byandreapaciolla
Javascript tdd byandreapaciolla
 
UPC Testing talk 2
UPC Testing talk 2UPC Testing talk 2
UPC Testing talk 2
 
Code Kata: String Calculator in Flex
Code Kata: String Calculator in FlexCode Kata: String Calculator in Flex
Code Kata: String Calculator in Flex
 
Anatomy of a Build Pipeline
Anatomy of a Build PipelineAnatomy of a Build Pipeline
Anatomy of a Build Pipeline
 

More from Ballerina

Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
Ballerina
 
Ballerina in the Real World: Motorola_KubeCon 2018
Ballerina in the Real World: Motorola_KubeCon 2018Ballerina in the Real World: Motorola_KubeCon 2018
Ballerina in the Real World: Motorola_KubeCon 2018
Ballerina
 
Ballerina integration with Azure cloud services_KubeCon 2018
Ballerina integration with Azure cloud services_KubeCon 2018Ballerina integration with Azure cloud services_KubeCon 2018
Ballerina integration with Azure cloud services_KubeCon 2018
Ballerina
 
Ballerina is not Java_KubeCon 2108
Ballerina is not Java_KubeCon 2108Ballerina is not Java_KubeCon 2108
Ballerina is not Java_KubeCon 2108
Ballerina
 
Microservice Integration from Dev to Production_KubeCon2018
Microservice Integration from Dev to Production_KubeCon2018Microservice Integration from Dev to Production_KubeCon2018
Microservice Integration from Dev to Production_KubeCon2018
Ballerina
 
Building a Microgateway in Ballerina_KubeCon 2108
Building a Microgateway in Ballerina_KubeCon 2108Building a Microgateway in Ballerina_KubeCon 2108
Building a Microgateway in Ballerina_KubeCon 2108
Ballerina
 
Ballerina ecosystem
Ballerina ecosystemBallerina ecosystem
Ballerina ecosystem
Ballerina
 
Orchestrating microservices with docker and kubernetes
Orchestrating microservices with docker and kubernetesOrchestrating microservices with docker and kubernetes
Orchestrating microservices with docker and kubernetes
Ballerina
 
Data integration
Data integrationData integration
Data integration
Ballerina
 
Service resiliency in microservices
Service resiliency in microservicesService resiliency in microservices
Service resiliency in microservices
Ballerina
 
Microservices integration
Microservices integration   Microservices integration
Microservices integration
Ballerina
 
Writing microservices
Writing microservicesWriting microservices
Writing microservices
Ballerina
 
Ballerina philosophy
Ballerina philosophy Ballerina philosophy
Ballerina philosophy
Ballerina
 
Ballerina: Cloud Native Programming Language
Ballerina: Cloud Native Programming Language Ballerina: Cloud Native Programming Language
Ballerina: Cloud Native Programming Language
Ballerina
 
Writing services in Ballerina_Ballerina Day CMB 2018
Writing services in Ballerina_Ballerina Day CMB 2018Writing services in Ballerina_Ballerina Day CMB 2018
Writing services in Ballerina_Ballerina Day CMB 2018
Ballerina
 
Resiliency & Security_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018  Resiliency & Security_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018
Ballerina
 
Stream Processing with Ballerina
Stream Processing with BallerinaStream Processing with Ballerina
Stream Processing with Ballerina
Ballerina
 
Secure by Design Microservices & Integrations
Secure by Design Microservices & IntegrationsSecure by Design Microservices & Integrations
Secure by Design Microservices & Integrations
Ballerina
 
Observability with Ballerina
Observability with BallerinaObservability with Ballerina
Observability with Ballerina
Ballerina
 
Serverless Ballerina
Serverless BallerinaServerless Ballerina
Serverless Ballerina
Ballerina
 

More from Ballerina (20)

Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
Role of Integration and Service Mesh in Cloud Native Architecture KubeCon 2108
 
Ballerina in the Real World: Motorola_KubeCon 2018
Ballerina in the Real World: Motorola_KubeCon 2018Ballerina in the Real World: Motorola_KubeCon 2018
Ballerina in the Real World: Motorola_KubeCon 2018
 
Ballerina integration with Azure cloud services_KubeCon 2018
Ballerina integration with Azure cloud services_KubeCon 2018Ballerina integration with Azure cloud services_KubeCon 2018
Ballerina integration with Azure cloud services_KubeCon 2018
 
Ballerina is not Java_KubeCon 2108
Ballerina is not Java_KubeCon 2108Ballerina is not Java_KubeCon 2108
Ballerina is not Java_KubeCon 2108
 
Microservice Integration from Dev to Production_KubeCon2018
Microservice Integration from Dev to Production_KubeCon2018Microservice Integration from Dev to Production_KubeCon2018
Microservice Integration from Dev to Production_KubeCon2018
 
Building a Microgateway in Ballerina_KubeCon 2108
Building a Microgateway in Ballerina_KubeCon 2108Building a Microgateway in Ballerina_KubeCon 2108
Building a Microgateway in Ballerina_KubeCon 2108
 
Ballerina ecosystem
Ballerina ecosystemBallerina ecosystem
Ballerina ecosystem
 
Orchestrating microservices with docker and kubernetes
Orchestrating microservices with docker and kubernetesOrchestrating microservices with docker and kubernetes
Orchestrating microservices with docker and kubernetes
 
Data integration
Data integrationData integration
Data integration
 
Service resiliency in microservices
Service resiliency in microservicesService resiliency in microservices
Service resiliency in microservices
 
Microservices integration
Microservices integration   Microservices integration
Microservices integration
 
Writing microservices
Writing microservicesWriting microservices
Writing microservices
 
Ballerina philosophy
Ballerina philosophy Ballerina philosophy
Ballerina philosophy
 
Ballerina: Cloud Native Programming Language
Ballerina: Cloud Native Programming Language Ballerina: Cloud Native Programming Language
Ballerina: Cloud Native Programming Language
 
Writing services in Ballerina_Ballerina Day CMB 2018
Writing services in Ballerina_Ballerina Day CMB 2018Writing services in Ballerina_Ballerina Day CMB 2018
Writing services in Ballerina_Ballerina Day CMB 2018
 
Resiliency & Security_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018  Resiliency & Security_Ballerina Day CMB 2018
Resiliency & Security_Ballerina Day CMB 2018
 
Stream Processing with Ballerina
Stream Processing with BallerinaStream Processing with Ballerina
Stream Processing with Ballerina
 
Secure by Design Microservices & Integrations
Secure by Design Microservices & IntegrationsSecure by Design Microservices & Integrations
Secure by Design Microservices & Integrations
 
Observability with Ballerina
Observability with BallerinaObservability with Ballerina
Observability with Ballerina
 
Serverless Ballerina
Serverless BallerinaServerless Ballerina
Serverless Ballerina
 

Recently uploaded

Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
Aftab Hussain
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 

Recently uploaded (20)

Graspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code AnalysisGraspan: A Big Data System for Big Code Analysis
Graspan: A Big Data System for Big Code Analysis
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 

Test Driven Development for Microservices

  • 2. Types of Tests from: "https://martinfowler.com/articles/microservice-testing"
  • 3. Testing Microservices Function/ Method Service REST Services Package Deploy Kubernetes End-to-endLogs Unit Observability updated from: "https://martinfowler.com/articles/microservice-testing"
  • 4. Demo 1 - Unit tests: sayHello
  • 5. Unit Test import ballerina/test; @test:Config function testSayHelloTDD() { string actual = sayHello(greetingAct); test:assertEquals(actual,greetingExp,msg="string test failed"); }
  • 6. Test Annotations import ballerina/test; @test:Config { before: "beforeTestBar", after: "afterTestBar", dependsOn: ["testFunctionPre1", "testFuncctionPre2"], groups: ["group1"] } function testBar() { // test logic for function bar() }
  • 7. More Test Annotations & Assertions import ballerina/test; @test:BeforeSuite {...} | @test:BeforeEach {...} | @test:AfterSuite {...} function testBar() { // test logic for function bar() test:assertEquals(actual,greetingExp,msg="string test failed"); test:assertTrue(value,msg="Assert True failed"); test:assertFail("Expected an exception"); }
  • 8. Running Tests ballerina init ballerina test [packageName] | [fileName.bal] --list-groups tests --groups group_a tests --disable-groups group_b tests --config myConf.conf
  • 9. Testing Microservices Function/ Method Service REST Services Package Deploy Kubernetes End-to-endLogs Unit Observability updated from: "https://martinfowler.com/articles/microservice-testing"
  • 11. Demo 2 - Service tests: Ballerina Service
  • 12. Unit Test with Mock @test:Mock { packageName: ".", functionName: "intAdd" } function mockIntAdd(int a, int b)returns int)... { return (a - b); } @test:Config function testIntAdd() { int answer = 0; answer = intAdd(5, 3); test:assertEquals(actual,2,msg="mock failed"); } function intAdd(int a, int b)returns int)... { return (a + b); }
  • 13. Service Test Setup function startService(){ serviceStarted=test:startServices("hello-service"); } @test:Config { before: "startService",after: "stopService" } function testFunc() { //... } function stopService() { test:stopServices("hello-service"); }
  • 14. Service Test Body @test:Config { before: "startService",after: "stopService" } function testFunc() { endpoint http:Client httpEndpoint { url: "http://localhost:9090" }; test:assertTrue(serviceStarted, msg = "Unable to start the service"); ... match response { ... test:assertEquals(res, response1); } error err => test:assertFail(msg = "Failed to call the endpoint:"); } }
  • 15. Testing Microservices Function/ Method Service REST Services Package Deploy Kubernetes End-to-endLogs Unit Observability updated from: "https://martinfowler.com/articles/microservice-testing"
  • 17. Demo 3 - Services (composition) Tests
  • 19. Testing Microservices Function/ Method Service REST Services Package Deploy Kubernetes End-to-endLogs Unit Observability updated from: "https://martinfowler.com/articles/microservice-testing"
  • 20. Demo 4 - Deployment Tests
  • 21. Service Deployment - Docker import ballerinax/docker; @docker:Config { registry:"ballerina.guides.io", name:"travel_agency_service", tag:"v1.0" } @docker:Expose{} # Auto Generated Dockerfile FROM ballerina/ballerina:0.975.1 LABEL maintainer="dev@ballerina.io" COPY travel_agency.balx /home/ballerina EXPOSE 9090 CMD ballerina run travel_agency.balx
  • 22. OSS Tools for Testing Containers Sysdig - Falco for k8 ● Uses rules ● Alerts on drift ● Includes container best practices ● Highly configurable Google - Container Structure Tests ● Unit Tests ○ for Docker Images ● Command Tests ○ verifies output of running a command inside container ● File Existence Tests ○ verifies existence of file at a location ● File Content Tests ○ verifies file contents ● Metadata Test ○ verifies container configuration
  • 23. Testing Microservices Function/ Method Service REST Services Package Deploy Kubernetes End-to-endLogs Unit Observability updated from: "https://martinfowler.com/articles/microservice-testing"
  • 24. Modern Approaches to Testing Microservices from "https://opensource.com/article/18/6/five-microservice-testing-strategies-startups" Documentation First AWS Testing (own-account) Full stack in-a-box (local) Shared Testing Instance Stubbed services Lorem ipsum congue tempus Lorem ipsum tempus Lorem ipsum congue tempus Lorem ipsum tempus Documentation First AWS own-account Full stack in-a-box local Shared Testing Instances Stubbed Services
  • 25. Breaking Things on Purpose ○ Inject something harmful ○ in order to build immunity ○ Chaos engineering ○ "thoughtful, planned experiments designed to reveal the weakness in our systems" ○ Testing proactively ○ instead of waiting for an outage ○ "Engineering Chaos" = better name image from: https://www.anshulpatel.in/post/chaos_engg_exprmnt_dsgn/
  • 26.
  • 27. Microservice Testing Reality Unit Tests Test functions Test methods Test services Integration Tests Test interactions within groups Test interactions between groups Test interactions outside groups Deployment Tests Test Container Configuration Test Container Management Configuration Test Endpoints Observability Events, logs and alerts Test in Production Engineering Chaos Modern Tests Test Documentation Full stack in-a-box AWS own-account Stubbed Services 05 01 02 03 04
  • 29. How to get involved Learn more Open source Get support http://ballerina.io http://github.com/ballerina-platform/ Stack Overflow #ballerina tag Practice http://exercism.io/tracks/ballerina