CN109902010A - The method and system that API is tested under a kind of KVM framework - Google Patents
The method and system that API is tested under a kind of KVM framework Download PDFInfo
- Publication number
- CN109902010A CN109902010A CN201910146739.6A CN201910146739A CN109902010A CN 109902010 A CN109902010 A CN 109902010A CN 201910146739 A CN201910146739 A CN 201910146739A CN 109902010 A CN109902010 A CN 109902010A
- Authority
- CN
- China
- Prior art keywords
- service
- api
- test
- response data
- tested under
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Abstract
The present invention provides the method and system that API is tested under a kind of KVM framework, and the Agent components placed before service obtain the transmission request data and returning response data of each service;The transmission request data and returning response data relationship being collected into generate corresponding JSON file Mock Service and carry out API test according to the transmission request data and returning response data of the JSON file analogy real service of generation.The API Calls being only really being used just are collected into, and if not using not going to test if, remove to simulate each true Service using Mock Service and solve the coupled relation that interdepends between API.Both it is huge by test data caused by permutation and combination to have solved traditional API test thinking, has also solved the problems, such as to couple between API.
Description
Technical field
The present invention relates to software testing technology fields, and in particular to API test method and system under a kind of KVM framework.
Background technique
API is some functions predetermined, it is therefore an objective to provide application program and developer is based on certain software or hardware
It is able to the ability of one group of routine of access, and is not necessarily to access source code, or understand the details of internal work mechanism.
API test specific gravity in currently a popular internet product test theory is mostly important, due to wanting quick response to use
Changes in demand is coped in family demand, and API test is better than unit testing, GUI test.Unit testing more mainstream is carried on a shoulder pole by researching and developing oneself
Appoint, accounting is heavier in previous research and development theory, suitable for the product life cycle long, demand change traditional mode infrequently,
Current trend iteratively faster and higher and higher customer demand experience can not be applicable in.In addition, the method that GUI test layer generallys use
It is the various user's usage scenarios of simulation, and whether the result for verifying these operations is correct, experience of being most close to the users, but also have very big
The shortcomings that: execution efficiency is lower to spend a large amount of human cost, even uses GUI automatization testing technique, the maintenance of use-case
It is still very big with Executing Cost.So being unable to satisfy lasting client's variation, stability and reusability are its significant deficiencies.
The above reason results in API test specific gravity and increases, and becomes the part of detecting for needing most optimization.Previous research and development model
Monomer structure is more used, so-called monomer structure refers to that expression layer, Business Logic and the data of all business scenarios are visited
Layer is asked all in an engineering, Uniform compilation is asked, is packaged deployment in environment.So monomer structure has publication simple, square
Just debugging, the features such as framework is simple, so being widely used always in the especially product of enterprise-level.
But popularizing with internet product, the test theory of internet product also obtains everybody approval and popularization.
The many disadvantages for also exposing monomer framework in this way, are mainly reflected in flexibility, scalability, stability and maintainability.
Micro services framework comes into being, this is a kind novel framework style, and a kind of large complicated software systems are no longer by one
A monomer composition, but be made of a series of mutually independent micro services.Each micro services operate in the process of oneself, exploitation
It is not all relied on deployment.
KVM is the system virtualization module of an open source, and each main of Linux is integrated in from after Linux 2.6.20
In release version.It is managed using the scheduler of Linux itself, so core source code is seldom relative to Xen.KVM mesh
Before have become one of mainstream VMM of academia.
Testing scheme for the API of monomer framework is the mainstream of a very long time API test, and main test mode is
For the external API design test data of offer, and cover a variety of logical combinations.Due to the bottom of code, road under monomer framework
Patrol that the API that layer, expression layer etc. externally show is relatively simple, so the test data that externally exposure can be passed to is for code logic
Cover it is limited, in addition there are also following major defect:
Stability is poor: when any one of monomer applications module is problematic, it all may cause and apply entirety unavailable,
Lack fault tolerant mechanism.No matter how small change, it is also desirable to repack entire application, and it is all relatively long to be packaged the time every time.
Poor expandability:, can not be unfavorable easily using module as unit flexible expansion capacity when simulating how concurrent scene
In the extending transversely of module.
It is maintainable poor: when any one of monomer applications module is problematic, to be all likely to result in the complexity of application
Property ramps, and when business scale is huger, the maintainability cost of whole project be will increase.
Meet the above feature based on the KVM virtualization system realized, multiple services all can external exposed interface, while these
Also there is logic association between micro services, will lead to two problems: the data volume of API test increases;There is coupling between each service
Conjunction relationship.
Virtualization system based on KVM framework is the virtualization system implementation of current mainstream, and real based on the frame
Existing virtualization system mostly uses micro services framework, tests for the API of this kind of virtualization system, proposes more preferably solution party
Case solves the short slab tested currently based on the API of the KVM virtualization system realized.
Summary of the invention
Based on KVM realize virtualization system it is multiple service all can external exposed interface, for API test data volume increase
Greatly;There is the problem of coupled relation between each service, the present invention provides API test method and system under a kind of KVM framework.
The technical scheme is that
A kind of method that API is tested under KVM framework, includes the following steps:
Analyze the coupled relation between each service;
Coupled relation between each service is decoupled;
Carry out the test of each service api interface.
In order to not only can guarantee API mass but also can be reduced the Test Strategy of use-case quantity, need to close the coupling between each service
System is decoupled;
Further, the coupled relation between each service is analyzed, comprising:
Obtain the request and response data of each service;
The request and response data that each service is obtained by analysis, determine the call relation between each service;It finds and is directed to
The method of calling of a certain service can significantly ensure that the quality of the service.
Determine that there are the services of coupled relation according to the call relation between service.
Further, the request and response data of each service are obtained, comprising:
The Agent components placed before service obtain the transmission request data and returning response data of each service;
The transmission request data and returning response data relationship being collected into generate corresponding JSON file.
Further, the coupled relation between each service is decoupled, comprising:
Mock Service is set and simulates complementary coupling pass between each service API of each true service solution
System.The most commonly used is realize Mock Service to replace the real service being relied on for the mode of decoupling.
Further, setting Mock Service simulates each true service and solves to interdepend between each service API
Coupled relation, comprising:
Each true service, which is simulated, by call relation Mock Service carries out API test.
Further, each true service is simulated by call relation Mock Service and carries out API test, comprising:
Mock Service is according to the transmission request data and returning response number of the JSON file analogy real service of generation
According to progress API test.The API Calls being only really being used just are collected into, if using not going to test if, do not made
It removes to simulate each true Service with Mock Service and solves the coupled relation that interdepends between API.Both it solved
Traditional API test thinking is huge by test data caused by permutation and combination, also solves the problems, such as to couple between API.
On the other hand, technical solution of the present invention also provides the system that API is tested under a kind of KVM framework, including analysis processing
Mould group, decoupling processing module and test module;
Analysis processing mould group, for analyzing the coupled relation between each service;
Processing module is decoupled, for decoupling the coupled relation between each service;
Test module, for carrying out the test of each service api interface.
Further, analysis processing mould group includes obtaining module, analysis and processing module;
Module is obtained, for obtaining the request and response data of each service
Analysis and processing module determines the calling between each service for analyzing the request and response data that obtain each service
Relationship simultaneously determines that there are the services of coupled relation according to the call relation between service.
Further, obtaining module is the Agent components before service is arranged in;
Agent components, for obtaining the transmission request data and returning response data of each service;
Agent components, the transmission request data for being also used to be collected into and returning response data relationship generate corresponding JSON text
Part.
Further, decoupling processing module is Mock Service module;
Mock Service module solves complementary coupling between each service API for simulating each true service
Conjunction relationship;
Mock Service module according to the transmission request data of the JSON file analogy real service of generation and returns to sound
Data are answered to carry out API test.
As can be seen from the above technical solutions, the invention has the following advantages that Mock Service is according to the JSON of generation
The transmission request data and returning response data of file analogy real service carry out API test.The API tune being only really being used
With being just collected into, if using not going to test if, not going to simulate using Mock Service each true
Service solves the coupled relation that interdepends between API.Both it had solved traditional API test thinking to lead by permutation and combination
The test data of cause is huge, also solves the problems, such as to couple between API.
In addition, design principle of the present invention is reliable, structure is simple, has very extensive application prospect.
It can be seen that compared with prior art, the present invention have substantive distinguishing features outstanding and it is significant ground it is progressive, implementation
Beneficial effect be also obvious.
Detailed description of the invention
Fig. 1 is to have coupled relation schematic diagram between each service in micro services framework;
Fig. 2 is the request and response schematic diagram between having each service of coupled relation;
Fig. 3 is the method flow relation schematic diagram that API is tested under a kind of KVM framework;
Fig. 4 is the method flow schematic diagram that API is tested under a kind of KVM framework.
Specific embodiment
The present invention will be described in detail with reference to the accompanying drawing and by specific embodiment, and following embodiment is to the present invention
Explanation, and the invention is not limited to following implementation.
Embodiment one
In the API test of traditional monomer framework, common Test Strategy is: being counted according to tested API parameter
The effective permutation and combination of column, and verify the correctness of correlated results;Check that the code of test result covers probability, according to omission
Coverage rate analysis finds out the test case of omission;The mark that API test is completed constantly is promoted to code coverage.But micro-
In the framework of service, whole function can split into many single services i.e. multiple independent Service, so originally
Whole application can be split as multiple API and cooperate jointly completion.Each Service corresponds to independent driver, and each driver is
It is independent offer individually independent service.In the internet mode, the Cyclic epidemic of product publication is even " small with " day "
When " it is unit, so the time of test execution is compressed seldom.This be with regard to need to find it is a kind of not only can guarantee API mass but also
It can be reduced the Test Strategy of use-case quantity, as shown in figure 4, the present invention provides a kind of method that API is tested under KVM framework, including
Following steps:
S1: the coupled relation between each service is analyzed;
Coupled relation mentioned here refers to, for example we need to test the api interface of Service A offer, still
Service A have invoked again Service X and Service Y composition, if X or Y since other reasons are unavailable, A
Also it just can not completely be tested, there are coupled relation such as Fig. 1 institutes before Service A and Service X and Service Y
Show.
In this step, the coupled relation between each service is analyzed, comprising:
Obtain the request and response data of each service;
Explanation is needed further exist for, the request and response data of each service are obtained, comprising:
The Agent components placed before service obtain the transmission request data and returning response data of each service;
The transmission request data and returning response data relationship being collected into generate corresponding JSON file.
Herein it should be noted that JSON file data format is as follows:
JSON data format one
Error is to call whether api succeeds, and errorType is type of error (being 0 if success) errorMessag
Be error message (if success if for sky) result be return as a result, (if failure if be returned as sky).
The request and response data that each service is obtained by analysis, determine the call relation between each service;It finds and is directed to
The method of calling of a certain service can significantly ensure that the quality of the service.
Determine that there are the services of coupled relation according to the call relation between service.
S2: the coupled relation between each service is decoupled;
For example we need to test the api interface of Service A offer, but Service A has invoked Service X again
It is formed with Service Y, if X or Y, since other reasons are unavailable, A also just can not be tested completely, so
We need a kind of method to decouple the test of Service A and Service X and Service Y, are then tested.
The most commonly used is realize Mock Service to replace the real Service being relied on for the mode of decoupling.So closing
Key point becomes the request and response for simulating true Service.As shown in Fig. 2, A is made of X and Y, then X and Y
Just there is the relationship that request returns to response that sends with A.So the user of Service A in fact only have Service X and
Service Y finds the mode to the calling of A, can significantly ensure that the quality of Service A.So problem turns
How chemical conversion finds Service X and Service Y to the calling of Service A, these testing cases are passed through,
The quality of Service A is just guaranteed substantially.
Mock Service is set and simulates complementary coupling pass between each service API of each true service solution
System.The most commonly used is realize Mock Service to replace the real service being relied on for the mode of decoupling.
As shown in figure 3, Mock Service according to the transmission request data of the JSON file analogy real service of generation and
Returning response data carry out API test.The API Calls being only really being used just are collected into, if not using
It does not go to test, removes to simulate each true Service using Mock Service and solve the interdepending coupling between API and close
System.Both it is huge by test data caused by permutation and combination to have solved traditional API test thinking, has also solved between API and couples
The problem of.
S3: the test of each service api interface is carried out, corresponding test case is called to carry out the test of API.
Embodiment two
Technical solution of the present invention also provides the system that API is tested under a kind of KVM framework, including analysis processing mould group, decoupling
Processing module and test module;
Analysis processing mould group, for analyzing the coupled relation between each service;Analysis processing mould group includes obtaining module, analysis
Processing module;
Module is obtained, for obtaining the request and response data of each service;Obtaining module is the generation before service is arranged in
Manage component;
Agent components, for obtaining the transmission request data and returning response data of each service;
Agent components, the transmission request data for being also used to be collected into and returning response data relationship generate corresponding JSON text
Part.
Analysis and processing module determines the calling between each service for analyzing the request and response data that obtain each service
Relationship simultaneously determines that there are the services of coupled relation according to the call relation between service.
Processing module is decoupled, for decoupling the coupled relation between each service;Decoupling processing module is Mock
Service module;
Mock Service module solves complementary coupling between each service API for simulating each true service
Conjunction relationship;
Mock Service module according to the transmission request data of the JSON file analogy real service of generation and returns to sound
Data are answered to carry out API test.
Test module, for carrying out the test of each service api interface.
Description and claims of this specification and term " first ", " second ", " third " " in above-mentioned attached drawing
The (if present)s such as four " are to be used to distinguish similar objects, without being used to describe a particular order or precedence order.It should manage
The data that solution uses in this way are interchangeable under appropriate circumstances, so as to the embodiment of the present invention described herein can in addition to
Here the sequence other than those of diagram or description is implemented.In addition, term " includes " and " having " and their any deformation,
It is intended to cover and non-exclusive includes.
The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use the present invention.
Various modifications to these embodiments will be readily apparent to those skilled in the art, as defined herein
General Principle can be realized in other embodiments without departing from the spirit or scope of the present invention.Therefore, of the invention
It is not intended to be limited to the embodiments shown herein, and is to fit to and the principles and novel features disclosed herein phase one
The widest scope of cause.
Claims (10)
1. a kind of method that API is tested under KVM framework, which comprises the steps of:
Analyze the coupled relation between each service;
Coupled relation between each service is decoupled;
Carry out the test of each service api interface.
2. the method that API is tested under a kind of KVM framework according to claim 1, which is characterized in that analyze between each service
Coupled relation, comprising:
Obtain the request and response data of each service
The request and response data that each service is obtained by analysis, determine the call relation between each service;
Determine that there are the services of coupled relation according to the call relation between service.
3. the method that API is tested under a kind of KVM framework according to claim 2, which is characterized in that obtain asking for each service
Summation response data, comprising:
The Agent components placed before service obtain the transmission request data and returning response data of each service;
The transmission request data and returning response data relationship being collected into generate corresponding JSON file.
4. the method that API is tested under a kind of KVM framework according to claim 3, which is characterized in that by the coupling between each service
Conjunction relationship is decoupled, comprising:
Mock Service is set and simulates complementary coupled relation between each service API of each true service solution.
5. the method that API is tested under a kind of KVM framework according to claim 4, which is characterized in that setting Mock
The each true service of Service simulation solves complementary coupled relation between each service API, comprising:
Each true service, which is simulated, by call relation Mock Service carries out API test.
6. the method that API is tested under a kind of KVM framework according to claim 5, which is characterized in that pass through call relation
The each true service of Mock Service simulation carries out API test, comprising:
Mock Service according to the transmission request data of the JSON file analogy real service of generation and returning response data into
Row API test.
7. the system that API is tested under a kind of KVM framework, which is characterized in that including analysis processing mould group, decoupling processing module and survey
Die trial block;
Analysis processing mould group, for analyzing the coupled relation between each service;
Processing module is decoupled, for decoupling the coupled relation between each service;
Test module, for carrying out the test of each service api interface.
8. the system that API is tested under a kind of KVM framework according to claim 7, which is characterized in that analysis processing mould group packet
It includes and obtains module, analysis and processing module;
Module is obtained, for obtaining the request and response data of each service
Analysis and processing module determines the call relation between each service for analyzing the request and response data that obtain each service
And determine that there are the services of coupled relation according to the call relation between service.
9. the system that API is tested under a kind of KVM framework according to claim 8, which is characterized in that obtaining module is setting
Agent components before service;
Agent components, for obtaining the transmission request data and returning response data of each service;
Agent components, the transmission request data for being also used to be collected into and returning response data relationship generate corresponding JSON file.
10. the system that API is tested under a kind of KVM framework according to claim 9, which is characterized in that decoupling processing module
For Mock Service module;
Mock Service module solves complementary coupling pass between each service API for simulating each true service
System;
Mock Service module, according to the transmission request data and returning response number of the JSON file analogy real service of generation
According to progress API test.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910146739.6A CN109902010A (en) | 2019-02-27 | 2019-02-27 | The method and system that API is tested under a kind of KVM framework |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910146739.6A CN109902010A (en) | 2019-02-27 | 2019-02-27 | The method and system that API is tested under a kind of KVM framework |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109902010A true CN109902010A (en) | 2019-06-18 |
Family
ID=66945678
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910146739.6A Pending CN109902010A (en) | 2019-02-27 | 2019-02-27 | The method and system that API is tested under a kind of KVM framework |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109902010A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110825641A (en) * | 2019-11-08 | 2020-02-21 | 安徽继远检验检测技术有限公司 | Micro-service application test tool set based on simulation data generator |
CN112162925A (en) * | 2020-09-29 | 2021-01-01 | 新华三大数据技术有限公司 | Test method and system based on service virtualization |
CN114238099A (en) * | 2021-12-09 | 2022-03-25 | 北京五八信息技术有限公司 | Method and device for gray scale test, electronic equipment and readable medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101819551A (en) * | 2009-02-27 | 2010-09-01 | 国际商业机器公司 | Method and system for recording service interaction data of enterprise message system |
US20150178182A1 (en) * | 2011-10-07 | 2015-06-25 | Syntel, Inc. | Software testing platform and method |
CN106547681A (en) * | 2015-09-18 | 2017-03-29 | 北京京东尚科信息技术有限公司 | The method and apparatus that data load simultaneously multiplexed analog service testing automatically |
CN108769179A (en) * | 2018-05-23 | 2018-11-06 | 北京顺丰同城科技有限公司 | A kind of service health state evaluation method and device |
-
2019
- 2019-02-27 CN CN201910146739.6A patent/CN109902010A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101819551A (en) * | 2009-02-27 | 2010-09-01 | 国际商业机器公司 | Method and system for recording service interaction data of enterprise message system |
US20150178182A1 (en) * | 2011-10-07 | 2015-06-25 | Syntel, Inc. | Software testing platform and method |
CN106547681A (en) * | 2015-09-18 | 2017-03-29 | 北京京东尚科信息技术有限公司 | The method and apparatus that data load simultaneously multiplexed analog service testing automatically |
CN108769179A (en) * | 2018-05-23 | 2018-11-06 | 北京顺丰同城科技有限公司 | A kind of service health state evaluation method and device |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110825641A (en) * | 2019-11-08 | 2020-02-21 | 安徽继远检验检测技术有限公司 | Micro-service application test tool set based on simulation data generator |
CN110825641B (en) * | 2019-11-08 | 2023-12-29 | 安徽继远检验检测技术有限公司 | Micro-service application test system based on simulation data generator |
CN112162925A (en) * | 2020-09-29 | 2021-01-01 | 新华三大数据技术有限公司 | Test method and system based on service virtualization |
CN114238099A (en) * | 2021-12-09 | 2022-03-25 | 北京五八信息技术有限公司 | Method and device for gray scale test, electronic equipment and readable medium |
CN114238099B (en) * | 2021-12-09 | 2022-08-09 | 北京五八信息技术有限公司 | Method and device for gray scale test, electronic equipment and readable medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102141962B (en) | Safety distributed test framework system and test method thereof | |
Holzmann et al. | Automating software feature verification | |
US8904353B1 (en) | Highly reusable test frameworks and tests for web services | |
US20090313603A1 (en) | System And Method For Creating Virtual Callback Objects | |
CN109902010A (en) | The method and system that API is tested under a kind of KVM framework | |
CN105389256A (en) | Unit testing method and system | |
JP2004500652A (en) | Method of designing, modeling or assembling a baseband stack for communication | |
US10824549B1 (en) | System and method for regression testing of an application programming interface | |
CN106803799B (en) | Performance test method and device | |
CN104750603A (en) | Multi-core DSP (Digital Signal Processor) software emulator and physical layer software testing method thereof | |
US20220237111A1 (en) | Distributed immutable data object testing | |
CN101765129A (en) | Network access test system and method for data value-added service | |
De Wet et al. | Using UML models for the performance analysis of network systems | |
Song et al. | Hy-Sim: Model based hybrid simulation framework for WSN application development | |
Cortellessa et al. | MOSES: MOdeling Software and platform architEcture in UML 2 for Simulation-based performance analysis | |
CN101876936A (en) | Service test method | |
Aynsley | Easier UVM for functional verification by mainstream users | |
Wittenburg et al. | Running real-world software on simulated wireless sensor nodes | |
Rose et al. | A model for the coanalysis of hardware and software architectures | |
CN109901963A (en) | Test method, the system, terminal of optimization hard disk performance test under a kind of linux | |
Saifan et al. | Model-based testing of distributed systems | |
Dietrich et al. | Formal methods for communication services: meeting the industry expectations | |
Coyne et al. | A methodology for unit testing actors in proprietary discrete event based simulations | |
Post et al. | A SystemC-based verification methodology for complex wireless software IP | |
Liu et al. | Towards a Flexible and High-Fidelity Approach to Distributed DNN Training Emulation |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190618 |
|
RJ01 | Rejection of invention patent application after publication |