CN114625645A - Service testing method and device, electronic equipment and readable storage medium - Google Patents

Service testing method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN114625645A
CN114625645A CN202210242959.0A CN202210242959A CN114625645A CN 114625645 A CN114625645 A CN 114625645A CN 202210242959 A CN202210242959 A CN 202210242959A CN 114625645 A CN114625645 A CN 114625645A
Authority
CN
China
Prior art keywords
target service
service
sandbox
return value
test
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210242959.0A
Other languages
Chinese (zh)
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.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology 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 Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202210242959.0A priority Critical patent/CN114625645A/en
Publication of CN114625645A publication Critical patent/CN114625645A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/52Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow
    • G06F21/53Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow by executing in a restricted environment, e.g. sandbox or secure virtual machine

Abstract

The invention provides a business testing method, a device, electronic equipment and a readable storage medium, wherein the method comprises the steps of obtaining sandbox configuration corresponding to a target service in a business test, deploying the sandbox service to the target service in the operation process according to the sandbox configuration, recording flow records of the target service in the operation process through the sandbox service, generating automatic cases corresponding to the flow records from the flow records according to request information and return value information, and carrying out the business test on the target service by adopting the automatic cases. The automatic use case is obtained by recording flow record conversion generated by the target service in the operation process, the conversion cost of the automatic use case is reduced, the conversion efficiency is improved, the sandbox configuration is obtained, the corresponding sandbox service can be automatically deployed by the target service in the operation process, the flow record, the automatic conversion automatic use case and the like of the target service in the operation process are recorded, and the learning and maintenance cost of bottom layer codes is effectively reduced.

Description

Service testing method and device, electronic equipment and readable storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for testing a service, an electronic device, and a readable storage medium.
Background
The Interface automation test refers to an automation test based on an API (Application Programming Interface), and mainly tests an Interface through a request and response process of an automation case simulation Interface in realizing a corresponding function, and is a main means for a service side to perform a service test, which is used for verifying processes of data exchange, transmission, control management between interfaces of a system and a component, logic dependency relationship and the like, and may include a function test, a performance test, a stability test, a security test and the like.
At present, a Python script is often adopted to realize an interface automated test architecture, and a corresponding automated test case needs to be compiled, so that a certain code basis is needed in the conversion process of the automated test case, the efficiency is low, and the learning and maintenance costs are high.
Disclosure of Invention
Embodiments of the present invention provide a service testing method, an apparatus, an electronic device, and a readable storage medium, so as to improve case conversion efficiency in an interface automation test, and achieve the effect of reducing learning and maintenance costs. The specific technical scheme is as follows:
in a first aspect of the present invention, there is provided a method for testing a service, where the method includes:
obtaining sandbox configuration corresponding to the target service;
deploying sandbox services to the target service in the operation process according to the sandbox configuration;
recording a flow record of the target service in the running process through the sandbox service, wherein the flow record comprises request information of the target service and return value information of the target service;
acquiring request information of the target service and return value information of the target service from the flow record, and generating the automation case corresponding to the flow record according to the request information and the return value information;
and performing service test on the target service by adopting the automatic case.
In a second aspect of the present invention, there is also provided a service testing apparatus, which may include:
the configuration acquisition module is used for acquiring sandbox configuration corresponding to the target service;
the service deployment module is used for deploying sandbox service to the target service in the running process according to the sandbox configuration;
the flow recording module is used for recording a flow record of the target service in the running process through the sandbox service, wherein the flow record comprises request information of the target service and return value information of the target service;
the use case generation module is used for acquiring request information of the target service and return value information of the target service from the flow record and generating the automatic use case corresponding to the flow record according to the request information and the return value information;
and the business test module is used for carrying out business test on the target service by adopting the automation case.
In a third aspect of the present invention, there is also provided an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
the memory is used for storing a computer program;
the processor is configured to implement the service testing method according to the first aspect when executing the computer program stored in the memory.
In a fourth aspect implemented by the present invention, there is also a computer-readable storage medium, in which a computer program is stored, which, when run on a computer, causes the computer to execute the service testing method of the first aspect described above.
In a fifth aspect of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the service testing method of the first aspect.
In the embodiment of the invention, in the service test, the sandbox configuration corresponding to the target service can be obtained, the sandbox service is deployed to the target service in the operation process according to the sandbox configuration, the flow record of the target service in the operation process can be recorded through the sandbox service, the request information of the target service and the return value information of the target service are obtained from the flow record, an automatic case corresponding to the flow record can be generated according to the request information and the return value information, and the service test can be carried out on the target service by adopting the automatic case. The automatic use case is obtained by recording flow record conversion generated by the target service in the operation process, the conversion cost of the automatic use case is reduced, the conversion efficiency is improved, the corresponding sandbox service can be automatically deployed by the target service in the operation process by obtaining the sandbox configuration, the flow record, the automatic conversion automatic use case and the like of the target service in the operation process are recorded, and the learning and maintenance cost of the bottom layer code is effectively reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is a flowchart illustrating steps of a service testing method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a second step of a method for testing services according to an embodiment of the present invention;
fig. 3 is a schematic diagram illustrating a docking flow of an online environment deployment sandbox service according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a docking flow of deploying a sandbox service in a test environment according to an embodiment of the present invention;
fig. 5 is a schematic flow chart of flow recording noise reduction according to an embodiment of the present invention;
fig. 6 is an exemplary diagram of a method for implementing service testing by persistent integration according to an embodiment of the present invention;
FIG. 7 is an architecture diagram of a business testing system provided by an embodiment of the present invention;
fig. 8 is a block diagram of a service testing apparatus according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention.
Fig. 1 is a flowchart of steps of a service testing method according to an embodiment of the present invention, and as shown in fig. 1, the method may include:
step 101, obtaining sandbox configuration corresponding to the target service.
In the embodiment of the invention, the target service can be a business service to be tested, the testing of the target service can be simulating to initiate different request information to the target service, and the function of the target service is tested according to the return value information of the target service response to determine whether the running condition of the target service is stable, safe and the like, so as to determine whether the target service is in a normal state, an error state and the like.
The sandbox is configured to configuration information of a sandbox service, the sandbox service is used for recording traffic records of a target service in an operation process, the sandbox service can record traffic records generated in processes of realizing different functions of different target services, wherein the target service corresponding to the sandbox service can be determined through the sandbox configuration, for example, the sandbox configuration can include information such as an Internet Protocol (IP) address, a port, a selected traffic sensing plug-in, a sampling rate and the like of the target service, wherein the target service corresponding to the sandbox service can be determined according to the IP address, the port required to be monitored by the sandbox service can be determined according to the port, a tool for recording traffic can be determined according to the traffic sensing plug-in selected in the sandbox configuration, the frequency of recording the traffic records can be determined according to the sampling rate and the like, optionally, the configuration information in the sandbox configuration can be preset according to requirements, And storing, where the sandbox configuration corresponding to the target service may be obtained from the stored sandbox configuration when performing a business test on the target service, and this is not particularly limited in the embodiment of the present invention.
And 102, deploying sandbox service to the target service in the running process according to the sandbox configuration.
In the embodiment of the invention, the target service can receive the request in the operation process and respond to the request to send the return value information to realize the corresponding function, and the deployment of the sandbox service to the target service in the operation process according to the sandbox configuration can be realized in the condition that the target service is in the operation process of the target service, the sandbox service is constructed according to the configuration information of the sandbox configuration, for example, the corresponding port is monitored according to the flow sensing plug-in arranged in the sandbox configuration, the target service is associated according to the address in the sandbox configuration, the sampling rate is set, and the like.
103, recording a flow record of the target service in the running process through the sandbox service, wherein the flow record comprises request information of the target service and return value information of the target service.
In the embodiment of the invention, the flow record can comprise request information received by the target service in the operation process and return value information sent by responding to the request information, a one-time complete flow of the function of the target service can be reflected, the flow record can be recorded through the sandbox service, and the incoming and outgoing flow data can be copied and stored, for example, in the operation process of the target service, the request information, the return value information corresponding to the request information, the request information for sub-calling and the return value information corresponding to the request information for sub-calling can be recorded, so as to obtain the flow record of the target service in the operation process.
The recorded traffic record may also be displayed, where the recorded traffic record may be displayed in real time during the recording process, or a query service for the traffic record may be provided after the recording is finished, and the traffic record is displayed when a query request corresponding to the traffic record is received.
And 104, acquiring request information of the target service and return value information of the target service from the flow record, and generating the automation case corresponding to the flow record according to the request information and the return value information.
In the embodiment of the invention, the recorded flow records can be converted into the automatic cases, so that the automatic cases can send the request information received in the operation process to the target service to be tested in the service test, and test the return value information returned according to the request information and the return value information returned by the target service in the operation process, wherein the automatic cases can be divided into core cases, conventional cases, abnormal cases and the like according to the test requirements, the core cases can be obtained by converting the flow records recorded in the operation process of the target service on-line environment manual test, the conventional cases can be obtained by converting the flow records recorded in the on-line environment operation process based on the target service, and the abnormal cases can be obtained by converting the flow records recorded in the abnormal environment operation process based on the target service.
And 105, performing service test on the target service by adopting the automation case.
In the embodiment of the invention, the automatic case can be played back in the target service according to the requirement so as to carry out the business test on the target service, namely, the automatic case can be executed to send the request information to the target service to be tested, the return value information of the target service to the request information is received, and the business test on the target service end can be realized by comparing whether the return value information accords with the return value information in the flow record adopted by the automatic case.
And playing back a plurality of automatic use cases on the target service to be tested in batch, and comparing the return value information played back by the automatic use cases on the target service with the return value information in the flow record.
In the embodiment of the invention, in the service test, the sandbox configuration corresponding to the target service can be obtained, the sandbox service is deployed to the target service in the operation process according to the sandbox configuration, the flow record of the target service in the operation process can be recorded through the sandbox service, the request information of the target service and the return value information of the target service are obtained from the flow record, an automatic case corresponding to the flow record can be generated according to the request information and the return value information, and the service test can be carried out on the target service by adopting the automatic case. The automatic use case is obtained by recording flow record conversion generated by the target service in the operation process, the conversion cost of the automatic use case is reduced, the conversion efficiency is improved, the corresponding sandbox service can be automatically deployed by the target service in the operation process by obtaining the sandbox configuration, the flow record, the automatic conversion automatic use case and the like of the target service in the operation process are recorded, and the learning and maintenance cost of the bottom layer code is effectively reduced.
Fig. 2 is a second flowchart of steps of a service testing method according to an embodiment of the present invention, and as shown in fig. 2, the method may include:
step 201, receiving configuration information input aiming at a target service, wherein the configuration information comprises target service information, flow port information, flow recording tool information and a sampling rate.
In the embodiment of the present invention, configuration information entered for a target service may be received, where the configuration information may include target service information, such as a name, an identifier, and an address of the target service, traffic port information, such as a port address of data access, traffic recording tool information, such as a name, a category, a version, and a calling method of a recording tool, and a sampling rate, such as the number of copied data packets per second. The page for inputting the configuration information may also be provided to the user, so that the configuration information input for the target service is received through the page, where the configuration information may include a traffic recording mode, a requirement of a service test, an attribute of the target service, and the like, and this is not particularly limited in the embodiment of the present invention.
Step 202, establishing sandbox configuration corresponding to the target service according to the configuration information, and providing a configuration interface for obtaining the sandbox configuration.
In the embodiment of the invention, after the configuration information is received, the configuration information can be stored, for example, the configuration information can be stored in MySQL (relational database), and a calling interface capable of inquiring and calling the configuration information is provided, so that the sandbox configuration corresponding to the target service is established.
Step 203, connecting the target service.
In the embodiment of the invention, when the business test is carried out on the target service, the remote sending and the execution of the command can be realized by establishing the trust relationship with the target machine, so as to connect the target service, wherein the target machine can be a server side for operating the target service.
And 204, calling the configuration interface through a shell script to acquire the sandbox configuration corresponding to the target service.
In the embodiment of the invention, the command can be remotely sent and executed through the Shell script, wherein the Shell script is an execution file consisting of Shell commands, the commands can be integrated into one file for service logic processing, the Shell script can run through the interpretation of an interpreter without compiling, and after the target service is connected, the calling command can be executed through the Shell script to call the configuration interface which is provided by the database and corresponds to the target service, so that the sandbox configuration corresponding to the target service is inquired and obtained.
And step 205, deploying the sandbox service to the target service in the operation process according to the sandbox configuration by adopting an attach mode.
In the embodiment of the invention, the sandbox configuration can be deployed on the process of the target service in an attach mode, the process refers to an instance of the service in the running process, the attach is a mode of inter-process communication, and the sandbox service can record the flow generated in the running process of the target service in the attach mode, so that the deployment of the sandbox service is realized.
In addition, according to the requirement, the embodiment of the present invention may deploy sandbox services to the target services in the running process in the online environment and the offline environment, where the online environment refers to an environment accessed by the user and generally provides services for the user, and the offline environment may include other environments that are not open to the user, such as a development environment and a test environment.
Fig. 3 is a schematic diagram of a docking process of an online environment deployed sandbox service according to an embodiment of the present invention, where when online deployment is performed, auditing, authorization, and the like need to be performed in advance, and at this time, an auditing process of an online publishing platform may be docked by a recording/playback platform service, so as to improve online deployment efficiency of the sandbox service, specifically as shown in fig. 3, the method includes developing a recording/playback platform service (Recorder) based on a business requirement, and an online publishing platform, where an online publishing platform is used for publishing different services facing a user, and the docking process is as follows:
step S11, an online application of the sandbox service is established to the online publishing platform through a Recorder;
s12, the release platform creates an application work order according to the online application;
step S13, the release platform checks the application worksheet step by step through a test engineer (QA leader) and a Research and Development engineer (RD leader);
step S14, applying for operation and maintenance root authority by the Recorder under the condition that the audit is passed;
and step S15, deploying the sandbox service to the target service in the running process in the online release platform by the Recorder according to the sandbox configuration based on the root authority.
Fig. 4 is a schematic diagram of a docking process for deploying sandbox services in a test environment according to an embodiment of the present invention, where when deployment of the sandbox services is performed in an online test environment, an environment platform may be docked by using a recording/playback platform service, so that while the test environment is deployed, sandbox configuration may be obtained through a call interface, and the sandbox services are directly deployed, so as to effectively improve efficiency of the deployment process, specifically as shown in fig. 4, the docking process includes developing a recording/playback platform service (Recorder) based on a service requirement, and an environment platform, and the docking process is as follows:
step S21, building a test environment by an environment platform;
step S22, the Recorder acquires sandbox configuration through a calling interface;
step S23, Recorder deploys sandbox service in the test environment.
And step 206, recording a flow record of the target service in the running process through the sandbox service, wherein the flow record comprises request information of the target service and return value information of the target service.
In this embodiment of the present invention, the traffic record may include request information and return value information, for example, the request information may include request parameters, request header (header) information, and request body (body) information, and the traffic record may further include sub-call request information and return detailed information, for example, the return detailed information may include information such as a database, a middleware, a HTTP (hypertext Transfer Protocol) call, and a cache, and specifically, step 206 may refer to the relevant description of step 103, and is not described herein again to avoid repetition.
And step 207, playing back the flow record on the target service in a noise reduction environment to obtain noise reduction return value information returned by the target service, wherein the noise reduction environment is a test environment with a code version identical to an operating code version of the target service.
In the embodiment of the invention, the problems of poor quality and more noise points may occur in the recorded flow records due to complex and changeable running environments of the target service and multiple interference factors, so that before the automatic use case is generated through the flow records, the noise reduction treatment can be performed on the flow records to remove the interference, improve the quality of the flow records and further improve the effect of the automatic use case for service test. The noise reduction environment refers to a test environment with a code version identical to an operation code version of the target service, the operation code version refers to a code version of an operation environment where the target service is located in an operation process, and the operation environment of the target service can be an online environment, an offline environment and the like. The playback of the traffic record on the target service in the noise reduction environment may be forwarding the request information in the traffic record to the target service in the noise reduction environment, and obtaining the noise reduction return value information returned by the target service in the noise reduction environment according to the request information.
And 208, performing noise reduction processing on the flow record according to the noise reduction return value information.
In the embodiment of the present invention, the noise reduction return value information may include normal return value information, or may include abnormal return value information, where the abnormality may be request timeout, request error, inconsistency between the result and the request, or inconsistency between the noise reduction return value information returned in the noise reduction environment and return value information corresponding to the request information in the traffic record, and the like, at this time, the traffic record with the abnormal noise reduction return value information may be processed, and for example, a node with the abnormal traffic record may be stored as a noise point and is not used as a judgment basis in subsequent test execution, or an abnormal node is removed, and the embodiment of the present invention is not particularly limited to this.
Fig. 5 is a schematic flow chart of flow recording noise reduction provided in an embodiment of the present invention, and as shown in fig. 5, the process includes:
step S31, the environment platform builds a noise reduction environment:
step S32, recording the flow record of the target service in the running process in the noise reduction environment by a Recorder;
step S33, the Recorder plays back the recorded flow record in the noise reduction environment;
step S34, the Recorder acquires the noise reduction return value information returned by the target service in the playback process, compares (diff) the noise reduction return value information with the return value information in the flow record, and determines the node corresponding to the noise reduction return value information as an abnormal node when the noise reduction return value information is inconsistent with the return value information in the flow record;
and step S35, the Recorder marks or removes the abnormal node to obtain the flow record after noise reduction.
Step 209, obtaining the request information of the target service and the return value information of the target service from the flow record after the noise reduction processing, and generating the automation case corresponding to the flow record according to the request information and the return value information.
In the embodiment of the present invention, step 209 may correspond to the related description of step 104, and is not repeated herein to avoid repetition.
If the target service can realize the function of 'auditing', the flow record 1 'requesting to audit 1-pass' and the flow record 2 'requesting to audit 2-pass' are obtained by recording in the operation process, and then an automatic case 1 can be generated according to the 'requesting to audit 1' and 'pass' of the flow record 1 and is used for testing the process of the target service auditing pass; and generating an automatic case 2 according to the 'request audit 2' and 'return' of the flow record 2, wherein the automatic case is used for testing the flow of the target service audit return.
Optionally, after the step 209, the method further includes:
and step S41, receiving a query request for the automation use case.
In the embodiment of the invention, after the flow records are converted into the automatic use cases, the query service of the automatic use cases can be provided, wherein the query service of the automatic use cases can comprise detailed data query, statistical data query and the like of the automatic use cases, and different query results are returned according to different query requests. Optionally, the query request may include the data type of the query as different use case parameters, the automatic use case statistical quantity, and the like, and may also include information of a target service, a querier, and the like that request the query, which is not specifically limited in this embodiment of the present invention.
Step S42, sending use case parameters corresponding to the automatic use cases in response to the query requests, wherein the use case parameters are determined according to the flow records corresponding to the automatic use cases, and the use case parameters comprise at least one of use case types, use case identifications, use case grades and use case numbers.
In the embodiment of the present invention, the use case parameters are key information characterizing an automated use case, and optionally, may be extracted and generated from a recorded traffic record, where the use case parameters may include a use case type, a use case level, a use case identifier, use case details, a use case quantity, and the like. Furthermore, the flow records can be associated with the automation use cases generated according to the flow records, so that efficient query can be performed, for example, after the automation use cases are generated by adopting flow record conversion, the flow records and the generated automation use cases are associated and managed through a unique key (trace _ id).
Step 210, executing the automation case, and sending test request information to the target service.
In the embodiment of the invention, when the target service needs to be subjected to the service test, the automatic use case generated based on the flow record can be adopted, and the automatic use case can be executed to send the test request information to the target service, wherein the test request information is the repeated engraving of the request information in the flow record corresponding to the automatic use case, so that the request information actually received by the target service in the running process can be simulated.
For example, the automation case 1 is executed to send the test request information "request to audit 1" to the target service to be tested, and the automation case 2 is executed to send the test request information "request to audit 2" to the target service to be tested.
And step 211, obtaining test return value information returned by the target service in response to the test request information.
In the embodiment of the invention, the test return value information returned by the target service in response to the test request information can be received.
For example, the test return value information "pass" of the reception target service response test request information "request audit 1", and the test return value information "return" of the reception target service response test request information "request audit 2".
Step 212, determining a service test result of the target service according to the return value information and the test return value information corresponding to the flow record.
In the embodiment of the invention, the business test result can be obtained by comparing the return value information of the target service in the test running process with the return value information in the actual running process, when the return value information corresponding to the flow record is consistent with the test return value information, the business test of the automation case on the target service can be considered to be successful, and when the return value information corresponding to the flow record is inconsistent with the test return value information, the business test of the automation case on the target service can be considered to be failed, and the abnormality can exist.
Optionally, after the step 211, the method further includes:
step 213, obtaining the code coverage rate of the target service in the process of responding to the test request information.
In the embodiment of the invention, the target service needs to execute the corresponding codes in the process of responding to the request information, so that the business test realized by the automatic case can cover the codes executed in the process of responding to the test request information by the target service, but cannot cover the codes not executed in the process of responding to the test request information by the target service. The code coverage rate is the ratio of the code quantity executed by the target service in the process of responding to the test request information in the total code quantity, and the code coverage rates of different automation cases in the process of performing the business test on the target service may be different.
And 214, determining the coverage degree of the automatic case to the target service in the service test according to the code coverage rate.
In the embodiment of the invention, the higher the code test rate is, the larger the coverage degree of the automatic case on the target service is, so that the test degree of the automatic case on the target service can be determined through the code coverage rate, and further the test sufficiency, effectiveness and the like of the automatic case can be evaluated.
In the embodiment of the invention, the target service can be used as a black box, and the dependent sub-call is called to perform mock, wherein the mock refers to a method for creating virtual object simulation for testing an object which is not easy to construct and obtain in the test process, so that when an automatic case is played back and executed, the functional regression test can be realized and the dependence of the business test on other services can be reduced by playing back the recorded context information.
In the embodiment of the invention, in the service test, the sandbox configuration corresponding to the target service can be obtained, the sandbox service is deployed to the target service in the operation process according to the sandbox configuration, the flow record of the target service in the operation process can be recorded through the sandbox service, the request information of the target service and the return value information of the target service are obtained from the flow record, an automatic case corresponding to the flow record can be generated according to the request information and the return value information, and the service test can be carried out on the target service by adopting the automatic case. The automatic use case is obtained by recording flow record conversion generated by the target service in the operation process, the conversion cost of the automatic use case is reduced, the conversion efficiency is improved, the corresponding sandbox service can be automatically deployed by the target service in the operation process by obtaining the sandbox configuration, the flow record, the automatic conversion automatic use case and the like of the target service in the operation process are recorded, and the learning and maintenance cost of the bottom layer code is effectively reduced. In addition, after the flow record is obtained by recording, the noise reduction processing is carried out on the flow record in the noise reduction environment, so that the interference is eliminated, the stability and the conversion efficiency of the automatic case for converting the flow record are improved, and the effect of carrying out the service test by adopting the automatic case is further improved.
In the embodiment of the invention, the service test can be realized through the Continuous Integration platform in practical application, and the Continuous Integration platform is used for carrying out automatic environment deployment, recording tool deployment, automatic case playback execution, result collection and the like so as to carry out the service test on the target service in an automatic CI (Continuous Integration) process. The automation service can be an asynchronous task framework and a scheduling system (vip-joba), the vip-joba can be developed based on a distributed task scheduling platform (xxl-joba), the continuous integration platform can be Octopus deployment, code management is carried out by adopting Git (distributed version control system), automatic deployment is triggered by Git when codes are changed, and automation CI is achieved.
In the embodiment of the present invention, the scheme shown in any one of fig. 1 and fig. 2 may be implemented based on a recording/playback platform service, where the recording/playback platform service is a service that can be used to record traffic records and generate an automated use case for playback based on the traffic records, and includes functions of online, offline, activation, freezing, and the like of each functional plug-in, and the recording/playback platform service may interface traffic records of an offline environment, an online environment, and the like of a target service, so that an executable automated use case may be generated through traffic, and optionally, the recording/playback platform service may be developed based on a business test requirement of the target service.
Fig. 6 is an exemplary diagram of a method for implementing a service test by persistent integration according to an embodiment of the present invention, as shown in fig. 6, a target service 302, an accurate test service 303, a test environment 304, a user service 305, and an external platform 306 are respectively interfaced with a recording/playback platform service 301(Recorder) as a center, wherein,
the recording/playback platform service 301 is configured to sense and record traffic records of an online environment and an offline environment of the target service 302 through traffic, where the recorded traffic records include recording online request information, recording sub-call request information, and recording return value information;
the recording/playback platform service 301 is further configured to generate an automation use case according to the traffic record;
the record/playback platform service 301 is also used to control the various functional plug-ins to be brought online, taken offline, or activated, frozen, etc.
The target service 302 is a business service to be tested, the target service 302 can generate online user traffic in the process that an online environment faces to user operation, and the target service 302 can generate offline manual test traffic when the online test environment is manually tested;
the accurate test service 303 is configured to receive a recording request reported by the recording/playback platform service 301, collect code coverage of an automation case played back by the recording/playback platform service 301, and screen and optimize the automation case according to the code coverage, for example, the accurate test service 303 may delete the automation case with low code coverage;
the test environment 304 is used for simulating an online environment in which the target service operates, so that the recording/playback platform service 301 plays back an execution automation case to the target service 302 in the test environment 304, and obtains a playback result to perform a service test;
the user service 305 is configured to read information of an automation case from the recording/playback platform service 301, so as to provide a user with a display service of all information such as a flow record, an automation case, a service test result, and the like, and execute a display service of result information of an automation case, a display service of a service test report, and the like;
the user service 305 is also used to provide options for triggering functions such as playback, execution, etc. of the automated use case, so that a tester can perform manual business testing on the target service 302 through the recording/playback platform service 301;
the external platform 306 may include a Release platform (Release management) 3061, an environment platform 3062, a dynamic flow work platform 3063, and the like, wherein the Release platform 3061 is used for creating an application based on the recording/playback platform service 301 to start a process of deploying sandbox service in the online environment, and the process of deploying the sandbox service in the online environment includes online deployment application, gradual audit, authorized deployment, and the like;
the environment platform 3062 is used for implementing test environment deployment, test environment management, and updating the test environment based on the update information provided by the recording/playback platform service 301;
the dynamic flow workbench 3063 is used for interfacing the automation continuous integration platform and the recording/playback platform service 301 through the octopus plug-in, and realizing the automation service test of the CI process.
Fig. 7 is an architecture diagram of a business testing system according to an embodiment of the present invention, as shown in fig. 7, the system includes a base layer, a service layer, an agent layer, a business layer, and a platform layer, wherein,
the method comprises the steps that secondary development of a source-opening tool (a sandbox-repeater plug-in) aiming at service test is completed on a basic layer, and basic functions of flow recording/playback can be realized, specifically comprising sub-call information recording and playback, sub-call mock, JVM (Java Virtual Machine) abnormal simulation and the like, and meanwhile, the deployment process of the tool is simplified through plug-in extension, wherein the extended plug-in comprises a Rest Template (HTTP request tool), Mybatis (persistent layer framework), a Redis (Remote Dictionary Server, Remote Dictionary service), a Hibeamate (object relation mapping framework of open source codes), an Encache (in-process cache framework), a JPA (Java Persistence API, Java persistent layer API) and the like;
an operation method for the tool use state is packaged in a service layer (sandbox-container), and comprises service application, configuration management, module mounting, module activation, module freezing, heartbeat monitoring and the like, and meanwhile, entry/sub-call data query, data analysis, mock data processing, recording, playback, memory and display of mock data and the like are supported;
the method mainly provides support of a rear-end interface service for pages on an agent layer and a business layer, meets operations such as flow access, configuration, case playback execution and the like, and specifically comprises interfaces such as mounting, activating and freezing of an agent sandbox on the agent layer, and interfaces such as python case access, manual case access, online flow access and abnormal case access for case playback execution in the business layer;
and providing an interactive page for a user at a platform layer to realize functions of configuration management, use case management, flow information query, mock information query, playback task starting and the like, so that the user can access with low cost and high efficiency.
In the embodiment of the invention, on the system level, the page capable of interactive slave operation is provided for the user through the platform layer, the user does not need to develop and understand the bottom layer tool, the use efficiency of the tool can be effectively improved, meanwhile, through cross-platform butt joint, a plurality of functional platforms such as a publishing platform, an environment platform, a dynamic flow working platform, a coverage rate precision test service platform and the like are opened by taking the recording/playback platform service as the center, the standardization and automation in the realization of the business test are further improved, and the efficiency and the effect of the business test are improved.
Fig. 8 is a block diagram of a service testing apparatus 40 according to an embodiment of the present invention, and as shown in fig. 8, the apparatus may include:
a configuration obtaining module 401, configured to obtain a sandbox configuration corresponding to a target service;
a service deployment module 402, configured to deploy a sandbox service to the target service in a running process according to the sandbox configuration;
a traffic recording module 403, configured to record a traffic record of the target service in an operation process through the sandbox service, where the traffic record includes request information of the target service and return value information of the target service;
a use case generating module 404, configured to obtain request information of the target service and return value information of the target service from the traffic record, and generate the automation use case corresponding to the traffic record according to the request information and the return value information;
and a service test module 405, configured to perform a service test on the target service by using the automation case.
Optionally, the apparatus further comprises:
and the flow playback module is used for playing back the flow record on the target service in a noise reduction environment to obtain the noise reduction return value information returned by the target service, wherein the noise reduction environment is a test environment with the code version being the same as the running code version of the target service.
And the flow denoising module is used for denoising the flow record according to the denoising return value information.
The use case generating module 404 is specifically configured to obtain request information of the target service and return value information of the target service from the traffic record subjected to the noise reduction processing, and generate the automation use case corresponding to the traffic record according to the request information and the return value information.
Optionally, the apparatus further comprises:
the query request receiving module is used for receiving a query request for the automatic use case;
and the query request response module is used for responding to the query request and sending use case parameters corresponding to the automatic use cases, wherein the use case parameters are determined according to the flow records corresponding to the automatic use cases, and the use case parameters comprise at least one of use case types, use case identifications, use case grades and use case quantities.
Optionally, the service testing module 405 includes:
the case execution submodule is used for executing the automatic case and sending test request information to the target service;
the response acquisition submodule is used for acquiring test return value information returned by the target service in response to the test request information;
and the business test submodule is used for determining a business test result of the target service according to the return value information and the test return value information corresponding to the flow record.
Optionally, the apparatus further comprises:
a code coverage rate obtaining module, configured to obtain a code coverage rate of the target service in a process of responding to the test request information;
and the test coverage obtaining module is used for determining the coverage degree of the automatic case on the target service in the service test according to the code coverage.
Optionally, the apparatus further comprises:
the system comprises a configuration information receiving module, a traffic recording module and a traffic recording module, wherein the configuration information receiving module is used for receiving configuration information input aiming at a target service, and the configuration information comprises target service information, traffic port information, traffic recording tool information and a sampling rate;
and the sandbox configuration establishing module is used for establishing the sandbox configuration corresponding to the target service according to the configuration information and providing a configuration interface for acquiring the sandbox configuration.
Optionally, the configuration obtaining module includes:
the target service connection submodule is used for connecting the target service;
and the sandbox configuration acquisition submodule is used for calling the configuration interface through the shell script and acquiring the sandbox configuration corresponding to the target service.
Optionally, the service deployment module 402 is specifically configured to deploy the sandbox service to the target service in the operation process according to the sandbox configuration in an attach manner.
In the embodiment of the invention, in the service test, the sandbox configuration corresponding to the target service can be obtained, the sandbox service is deployed to the target service in the operation process according to the sandbox configuration, the flow record of the target service in the operation process can be recorded through the sandbox service, the request information of the target service and the return value information of the target service are obtained from the flow record, an automatic case corresponding to the flow record can be generated according to the request information and the return value information, and the service test can be carried out on the target service by adopting the automatic case. The automatic use case is obtained by recording flow records generated by the target service in the operation process and converting the flow records, so that the conversion cost of the automatic use case is reduced, the conversion efficiency is improved, the corresponding sandbox service can be automatically deployed by the target service in the operation process by obtaining the sandbox configuration, the flow records, the automatic conversion automatic use case and the like of the target service in the operation process are recorded, and the learning and maintenance cost of bottom layer codes is effectively reduced. In addition, after the flow record is obtained by recording, the noise reduction processing is carried out on the online user flow in the noise reduction environment, so that the interference is eliminated, the stability and the conversion efficiency of the automatic case for converting the flow record are improved, and the effect of carrying out the service test by adopting the automatic case is further improved.
Fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present invention, as shown in fig. 9, including a processor 501, a communication interface 502, a memory 503, and a communication bus 504, where the processor 501, the communication interface 502, and the memory 503 are configured to communicate with each other through the communication bus 504,
a memory 503 for storing a computer program;
the processor 501, when executing the program stored in the memory 503, implements the following steps:
obtaining sandbox configuration corresponding to the target service;
deploying sandbox services to the target service in the operation process according to the sandbox configuration;
recording a flow record of the target service in the running process through the sandbox service, wherein the flow record comprises request information of the target service and return value information of the target service;
acquiring request information of the target service and return value information of the target service from the flow record, and generating the automation case corresponding to the flow record according to the request information and the return value information;
and adopting the automatic case to carry out business test on the target service.
The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The Memory may include a Random Access Memory (RAM), and may also include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In a further embodiment provided by the present invention, a computer-readable storage medium is further provided, in which instructions are stored, and when the instructions are executed on a computer, the instructions cause the computer to execute the service testing method described in any one of the above embodiments.
In a further embodiment of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the method of service testing as described in any of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to be performed in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A method for service testing, the method comprising:
obtaining sandbox configuration corresponding to the target service;
deploying sandbox services to the target service in the operation process according to the sandbox configuration;
recording a flow record of the target service in the running process through the sandbox service, wherein the flow record comprises request information of the target service and return value information of the target service;
acquiring request information of the target service and return value information of the target service from the flow record, and generating the automation case corresponding to the flow record according to the request information and the return value information;
and performing service test on the target service by adopting the automatic case.
2. The method according to claim 1, wherein before the obtaining request information of the target service and return value information of the target service from the traffic record and generating the automation use case corresponding to the traffic record according to the request information and the return value information, the method further comprises:
the flow record is played back on the target service in a noise reduction environment to obtain noise reduction return value information returned by the target service, wherein the noise reduction environment is a test environment with the same code version as the running code version of the target service;
carrying out noise reduction processing on the flow record according to the noise reduction return value information;
the acquiring request information of the target service and return value information of the target service from the flow record, and generating the automation case corresponding to the flow record according to the request information and the return value information includes:
and acquiring request information of the target service and return value information of the target service from the flow records after the noise reduction processing, and generating the automation use case corresponding to the flow records according to the request information and the return value information.
3. The method according to claim 1, wherein after the obtaining request information of the target service and the return value information of the target service from the traffic record and generating the automation use case corresponding to the traffic record according to the request information and the return value information, the method further comprises:
receiving a query request for the automation use case;
and responding to the query request to send use case parameters corresponding to the automatic use case, wherein the use case parameters are determined according to the flow records corresponding to the automatic use case, and the use case parameters comprise at least one of use case type, use case identification, use case grade and use case quantity.
4. The method of claim 1, wherein the employing the automation use case to conduct business testing on the target service comprises:
executing the automation case, and sending test request information to the target service;
obtaining test return value information returned by the target service in response to the test request information;
and determining a service test result of the target service according to the return value information and the test return value information corresponding to the flow record.
5. The method of claim 4, wherein after obtaining the test return value information returned by the target service in response to the test request information, further comprising:
acquiring the code coverage rate of the target service in the process of responding to the test request information;
and determining the coverage degree of the automatic case to the target service in the service test according to the code coverage rate.
6. The method of claim 1, wherein before obtaining the sandbox configuration corresponding to the target service, the method comprises:
receiving configuration information input aiming at a target service, wherein the configuration information comprises target service information, flow port information, flow recording tool information and a sampling rate;
establishing sandbox configuration corresponding to the target service according to the configuration information, and providing a configuration interface for acquiring the sandbox configuration;
the obtaining of the sandbox configuration corresponding to the target service includes:
connecting the target service;
and calling the configuration interface through a shell script to obtain the sandbox configuration corresponding to the target service.
7. The method of claim 1, wherein deploying sandboxed services to the target service in a running process according to the sandbox configuration comprises:
and deploying the sandbox service to the target service in the operation process according to the sandbox configuration in an attach mode.
8. A traffic testing apparatus, characterized in that the apparatus comprises:
the configuration acquisition module is used for acquiring sandbox configuration corresponding to the target service;
the service deployment module is used for deploying sandbox service to the target service in the running process according to the sandbox configuration;
the flow recording module is used for recording a flow record of the target service in the running process through the sandbox service, wherein the flow record comprises request information of the target service and return value information of the target service;
the use case generation module is used for acquiring request information of the target service and return value information of the target service from the flow record and generating the automatic use case corresponding to the flow record according to the request information and the return value information;
and the business test module is used for carrying out business test on the target service by adopting the automation case.
9. An electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
the memory is used for storing a computer program;
the processor is configured to implement the service testing method according to any one of claims 1 to 7 when executing the computer program stored in the memory.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the service testing method according to any one of claims 1 to 7.
CN202210242959.0A 2022-03-11 2022-03-11 Service testing method and device, electronic equipment and readable storage medium Pending CN114625645A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210242959.0A CN114625645A (en) 2022-03-11 2022-03-11 Service testing method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210242959.0A CN114625645A (en) 2022-03-11 2022-03-11 Service testing method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN114625645A true CN114625645A (en) 2022-06-14

Family

ID=81901582

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210242959.0A Pending CN114625645A (en) 2022-03-11 2022-03-11 Service testing method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114625645A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115203063A (en) * 2022-09-16 2022-10-18 平安银行股份有限公司 Playback method and system of production flow re-running risk program based on real-time recording
CN115834443A (en) * 2022-09-07 2023-03-21 深圳依时货拉拉科技有限公司 Flow playback method and device, computer equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115834443A (en) * 2022-09-07 2023-03-21 深圳依时货拉拉科技有限公司 Flow playback method and device, computer equipment and storage medium
CN115203063A (en) * 2022-09-16 2022-10-18 平安银行股份有限公司 Playback method and system of production flow re-running risk program based on real-time recording

Similar Documents

Publication Publication Date Title
US7917896B2 (en) Extensible execution language
CN107122258B (en) Method and equipment for checking state code of test interface
US8141043B2 (en) Automated business process testing that spans multiple platforms or applications
CN114625645A (en) Service testing method and device, electronic equipment and readable storage medium
CN112131829A (en) Verification method, system and related device of chip register
CN111897724B (en) Automatic testing method and device suitable for cloud platform
CN112052172B (en) Rapid test method and device for third-party channel and electronic equipment
CN112199300B (en) Interface testing method and device, electronic equipment and storage medium
CN110879781B (en) Program debugging method, device, electronic equipment and computer readable storage medium
CN111522728A (en) Method for generating automatic test case, electronic device and readable storage medium
CN112260885B (en) Industrial control protocol automatic test method, system, device and readable storage medium
CN115080398A (en) Automatic interface test system and method
CN112650688A (en) Automated regression testing method, associated device and computer program product
CN111857103B (en) Vehicle diagnosis method, device, equipment and storage medium
KR20070104202A (en) Automation test service system for view software of portable telephone and method thereof
CN114077540A (en) Interface test system and interface test method
CN116719735A (en) Test case generation method and device
CN115396501B (en) Information processing method and device, electronic equipment and readable storage medium
CN111708712A (en) User behavior test case generation method, flow playback method and electronic equipment
CN111078527B (en) Auxiliary system and method for pressure testing of server
CN110806981B (en) Application program testing method, device, equipment and storage medium
US20220197945A1 (en) Computer-implemented method for analyzing a transaction log
CN115373973A (en) Software system testing method and device
CN115373970A (en) Software system testing method and device
CN116932306A (en) Electronic equipment testing device, method and testing equipment

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