If you are developing applications that connect to multiple microservices, Software-as-a-Service (SaaS) APIs, legacy systems, and other third-party services, creating a robust test environment can be tricky. difficult.
For example, suppose an API that you validate is for a microservice developed by your team. In this case, you likely have development capabilities including continuous integration and continuous delivery (CI / CD), infrastructure as code, and tools to create test datasets to enable a test environment for this service.
However, even with these capabilities, it can become expensive to launch multiple test services when teams are developing many cloud-native applications and microservices.
If it’s a third-party API, SaaS, or data feed, you might have to rely on the infrastructure and testing capabilities of that service. Although these test environments must support the functionality of the production system, they may not have a complete data set and putting them under load to support performance testing may violate the service conditions or be expensive.
API and service virtualization platforms aim to solve these complexities by creating and simulating APIs and service endpoints. Instead of creating a test environment, the service virtualization platform serves as endpoints for testing downstream applications and composite services, and it responds to requests and transactions from an application or service as it is. connection.
If you only work with a few APIs, API mocking can be a good practice for simulating endpoints, and tools like Mockito, JMock, or WireMock are Java options. But once you have many development teams, growing APIs, or complex test datasets, a more scalable approach like service virtualization is needed.
Additionally, whether you are testing applications that process credit cards, connect to bill payment services, or perform other complex transactions, service virtualization platforms enable validation against a wider range. user experiences and error scenarios.
I spoke with Anna Ramadoss, Cloud Engineer in Financial Services, about using a service virtualization platform. She says: “Service virtualization, when integrated into teams, sharpens the line between back-end and dependent systems. Updates are immediate and delivery times are much faster. The result is a well-designed system with faster updates on the market. It can also reduce infrastructure needs and costs.
How service virtualization enables left shift testing
Many organizations are looking to shift their testing efforts to the left to identify and resolve issues faster. But what happens when a test environment is not available for dependent services?
It is natural for developers to work around blockages and obstacles in their engineering efforts. When developing applications, should developers wait for the infrastructure and testing capabilities of an API, or are they more likely to postpone such testing later in the development process?
Even more problematic, will developers make assumptions about the behaviors of an API and then be forced to fix the flaws later in the development process, or worse, when they are detected in production?
There are many advantages to implementing a service virtualization platform and requiring service virtualization as a development standard, especially for teams that require extensive testing capabilities against many APIs. . Here are several benefits of using a service virtualization platform to facilitate left shift testing:
- Service virtualization is a natural extension of unit test development and continuous testing for microservices. As part of the development process, developers or QA engineers must configure endpoints in the service virtualization platform that simulate API responses. All developers can use these endpoints when building downstream applications and services.
- Service virtualization layers simplify testing against multiple versions of an API by exposing endpoints for all supported versions. When testing against new API versions, developers can create tests that compare the responses of the latest version with the old ones. This type of A / B testing can be particularly useful for validating the downstream impacts of new versions of machine learning and predictive analytics models.
- Service virtualizations can be bundled with test data sets and used to validate transactions. After developers complete a test case, they can refresh the endpoint to the original test dataset and repeat the tests if necessary.
- When operating in a cloud, service virtualization platforms can increase and decrease capacity depending on the volume of testing. As a result, the infrastructure can scale to accommodate many developers running concurrent tests or more robust performance tests.
By solving a common test infrastructure challenge, teams can use the capabilities of a service virtualization platform to implement new test cases earlier in the development process.
Platform providers suggest other use cases. For example, SmartBear recommends that development teams use service virtualization to improve security testing, automate different test cases by message type, and support iterative designs.
Parasoft recommends using service virtualization to test malformed data responses, simulate high latency, or validate responses to larger payloads. Broadcom Service Virtualization (formerly CA DevTest) advises development teams to chain testing into multistep transactions and continuously validate business workflows.
Ramadoss advises development teams to determine their testing requirements to see if API virtualization is sufficient, or if more generalized service validation is required. For example, she says, “service virtualization extends to TCP protocols to support services from credit bureaus like TransUnion, Equifax, and Experian.” Other protocols may be required, including database (JDBC), middleware (JMS, Rabbit MQ and others), and mainframe protocols (CICS and others).
I spoke to Shamim Ahmed, CTO devops at Broadcom, about how devops organizations are using service virtualization in virtual service environments.
He says, “As more organizations move towards component architectures for their software systems, we are seeing a growing trend towards the adoption of microservices for development and containerization for deployment. To support this trend, virtual services can be packaged and deployed in containers, instantiated on demand, and decommissioned when no longer needed.
How service virtualization works
Platforms have different capabilities for creating service endpoints, and these are the common approaches:
- Link or download an API definition in Web Service Description Language (WSDL), Web Application Description Language (WADL), or OpenAPI Specification (OAS) (Swagger)
- Recording transactions using browser plug-ins or web server proxies
- Manually create service definitions, which can be useful when downstream developers want to test before APIs are ready
After creating endpoints, platforms typically allow you to connect to test data sources, upload test data, or automate the generation of test data.
Generating test data is very useful when validating forms or downloading documents and processing complex transactions. It is also a more secure way to create fictitious datasets on Personally Identifiable Information (PII) such as names, Social Security numbers, or credit card numbers.
Once there are service endpoints, service virtualization platforms offer SDKs, IDE plugins, and CI / CD tool plugins as different ways to interface them and to exploit them. Development teams that target frequent deployments can improve continuous testing practices by having more API endpoints available and increasing the scope of test datasets.
Agile development teams that use service virtualization platforms and mature continuous testing practices should consider several best practices, such as creating negative test cases and training technical staff.
Some best practices for speeding up test cycles include defining infrastructure requirements, securing virtualized services, and regularly updating systems. Executives should also seek tangible business benefits, such as bringing new applications to production faster and reducing costs.
As more organizations modernize applications for the cloud, develop microservices, and integrate with many SaaS platforms, service virtualization is a critical platform capability to support robust testing. and continuous.