WHITE PAPER. An Insight into Microservices Testing Strategies. Abstract. Arvind Sundar, Technical Test Lead

Similar documents
WHITE PAPER. Assuring success in blockchain implementations by engineering quality in validation

ADVANTAGE YOU. Drive TCO* reduction through Infosys TIBCO solutions

WHITE PAPER. Master Data Management as a Solution Using SAP MDM and Complementing Technologies

RPA VALIDATION PITFALLS AND HOW TO AVOID THEM

ACCELERATING DIGITIZATION THROUGH NEXT-GENERATION INTEGRATION

PERSPECTIVE. Microservices A New Application Paradigm. Abstract

INFOSYS BUSINESS PROCESS MANAGEMENT OFFERINGS

REDUCING TIME TO MARKET WITH DEVOPS

VIEW POINT. Five Commandments for Successful COTS Package Testing. Abstract

A 7-STEP FRAMEWORK TO IMPLEMENT CICD IN ETL TESTING

THE API GLOBE- TROTTERS

CASE STUDY. Streamlined Operations Through New Business Process Transformation

AUTOMATING BIG DATA TESTING FOR PERFORMANCE

BANKING WITH THE RIGHT REGULATIONS

PERSPECTIVE. Need for a Comprehensive Test Maturity Model. Abstract. - Reghunath Balaraman, Harish Krishnankutty

PERSPECTIVE. Assuring the digital utilities transformation. Gaurav Kalia Client Solution Manager

TRANSFORMING THE LANDSCAPE FOR INSURANCE CLAIMS

MODERNIZING THE MIDDLEWARE

VIEW POINT. The Enterprise QA Transformation Model A solution to enhance an enterprises testing maturity. Abstract. Reghunath Balaraman, Aromal Mohan

ACCELERATE YOUR JOURNEY TO BEING DIGITAL

WHITE PAPER. Getting started with Continuous Integration in software development. Amruta Kumbhar, Madhavi Shailaja & Ravi Shankar Anupindi

Progressive Organization PERSPECTIVE

RETRANSFORM BEYOND AGILE FOR FASTER, INTEGRATED IT SERVICE DELIVERY

RETRANSFORM BEYOND AGILE FOR FASTER, INTEGRATED IT SERVICE DELIVERY

WHITE PAPER. Integrated Profitability Analytics The Need, Struggles, and Future

RETAIL AND CPG HUMAN AMPLIFICATION IN THE ENTERPRISE

KNOWLEDGE-BASED ENGINEERING (KBE) Key product-development technology to enhance competitiveness

BEST STORIES OF INFOSYS SALESFORCE IMPLEMENTATION

PERSPECTIVE. Operational Risk Management in Banks: The Way Forward

CHANGE IMAGINED. CHANGE DELIVERED

KEEP THE LIGHTS ON - APPLICATION MAINTENANCE AND SUPPORT

WHITE PAPER. Banks Regulatory Reporting Compliance The Challenges and the Solution. Abstract

PERSPECTIVE. Policy Administration System Upgrade An Agile, Lean, and Flexible Approach

PERSPECTIVE. Accounting General Ledger Challenges in Facets. Vikas Kumar Abstract

WHITE PAPER MICRO FUNCTIONS BUILDING BLOCKS FOR FINANCIAL SERVICES IN THE OPEN WORLD

WHITE PAPER. Charting the Course for a Smooth Global Rollout. Abstract. - Nitin Lehri and Soumyendra Mohanty

PERSPECTIVE. Effective Capacity Management with Modeling and Simulation - assisted Performance Testing. Abstract

WHITE PAPER. Application Grading for Comprehensive Quality Assurance. Abstract

CMO Challenges Today: How Are They Reacting?

PERSPECTIVE. MAKING GPP (Global PAYplus) TESTING PREDICTABLE

ENABLING SALES TEAMS TO CREATE WINNING QUOTES

PERSPECTIVE. Creating Business Value with Mature QA Practices. Abstract

A PATH TO GDPR READINESS WHITE PAPER

BEST STORIES FOR DIGITAL IN COMMUNICATION SERVICES

PREDICTIVE ANALYTICS FOR DATA-DRIVEN DECISIONS

PERSPECTIVE. Shrink Resolution Times with Field Service Automation (FSA) Abstract

WHITE PAPER. Evaluation Framework: To Build or to Buy CRM Software? Abstract

ENHANCING BUSINESS EFFICIENCY WITH AI AND ENGINEERING DATA ANALYTICS

Boundaryless Information PERSPECTIVE

DIGITAL OUTLOOK BANKING INDUSTRY

PRODUCT COMPLAINTS MANAGEMENT. Infosys Handbook For Life Sciences

INFOSYS SMART OILFIELD SERVICES SOLUTION FOR SAP ERP

INFOSYS PROCUREMENT AND PLANNING PRACTICE

WHITE PAPER. Payments organizations can leverage APIs to monetize their data and services. Abstract

Reimagining Life Sciences With AI-Enabled Digital Transformation. Abstract

VIEW POINT TRADE RECONSTRUCTION REQUIREMENTS:CHALLENGES AND SOLUTION

WHITE PAPER. Improved Compliance Management in Banks through Cognitive Analysis

PERSPECTIVE. Using QR codes to track and identify counterfeit products

INFOSYS BPM DIGITAL Empowering you to cash on digital opportunities

WHITE PAPER. The λ Validation Model for Regulatory Application Development. Overview. Madhu Venantius Laulin Expedith

WHITE PAPER. How to optimize close cycle using Hyperion Financial Management. - Navpreet Singh, Principal Consultant

WHITE PAPER. IoT-enabled Banking Services

WHITE PAPER. Relationship-based pricing (RBP) in Financial Services Improve customer retention and market share with an innovative pricing approach

WHITE PAPER. Technology Trends for Road User Safety in Public Sector. Abstract

FROM MONOLITHIC MAINFRAMES TO CLOUD FOR FASTER TIME TO MARKET

NAVIGATE YOUR NEXT TARGET PERFORMANCE WITH DIGITIZE CFO DASHBOARD

WHITE PAPER. Focus on value added services by network companies a paradigm shift. Rahul Kaushal, Ramakant Mittal

COMPLIANCE AND RISK MANAGEMENT AS A CATALYST FOR CHANGE

WHITE PAPER LEVERAGING 3-C PHILOSOPHY FOR ENHANCED ROI FROM CHANNELS

WHITE PAPER. Effective Audit Hosting Strategy: A Perspective. Abstract. Pranav Gadre, Sanjay Martis

INFOSYS REALTIME STREAMS

WHITE PAPER. Pick the right SAP UI/UX offering for your business. Abstract

DIGITAL OUTLOOK CONSUMER PACKAGED GOODS INDUSTRY

STUDY. The State of the Store Insights from Consumers and Retailers into the European Shopping Experience

MARGIN MANAGEMENT IN THE OIL & GAS INDUSTRY WHITE PAPER

Feature Scope Description for Enterprise Messaging THE BEST RUN FEATURE SCOPE DESCRIPTION PUBLIC

WHITE PAPER. Cloud-Based Human Capital Management: Accelerating Organizational Evolution to be #MoreTogether. Abstract

VIEW POINT. Clearing the clouds of SuccessFactors. Abstract. Jitendra Chakravarty, Principal Consultant

DIGITAL OUTLOOK INDUSTRIAL MANUFACTURING INDUSTRY

HOW AGILE DO YOU WANT IT?

WHITE PAPER. Leveraging advanced validation techniques for retail size optimization. - Divya Mohan C, Chitra Sylaja

APIFICATION OF FINANCIAL SERVICES - ADAPTING TO A CUSTOMER CENTRIC WORLD WHITE PAPER

WHITE PAPER. Count your inventory in the right way for right result

VIEW POINT. Making risk-free, accelerated legacy modernization possible! Abstract

DevOps Journey. adoption after organizational and process changes. Some of the key aspects to be considered are:

PERSPECTIVE. Crisis Management In The Times Of Global Manufacturing Supply Chains

AVOIDING EQUIPMENT FAILURE WITH ENGINEERING DATA ANALYTICS AND AI

SELF-SERVICE FOR DATA PREPARATION AND ADVANCED ANALYTICS OVERVIEW

VIEW POINT. Experience Commerce

Microservices: Embracing the Unix mantra Do one thing and do it well

WHITE PAPER. End User empowerment for improved Asset Maintenance

SEVEN FEATURED PEGA CASE STUDIES. Different needs, different industries, tailored solutions leveraging Pega solutions

DIGITAL TRANSFORMATION WITH INTELLIGENT SOLUTIONS FROM INFOSYS AND PEGA

CASE STUDY THE SPEND ELIXIR

DIGITAL OUTLOOK AUTOMOTIVE INDUSTRY

WHITE PAPER. Coalition loyalty: Loyalty s new definition

PERSPECTIVE. Customer Loyalty Quotient Strategy: Key to an emotional connect with customers. Abstract

WHITE PAPER. Embracing Microservices Architecture in Telecommunications Adoption and measuring success of microservices

WHITE PAPER. Loss Prevention Data Mining Using big data, predictive and prescriptive analytics to enpower loss prevention.

VIEW POINT. Approach to The Elemental Impurities Risk Assessment in Pharmaceuticals

Transcription:

WHITE PAPER An Insight into Microservices Testing Strategies Arvind Sundar, Technical Test Lead Abstract The ever-changing business needs of the industry necessitate that technologies adopt and align themselves to meet demands and, in the process of doing so, give rise to newer techniques and fundamental methods of architecture in software design. In the context of software design, the evolution of microservices is the result of such an activity and its impact percolates down to the teams working on building and testing software in the newer schemes of architecture. This white paper illustrates the challenges that the testing world has to deal with and the effective strategies that can be envisaged to overcome them while testing for applications designed with a microservices architecture. The paper can serve as a guide to anyone who wants an insight into microservices and would like to know more about testing methodologies that can be developed and successfully applied while working within such a landscape.

Introduction Microservices attempt to streamline the software architecture of an application by breaking it down into smaller units surrounding the business needs of the application. The benefits that are expected out of doing so include creating systems that are more resilient, easily scalable, flexible, and can be quickly and independently developed by individual sets of smaller teams. Formulating an effective testing strategy for such a system is a daunting task. A combination of testing methods along with tools and frameworks that can provide support at every layer of testing is key; as is a good knowledge of how to go about testing at each stage of the test life cycle. More often than not, the traditional methods of testing have proven to be ineffective in an agile world where changes are dynamic. The inclusion of independent micro-units that have to be thoroughly tested before their integration into the larger application only increases the complexity in testing. The risk of failure and the cost of correction, post the integration of the services, is immense. Hence, there is a compelling need to have a successful test strategy in place for testing applications designed with such an architecture.

Microservices architecture Challenges in testing microservices The definition of what qualifies as a microservice is quite varied and debatable with some SOA (service-oriented architecture) purists arguing that the principles of microservices are the same as that of SOA and hence, fundamentally, they are one and the same. However, there are others who disagree and view microservices as being a new addition to software architectural styles, although there are similarities with SOA in the concepts of design. Thus, a simpler and easier approach to understand what microservices architecture is about, would be to understand its key features: Self-contained and componentized Decentralized data management Resilient to failures Built around a single business need Reasonably small (micro) The points above are not essentially the must-haves for a service to be called a microservice, but rather are good-to-have. The list is not a closed one either, as it can also include other features that are common among implementations of a microservices architecture. However, the points provide a perspective of what can be termed as a microservice. Now that we know what defines a microservice, let us look at the challenges it poses to testers. The distributed and independent nature of microservices development poses a plethora of challenges to the testing team. Since microservices are typically developed by small teams working on multiple technologies and frameworks, and are integrated over light-weight protocols (usually ReST over HTTPs, though this is not mandatory), the testing teams would be inclined to use the Web API testing tools that are built around SOA testing. This, however, could prove to be a costly mistake as the timely availability of all services for testing is not guaranteed, given that they are developed by different teams. Furthermore, the individual services are expected to be independent of each other although they are interconnected with one another. In such an environment, a key factor in defining a good test strategy would be to understand the right amount of testing required at each point in the test life cycle. Additionally, if these services integrate with another service or API that is exposed externally or is built to be exposed to the outside world, as a service to consumers, then a simple API testing tool would prove to be ineffective. With microservices, unlike SOA, there is no need to have a service level aggregator like ESB (enterprise service bus) and data storage is expected to be managed by the individual unit. This complicates the extraction of logs during testing and data verification, which is extremely important in ensuring there are no surprises during integration. The availability of a dedicated test environment is also not guaranteed as the development would be agile and not integrated.

Approach to testing microservices and testing phases In order to overcome the challenges outlined above, it is imperative that the test manager or lead in charge of defining the test strategy appreciates the importance of Mike Cohn s Test Pyramid i and is able to draw an inference of the amount of testing required. The pictorial view emphasizes the need to have a bottom-up approach to testing. It also draws attention to the number of tests and in turn, the automation effort that needs to be factored in at each stage. The representation of the pyramid has been slightly altered for the various phases in microservice testing. These are: Scope of Testing Mike Cohn s Testing Pyramid E2E UI Testing Integration Testing Contrast Testing Unit Testing Number of Tests Execution Time i. Unit testing iii. Integration testing The scope of unit testing is internal to the service and in terms of volume of tests, they are the largest in number. Unit tests should ideally be automated, depending on the development language and the framework used within the service. ii. Contract testing Contract testing is integral to microservices testing and can be of two types, as explained below. The right method can be decided based on the end purpose that the microservice would cater to and how the interfaces with the consumers would be defined. a) Integration contract testing: Testing is carried out using a test double (mock or stub) that replicates a service that is to be consumed. The testing with the test double is documented and this set needs to be periodically verified with the real service to ensure that there are no changes to the service that is exposed by the provider. b) Consumer-driven contract testing: In this case, consumers define the way in which they would consume the service via consumer contracts that can be in a mutually agreed schema and language. Here, the provider of the service is entrusted with copies of the individual contracts from all the consumers. The provider can then test the service against these contracts to ensure that there is no confusion in the expectations, in case changes are made to the service. Integration testing is possible in case there is an available test or staging environment where the individual microservices can be integrated before they are deployed. Another type of integration testing can be envisaged if there is an interface to an externally exposed service and the developer of the service provides a testing or sandbox version. The reliance on integration tests for verification is generally low in case a consumerdriven contract approach is followed. iv. End-to-end testing It is usually advised that the top layer of testing be a minimal set, since a failure is not expected at this point. Locating a point of failure from an end-to-end testing of a microservices architecture can be very difficult and expensive to debug.

Testing scenarios and test strategy In order to get a clear understanding of how testing can be carried out in different scenarios, let us look at a few examples that can help elucidate the context of testing and provide a deeper insight into the test strategies used in these cases. Scenario 1: Testing between microservices internal to an application or residing within the same application This would be the most commonly encountered scenario, where there are small sets of teams working on redesigning an application by breaking it down into microservices from a monolithic architecture. In this example, we can consider an e-commerce application that has two services a) selecting an item and b) reserving an item, which are modelled as individual services. We also assume there is a close interaction between these two services and the parameters are defined using agreed schemas and standards. Mocked Service Select an Item Reserve an item Integration Contract Testing Scope Unit Testing Scope REST over HTTPS Item ID. date Reservation ID Application Integration Testing Scope For unit testing, it would be ideal to use a framework like xunit (NUnit or JUnit). The change in data internal to the application needs to be verified, apart from checking the functional logic. For example, if reserving an item provides a reservation ID on success in the response to a REST call, the same needs to be verified within the service for persistence during unit testing. The next phase of testing in contract testing. In case there are several dissimilar consumers of the service within the application, it is recommended to use a tool that can enable consumer-driven contract testing. Open source tools like Pact, Pacto, or Janus can be used. This has been discussed in further detail in the last example and hence, in the context of this example, we will assume that there is only a single consumer of the service. For such a condition, a test stub or a mock can be used for testing by way of integration contract testing. Data being passed between the services needs to be verified and validated using tools like SOAPUI. For example, an item number being passed between the services that selects it to the one that reserves it. E2E tests should ensure that dependency between microservices is tested at least in one flow, though extensive testing is not necessary. For example, an item being purchased should trigger both the select and reserve microservices.

Scenario 2: Testing between internal microservices and a third-party service Here, we look at a scenario where a service with an application consumes or interacts with an external API. In this example, we have considered a retail application where paying for an item is modelled as a microservices and interacts with the PayPal API that is exposed for authenticating the purchase. Let us look at the testing strategy in each phase of the test cycle in this case: Pay for an Item Integration Testing Scope PayPal Sandbox API Unit Testing Scope REST over HTTPS Contract Testing Scope Application Test Double Firewall PayPal (External) API Virtual Provider Unit tests should ensure that the service model is catering to the requirements defined for interacting with the external service, while also ensuring that internal logic is maintained. Since there is an external dependency, there exists a need to ensure that requirements are clearly defined and hence, documenting them remains key. TDD approach is suggested where possible and any of the popular frameworks discussed in the previous example can be chosen for this. Contract testing can be used in this case to test the expectations from consumer microservices, that is, the applications internal service, decoupling it from the dependency on the external web service to be available. In this context, test doubles, created using tools like Mockito or Mountebank, can be used to define the PayPal API s implementation and tested. This is essentially integration contract testing and again needs to be verified with a live instance of the external service periodically, to ensure that there is no change to the external service that has been published and consumed by the consumer. Integration tests can be executed if the third-party application developer provides a sandbox (e.g. PayPal s Sandbox API ii ) for testing. Live testing for integration is not recommended. If there is no availability of a sandbox, integration contract testing needs to be exercised thoroughly for verification of integration. E2E tests should ensure that there are no failures in other workflows that might integrate with the internal service. Also, a few monitoring tests can be set up to ensure that there are no surprises. In this example, selecting and purchasing an item (including payment) can be considered an E2E test that can run at regular and pre-defined intervals to spot any changes or breaks.

Scenario 3: Testing for a microservice that is to be exposed to public domain Consider an e-commerce application where retailers can check for availability of an item by invoking a Web API. Unit Testing Scope Application REST over HTTPS REST over HTTPS Customer Contract 1 Customer Contract 2 Virtual Consumer 1 Virtual Consumer 2 Consumer Driven Contract Testing Scope Unit tests should cover testing for the various functions that the service defines. Including a TDD development can help here to ensure that the requirements are clearly validated during unit testing. Unit test should also ensure that data persistence within the service is taken care of and passed on to other services that it might interact with. Contract testing In this example, consumers need to be set up by using tools that help define contracts. Also, the expectations from a consumer s perspective need to be understood. The consumer should be well-defined and in line with the expectations in the live situation and contracts should be collated and agreed upon. Once the consumer contracts are validated, a consumer-driven contract approach to testing can be followed. It is assumed that in this scenario, there would be multiple consumers and hence, individual consumer contracts for each of them. For example, in the above context, a local retailer and an international retailer can have different methods and parameters of invocation. Both need to be tested by setting up contracts accordingly. It is also assumed that consumers subscribe to the contract method of notifying the provider on the way they would consume the service and the expectations they have from it via consumer contracts. E2E tests minimal set of E2E tests would be expected in this case, since interactions with external third parties are key here

In conclusion Improvements in software architecture has led to fundamental changes in the way applications are designed and tested. Teams working on testing applications that are developed in the microservices architecture need to educate themselves on the behavior of such services, as well as stay informed of the latest tools and strategies that can help deal with the challenges they could potentially encounter. Furthermore, there should be a clear consensus on the test strategy and approach to testing. A consumer-driven contract approach is suggested as it is a better way to mitigate risk when services are exposed to an assorted and disparate set of consumers and as it further helps the provider in dealing with changes without impacting the consumer. Ensuring that the required amount of testing is focused at the correct time, with the most suitable tools, would ensure that organizations are able to deal with testing in such an environment and meet the demands of the customer. References : i https://www.mountaingoatsoftware.com/blog/the-forgotten-layer-of-the-test-automation-pyramid ii https://www.sandbox.paypal.com For more information, contact askus@infosys.com 2017 Infosys Limited, Bengaluru, India. All Rights Reserved. Infosys believes the information in this document is accurate as of its publication date; such information is subject to change without notice. Infosys acknowledges the proprietary rights of other companies to the trademarks, product names and such other intellectual property rights mentioned in this document. Except as expressly permitted, neither this documentation nor any part of it may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, printing, photocopying, recording or otherwise, without the prior permission of Infosys Limited and/ or any named intellectual property rights holders under this document. Infosys.com NYSE: INFY Stay Connected