Vivek Mahajan & Ishaan Madaan
MicroServices Workshop
Flight Reservation Application
Reservation
Service
Flight Details
Service
User Details
Service
Docker & Microservices
Docker Is one of the Reason to make the microservices popular, that helps the software to
build and ship faster.
user details
-mysql
Flight Details
Service
Reservation
Service
flightdetails -
mysql
Reservation-
mysql
User login
Service
7070 9090 6060
Docker Containers
Swagger
● A Good Friend of Qa.
● Rest Api Documentation Api
● Many other Features
http://localhost:7070/userdetails/swagger-ui.html
http://localhost:6060/reservation/swagger-ui.html
http://localhost:9090/flightdetails/swagger-ui.html
.
Unit Tests
UNIT TESTING is a level of software testing where
individual units/ components of a software are tested.
A unit is the smallest testable part of any software,
for eg, a class method.
On which side of the pyramid should the following validations
test lie:
● Passenger.cardNumber.length = 16
● Passenger.firstName.length > 3
● Passenger.lastName.length > 3
● Passenger.phoneNumber.length > 3
● Passenger.phoneNumber contains only numerals
● Passenger.flightId != null
● Passenger.email contains @
● A unit or a method may exhibit multiple behaviors and hence, each behavior
must be tested as a separate test and not all in one.
● Always use mocks for simulating external behavior when testing a method or a
unit in isolation.
Best Practices of writing Unit Tests
@Test
public void validateReservationData() {
Passenger passenger = new Passenger();
passenger.setFirstName("some invalid name");
passenger.setLastName("some invalid name");
passenger.setPhone("some invalid name");
passenger.setEmail("some invalid name");
reservation.setFlight_id(null);
reservation.setPassenger(passenger);
assertTrue("first name is invalid",ReservationValidator
.isValidPassengerName(reservation.getPassenger().getFirstName()));
assertTrue("last name is invalid",ReservationValidator
.isValidPassengerName(reservation.getPassenger().getLastName()));
assertTrue("email is invalid",ReservationValidator
.isValidPassengerName(reservation.getPassenger().getEmail()));
assertTrue("phone is invalid",ReservationValidator
.isValidPassengerName(reservation.getPassenger().getPhone()));
}
Bad Practice
@Test
public void validatePassengerEmail() { }
@Test
public void validatePassengerContact() { }
@Test
public void validateFlightId) { }
@Test
public void validatePassengerEmail() { }
Good Practice
FlightReservation Application
Reservation
Service
Flight Details
Service
Consumer
Producer
FlightReservation Application
Reservation
Service
Flight Details
Service
Consumer
Producer
Mock
Mock
Cheap But Not TrustWorthy
Integration test (Api test)
Reservation
Service
Flight Details
Service
Consumer
Producer
Make the whole
System up and test
the integration
Costly but
trustWorthy
Violates the
concept of
Microservices
(independent(
Contract test
Reservation
Service
Flight Details
Service
Consumer
Producer
Write test on the basis
of initial contract
contract test
file
PACT FRAMEWORK
Service Virtualization
● To make the System Persistent
○ Dealing With third party API’s
○ Critical System Dependency
○ Functional Test Flows
● Load Testing
MounteBank
MounteBank
● npm install -g mountebank.
● mb start --configfile imposter.json
● Default Port 2525
RECORD NETWORK TRAFFIC & PLAYBACK
Monitoring
● We need to monitor the Services As part of Testing.
● Services should be configured in such a way that an alarm
is raised in case of a failure.
LOGGING
Do We need to Test the Logging??
Questions
Links
GitHub:
https://github.com/ishaanmadaan008/microservices_vodqa
Feedback Url:
https://tinyurl.com/y8fqhnwz

Microservices workshop