Fundamentals of microservices architecture testing

The importance of microservices architecture testing

Increased adoption of digital has pushed the need for speed to the forefront. The need to conceptualize, develop, launch new products and iterate to make them better, much ahead of the competition and gain customer mindshare, has become the critical driver of growth. Adoption of agile principles or movement towards scrum teams for increased agility are all steps in this direction. Disruptive changes have also taken place on the application front with the 3-tier architecture of the late 90s and subsequent 2 tier monolithic architecture giving way to one that is based on microservices.

Having a single codebase made a monolithic architecture less risky but slow to adopt changes, the exact opposite of a services-based architecture. Microservices architecture makes it easier for multiple development teams to make changes to the codebase in parallel. By transforming an application into a distributed set of services that are highly independent, yet interdependent, provides the ability to create new services/functionalities and modify services without impacting the overall application. These changes can be achieved by teams cutting across geographies or locations and makes it easier for them to understand functional modules rather than the humongous application codebase. However, the highly distributed nature of services also gives them a heightened ability to fail.

Breaking it down – Testing strategies in a microservice architecture

At the core, a microservices architecture comprises of 3 layers – a REST layer that allows the service to expose APIs, the database layer, and the service layer. A robust testing strategy needs to cover all these layers and ensure that issues are not leaked to production. The further an issue moves across stages, the impact increases on account of multiple teams getting affected. Hence the test plan must cover multiple types of testing like service testing, subsystem testing, client acceptance testing, performance testing, etc. Subsequent paragraphs outline key aspects of service level testing and integration testing in a microservices architecture-based application landscape.

In service level testing, each service forming a part of the application architecture needs to be validated. Each service has dependencies on other services and transmits information to others based on need. In a monolith architecture, since connections are being established from one class to the other within the same Java Virtual machine (JVM), chances of failure are far lower. However, in a services architecture, these are distributed, driving the need for network calls to access other services and makes it more complex.

Functional Validation: The primary goal in services testing is the functionality validation of a service. Key to this is the need to understand all events the service handles through both internal as well as external APIs. At times this calls for simulating certain events to ensure that they are being handled properly by the service. Collaboration with the development team is key to understand incoming events being handled by the service as part of its functionality. A key element of functional validation – API contract testing, tests the request and response payload along with a host of areas like pagination and sorting behaviors, metadata, etc.

Compatibility: Another important aspect is recognizing and negating backward compatibility issues. This happens during the launch of a changed version of the service that breaks existing clients running in production. Changes that happen to API contracts need to be evaluated in detail to understand if they are mandatory and capable of breaking clients in production. An addition of a new attribute or a parameter may not classify as a breaking change; however, changes to response payload, behavior, error codes, or datatypes have the ability to break. A change in value typically changes the logic behind it as well. They need to be uncovered much earlier in the service testing lifecycle.

Dependencies: Another aspect of focus is external dependencies, where one would test both incoming as well as outgoing API calls. Since these are heavily dependent on the availability of other services and hence other teams, there is a strong need to obviate dependency through the usage of mocks. Having conversations with developers and getting them to insert mocks while creating individual services will enable testing dependencies without waiting for the service to be available. It is imperative to make sure the mocks are easily configurable without needing access to the codebase. Usage of mocks also drives ease in automation giving teams the ability to run independently with no configuration.

Understanding Microservices Architecture Testing

Once each service is tested for its functionality, the next step is to move onto validate how the various collaborating services work together end to end. Known as subsystem testing or integration testing, it tests the whole functionality exposed together. Understanding the architecture or application blueprint by discussions with the development team is paramount in this stage. Further, there is a strong need to use real services deployed in the integration environment rather than mocks used for external dependencies.

As part of integration testing, there is a need to validate if the services are wired very closely and talking to each other. The event stream and inter-service API calls need to be configured properly so inter-service communication channels are proper. If the service functionality level testing is proper, the chances of finding errors are minimal in this stage, since the required mocks created in the functionality testing stage would have ensured that the services function properly.

Looking in-depth, we find that the testing strategies in a microservices architecture are not extremely different from those adopted for a monolith application architecture. The fundamental difference comes in the way the interdependencies and communication between multiple services forming a part of the larger application are tested to ensure that the application as a whole function in line with expectations.

Bandwidth Testing for superior user experience – here’s how?

The Bandwidth Testing process simulates a low internet bandwidth connection and checks how your application behaves under desired network speed.

Considering a scenario where a specific application’s home page always loads in milliseconds in office premises this may not be the case when an end-user with low network speed accesses the application. To enhance user experience and get to know the application load times at specific network bandwidth speeds, we can simulate it and identify specific component/service call which is taking more time and can be improved further.

How to test bandwidth

Prerequisites:

Bandwidth speed test can be done using Chrome browser. You should set your ‘Network’ panel in the chrome browser as per the below requirements.

Setup:

  1. Go to Customize and control Google Chrome at the top right corner and click More tools, then select Developer tools
    • Or press keyboard shortcut Ctrl + Shift + I
    • Or press F12
  2. Then click the ‘No throttling’ dropdown and choose Add… option under the Custom section.
  3. Click Add custom profile
  4. You will need to enter profile name in order to click on Add button. For example, ‘TestApp 1 MBPS’.
  5. Fill in the Download, Upload, Latency columns as below and click Add.

Example for 100Kbps:

Download (kb/s)Upload (kb/s)Latency (ms)
10050300

Example for 1Mbps:

Download (kb/s) Upload (kb/s)Latency (ms)
102451250

Example for 2.5Mbps:

Download (kb/s)Upload (kb/s)Latency (ms)
2600150030

Configuring Chrome is a one-time affair. Once Chrome has been configured for bandwidth speed test, use the same settings by selecting the profile name [TestApp 1 MBPS] from the No Throttling drop-down.

Metrics to be collected for bandwidth testing:

  • Data transferred (KB)
  • Time taken for data transfer (seconds)

Using Record network activity option in the Chrome browser, you can get the above attributes.

Note: Toggle button “Record network log”/”Stop recording network log” and button “Clear” are available in the network panel.

It is best practice to close all the non-testing applications/tools in the system and other tabs from Chrome where the testing is performed.

Steps for recording network activity:

  1. Open Developer Tools and select the Network tab.
  2. Clear network log before testing.
  3. Make sure Disable cache checkbox is checked.
  4. Select the created network throttling profile (say ‘TestApp 1 MBPS’).
  5. Start recording for the steps to be measured as per the scenario file.
  6. Wait for the completion of step and page is fully loaded to check the results
  7. Data transferred size for each recorded step will be displayed down in the status bar as highlighted. The size will be in byte/kilobyte/megabyte. Make note of it.
  8. Time taken for data transfer will be displayed in the timeline graph. The horizontal axis represents the time scale in a millisecond. Take the
  9. Maximum time. Take approximate value from the graph and make note of it.

Here is the sample screenshot taken for login process of snapdeal application page in which specific js component (base.jquery111.min.js) loading took 4.40s and also while searching for any product searchResult.min.js took 4.08s which can be improved further for better user experience.

This Bandwidth Testing Process helps in every possible way to improve user experience by identifying specific component or API calls which are taking more time to load and it helps developers to fix those specific components.

Your application’s performance is a major differentiator that decides whether it turns out to be a success or fails to meet expectations. Ensure your applications are peaked for optimal performance and success.

Improve page load speed and user experience with Trigent’s testing services

Trigent’s experienced and versatile Quality Assurance and Testing team is a major contributor in the successful launch, upgrade and maintenance of quality software used by millions around the globe. Our experienced responsible testing practices put process before convenience to delight stakeholders with an impressive industry rivaled Defect Escape Ratio or DER of 0.2.

Got a question? Contact us for a consultation

Responsible Testing – Human centricity in Testing

Responsibility in testing – What is responsible testing?

Consumers demand quality and expect more from products. The DevOps culture emphasizes the need for speed and scale of releases. As CI/CD crisscrosses with quality, it is vital to engage a human element in testing to foresee potential risks and think on behalf of the customer and the end-user.

Trigent looks at testing from a multiplicity of perspectives. Our test team gets involved at all stages of the DevOps cycle, not just when the product is ready. For us, responsible testing begins early in the cycle.

Introducing Quality factor in DevOps

A responsible testing approach goes beyond the call of pre-defined duties and facilitates end-to-end stakeholder assurance and business value creation. Processes and strategies like risk assessment, non-functional tests, and customer experiences are baked into testing. Trigent’s philosophy of Responsible Testing characterizes all that we focus on while testing for functionality, security, and performance of an application.

Risk coverage: Assessing the failure and impact early on is one of the most critical aspects of testing. We work along with our clients’ product development teams to understand what’s important to stakeholders, evaluate and anticipate risks involved early on giving our testing a sharp focus.

Collaborative Test Design: We consider the viewpoints of multiple stakeholders to get a collaborative test design in place. Asking the right questions to the right people to get their perspectives helps us in testing better.

Customer experience: Responsible Testing philosophy strongly underlines customer experience as a critical element of testing. We test for all promises that are made for each of the customer touchpoints.

Test early, test often: We take the shift-left approach early on in the DevOps cycle. More releases and shorter release times mean testing early and testing often translates into constantly rolling out new and enhanced requirements.

Early focus on non-functional testing: We plan for the non-functional testing needs at the beginning of the application life cycle. Our teams work closely with the DevOps team’s tests for security, performance, and accessibility – as early as possible.

Leverage automation: In our Responsible Testing philosophy, we look at it as a means to get the process to work faster and better. Or to leverage tools that can give better insights into testing, and areas to focus on testing. The mantra is judicious automation.

Release readiness: We evaluate all possibilities of going to the market – checking if we are operationally ready, planning for the support team’s readiness to take on the product. We also evaluate the readiness of the product, its behavior when it is actually released, and prepare for the subsequent changes expected.

Continuous feedback: Customer reviews, feedback speaks volumes of their experience with the application. We see it as an excellent opportunity to address customer concerns in real-time and offer a better product. Adopting the shift-right approach we focus on continuously monitoring product performance and leveraging the results in improving our test focus.

Think as a client. Test as a consumer.

Responsibility in testing is an organizational trait that is nurtured into Trigent’s work culture. We foster a culture where our testers imbibe qualities such as critical thinking on behalf of the client and the customer, the ability to adapt, and the willingness to learn.

Trigent values these qualitative aspects and soft skills in a responsible tester that contribute to the overall quality of testing and the product.
Responsibility: We take responsibility for the quality of testing of the product and also the possible business outcomes.

Communication: In today’s workplace, collaborating with multiple stakeholders, teams within and outside the organization is the reality. We emphasize not just the functional skill sets but the ability to understand people, empathize with different perspectives, and express requirements effectively across levels and functions.

Collaboration: We value the benefits of a good collaboration with BA/PO/Dev and QA and Testing – a trait critical to understanding the product features, usage models, and working seamlessly with cross-functional teams.

Critical thinking: As drivers of change in technology, it is critical to develop a mindset of asking the right questions and anticipating future risks for the business. In the process, we focus on gathering relevant information from the right stakeholders to form deep insights about the business and consumer. Our Responsible Testing approach keeps the customer experience at the heart of testing.

Adaptability & learning: In the constantly changing testing landscape, being able to quickly adapt to new technologies and the willingness to learn helps us offer better products and services.

Trigent’s Responsible Testing approach is a combination of technology and human intervention that elevates the user experience and the business value. To experience our Responsible Testing approach, talk to our experts for QA & Testing solutions.

Learn more about responsible testing in our webinar and about Trigent’s software testing services.

Responsible Testing in the Times of COVID

As a software tester, I have ensured that software products and applications function and perform as expected. My team has been at the forefront of using the latest tools and platforms to enable a minimal defect product for the market release. We are proud to have exceeded industry standards in terms of defect escape ratios.

The health scare COVID has interrupted almost all industries and processes, but society is resilient, never gives up, and life (and business) must go on. We are up to the task and giving our best in adapting to the testing times and situations.

Testing times for a software tester

While we have leveraged existing resources and technology to run umpteen tests in the past, the current pandemic that has enveloped the world has put us in unchartered territory. While our clients understand the gravity of the situation, they also need to keep their business running. We now work from home and continue testing products just like before without interruption. There have been challenges, but we have ensured business continuity to protect our client from any adverse impact of this disruption. From our testers struggling to adapt to the new world order, I would like to share how we sailed through these trying times. It might help you do what you do best, test!

Ensure access, security/integrity

As testers, we work in different environments such as on-prem, on the cloud, or the client-side cloud environment. Working from a secure office environment, we have access to all environments. It is not the same anymore, as we now use public networks. The best and most secure way to access governed environments is to connect via a VPN to access different environments securely. VPN’s offer secure, pre-engineered access and provide additional levels of bandwidth and control.

Use cloud-devices for compatibility tests

Testing applications for different platforms and devices is simpler at the workplace as we have ready access to company-owned devices (some of which are expensive). It’s not the same when working from home. Besides, these devices cannot be a shared resource. The unavailability of devices cannot act as a blockade. I am leveraging the cloud using resources such as SauceLab, Devicefarm alongside options such as simulators and emulators configured on my system.

Augment access speed for reliable testing

One concern working from home is the need for a dependable, high-speed internet connection. However, I signed up with a service provider offering verified speed. I buttressed my connectivity by arranging for an alternate internet connection from a different service provider with similar bandwidth capability. I made a distinction between these networks as network1 and network2, ensuring that the networks get utilized for the designated purpose, and bandwidth issues avoided.

Coordinate test plans with collaboration utilities

In the initial days of the work-from-home arrangement, I found it difficult to coordinate with the team and there were productivity concerns. This is when we decided to chalk a schedule to address coordination issues. We decided to better utilize the messenger tools provided to us for seamless communication. As a first step towards making optimal use of these messenger tools we drew guidelines on the do’s and don’ts to optimally use our time. This article penned by a senior colleague worked as a handy reference on using one such communication tool.

The future looks uncertain with Covid’s impact deepening by the day. In these times when everything looks uncertain we as responsible testers can play our role in ensuring that we are available to our partners and help products and apps reach their respective audience.

Getting Started – Selenium with Python Bindings

Introduction

Selenium Python binding provides a simple API to write functional/acceptance tests using Selenium WebDriver. Through Selenium Python API you can access all functionalities of Selenium WebDriver in an intuitive way. Selenium Python bindings also provide a convenient API to access Selenium WebDrivers such as Firefox, IE, Chrome, etc. The current supported Python versions are 2.7, 3.5, and above. In this blog, I will explain the Selenium 3 WebDriver API and in the next one, I will explain how to install and configure PyDev in Eclipse.

What is Python?

Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. It’s high-level built in data structures, combined with dynamic typing and binding, makes it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python’s simple, easy-to-learn syntax emphasizes readability, and, therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form, free of charge, for all major platforms, and can be freely distributed.

Related: Define, Implement, Migrate and Script Automated Tests for End-to-end Automation of Applications Spanning Multiple Technologies.

What is Selenium?

Selenium is an open-source automation tool to test your web application. You can do this in various ways. For instance:

  • Selenium supports multiple languages such as Java, C#, Python, Ruby etc..
  • Selenium has components like, IDE, WebDriver.

Downloading Python bindings for Selenium

You can download Python bindings for Selenium from the PyPI page for the Selenium package. However, a better approach would be to use pip to install the selenium package. Python 3.6 has pip available in the standard library. Using pip, you can install selenium like this: `pip install selenium’. You may consider using virtualenv to create isolated Python environments. Python 3.6 has pyvenv which is almost the same as virtualenv.

Detailed instructions for Windows users

Note: You should have an Internet connection to perform this installation.

  1. Install Python 3.6 using the MSI available in python.org download page.
  2. Start a command prompt using the cmd.exe program and run the pip command as given below to install selenium.

C:Python35Scriptspip.exe install selenium.

Advantages of Python in Selenium

  1. Compared to other languages, Python takes less time to run the script and complete the execution.
  2. Python uses indentation, not braces ({}), making it easy to understand the code flow.
  3. Python is simpler and more compact.

Simple Usage

If you have installed Selenium Python bindings, you can start using it from Python in the following way:

from selenium import webdriver
 from selenium.webdriver.common.keys import Keys
 driver = webdriver.Firefox()
 driver.get("http://www.python.org")
 assert "Python" in driver.title
 elem = driver.find_element_by_name("q")
 elem.clear()
 elem.send_keys("pycon")
 elem.send_keys(Keys.RETURN)
 assert "No results found." not in driver.page_source
 driver.close()

If you found this interesting, don’t miss my next blog, ‘Install and Configure PyDev in Eclipse’.

Read Other Selenium related blogs:

Web Application Testing with Selenium WebDriver

Introduction to Selenium with C Sharp