CN106603283B - A kind of method, apparatus and centralized management platform of analog service - Google Patents

A kind of method, apparatus and centralized management platform of analog service Download PDF

Info

Publication number
CN106603283B
CN106603283B CN201611152471.XA CN201611152471A CN106603283B CN 106603283 B CN106603283 B CN 106603283B CN 201611152471 A CN201611152471 A CN 201611152471A CN 106603283 B CN106603283 B CN 106603283B
Authority
CN
China
Prior art keywords
simulation
service
stake
data
public
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.)
Active
Application number
CN201611152471.XA
Other languages
Chinese (zh)
Other versions
CN106603283A (en
Inventor
马家麒
梁议尹
黄嵘
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Vipshop Guangzhou Software Co Ltd
Original Assignee
Guangzhou Pinwei Software Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Guangzhou Pinwei Software Co Ltd filed Critical Guangzhou Pinwei Software Co Ltd
Priority to CN201611152471.XA priority Critical patent/CN106603283B/en
Publication of CN106603283A publication Critical patent/CN106603283A/en
Application granted granted Critical
Publication of CN106603283B publication Critical patent/CN106603283B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/14Network analysis or design
    • H04L41/145Network analysis or design involving simulating, designing, planning or modelling of a network
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/22Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks comprising specially adapted graphical user interfaces [GUI]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

A kind of method that the present invention discloses analog service, step include: that the matched data of simulation are completed in crawl, are recorded as public stake from extraction simulation matching condition and response in the matched data of simulation is completed;The IP address of public stake is configured, control with public stake there is the link of same IP address to call public stake;With the simulation matching condition in the public stake called, executes and order is matched by the present day analog that there is the tested service of same IP address to issue with the link;If present day analog successful match, the response is returned to tested service.The invention also discloses a kind of device of analog service and centralized management platforms, the present invention is directed to the redis data or the unsuccessful request data of this system matching by grabbing external system in real time and automatic recording is responded into public stake, both the workload for having reduced test assignment improves the working efficiency of joint debugging test, flow is saved again, has saved cost.

Description

A kind of method, apparatus and centralized management platform of analog service
Technical field
The present invention relates to testing field, in particular to the method, apparatus and centralized management platform of a kind of analog service.
Background technique
With the hair people of social science and technology, business scenario and joint debugging that the system of the management internal services of enterprise is related to Test data is extremely complex, and enterprise's application platform is seldom isolated to be existed, and major applications platform is all to being connected to different suppliers Platform, one is served with assembly.And existing a variety of service phantom frames or system be substantially need to write code and And mainly research and development are only limitted to unit testing or integrated survey, and only support the simulation of the puppy parcs such as HTTP, SOCKS.And it is right Mainly doing in tester is Black-box Testing, but code capacity is restricted and traffic pressure is big, to write a mock and remove mould Quasi- external service is difficult, very influence working efficiency.In particular, some Large-Scale Interconnected nets company, a system are often Multiple external systems are relied on, the business scenario and joint debugging test data being related to are extremely complex, if each business scenario and connection Test data is adjusted to encode one by one, test job amount is big, and test job inefficient.
Summary of the invention
The main object of the present invention is to propose the method, apparatus and centralized management platform of a kind of analog service, it is intended to be passed through The simulation region that is completed of crawl external system matches unsuccessful request data and response automatic recording with data or this system in real time At public stake, the workload for not only having reduced test assignment improves the working efficiency of joint debugging test, but also saves flow, saved at This.
To achieve the above object, the method for a kind of analog service proposed by the present invention, comprising steps of simulation is completed in crawl Matched data are recorded as public stake from extraction simulation matching condition and response in the matched data of simulation is completed;Configuration is public The IP address of stake altogether, control with public stake there is the link of same IP address to call public stake;With in the public stake called Simulation matching condition, execute by with the link have same IP address tested service issue present day analog match life It enables;If present day analog successful match, the response is returned to tested service.
Preferably, the matched data of simulation are completed in the crawl, extract simulation from being completed in the matched data of simulation The step of matching condition and response are recorded as public stake includes: to grab being completed for external system to simulate matched data, will be grabbed The data recording taken is the first public stake;The data that it fails to match in the completed simulation matching of this system are grabbed, will be grabbed Data recording be the second public stake.
Preferably, redis is the caching that the matched data generation of simulation is completed by external system acquisition, and can be by network public affairs With the matched data of simulation are completed in the crawl external system, the step of by the data recording grabbed being first public Include: the communication connection relationship of foundation and external system, arranges the recording rule of the first public stake;It is public according to the first of the agreement The recording rule of stake altogether, grabs the redis generated by external system;Grabbed redis is parsed, extracts and is completed from redis Simulation matching condition and response;It records extracted simulation matching condition and response is the first public stake.
Preferably, the data that it fails to match in the completed simulation matching of described crawl this system, it fails to match from described Data in extract simulation matching condition and response the step of being recorded as second public include: the recording for arranging the second public stake Rule;According to the recording of the second public stake of agreement rule, it fails to match in the completed simulation matching of crawl this system Data;Simulation matching condition and response are extracted from the data grabbed;Record extracted simulation matching condition and response For the second public stake.
Preferably, described to use the simulation matching condition, execute the current mould of the received same IP address of the link The step of quasi- matching order includes: the matched request of present day analog received with the same IP address of the link;Parsing is called Public stake, with release simulation matching condition and response;With the simulation matching condition discharged, the current of the request is executed Simulation matching order.
The invention also discloses a kind of devices of analog service, comprising: simulation matching is completed for grabbing in handling module Data;Module is recorded, for being public stake by the data recording grabbed;Parsing module, for parse called it is public Stake, with release simulation matching condition and response;IP configuration module, for configuring the IP address of the public stake;Control module is used In control and public stake there is the link of same IP address to call public stake;Receiving module, it is same with the link for receiving The matched request of the present day analog of IP address;Execution module executes the link and receives for using the simulation matching condition Same IP address present day analog match order;Respond module returns to the response extremely if being used for present day analog successful match Tested service.
Preferably, the handling module includes the first picking unit and the second picking unit, and the recordings module includes the One recording elements and the second recording elements;First picking unit simulates matched data for grabbing being completed for external system;The Two picking units, for grabbing the data that it fails to match in the completed simulation matching of this system;First recording elements, being used for will The data recording that first picking unit is grabbed is the first public stake;Second recording elements, for being grabbed the second picking unit The data recording taken is the second public stake.
Preferably, first picking unit includes: to establish subelement, is closed for establishing with the communication connection of external system System;First about stator unit, the recording for arranging the first public stake is regular;First crawl subelement, for according to it is described about The redis for simulating matched data and generating is completed by external system in the recording rule of the public stake of fixed first, crawl;First mentions Subelement is taken, for parsing the redis, simulation matching condition and response are extracted from the data grabbed.
Preferably, second picking unit includes: that the second about stator unit, recording for arranging the second public stake is advised Then;Second crawl subelement, the recording for the second public stake according to the agreement is regular, grabs the completed mould of this system The data that it fails to match in quasi- matching;Second extracts subelement, for having extracted this system from the data that it fails to match The simulation matching condition of completion and response.
The invention also discloses a kind of centralized management platforms of analog service, including the as above of one or more different agreements The device of the analog service;And simulation various protocols service platform simulates various protocols service function for receiving request Platform processes service request;And UI interactive testing module, for establishing UI interactive testing model and interaction specifications, editor is static HTML, to be responsible for the interaction docking of all analog services;And simulation test framework, the test-types for simulating different establish mould Quasi- test frame;And log management module can carry out the note of log for providing log management function to the result of simulation test It records, check, download and clears up;And simulated database, for storing all data of analog service.
The present invention matches unsuccessful ask by the completed simulation matched data or this system for grabbing external system in real time Ask data and response automatic recording at public stake, the workload for both reducing test assignment improves the working efficiency of joint debugging test, Flow is saved again, has saved cost.
Detailed description of the invention
In order to illustrate the embodiments of the present invention more clearly or technology in the prior art configures, and to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with The structure shown according to these attached drawings obtains other attached drawings.
Fig. 1 is the flow diagram of one embodiment of method of analog service of the present invention;
Fig. 2 is that the matched data of simulation are completed in present invention crawl, extracts simulation from being completed in the matched data of simulation Matching condition and response are recorded as the flow diagram of public stake;
Fig. 3 is that being completed for present invention crawl external system simulates matched data, is first by the data recording grabbed The flow diagram of public stake;
Fig. 4 is the data that it fails to match in the completed simulation matching of present invention crawl this system, the data that will be grabbed It is recorded as the flow diagram of the second public stake;
Fig. 5 is of the present invention with the simulation matching condition, executes working as the received same IP address of the link The flow diagram of front simulation matching order;
Fig. 6 is the functional block diagram of the device of analog service of the present invention;
Fig. 7 is that the function of handling module in one embodiment of the invention refines schematic diagram;
Fig. 8 is the function refinement schematic diagram that module is recorded in one embodiment of the invention;
Fig. 9 is that the function of the first picking unit in one embodiment of the invention refines schematic diagram;
Figure 10 is that the function of the second picking unit in one embodiment of the invention refines schematic diagram;
Figure 11 is the structural schematic diagram of the centralized management platform of analog service in one embodiment of the invention.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, carries out to the technology configuration in the embodiment of the present invention clear, complete Site preparation description, it is clear that described embodiment is only a part of the embodiments of the present invention, instead of all the embodiments.Base Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts it is all its His embodiment, shall fall within the protection scope of the present invention.
It is to be appreciated that if relating to directionality instruction (such as up, down, left, right, before and after ...) in the embodiment of the present invention, Then directionality instruction be only used for explain under a certain particular pose (as shown in the picture) between each component relative positional relationship, Motion conditions etc., if the particular pose changes, directionality instruction is also correspondingly changed correspondingly.
Referring to Fig.1, Fig. 1 is a kind of flow diagram of one embodiment of method of analog service of the present invention, and the present invention provides A kind of method of analog service, steps are as follows:
The matched data of simulation are completed in step S10, crawl, extract simulation matching from being completed in the matched data of simulation Condition and response are recorded as public stake;
In step slo, the matched data of simulation are completed by crawl in this system, simulate matched data from being completed It is middle to extract simulation matching condition and respond the public stake for being recorded as to call, without separately configuring public stake, that is, flow is saved, The intelligence of automatic configuration is improved again.
Step S20 configures the IP address of public stake, and the link that controlling has same IP address with public stake calls public Stake;
It in step S20, is configured by the IP of public stake, it (is Internet that establishing, which has same IP address with public stake, Protocol Address, and be translated into internet protocol address) link connecting relation, call the public affairs to control the link Stake altogether.It should be appreciated that in this step, initialization operation is completed in default simulator.Simulator initialization operation needs Complete two aspect preparation, first, need to dispose test environment (referring mainly to hardware environment), with the analog service for simulator Stable and controllable environment is provided, the work quality and efficiency of simulator are improved.It is previously run building or deployment and tested service Between external service the docking of network communication services interface, establish WEB UI interactive testing model, a variety of test-types of building Frame, the link configuration for being packaged with different agreement are matched according to the serve port that the protocol service of tested service disposes tested service It when setting and present decoupling dependence situation, executes decoupling and relies on, to get around the port of relied on external service.And these test wrappers The deployment in border has the analog service platform of the several simulators of centralized management to complete, and initially sets up simulator and tested clothes Network communication between business and external service;Then set up WEB UI interface alternation test model and interaction specifications, step below Suddenly in interface operation, without coding;The demand for tested service constructs the frame of a variety of test-types again, such as: it is single First test, integration testing, automatic test, functional test and pressure test are stored with simulation in the frame of every kind of test-types The test module of the test case of external service behavior;It is serviced according to different agreement to the chain of each simulator encapsulation different agreement Road configuration;The destination service port configuration of tested service is modified according to the protocol service of tested service, tested A services (i.e. quilt Survey service) it is originally the service of the B outside relying on (i.e. external service), the destination service of present A service is not directed to B service and is changed to It is directed toward simulator.Second, need to dispose testing service (referring mainly to software environment), to provide test for test method of the invention Object.Testing service includes test and management unit and test execution unit, and simulator is equal to test and management unit, the simulation Device manages the operation of single simulation test, and a virtual stake adaptation (Stub Matcher) is equal to test and holds in simulator Row unit, the stake adaptation carry out simulation test and execute control, and specifically, the test module in simulator stores simulation The test case of external service behavior, element of the stake adaptation for the Call Condition of simulation testing module, to replace testing mould The interface of block receives or transmits the data of test module, wherein the Call Condition of the test module is in stake adaptation The simulation matching condition of editor, either, the simulation of the customized service of api function editor by registering customized Service events Test matching condition.Stake adaptation carries out testing and control according to simulation test matching condition.
The initialization of simulator of the present invention further includes creation simulator, the A service that the simulator is used to simulate and be tested Carry out the external B service of really interaction.The simulator can use JETTY server, which is an open source Servelet container (servelet is the server write with JAVA, major function be interactively to browse and Data are modified, dynamic WEB content is generated), it is the WEB container based on JAVA.JETTY server can be used as embedded server It uses, the speed of service of JETTY server is very fast, and is lightweight, and JETTY server is write using Java language , its API is issued in the form of one group of JAR packet.JAR packet (encapsulation package of JAVA) management is used for RPC protocol emulation (Remote Procedure Call Protocol-- remote procedure call protocol), it is that one kind passes through network from remote computer program Request service, the agreement without understanding underlying network technology), it is managed collectively the JAR packet of client, it is possible to understand that ground, JAR Packet can be used for parsing different agreement service.Then when tested A service is interacted by the B service outside interface calling in test When, it is changed to that simulator is called to simulate the interaction, i.e., the tested A service request of script is modified and be directed toward, be no longer point to B service and change To be directed toward simulator.
Step S30, with the simulation matching condition in the public stake called, with executing the received same IP of the link The present day analog of location matches order;
In step s 30, the step of simulation matching condition used in the public stake called, it should be appreciated that ground It is that can just be obtained by simulation matching condition and transported by it for public stake solution ginseng/analysis ginseng process there is also one after calling public stake With.Entire step is that a kind of certain moduli intends matching process, which is automatically generated by the crawl data called Public stake, obtain completed simulation matching condition, execute current simulation matching order, that is, realize a kind of analog service Intelligence configuration, and save flow for this system, saved cost.
Step S40 returns to the response to tested service if present day analog successful match.
It in step s 40, is one of matched responsive measures of simulation, if present day analog successful match, what return was called Response in public stake completes the task of this analog service to tested service.
Specifically, referring to Fig. 2, in the present embodiment, step S10 includes:
Step S11, it is first public by the data recording grabbed that grab external system, which is completed the matched data of simulation, Stake;
Step S12, crawl this system is completed to simulate the data that it fails to match in matching, the data recording that will be grabbed For the second public stake.
In step slo, the data source of public stake has two big sources, and one derives from external system, another is derived from This system.It should be appreciated that the external system is i.e. non-tested service and the system of non-external service, will derive from respectively outer The matched data recording of simulation that is completed of system is the first public stake, by data source in the completed simulation of this system The data recording that it fails to match in matching is the second public stake.Because data content is different, therefore the name of public stake is different, so as to area Point.
It is understood that described this system, which refers to, carries out the matched analog service system of present day analog, the external system Refer to i.e. non-tested service side non-external service side again, is the other systems of this system communication connection.Described this system it is common Simulating matched process is: the port of monitored link of this system starting is begun listening for, when listen to have it is identical as simulator When the request of IP, the request, packet parsing request are intercepted, and the request after parsing is sent to an adaptation, stake adaptation connects After receiving request, matching order is executed according to simulation matching condition, stake adaptation starts testing and control, if successful match, stake matching The default response that device releases simulation test is back to tested service;If it fails to match, stake adaptation forwards the request to external service, And true response of the external service to request is received, it is back to tested service.In this way, the completed simulation matching of this system In the data that it fails to match also should a successful match the data obtained at last.So the matched number of simulation is completed in external system According to can be completed simulation matched data with the data that it fails to match in the completed simulation matching of this system, and match Successful data have been stored in this system, and so there is no need to grab again.
In the present embodiment, referring to Fig. 3, the step S11 the following steps are included:
Step S111 establishes the communication connection relationship with external system, arranges the recording rule of the first public stake;
In step S111, establish with the communication connection of external system, be that can grab the precondition of external system data, and about The recording rule of fixed first public stake is counted needed for described to guarantee to correctly capture the required data in external system According to refer to present day analog it is matched needed for matching condition and response.
Step S112 grabs the redis generated by external system according to the recording of the first public stake of agreement rule;
Step S112 is the execution step for correctly capturing required data in external system.(redis is one to the redis Being write using ANSI C language of a open source, support network, it is memory-based also can persistence log type, Key-Value number According to library, and provide the API of multilingual), it is that the caching simulating matched data and generating is completed by external system acquisition, and it can quilt Network is public.The redis is that tester would generally use all normal interface requests and sound in testing field The public caching that should be sent.
Step S113 parses grabbed redis, completed simulation matching condition and response is extracted from redis;
Step S113 is from the redis grabbed, the step of obtaining completed simulation matching condition and respond.It is worth One is with mentioning, because code regulation existing for inside redis, also needs first to parse grabbed redis, ability after parsing Extract required data.
Step S114, records extracted simulation matching condition and response is the first public stake.
Step S114 is the step of the simulation matching condition of extraction and response are recorded as first public.It should be understood that ground It is that the recording step, which is an automatic recording process, to be performed as the first recording elements built in this system.
In the present embodiment, referring to Fig. 4, the step S12 the following steps are included:
Step S121 arranges the recording rule of the second public stake;
In step S121, the recording rule of the second public stake of agreement is to guarantee to correctly capture in this system Required data, it is described needed for data refer to matching condition and response needed for present day analog is matched.
Step S122, according to the recording of the second public stake of agreement rule, the completed simulation of crawl this system The data that it fails to match in matching;
In step S122, according to the recording of the second public stake rule, could correctly it be grabbed in the database of this system Get the completed matched data of simulation of this system.The data that it fails to match in the completed simulation matching of this system, It should be appreciated that, if it fails to match, this system forwards the request to external service in the completed simulation matching of this system, And response of the external service to request is received, by this indemnifying measure, it fails to match in the completed simulation matching of this system Data also should at last after primary successfully simulation matching data.The data that it fails to match should include requesting, Complete the simulation data such as matching condition and response.
Step S123 extracts simulation matching condition and response from the data grabbed;
In step S123, because data are grabbed from the database of this system, by the inside generation of this system Code rule, so needing to carry out technical treatment just to the data grabbed that simulation matching condition and response can be extracted.
Step S124, records extracted simulation matching condition and response is the second public stake.
Step S124 is the step of the simulation matching condition of extraction and response are recorded as second public.It should be understood that ground It is that the recording step is also an automatic recording process, is performed as the second recording module built in this system.
In the present embodiment, referring to Fig. 5, the step S30 the following steps are included:
Step S31 receives the matched request of present day analog with the same IP address of the link;
It is the beginning of the conventional simulation service steps of herein described simulator in step S31.The monitored link of starting Port begin listening for, when listening to the request with IP identical as simulator, intercept the request.
Step S32 parses the public stake called, with release simulation matching condition and response;
In step s 32, the public stake called is by being called with public stake with the link of same IP, and in step In rapid S31, the link interception is the matched request of present day analog with the same IP address of the link.It follows that being adjusted The IP of public stake and the matched request of present day analog is the same IP, in this way, the simulation matching condition in public stake It could be adapted with the matched request of the present day analog with response.
Step S33 executes the present day analog matching order of the request with the simulation matching condition discharged.
Step S33 is the matched execution step of present day analog.Only when the simulation matching condition in the public stake called When being adapted with response with the matched request of the present day analog, the simulation matching condition that the public stake is discharged could become The matched Call Condition of present day analog could execute present day analog matching order.
Step S31-33, after specifically teaching the matched detailed step of present day analog and the starting of the application simulator, mould The conventional simulation service steps of quasi- device.
It should be noted that the conventional simulation service steps of the simulator: firstly, in the process of simulator initialization In, the stake adaptation in simulator calls the test case data being stored in simulator, judges called test case number According to intention, and matching condition according to the specific data editor simulation in the test case data and default response are generated as Stake;Further, the parametrization stake, it should be understood that the variability of external service determines simulation matching condition and pre- If response is changeable, i.e. stake can be a constant, be also possible to a variable, in this way, stake is interpreted as a pile function, mould Quasi- matching condition is functional expression, and presetting response is return value, and parameterizes stake and be exactly passed to parameter when function defines, and Relatively, analytic parameter is exactly that argument is passed to when calling function, in this way, stake is defined as a function, biography when function defines The parameter entered is parameter, and while calling function incoming parameter is argument, and the process that stake parameterizes is: configuring the lattice of the parameter of stake Formula adds stake parameter, completes parametrization, generates stake parameter.Different external services of the parametrization of stake to be adapted to various protocols, Therefore pile function can automatically generate, and also can customize, but automatically raw pile function and its essential difference of customized pile function exists In: customized pile function calls priority level to be higher than original function, and the priority level of original function is higher than the pile function automatically generated. For example, it is assumed that can be found in code some function script definition, the pile function automatically generated at this time be it is invalid, Because original function priority level is higher than the pile function automatically generated.And customized pile function can be brought the advantage that: be called Its possible return value of original function is a fixed value, cannot return to a desired value, so that the code branch that test is different.And The return value of pile function can freely be controlled by user, thus have greater flexibility.Therefore in the present embodiment, this letter The i.e. default response of several return values, using a kind of beanshell (JAVA source code interpreter) dynamic generation.
And parametrization stake of the invention is also a kind of embodiment of intelligent Matching function.The matching condition and analog response of stake It all parameterizes therewith, it should be appreciated that ground is, if the parameter format of stake configuration is $ { parameter name }, when provided with parameter format Afterwards, stake parameter also must be provided with, and being otherwise tested service request can match unsuccessful, only reset stake parameter, allow stake Parameter replaces the format parameter of matching condition and analog response, at this moment requests again primary, and just can see obtain Response.
In the present invention, it should be noted that stake is public affairs according to the different instructions of the specific data in test case data Stake and privately owned stake altogether, the specific data are according to the intention difference for simulating external service and by number specific inside this system According to the public stake can be created and is called in the link, and the data for being also possible to grab redis automatically generate, can quilt It is associated with the link under the same IP address with public stake to call, the privately owned stake can only create in the link, and being only should Link is privately owned.Newly-built stake mentioned here includes customized pile function and original function.
Especially it should be noted that, there are two types of the recording approach of the public stake: 1, grabbing flow from outside service systems It is recorded, scene: when platform is docked with ApiTester (interface testing platform) and DCT (making data platform)), because When the test of ApiTester and DCT, all normal interface requests and response can send a public redis and cache, and put down Platform can periodically extracting these data from redis automatically generates public stake;2, when simulator, which mismatches, requests, pass through stake transcripter The request and response that (Stub Recorder) record analog device intercepts and mismatch directly forwards are generated as public stake.Public stake Also have and record rule, the public stake recording rule automatically generates recording after can pre-establishing default rule by internal code Rule can also be artificially arranged in the page.It is described by internal code pre-establish the public stake automatically generated after default rule with The difference of the public stake for making setting by oneself in the page is exactly the difference of the above-mentioned pile function given birth to automatically and customized pile function.
The simulation matching has a variety of matching rules abundant, and the matching rule is supported in logic between multiple stakes AND, OR and NOT relationship, matched operator supports equals (value is equal), contains (value includes) and regex, and (value is just Then expression formula matches), return is default if indicating that the URI of HTTP request includes Stock/Wms/add and is POST request rings The operation answered is: first selecting matching rule, input indicates URI, the matched operator contains of reselection of HTTP request, value For Stock/Wms/add, and the default response passes through beanshell dynamic generation according to selection matching rule.
After the completion of the initialization of simulator, starts monitored link, listen to the request with the same IP address of link, simulator Interception request, analysis request generate required parameter, extract the request object that required parameter is converted to unified encapsulation different agreement, For transmission request object to stake adaptation, stake adaptation receives request object, calls stake parameter, stake parameter is parsed, to discharge simulation The matching condition of device and default response execute matching order according to simulation matching condition, return to corresponding response.
The process of tested service request reception before the matching of simulator common simulation executes, link startup when, will start One InboundChannel (InboundChannel services the channel communicated between simulator dedicated for A), for monitoring The request from A service received, after receiving request, by Request Extrator (request export) to the parameter of request into Row extracts (parameter of such as uri, body), switchs to RequestElement (request object) such as, the different associations such as HTTP, OSP The request content of view is uniformly converted to the required parameter that RequestElement request object is packaged with different agreement.Simulator RequestElement Stub Matcher (stake adaptation) is passed to again to be matched with the stake of user preset.Entirely request The operation for resolving to RequestElement is realized by the internal code of simulator.
In the present invention, there are also the process of stake parametric solution ginseng before the matching of simulator conventional simulation executes, stake can be one A constant is also possible to a variable, in this way, stake is defined as a function, the parameter that is passed to when function defines parameter, And parameter incoming when calling function is argument, with condition and the default parameter responded, then simulator first replaces the area Zhuan Li It matches again.If successful match, simulator returns to default response to tested service;Either, if it fails to match, simulator forwarding Request receives external service and is back to tested service to the true response of request to external service.
After the simulator intercepts the step of request issued by tested service, the analysis request is simultaneously sent to stake Before the step of orchestration further include: simulator monitoring request judges the executive condition of matching order according to the monitoring situation of request; If monitoring request needs to be implemented matching order, analysis request is simultaneously sent to an adaptation;Either, if monitoring request does not need to return When returning default response, suspend the link of simulator, do not execute matching, directly forwards tested service request and returning to external service pair The true response of request;Either, if monitoring request is not needed using simulator, stop the link of simulator, analog service Listening port is closed, error information is returned.
It should be understood that according to the complexity of enterprise customer's business, in order to meet the need of the various matchings of user and forwarding It wants, the simulator completes the function of monitoring request by the control of link state, it should be appreciated that ground is monitor request same When be demand in conjunction with user, if user can suspend the link of simulator when not needing to match direct forwarding, if User does not use simulator, can stop the link of simulator, and analog service closes listening port, and user initiates request to mould again Quasi- device, will receive the error information of connection failure.
Referring to Fig. 6, the invention also discloses a kind of devices of analog service, comprising:
The matched data of simulation are completed for grabbing in handling module 10;
Module 20 is recorded, for being public stake by the data recording grabbed;
The matched data of simulation are completed by crawl in this system, extract simulation from being completed in the matched data of simulation It is recorded as the public stake that can be called with condition and response, without separately configuring public stake, i.e. saving flow, and raising automation The intelligence of configuration.
Parsing module 30, for parsing the public stake called, with release simulation matching condition and response;
IP configuration module 40, for configuring the IP address of the public stake;
It is configured by the IP of public stake, it (is Internet Protocol that establishing, which has same IP address with public stake, Address, and be translated into internet protocol address)) link connecting relation, call the public stake to control the link.It answers This is appreciated that in this step, initialization operation is completed in default simulator.Simulator initialization operation needs to complete two The preparation of aspect, first, need to dispose test environment (referring mainly to hardware environment), to provide stabilization for the analog service of simulator And controllable environment, improve the work quality and efficiency of simulator.Building or deployment is previously run to take with tested service and outside WEB UI interactive testing model, a variety of test-types frames of building, encapsulation are established in the docking of network communication services interface between business There is the link configuration of different agreement, is configured according to the serve port that the protocol service of tested service disposes tested service and presentation solves It when coupling relies on situation, executes decoupling and relies on, to get around the port of relied on external service.And the deployment of these test environment is equal There is the analog service platform of the several simulators of centralized management to complete, initially sets up simulator and tested service and outside takes Network communication between business;WEB UI interface alternation test model and interaction specifications are then set up, following step is at interface Operation, without coding;The demand for tested service constructs the frame of a variety of test-types again, such as: unit testing integrates Test, automatic test, functional test and pressure test are stored with simulation external service behavior in the frame of every kind of test-types Test case test module;It is serviced according to different agreement to the link configuration of each simulator encapsulation different agreement;According to The destination service port configuration of the tested service of protocol service modification of tested service, tested A service (i.e. tested service) are original It is the B service (i.e. external service) outside relying on, the destination service of present A service is not directed to B service and is changed to point to simulator. Second, need to dispose testing service (referring mainly to software environment), to provide test object for test method of the invention.Test clothes Business includes test and management unit and test execution unit, and simulator is equal to test and management unit, and the simulator manages single The operation of simulation test, and a virtual stake adaptation (Stub Matcher) is equal to test execution unit in simulator, institute It states an adaptation implementation simulation test and executes control, specifically, the test module storage simulation external service in simulator The test case of behavior, element of the stake adaptation for the Call Condition of simulation testing module, to replace the interface of test module, Receive or transmit the data of test module, wherein the Call Condition of the test module is the mould edited in stake adaptation Quasi- matching condition is either matched by registering the simulation test of the customized service of api function editor of customized Service events Condition.Stake adaptation carries out testing and control according to simulation test matching condition.
The initialization of simulator of the present invention further includes creation simulator, the A service that the simulator is used to simulate and be tested Carry out the external B service of really interaction.The simulator can use JETTY server, which is an open source Servelet container (servelet is the server write with JAVA, major function be interactively to browse and Data are modified, dynamic WEB content is generated), it is the WEB container based on JAVA.JETTY server can be used as embedded server It uses, the speed of service of JETTY server is very fast, and is lightweight, and JETTY server is write using Java language , its API is issued in the form of one group of JAR packet.JAR packet (encapsulation package of JAVA) management is used for RPC protocol emulation (Remote Procedure Call Protocol-- remote procedure call protocol, it is that one kind passes through network from remote computer program Request service, the agreement without understanding underlying network technology), it is managed collectively the JAR packet of client, it is possible to understand that ground, JAR Packet can be used for parsing different agreement service.Then when tested A service is interacted by the B service outside interface calling in test When, it is changed to that simulator is called to simulate the interaction, i.e., the tested A service request of script is modified and be directed toward, be no longer point to B service and change To be directed toward simulator.
Control module 50 calls public stake for controlling the link for having same IP address with public stake;
Control module 50 calls public stake for controlling link, is with being worth mentioning, only when in the public stake called Simulation matching condition and response with the present day analog is matched request to be adapted when, simulation that the public stake is discharged The matched Call Condition of present day analog could be become with condition, present day analog matching order could be executed.
It is described to call the process joined there is also one to public stake solution ginseng/analysis after public stake, it can just obtain simulation matching Condition is used by it.Entire step is that a kind of certain moduli intends matching process, the crawl number which passes through calling According to the public stake automatically generated, completed simulation matching condition is obtained, current simulation matching order is executed, that is, realizes one The intelligence configuration of kind analog service, and flow is saved for this system, save cost.
Receiving module 60, for receiving and the matched request of present day analog of the same IP address of the link;
The port for the monitored link that receiving module 60 starts is begun listening for, and has asking for IP identical as simulator when listening to When asking, the request is intercepted.At this point, being the beginning of the conventional simulation service steps of the simulator.
Execution module 70 executes working as the received same IP address of the link for using the simulation matching condition Front simulation matching order;
Execution module 70 completes the matched conventional simulation of present day analog and executes.It is with being worth mentioning, only when being called Public stake in simulation matching condition and response with the present day analog it is matched request be adapted when, the public stake is released The simulation matching condition put could become the matched Call Condition of present day analog, could execute present day analog matching order.
It should be noted that the conventional simulation service steps of the simulator: firstly, in the process of simulator initialization In, the stake adaptation in simulator calls the test case data being stored in simulator, judges called test case number According to intention, and matching condition according to the specific data editor simulation in the test case data and default response are generated as Stake;Further, the parametrization stake, it should be understood that the variability of external service determines simulation matching condition and pre- If response is changeable, i.e. stake can be a constant, be also possible to a variable, in this way, stake is interpreted as a pile function, mould Quasi- matching condition is functional expression, and presetting response is return value, and parameterizes stake and be exactly passed to parameter when function defines, and Relatively, analytic parameter is exactly that argument is passed to when calling function, in this way, stake is defined as a function, biography when function defines The parameter entered is parameter, and while calling function incoming parameter is argument, and the process that stake parameterizes is: configuring the lattice of the parameter of stake Formula adds stake parameter, completes parametrization, generates stake parameter.Different external services of the parametrization of stake to be adapted to various protocols, Therefore pile function can automatically generate, and also can customize, but automatically raw pile function and its essential difference of customized pile function exists In: customized pile function calls priority level to be higher than original function, and the priority level of original function is higher than the pile function automatically generated. For example, it is assumed that can be found in code some function script definition, the pile function automatically generated at this time be it is invalid, Because original function priority level is higher than the pile function automatically generated.And customized pile function can be brought the advantage that: be called Its possible return value of original function is a fixed value, cannot return to a desired value, so that the code branch that test is different.And The return value of pile function can freely be controlled by user, thus have greater flexibility.Therefore in the present embodiment, this letter The i.e. default response of several return values, using a kind of beanshell (JAVA source code interpreter) dynamic generation.
And parametrization stake of the invention is also a kind of embodiment of intelligent Matching function.The matching condition and analog response of stake It all parameterizes therewith, it should be appreciated that ground is, if the parameter format of stake configuration is $ { parameter name }, when provided with parameter format Afterwards, stake parameter also must be provided with, and being otherwise tested service request can match unsuccessful, only reset stake parameter, allow stake Parameter replaces the format parameter of matching condition and analog response, at this moment requests again primary, and just can see obtain Response.
In the present invention, it should be noted that stake is public affairs according to the different instructions of the specific data in test case data Stake and privately owned stake altogether, specific data mentioned here are different and specific by this system inside according to the intention of simulation external service Different data, the public stake can be created and be called in the link, and the data for being also possible to grab redis are given birth to automatically At, the link that can be associated under the same IP address with public stake calls, and the privately owned stake can only create in the link, and It is only privately owned for the link.Newly-built stake mentioned here includes customized pile function and original function.
Especially it should be noted that, public stake also have recording rule, there are two types of the recording approach of the public stake: 1, from Outside service systems crawl flow is recorded, scene: platform and ApiTester (interface testing platform) and DCT (it is flat to make data Platform)) docking when because when the test of ApiTester and DCT, all normal interface requests and response can send one it is public Redis cache, platform can timing extract these data from redis and automatically generate public stake;2, when simulator mismatch is asked When asking, the request directly forwarded is intercepted and mismatched by stake transcripter (Stub Recorder) record analog device and response is given birth to As public stake.The public stake recording rule automatically generates recording rule after can pre-establishing default rule by internal code Then, can also artificially be arranged in the page.It is described that the public stake automatically generated after default rule and institute are pre-established by internal code Stating in the difference that the page makes the public stake of setting by oneself is exactly the difference of the above-mentioned pile function given birth to automatically and customized pile function.
The simulation matching has matching rule abundant, and the matching condition of stake is supported in logic between multiple stakes AND, OR and NOT relationship;Matched operator supports equals (value is equal), and contains (value includes), regex (are worth canonical Expression formula matching), such as the following figure, indicate that the URI of HTTP request includes Stock/Wms/add and is that POST request is then returned and preset Response.And the default response passes through beanshell dynamic generation according to different simulation matching conditions.
After the completion of the initialization of simulator, start monitored link, listen to the request of same IP address, simulator interception is asked It asks, analysis request generates required parameter, extracts the request object that required parameter is converted to unified encapsulation different agreement, and transmission is asked Ask object to stake adaptation, stake adaptation receives request object, calls stake parameter, stake parameter is parsed, to discharge of simulator With condition and default response, matching order is executed according to simulation matching condition, returns to corresponding response.
The process of tested service request reception before the matching of simulator common simulation executes, link startup when, will start One InboundChannel (InboundChannel services the channel communicated between simulator dedicated for A), for monitoring The request from A service received, after receiving request, by Request Extrator (request export) to the parameter of request into Row extracts (parameter of such as uri, body), switchs to RequestElement (request object) such as, the different associations such as HTTP, OSP The request content of view is uniformly converted to the required parameter that RequestElement request object is packaged with different agreement.Simulator RequestElement Stub Matcher (stake adaptation) is passed to again to be matched with the stake of user preset.Entirely request The operation for resolving to RequestElement is realized by the internal code of simulator.
In the present invention, there are also the process of stake parametric solution ginseng before the matching of simulator conventional simulation executes, stake can be one A constant is also possible to a variable, in this way, stake is defined as a function, the parameter that is passed to when function defines parameter, And parameter incoming when calling function is argument, with condition and the default parameter responded, then simulator first replaces the area Zhuan Li It matches again.If successful match, simulator returns to default response to tested service;Either, if it fails to match, simulator forwarding Request receives external service and is back to tested service to the true response of request to external service.
After the simulator intercepts the step of request issued by tested service, the analysis request is simultaneously sent to stake Before the step of orchestration further include: simulator monitoring request judges the executive condition of matching order according to the monitoring situation of request; If monitoring request needs to be implemented matching order, analysis request is simultaneously sent to an adaptation;Either, if monitoring request does not need to return When returning default response, suspend the link of simulator, do not execute matching, directly forwards tested service request and returning to external service pair The true response of request;Either, if monitoring request is not needed using simulator, stop the link of simulator, analog service Listening port is closed, error information is returned.
It should be appreciated that according to the complexity of enterprise customer's business, in order to meet the need of the various matchings of user and forwarding It wants, the simulator completes the function of monitoring request by the control of link state, it should be appreciated that ground is monitor request same When be demand in conjunction with user, if user can suspend the link of simulator when not needing to match direct forwarding, if User does not use simulator, can stop the link of simulator, and analog service closes listening port, and user initiates request to mould again Quasi- device, will receive the error information of connection failure.
Respond module 80 returns to the response to tested service if being used for present day analog successful match.
Respond module 80 is, if present day analog successful match, to return to institute for completing to simulate one of matched responsive measures The response in public stake called completes the task of this analog service to tested service.
In the present invention, the matched data of simulation are completed by crawl in the present apparatus, simulate matched data from being completed It is middle to extract simulation matching condition and respond the public stake for being recorded as to call, without separately configuring public stake, that is, flow is saved, The intelligence of automatic configuration is improved again.
Referring to Fig. 7, the handling module 10 includes:
First picking unit 11 simulates matched data for grabbing being completed for external system;
Second picking unit 12, for grabbing the data that it fails to match in the completed simulation matching of this system.
In the present invention, the data source of the public stake has two big sources, and one derives from external system, another source In this system.It should be appreciated that the external system is i.e. non-tested service and the system of non-external service, will derive from respectively The matched data recording of simulation that is completed of external system is the first public stake, by data source in the completed simulation of this system The data recording that it fails to match in matching is the second public stake.Because data content is different, therefore the name of public stake is different, so as to It distinguishes.
It should be appreciated that described this system, which refers to, carries out the matched analog service system of present day analog, the external system Refer to i.e. non-tested service side non-external service side again, is the other systems of this system communication connection.Described this system it is common Simulating matched process is: the port of monitored link of this system starting is begun listening for, when listen to have it is identical as simulator When the request of IP, the request, packet parsing request are intercepted, and the request after parsing is sent to an adaptation, stake adaptation connects After receiving request, matching order is executed according to simulation matching condition, stake adaptation starts testing and control, if successful match, stake matching The default response that device releases simulation test is back to tested service;If it fails to match, stake adaptation forwards the request to external service, And true response of the external service to request is received, it is back to tested service.In this way, the completed simulation matching of this system In the data that it fails to match also should a successful match the data obtained at last.So the matched number of simulation is completed in external system According to can be completed simulation matched data with the data that it fails to match in the completed simulation matching of this system, and match Successful data have been stored in this system, and so there is no need to grab again.
Referring to Fig. 8, the recording module 20 includes:
First recording elements 21, the data recording for being grabbed the first picking unit are the first public stake;
The step of simulation matching condition of extraction and response are recorded as first public by the first recording elements 21.It should manage Solution ground is that the recording step, which is an automatic recording process, to be performed as the first recording elements 21 built in this system.
Second recording elements 22, the data recording for being grabbed the second picking unit are the second public stake.
The step of simulation matching condition of extraction and response are recorded as second public by the second recording elements 22.It should manage Solution ground is that the recording step is also an automatic recording process, is performed as the second recording module built in this system.
Referring to Fig. 9, first picking unit 11 includes:
Subelement 111 is established, for establishing and the communication connection relationship of external system;
First about stator unit 112, the recording for arranging the first public stake is regular;
Subelement 111 is established for establishing and the communication connection of external system, is the precondition that can grab external system data, And first about stator unit 112 arrange the first public stake recording rule, be to guarantee to correctly capture external system In required data, it is described needed for data refer to matching condition and response needed for present day analog is matched.
First crawl subelement 113, the recording for the first public stake according to the agreement is regular, grabs by external system Be completed and simulate the redis that matched data generate;
The first crawl execution of subelement 113 correctly captures required data in external system.(redis is one to the redis Being write using ANSI C language of a open source, support network, it is memory-based also can persistence log type, Key-Value number According to library, and provide the API of multilingual), it is that the caching simulating matched data and generating is completed by external system acquisition, and it can quilt Network is public.The redis is that tester would generally use all normal interface requests and sound in testing field The public caching that should be sent.
First extracts subelement 114, and for parsing the redis, simulation matching condition is extracted from the data grabbed And response.
First extracts subelement 114 from the redis grabbed, obtains the step of completed simulation matching condition and response Suddenly.It is, because code regulation existing for inside redis, also needs first to parse grabbed redis, to solve with being worth mentioning Required data can be just extracted after analysis.
In the present invention, communication connection is initially set up, arranges the recording rule of the first public stake, according to the first public stake Recording rule could grab in external system simulated database comprising simulation matched data is completed by external system acquisition redis;Again since the redis can be public by network, so this system is just able to achieve crawl;Again because redis is data cached Library, so the redis that parsing is grabbed, extracts simulation matching condition from redis and response is recorded as the first public stake.It is described Redis be include the matched data of simulation are completed by external system and are generated data cached, and can be public by network.Institute The redis stated is one that tester would generally use all normal interface requests and response transmission in testing field Public caching.
Referring to Fig.1 0, second picking unit 12 includes:
Second about stator unit 121, the recording for arranging the second public stake is regular;
The second recording rule that about stator unit 121 arranges the second public stake is to guarantee to correctly capture this and be Required data in system, the required data refer to the matched required matching condition of present day analog and response.
Second crawl subelement 122, the recording for the second public stake according to the agreement is regular, and crawl this system is The data that it fails to match in the simulation matching of completion;
Second crawl subelement 122, could be correct in the database of this system according to the recording rule of the second public stake Ground grabs the completed matched data of simulation of this system.The number that it fails to match in the completed simulation matching of this system According to, it should be appreciated that ground is that in the completed simulation matching of this system, if it fails to match, this system forwards the request to external clothes Business, and response of the external service to request is received, by this indemnifying measure, matches and lose in the completed simulation matching of this system The data lost also primary at last should successfully simulate the data after matching.The data that it fails to match should include request, The simulation data such as matching condition and response are completed.
Second extracts subelement 123, for extracting the completed simulation of this system from the data that it fails to match With condition and response.
Second extracts subelement 123 because data are grabbed from the database of this system, by this system Portion's code regulation, so needing to carry out technical treatment just to the data grabbed that simulation matching condition and response can be extracted.
In the present invention, data needed for the second public stake are originated from the data in this system, so directly in this system about The recording rule of fixed second public stake;Further according to the recording rule of the second public stake of agreement, the completed mould of this system is grabbed Related data in the case of it fails to match in quasi- matching, according to this system indemnifying measure that it fails to match: forwarding the request to outside Service, and true response of the external service to request is received, the result which obtains also should once simulate survey at last Try the result of successful match.This system data that it fails to match are grabbed, simulation matching condition is extracted and response is recorded as the second public affairs Stake altogether.
Referring to Fig.1 1, the invention also discloses a kind of centralized management platform of analog service, a kind of concentration of analog service Manage platform characterized by comprising the device of analog service described in one or more different agreements;And a variety of associations of simulation Service platform is discussed, for receiving request, simulates various protocols service function platform processes service request;And UI interactive module, it uses In establishing UI interactive testing model and interaction specifications, static state HTML is edited, to be responsible for the interaction docking of all analog services;And mould Quasi- test structure, establishes simulation test frame for simulating different test-types;And log management module, for providing log Management function can carry out the record of log to the result of simulation test, check, downloads and clear up;And simulated database, for depositing Store up all data of analog service.
The simulation various protocols service platform includes protocol component module and service Port Management module, the protocol groups Part module, after receiving request, the protocol type on the address acquisition request URL hands to the simulator of adapting protocol type It is handled, it includes simulation puppy parc service unit and simulation custom protocol service unit, the serve port management Module, the port for modifying tested service, external service and simulator according to different agreement service configure, so as to simulator into Enter the role of proxy server.
The simulation test framework is to provide the simulation test analysis tool of simulation test use-case, it includes simulation test Test module, management module and statistical analysis module, the test module are used to execute the simulation matching life of different test-types When enabling, called simulation test use-case is provided, and the simulation test use-case is repeatedly used;The management module For managing the calling of the simulation test use-case of different simulation testing type;The statistical analysis module is for counting and analyzing institute State the result of simulation test.Simulation test framework different instructions according to expected from simulation test are different test-types, The simulation test framework that different test-types are established is simulated again, and the type of the simulation test framework includes unit testing frame Structure, integration testing framework, functional test framework and pressure test framework, every kind of simulation test framework are to extract every kind of test The independent architecture of the general character part composition of type.
In a further preferred embodiment, the centralized management platform of the analog service further includes decoupling Depending module, When the case where decoupling relies on is presented, the centralized management platform of analog service executes decoupling and relies on, to get around relied on external service Interface.
In the present invention, the B service outside dependence is originally in tested A service, now in tested A service and outside Establish the platform of the open many simulators of centralized management between B service, and platform by interface from it is different External server cooperation interaction handles the business of tested service.It should be appreciated that the coupling in calculating both be partial to or More persons' affects one another, and decoupling seeks to release this influence, enhances the respective ability of being individually present, can infinitely reduce presence The degree of coupling, but cannot eradicate, otherwise just lose mutual association, lose that there are meanings.
The effect of service analog platform is service decoupling, can be used for researching and developing or tester gets around external service and individually tests Oneself responsible service.Service decoupling scene: 1) B service is adjusted in A service, and B services unavailable for some reason or unstable, example Such as one passport.api logged in of login page tune, but passport.api does not connect and leads to not log in;2) A is serviced B service is adjusted, the data or scene of B service are difficult to construct, such as one passport.api logged in of login page tune, Passport.api can return to some error codes in certain extreme cases;3) when automatic test, B service is adjusted in A service, due to B service is uncontrollable, and data, which often change, causes test data often to change.Such as: Jetty can be controlled from test case It runs, so as to smoothly realize automatic test so that automatic test eliminates the reliance on external environment.
In the present invention, it is a kind of simulator that the device of above-mentioned all analog services, which can be approximately considered, tested A service (i.e. tested service) is originally that the service of the B outside relying on (i.e. external service), present A service are not directed to B service and are changed to point to Simulator.When A service sends a request by simulator, the stake inside simulator carries out preset condition and required parameter Matching, it may occur that two kinds may: 1) unmatch, then simulator only does transfer, forwards the request to B service, B service is true Response returns to simulator, and simulator records the request and response and returns the response to A service.Such case, user is not The presence of simulator can be perceived;2) it matching, then the default response of the stake matched can be returned at once A service by simulator, Request will not be forwarded to B service.If simulator monitoring request does not need to return to default response, suspend the link of simulator, no Matching is executed, tested service request and true response of the returning to external service to request are directly forwarded;Either, if monitoring request When not needing using simulator, stop the link of simulator, analog service closes listening port, returns to error information.
After simulator initialization operation, the test case of simulation external service behavior is stored in test module;Execute mould Block monitors the monitored link port of simulator starting, listens to the request of same IP, is intercepted, and request is in link by message Parsing module is parsed, and is converted to the request object of unified encapsulation different agreement after parsing by conversion module, is monitored simultaneously Judgment module is monitored request, judges whether to match, if desired match, and stubs receive request, and execution module is held Row matching order, the matching order are to send the related data of request to test module, and call test module, according to Match condition, respond module return to corresponding response, and the respective response includes default response and true response, if matching at Function returns to default response;If it fails to match, external service is forwarded requests to, external service is received and the true response of request is returned It returns.Record the response that module crawl flow records the request and return that it fails to match simultaneously, generate public stake, can by with the public affairs Link reference under the same IP of stake altogether.
The centralized management platform of the analog service is exactly the mould to said one or multiple and different protocol services The platform that quasi- device is managed concentratedly, the central principle of analog service platform are an agency service platforms, to carry out simulation suit The test environment of the simulator building adaptation of business;Suitable simulator and different agreement are found according to the request type of tested service Link configuration, to provide corresponding service;Centralized management to multiple simulators, configuration is shared, improves joint debugging and tests work Make efficiency;Log recording and database provide the regular service of centralized management.
Illustrating ground is, is that the pressure of platform offer is activated individually to survey packet, the pressure is surveyed when constructing function test frame Packet supports puppy parc, such as http protocol and custom protocol, such as the service simulation of OSP agreement pressed when surveying, and presses Surveying packet is also that starting is arranged by the stake of web interface given link, is configured without repeating.Step are as follows: a key download platform first The pressure of offer surveys packet, and starting pressure surveys simulator, carries out pressure simulation test, be directly viewable test result by interface.
The centralized management platform of the analog service tests the joint debugging of tester, develops joint debugging, abnormal scene And the test of complicated test scene is more simplified, also makes the simplification for pressing measured data and environment.
In practical applications, a kind of method, apparatus of analog service of the invention and the detailed process of centralized management platform It is as follows:
One, the device of analog service
By taking http protocol is simulated as an example:
1. the included Nginx of simulator receives request, Nginx is received according to the forwarding port of the configuration of user, Nginx After request, the listening port for being forwarded to respective links starting.
2. will start an InboundChannel when link startup, (InboundChannel is dedicated for A service The channel communicated between simulator), for monitoring the request from A service received.After receiving request, pass through Request Extrator extracts (parameter of such as uri, body) to the parameter of request, switchs to a RequestElement request object (request content of the different agreements such as HTTP, OSP is uniformly converted to RequestElement request object).
3. simulator RequestElement is passed to again the stake of Stub Matcher (stake adaptation) and user preset into Row matching.
4. it fails to match will (OutboundChannel be used exclusively for simulator and B by OutboundChannel The channel of communication for service is only just established in forwarding) it is forwarded to real service and receives response, and pass through Stub Recorder (stake transcripter, dedicated for the response of the interception of record analog device and forwarding is recorded as public stake), which is recorded, to be responded, Then true response is returned to requesting party (A service) by InBoundChannel.
5. after successful match, default response can be directly returned to requesting party (A service) by InBoundChannel.
The simulator realizes the common matching process practical operation process of analog service:
1, the link configuration of simulator, comprising: link ID, link IP, link name, link listening port, link monitoring Whether matching, destination service Target IP, destination service Host/URL, destination service port and protocol type are used, wherein first A link can all play a listening port, destination service user is set it fails to match after forwarding, supported protocol type includes: HTTP, OSP, Thrift etc.;
2, list of link and state control, link state include: starting, pause (only forwarding, which mismatches, uses) and stop;
3, Nginx is configured, and is used for http protocol or Thrift protocol emulation, Nginx built in platform, and user no longer needs to taking Nginx is operated on business device, need to only be configured on the page;
4, JAR assures reason, is used for RPC protocol emulation, is managed collectively the JAR packet of client, convenient for parsing different agreement clothes Business.
5, stake configures, and specifies the settings such as simulation matching rule, default response, stake parameter, each settable multiple stakes of link;
6, rule setting is recorded in public stake, and there are two types of the recording approach of public stake: 1, grabbing flow from outside service systems It is recorded;2, when simulator, which mismatches, requests, by the interception of stake transcripter (Stub Recorder) record analog device and not It matches the request directly forwarded and response is generated as public stake.Rule is recorded in the public stake to be arranged by hand, if there is not Existing condition can also automatically generate recording rule;
7, log recording, simulation record the log of forwarding when it fails to match, record backspace default sound when simulating successful match The log answered;
8, the service pressure being activated individually surveys packet and carries out pressure test, service simulation when the pressure of HTTP and DSP agreement being supported to survey, One key downloading pressure surveys packet, and starting pressure surveys simulator, and pressure surveys simulator itself and carries out pressure test, checks test result.
Two, the centralized management platform of analog service
The centralized management platform of the analog service is exactly the platform managed concentratedly to the simulator, simulation suit The central principle of business platform is an agency service platform, and the action of the platform includes the simulation to carry out analog service The test environment of device building adaptation;Suitable simulator and link configuration are found according to the request type of tested service, to provide Corresponding service;Centralized management to multiple simulators, configuration is shared, improves joint debugging test job efficiency;Log recording and The data etc. of analog service are stored, the operating procedure of platform:
Step 1 establishes UI interactive testing model so that all operation of user be substantially from the WEB interface of platform into Row, without coding;
Step 2 generates test frame, comprising: unit testing frame, integration testing frame, function using test model Test frame and pressure test frame;
Step 3 executes decoupling when the case where decoupling relies on is presented and relies on, to get around the interface of relied on external service;
Step 4 writes test event, by simulating the test case of external service or registering customized Service events Api function, by the scripting editing write into test frame in corresponding simulator;
Step 5 implements simulation test matching, returns to corresponding response in simulator;
Step 6, log recording can carry out the record of log, check, download and clear up, if successful match, return default The log of response;If it fails to match, the log of forwarding is returned;
Step 7, simulated database collect test data, store and manage,
The test frame is applicable in scene: 1) functional test, integration testing and unit testing
Test or research staff pass through handle when doing functional test, integration testing, unit testing even functional development Own services are docked to platform simulator, can simply get around external unstable, unavailable, complicated external service service around Open and can simulate any return of external service.User only need to pay close attention to own services functionally and logically to realize pair The decoupling of external service relies on.
2) performance test
When tester does pressure survey, the pressure survey packet that platform provides is downloaded on pressure survey machine and started.Pressure surveys packet Can independent startup high performance analog service, peaceful playscript with stage directions body is docked by interface and acquisition stake and link dependency number on startup According to.User, which presses, to be relied on service without deployment outside when survey and makes high-volume outside pressure measured data, as long as simply outside Rely on the performance and pressure measured data for being changed to connection simulator and paying close attention to tested service itself.The pressure that the platform provides surveys packet, branch Service simulation when the pressure of puppy parc and custom protocol is surveyed is held, and presses that survey packet be also the stake using web interface given link Setting is configured without repeating.Step are as follows: the pressure that a key download platform first provides surveys packet, and starting pressure surveys simulator, carries out pressure Simulation test is directly viewable test result by interface.
It should be appreciated that protocol service is divided into puppy parc service and custom protocol service in the present embodiment, have Body, service analog platform has the scheme of following several simulations for different agreement service:
1) HTTP/Thrift protocol emulation (puppy parc simulation):
Platform simulator is directed toward in IP (passing through modification DNS configuration) address that user services B, by built in platform The port of the monitored link of simulator starting is directed toward in the request that Nginx services A.
2) OSP protocol emulation (custom protocol simulation):
User is pointing directly at the IP that B is serviced by the IP and port of the static routing of OSP the IP and corresponding OSP of simulator The port of the monitored link of link.
It should be added that Nginx is the Reverse Proxy of an open source, platform has only used Nginx Port mapping function, is used for http protocol or Thrift protocol emulation, Nginx built in platform, and user no longer needs to using server Nginx is operated, need to only be configured on the page.Such as it is in Nginx configuration page configuration: Server Name: Cart.api.vip.com listen Port:80 default listening port: 1234, actually a configuration text can be generated in Nginx Part content is as follows:
The request and port for indicating the domain cart.api.vip.com are 80, and being uniformly forwarded to listening port is 1234 Link.Such as request is http://cart.api.vip.com:80/xxx, becomes http after forwarding by Nginx: // 127.0.0.1:1234。
The principle of Nginx reverse proxy, which refers to, receives the connection request on internet with proxy server, then will The server being transmitted on internal network is requested, and the result obtained from server is returned to and requests to connect on internet Client, proxy server externally will appear as a server at this time.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, method, article or the device that include a series of elements not only include those elements, and And further include the other elements being not explicitly listed, or further include for this process, method, article or device institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do There is also other identical elements in the process, method of element, article or device.The embodiments of the present invention are only Description, does not represent the advantages or disadvantages of the embodiments.Through the above description of the embodiments, those skilled in the art can be clearly Recognize that above-described embodiment method can add the mode of required generic hardware system to realize by software, naturally it is also possible to pass through Hardware, but the former is more preferably embodiment in many cases.Based on this understanding, technology configuration of the invention substantially or Person says that the part that contributes to existing technology can be embodied in the form of software products, computer software product storage In a storage medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal device (can be The electronic equipments such as mobile phone, computer, server or the network equipment) execute method described in each embodiment of the present invention.
The above is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all in the present invention Inventive concept under, using equivalent structure transformation made by description of the invention and accompanying drawing content, or directly/be used in it indirectly He is included in scope of patent protection of the invention relevant technical field.

Claims (8)

1. a kind of method of analog service, which is characterized in that comprising steps of
The matched data of simulation are completed in crawl, extract simulation matching condition and response record from being completed in the matched data of simulation It is made as public stake;
The IP address of public stake is configured, control with public stake there is the link of same IP address to call public stake;
With the simulation matching condition in the public stake called, the tested clothes by having same IP address with the link are executed The simulation that business issues matches order;
If present day analog successful match, the response is returned to tested service;
The matched data of simulation are completed in the crawl, extract simulation matching condition and sound from being completed in the matched data of simulation The step of should being recorded as public stake includes:
The matched data of simulation are completed in crawl external system, are the first public stake by the data recording grabbed;
The data that it fails to match in the completed simulation matching of this system are grabbed, are second public by the data recording grabbed Stake.
2. the method for analog service as described in claim 1, which is characterized in that redis was that external system generates includes outer The caching for simulating matched data is completed in system, and can be public by network, and simulation is completed in the crawl external system The data matched, by the data recording grabbed be first public the step of include:
The communication connection with external system is established, the recording rule of the first public stake is arranged;
According to the recording of the first public stake of agreement rule, the redis generated by external system is grabbed;
Grabbed redis is parsed, completed simulation matching condition and response are extracted from redis;
It records extracted simulation matching condition and response is the first public stake.
3. the method for analog service as described in claim 1, which is characterized in that the completed simulation of crawl this system The data that it fails to match in matching, it is public to be recorded as second for extraction simulation matching condition and response from the data that it fails to match Stake the step of include:
Arrange the recording rule of the second public stake;
According to the recording of the second public stake of agreement rule, what it fails to match in the completed simulation matching of crawl this system Data;
Simulation matching condition and response are extracted from the data grabbed;
It records extracted simulation matching condition and response is the second public stake.
4. the method for analog service as described in any one of claims 1 to 3, which is characterized in that described with the simulation With condition, the present day analog for executing the received same IP address of the link matches the step of ordering and includes:
The matched request of present day analog that the tested service that receiving has same IP address with the link issues;
The public stake called is parsed, with release simulation matching condition and response;
With the simulation matching condition discharged, the present day analog matching order of the request is executed.
5. a kind of device of analog service characterized by comprising
The matched data of simulation are completed for grabbing in handling module;
Module is recorded, for being public stake by the data recording grabbed;
Parsing module, for parsing the public stake called, with release simulation matching condition and response;
IP configuration module, for configuring the IP address of the public stake;
Control module calls public stake for controlling the link for having same IP address with public stake;
Receiving module matched is asked for receiving the present day analog that the tested service for having same IP address with the link issues It asks;
Execution module executes the present day analog of the received same IP address of the link for using the simulation matching condition Matching order;
Respond module returns to the response to tested service if being used for present day analog successful match;
The handling module include the first picking unit and the second picking unit, the recordings module include the first recording elements with Second recording elements;
First picking unit simulates matched data for grabbing being completed for external system;
Second picking unit, for grabbing the data that it fails to match in the completed simulation matching of this system;
First recording elements, the data recording for being grabbed the first picking unit are the first public stake;
Second recording elements, the data recording for being grabbed the second picking unit are the second public stake.
6. the device of analog service as claimed in claim 5, which is characterized in that first picking unit includes:
Subelement is established, for establishing and the communication connection relationship of external system;
First about stator unit, the recording for arranging the first public stake is regular;
First crawl subelement, the recording for the first public stake according to the agreement is regular, grabs by the complete of external system The redis generated at matched data are simulated;
First extracts subelement, and for parsing the redis, simulation matching condition and response are extracted from the data grabbed.
7. the device of analog service as claimed in claim 5, which is characterized in that second picking unit includes:
Second about stator unit, the recording for arranging the second public stake is regular;
Second crawl subelement, the recording for the second public stake according to the agreement is regular, and crawl this system is completed The data that it fails to match in simulation matching;
Second extract subelement, for from the data that it fails to match extract the completed simulation matching condition of this system with Response.
8. a kind of centralized management platform of analog service characterized by comprising
One or more different agreements as the described in any item analog services of claim 5-7 device;And
Various protocols service platform is simulated, for receiving request, simulates various protocols service function platform processes service request;And
UI interactive module edits static state HTML, for establishing the model and interaction specifications of UI interactive testing to be responsible for all simulations The interaction docking of service;And
Simulation test structure module establishes simulation test frame for simulating different test-types;And
Depending module is decoupled, when decoupling the case where relying on for rendering, decoupling is executed and relies on, with the relied on external service of bypass Interface;And
Log management module, for providing log management function, can to the result of simulation test carry out log record, check, Downloading and cleaning;And
Simulated database, for storing all data of analog service.
CN201611152471.XA 2016-12-13 2016-12-13 A kind of method, apparatus and centralized management platform of analog service Active CN106603283B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611152471.XA CN106603283B (en) 2016-12-13 2016-12-13 A kind of method, apparatus and centralized management platform of analog service

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611152471.XA CN106603283B (en) 2016-12-13 2016-12-13 A kind of method, apparatus and centralized management platform of analog service

Publications (2)

Publication Number Publication Date
CN106603283A CN106603283A (en) 2017-04-26
CN106603283B true CN106603283B (en) 2019-09-13

Family

ID=58802436

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611152471.XA Active CN106603283B (en) 2016-12-13 2016-12-13 A kind of method, apparatus and centralized management platform of analog service

Country Status (1)

Country Link
CN (1) CN106603283B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107579879A (en) * 2017-09-26 2018-01-12 深圳震有科技股份有限公司 A kind of network simulation method of testing, emulation server and storage medium
CN110032454A (en) * 2018-01-12 2019-07-19 北京京东尚科信息技术有限公司 Remote invocation method, system and relevant device and computer readable storage medium
CN108268375B (en) * 2018-01-12 2021-04-30 深圳壹账通智能科技有限公司 Application program testing method and device, computer equipment and storage medium
CN108897691B (en) * 2018-06-29 2022-02-15 百度在线网络技术(北京)有限公司 Data processing method, device, server and medium based on interface simulation service
CN109271325B (en) * 2018-10-26 2022-11-04 携程旅游网络技术(上海)有限公司 Application testing method, system, electronic device and storage medium
CN110704262A (en) * 2019-09-17 2020-01-17 广州市玄武无线科技股份有限公司 Dynamic service logic debugging method, system, storage medium and intelligent device
CN112702436B (en) * 2020-12-29 2023-06-20 广州品唯软件有限公司 Flow recording method, device, computer equipment and storage medium
CN114553929B (en) * 2022-01-10 2024-04-12 多点生活(成都)科技有限公司 Recording playback enhancement method and device for recording call dynamic Mock
CN114973515A (en) * 2022-01-25 2022-08-30 浙江浩瀚能源科技有限公司 Plug-and-play charging function testing method and device for charging pile and storage medium
CN115033495B (en) * 2022-08-02 2022-12-20 荣耀终端有限公司 Pressure measurement model creating method and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1873626A (en) * 2005-06-01 2006-12-06 中兴通讯股份有限公司 Unit test system and method for automatic generating stub and driving function
CN101110055A (en) * 2007-08-31 2008-01-23 中兴通讯股份有限公司 Device for implementing general use pile function in unit test and implementing method thereof
CN102740342A (en) * 2012-06-08 2012-10-17 大唐移动通信设备有限公司 Network management equipment performance simulation test method and system
CN104683386A (en) * 2013-11-26 2015-06-03 腾讯科技(深圳)有限公司 Pile service implementation method and device capable of customizing response
CN105302721A (en) * 2015-10-29 2016-02-03 普元信息技术股份有限公司 System and method for realizing integration testing of centralized analog server in cloud computing platform

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FI20115104A0 (en) * 2011-02-02 2011-02-02 Teknologian Tutkimuskeskus Vtt Oy SYSTEM AND METHOD FOR MODEL-BASED TESTING

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1873626A (en) * 2005-06-01 2006-12-06 中兴通讯股份有限公司 Unit test system and method for automatic generating stub and driving function
CN101110055A (en) * 2007-08-31 2008-01-23 中兴通讯股份有限公司 Device for implementing general use pile function in unit test and implementing method thereof
CN102740342A (en) * 2012-06-08 2012-10-17 大唐移动通信设备有限公司 Network management equipment performance simulation test method and system
CN104683386A (en) * 2013-11-26 2015-06-03 腾讯科技(深圳)有限公司 Pile service implementation method and device capable of customizing response
CN105302721A (en) * 2015-10-29 2016-02-03 普元信息技术股份有限公司 System and method for realizing integration testing of centralized analog server in cloud computing platform

Also Published As

Publication number Publication date
CN106603283A (en) 2017-04-26

Similar Documents

Publication Publication Date Title
CN106603283B (en) A kind of method, apparatus and centralized management platform of analog service
CN106776313A (en) A kind of method of analog service, device and centralized management platform
CN109889551A (en) A kind of method of the Internet of Things cloud platform of Intelligent hardware access
CN104579822B (en) Mobile application automated performance testing system and method based on Http agreements
US8713177B2 (en) Remote management of networked systems using secure modular platform
US7117411B2 (en) Methods and systems for testing communications network components
CN108427631A (en) A kind of application test systems, method, electronic equipment and readable storage medium storing program for executing
US10310594B2 (en) Knowledge base in virtual mobile management
CN104636146A (en) Online visual customizing method and system
CN102571396A (en) Communication network system and routing inspection subsystem and routing inspection method of communication equipment
CN107332857B (en) Network data transmission method, device, system and storage medium
JP2011086291A (en) System landscape-compatible inter-application communication infrastructure
CN113419940B (en) Program log acquisition and regression method and corresponding device, equipment and medium thereof
US20210034338A1 (en) Communications Enablement Platform, System, and Method
CN113658591B (en) Voice interaction adaptation system for intelligent home
WO2021244644A1 (en) Method for dynamically integrating application, and software system and machine therefor
CN110049001A (en) A kind of method, apparatus, storage medium and server for realizing WebService service
CN107395747A (en) A kind of high extended method based on STF platforms
CN111176662B (en) Architecture implementation method capable of being freely assembled and deployed in distributed and single environment and deployment method
CN101997721A (en) System, method and corresponding device for managing telecommunication network
CN115150377A (en) Method and device for calling and processing simulation interface
CN105656974B (en) A kind of Satellite Observations processing method and system
CN101969442B (en) Process running environment perception and migration based network analog framework implementation method
CN113518022A (en) Method for connection configuration of user equipment and household equipment
CN111221687B (en) Cloud storage testing system and method

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
TA01 Transfer of patent application right

Effective date of registration: 20171205

Address after: 510000 Guangzhou City, Guangzhou, Guangdong, Fangcun Avenue, one of the 314 self compiled

Applicant after: Guangzhou Pinwei Software Co., Ltd.

Address before: Liwan District Fangcun Huahai street Guangzhou city Guangdong province 510000 No. 20 self 1-5 building (only for office use)

Applicant before: Guangzhou VIPSHOP Information and Technology Co., Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20220106

Address after: 510000 Room 601, 128 Dingxin Road, Haizhu District, Guangzhou City, Guangdong Province (office only)

Patentee after: Vipshop (Guangzhou) Software Co.,Ltd.

Address before: 510000 No. 314, Fangcun Avenue, Liwan District, Guangzhou City, Guangdong Province

Patentee before: GUANGZHOU PINWEI SOFTWARE Co.,Ltd.

TR01 Transfer of patent right