You are on page 1of 4

2019 International Conference on Information Technology and Computer Application (ITCA)

Design and Research of Microservice Application


Automation Testing Framework
Yang WANG and Lei CHENG* Xin SUN
Information and Communications Testing and Simulation Power Technology Center
Center State Grid Zhejiang Electric Power Co., LTD. Research
China Electric Power Research Institute Institute
Beijing, China Zhejiang, China
hesoyam123456@sina.com

Abstract—Microservice style breaks through the traditional According to the test characteristics and test objects, a
monolithic application into a new generation of distributed hierarchical data-driven testing framework for microservice
architecture, which realizes agile development and deployment. applications is presented in this paper. Aiming at the test case
How to ensure its quality and reliability by testing technology is generation, an automatic generation method based on the
the focus in the software engineering. According to the extended interface description file is designed. This research
characteristics of microservice application, this paper analyzes will improve the software testing ability and accelerate the
the test objects and test procedure, proposes an automation implementation and promotion of microservice applications in
testing framework based on modularization and data-driven, and SGCC (State Grid Corporation of China).
illustrates the main functions and processes of each layer.
Furthermore, a data structure based on the extended interface
description file is designed so as to generate test case data II. MICROSERVICE APPLICATION TESTING ANALYSIS
automatically. This framework will contribute to establishing the
microservice testing platform and standard for SGCC (State A. Test Objects
Grid Corporation of China), which is able to improve the Microservices have unique architectural characteristics such
enterprise testing capability, raise work efficiency and achieve as flexible technology selection, distributed structure, easy
effective management. expansion and controllable complexity. The internal design and
code implementation of the microservice application are
Keywords-microservices; automated testing; testing framework;
encapsulated and only the service interfaces are provided for
test data; test case generation
users. Therefore, the test is mainly based on the service
interface [2]. The test objects include the following two aspects.
I. INTRODUCTION
1) Function Testing: Its main purpose is to test whether
With the rapid development of information technology, the
the service is able to achieve the expected functional results
traditional software monolithic architecture has seriously
restricted the rapid update and iteration of projects. and whether the system can operate normally. The tester
Microservice architecture is a new generation of software compares the returned data with the expected result through
architecture which divides a traditional software system into automatic recording, detection and playback so as to verify
different modules. Each microservice focuses on a single whether the service can achieve the expected function.
business and runs in an independent process. It uses lightweight 2) Performance Testing: Its main purpose is to test the
communication mechanism to cooperate with each other in service load by measuring the maximum number of requests
order to achieve a complete application. Microservices have the service can handle, response time and so on. Microservices
unique distributed architecture features, such as high cohesion, divide a monolith into several services that run independently,
low coupling, high fault tolerance and easy expansion, which which increases the complexity of communication, so the load
cannot fully meet the test requirements through traditional
of concurrent access by multiple clients is particularly
testing methods [1]. In addition, microservices provide a kind
of machine to machine communication mechanism, so that it is important.
difficult to test them manually. Automated testing can replace B. Test Procedure
the traditional manual testing for functional and non-functional
There are six processes in the general procedure of
testing, thus improving the testing efficiency greatly. Therefore,
automated testing for microservice applications: test
in order to improve software quality, optimize work efficiency
environment construction, software behavior modeling [3], test
and achieve effective management, it is of great theoretical and
case generation, test case execution, test result analysis and test
practical significance to research an automation testing solution
process improvement. In the testing framework, the modular
and key technologies for microservice applications.
layered design idea can be used to separate the functions of
each test process, reduce the coupling of each function and
Supported by State Grid Corporation of China Science and Technology make it easy to manage and extend. Moreover, data-driven
Project (5700-201941223A-0-0-00).

978-1-7281-6494-6/19/$31.00 ©2019 IEEE 257


DOI 10.1109/ITCA49981.2019.00063

Authorized licensed use limited to: University of Exeter. Downloaded on June 20,2020 at 18:28:52 UTC from IEEE Xplore. Restrictions apply.
technology can separate test logic from test data, remove the Data Layer
binding between data and scripts and improve the WADL
WADL File Parser Extended File
maintainability and reusability of the system [4].

C. Test Case Generation Input


Expected
Output
The key to improve the test automation lies in the test case Data
Data
generation automation. The service interface is described by
WADL (Web Application Description Language). Testers Data File WADL
Database
parse WADL files in order to get some information about the File
interface input parameters for automated testing. However,
Test Case Layer
only the parameter name and type are described in the WADL,
which lacks of test basis, so the WADL file needs to be Single Composite
extended. Reference [5], [6] and [7] put forward an automatic Parameter Test Parameter Test
test case generation method based on the extended interface Case Generation Case Generation
Microservice
description file, but they all lack of the complex constraint of a Application
parameter value. In reference [8], regular expression is Reverse Test Service
Function Case Filter Interface
proposed to describe parameter value constraints, but there is Test Script
no constraint between parameters. This paper will make some Generation Performance
improvements based on the previous studies. Test Script
Generation

III. AUTOMATION TESTING FRAMEWORK


Execution Layer Adaptation Layer
According to the characteristics, objects and processes of Function Performance Software
microservice testing, this section proposes a microservice Testing Tool Testing Tool Standard
application automation testing framework, as shown in Fig. 1.
The framework is based on the idea of layering and Hardware
Function Performance Standard
modularization. Each level is independent of each other and the Testing Testing
functions in every layer are modularized, which is good for
management and extension [9]. There are six layers in the Analysis Layer Management Layer
framework: adaptation layer, data layer, test case layer,
execution layer, analysis layer and management layer. The Test Result Collection Test Report Sending
framework is an overall solution for microservice testing. It
clarifies the task allocation, control process and dependency Function Performance Test Process
between components in the whole test, specifies the Verification Evaluation Measurement
architecture of the test program and provides support for
Configuration
component reuse. Test Report Generation Optimization

A. Adaptation Layer Figure 1. Microservice Application Automation Testing Framework


The adaptation layer establishes the interface standards of
software and hardware for data communication between the
microservice interface and the framework. The software B. Data Layer
standard defines the format and communication protocol of The data layer uses data-driven technology to organize the
data sending and receiving. The hardware standard defines the input and expected output of the tested object in a certain form
electrical index, time sequence and communication standard. to provide data for the test case layer. First of all, the WADL
The mainstream microservices interact with each other in a extended file is resolved by the file parser. After that the test
RESTful way, following the REST (Resource Representational data is generated for each input parameter according to the
State Transfer) software architecture. principle of equivalence class division, random generation and
boundary value, and then the expected result data is generated
according to the validity of the test data. For performance
testing, sufficient additional valid data need to be generated.
All the test data can be saved in database and read through
different forms of data files.
The WADL file contains a small amount of information
about microservice interface parameters. In many cases,
parameters are not only self-constrained, but also mutually
constrained. Regular expression is a kind of logical formula
that can express rules flexibly and is very suitable for
expressing parameter constraints. The expansion of the WADL
file is accomplished by adding special XML (Extensible

258

Authorized licensed use limited to: University of Exeter. Downloaded on June 20,2020 at 18:28:52 UTC from IEEE Xplore. Restrictions apply.
Markup Language) tags to the Decimal, String and Boolean The name indicates the parameter name and the value
XML Schema basic data type parameters and using regular depicts the parameter value. The isvalid is a boolean type,
expressions to describe parameter constraints. The structure of indicating whether it is a valid parameter value. The
each parameter is shown in Fig. 2. The name, type and required constraint_list is a set that represents a list of constraints on
represent the name, type and nullability of a parameter other parameters when the parameter is in the current value.
respectively. These are the original parameter information in Each constraint in the constraint_list includes two parts of the
the WADL. The expression depicts the regular expression for constrained parameter: its name and the regular expression.
parameter value and constraints means the constraint queue of
the current parameter and other parameters. Each constraint Typical pairwise testing algorithms include AETG and IPO
constrain is a triplet, including the current parameter value, the [11]. Both of them need to generate uncovered pairing set UC
constrained parameter name and the regular expression of the and then generate test cases iteratively through different
constrained parameter value. strategies until all pairs of UC are covered. Based on the
parameter structure and constraint between parameters
name designed in this paper, the following two combination
principles are formulated:
type value
constrain x By obtaining the isvalid of each parameter, it is
required constrain
constraint c_name ensured that only at most one parameter in a parameter
combination is invalid.
expression c_expression
x When combining parameter pm and pn, if the
constraints
constraint_list of pm is not empty and it contains pn, It
Figure 2. Parameter structure in WADL file should be ensure that there is no combination of pm and
pn other than the constraint list.
C. Test Case Layer In this way, the combination of invalid parameters can be
avoided and also the number of UC can be reduced, thus the
The test case layer automatically generates test cases using
number of test cases will be reduced so as to effectively avoid
data read from the data layer and then generates test scripts for
the explosion of data cases caused by combination of
the executive layer. The test script is a kind of executable data
parameters.
file that can be generated automatically by test tools or
programmed manually. The test script can be divided into
functional script and performance script for different test D. Execution Layer
objects. Before the performance script is generated, the reverse In the execution layer, the test script is imported into the
test cases need to be filtered out through the validity of the test tool so as to perform automated test execution.
parameters and only valid test cases are reserved. It is noted Microservice application interface automation testing tools
that the script itself does not contain test data, which is easy to include WebInject, WStest, SoapUI, TestMaker, QEngine,
maintain and extend. JMeter and so on [3][12]. During the function script execution,
the scripts are executed one by one according to the execution
The automatic test case generation method varies according strategy preset by the tester and an exception will be thrown
to the parameter type. There are two types of parameters about when a test case does not meet the expected result. Before the
microservice application interface: single parameter and performance script execution, the tester sets the threshold value
composite parameter. For the single parameter, test cases are for the utilization rate of hardware resources, response time and
generated automatically one by one for each values of the other performance indicators in order to use them evaluate the
parameter. Composite parameter means that any one parameter test results.
must appear in the specified order and only once, therefore the
various combinations of parameters need to be covered in
E. Analysis Layer
generating test cases.
The analysis layer includes some analysis operations after
If there are k parameters in the service interface and each executing test scripts. Test results should be collected firstly,
parameter has n values, then the number of fully combined test including the description of each test case and its execution
cases is nk which could be so huge. The pairwise method can return data. After that, the function can be verified. Testers
transform the parameter complete combination into the check the test execution process that does not meet the
parameter pair coverage, which is able to reduce the number of expected results and then analyze the specific defect reasons.
test cases greatly and is considered an effective test method On the basis of the preset threshold, the performance test can
[10]. The following definitions are made in this paper. For a be evaluated and the cases that do not meet the performance
microservice application interface, its parameters can be standards can be analyzed in depth. Finally, the test report is
expressed as a set P, where the value of each parameter pi can generated.
be represented as a set V. For a value vj of a parameter pi, its
structure can be described as a quadruple, namely, F. Management Layer
In the management layer, test reports will be distributed and
pi.vj = (name, value, isvalid, constrain_list).    sent to the test related stakeholders, such as project manager,
test director, development engineer, etc. After the entire test

259

Authorized licensed use limited to: University of Exeter. Downloaded on June 20,2020 at 18:28:52 UTC from IEEE Xplore. Restrictions apply.
framework has been running for a period of time, some REFERENCES
quantifiable attributes of the test process can be collected and [1] X. W. Wang and L. Du, “State Grid Corporation of China Science and
analyzed so as to measure the testing process. Finally, the test Technology Project Feasibility Study Report on Testing System and Key
process of the microservice applications can be improved by Technologies for Microservice Applications,” unpublished.
optimizing the test configuration. [2] X. G. Feng and J. X. Liu, Review on Web Service Testing Technologies,
Microcomputer Applications, vol. 31, no. 1, pp. 21-26, Jan 2010.
[3] C. Y. Ma, Y. A. Zhu and W. Lu, Automatic Test for Web Services,
IV. CONCLUSION Computer Science, vol. 39, no. 2, pp. 162-169, Feb 2012.
In this paper, a microservice application automation testing [4] S. G. Li and X. M. Ding, A Method of Automatic Test Data Generation
solution is proposed and a testing framework is designed based Based on Extended WSDL, Journal of Southwest China Normal
University(Natural Science Edition), vol. 36, no. 1, pp. 188-192, Feb
on modularization and data-driven technology. The framework 2011.
completes the automated testing of the microservice interface [5] X. L. Yuan, “Automatic Test Cases Generation Based on Extended
through coordination among the adaptation layer, data layer, WSDL,” Diss. Southwest University, May 2009.
test case layer, execution layer, analysis layer and management [6] N. Q. Jiang, “Automatic Test Case Generation Method Based on
layer. The extended WADL file structure and parameter data Extended WSDL for Web Services,” Diss. Hefei University of
structure are designed for the test case data generation, which is Technology, Apr 2012.
the key part of automation test, and also the parameter [7] S. G. Li, “A Method of Automatic Test Data Generation Based on
combination coverage problem is optimized. In the future, a set Extended WSDL,” Diss. Southwest University, May 2010.
of microservice application test tools can be developed based [8] Z. H. Hao, “The Research of Auto Web Service Test Based on Regular
on this framework in combination with relevant standards of Expression Extension,” Diss. South China University of Technology,
May 2012.
SGCC, which contributes to forming a unified test standard and
[9] M. Dong, “Research on the Technology of Test Automation Scripts
platform for the enterprises. Genertion for Web Services,” Diss. Shijiazhuang Tiedao University, Jan
2014.
ACKNOWLEDGMENT [10] Y. J. Wu, “Analyses and Implementing of Algorithms for Pairwise
Testing,” Diss. Huazhong University of Science & Technology, Jan
This research was supported by State Grid Corporation of 2008.
China Science and Technology Project (5700-201941223A-0- [11] F. Liang and X. Q. Song, Method of Generation Pair-cover Test Cases
0-00). We would like to acknowledge our sponsors for their Based on AETG Algorithm, Computer Engineering and Design, vol. 35,
financial support. no. 11, pp. 3850-3854, Nov 2014.
[12] P. F. Liu, “Design and Implementation of Web Service Testing Tool,”
Diss. Inner Mongolia University, Jun 2016.

260

Authorized licensed use limited to: University of Exeter. Downloaded on June 20,2020 at 18:28:52 UTC from IEEE Xplore. Restrictions apply.

You might also like