CN112527568A - Data flow testing method and device, electronic equipment and storage medium - Google Patents

Data flow testing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112527568A
CN112527568A CN202011552435.9A CN202011552435A CN112527568A CN 112527568 A CN112527568 A CN 112527568A CN 202011552435 A CN202011552435 A CN 202011552435A CN 112527568 A CN112527568 A CN 112527568A
Authority
CN
China
Prior art keywords
data
response text
tested
character string
stream file
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
CN202011552435.9A
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.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management 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 Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202011552435.9A priority Critical patent/CN112527568A/en
Publication of CN112527568A publication Critical patent/CN112527568A/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/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • 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/3684Test management for test design, e.g. generating new test cases
    • 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/3692Test management for test results analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/116Details of conversion of file system types or formats

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Computer Hardware Design (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention relates to the technical field of big data, and provides a data flow testing method, a device, electronic equipment and a storage medium, wherein the method comprises the following steps: receiving a flow recording playback request of an application to be tested, which is sent by a tested service system; analyzing and acquiring a first data stream file to be tested and backing up the first data stream file to a database file system; performing database mirror image recovery on the first data stream file in the database file system to obtain a first response text of the application to be tested; monitoring the flow record of the application to be tested to obtain a second data stream file, and playing back the second data stream file to obtain a second response text; and comparing the first response text with the second response text to generate test result data. The invention keeps the basic data before playback consistent with the basic data during recording, thereby improving the accuracy of the test result data returned by the flow recording and playback.

Description

Data flow testing method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of big data, in particular to a data flow testing method and device, electronic equipment and a storage medium.
Background
With the development of the information industry, more and more application systems are brought online, when the application systems need to be modified, regression testing needs to be performed on the whole module, in the prior art, regression testing is performed through a flow recording playback or drainage testing scheme, the flow recording playback scheme is that after data stream files of the application systems are recorded, flow is stored in the tested system in a file mode for regression testing, the drainage testing scheme is that flow in the running process of the application systems is guided to the tested system in a file flow mode for regression testing, and feedback of the tested system is observed, however, the flow recording playback or drainage testing scheme has the phenomenon of consistency of environment basic data, and the accuracy of testing result data returned by the regression testing is low.
Disclosure of Invention
In view of the above, it is necessary to provide a data traffic testing method, apparatus, electronic device and storage medium, which can improve the accuracy of the test result data returned by the traffic recording and playback by keeping the basic data before playback consistent with the basic data during recording.
A first aspect of the present invention provides a data traffic testing method, where the method includes:
receiving a flow recording playback request of an application to be tested, which is sent by a tested service system;
analyzing the flow recording and playback request to obtain a first data stream file of the application to be tested, and backing up the first data stream file to a database file system;
performing database mirror image recovery on the first data stream file in the database file system to obtain a first response text of the application to be tested;
monitoring the flow recording of the application to be tested to obtain a second data stream file, and playing back the second data stream file to obtain a second response text;
and comparing the first response text with the second response text to generate test result data.
Optionally, the comparing the first response text with the second response text to generate test result data includes:
converting the first response text into a first character string and converting the second response text into a second character string;
identifying format types of the first response text and the second response text;
comparing the first character string with the second character string according to the format type to obtain a comparison result;
when the comparison result is that the first character string is consistent with the second character string, generating test result data of the application to be tested, which is tested successfully; or
And when the comparison result is that the first character string is inconsistent with the second character string, the application to be tested fails to test the test result data.
Optionally, when the format type is a Json format type, the comparing the first character string with the second character string according to the format type to obtain a comparison result includes:
parsing the first response text into a first directory tree and parsing the second response text into a second directory tree;
traversing first data of each node of each layer from a root node of the first directory tree, and judging whether the first data of each node of each layer of the first directory tree is the same as second data of the same node of the same layer of the second directory tree;
when the first data of each node of each layer of the first directory tree is the same as the second data of the same node of the same layer of the second directory tree, generating a comparison result that the first character string is consistent with the second character string; or
And when the first data of any node of any layer of the first directory tree is different from the second data of the same node of the same layer of the second directory tree, generating a comparison result that the first character string is inconsistent with the second character string.
Optionally, the traversing the first data of each node of each layer from the root node of the first directory tree includes:
judging whether each layer has a plurality of child nodes;
when a plurality of child nodes exist in each layer, sequencing the child nodes according to a preset rule, and determining the node sequenced at the first as an initial node;
and traversing the first data of each node of each layer in turn from the initial node of each layer.
Optionally, when the format type is an XML format type, the comparing the first character string with the second character string according to the format type to obtain a comparison result includes:
converting the first response text into a first DOM tree, and converting the second response text into a second DOM tree;
judging whether the layer number of the first DOM tree is the same as that of the second DOM tree or not;
comparing third data of each layer of the first DOM tree with fourth data of the same layer of the second DOM tree when the layer number of the first DOM tree is the same as that of the second DOM tree;
when the third data of each layer of the first DOM tree is the same as the fourth data of the same layer of the second DOM tree, generating a comparison result that the first character string is consistent with the second character string; or
And when the third data of any layer of the first DOM tree is different from the fourth data of the same layer of the second DOM tree, generating a comparison result that the first character string is inconsistent with the second character string.
Optionally, the performing data mirror recovery on the first data stream file in the database file system to obtain the first response text of the application to be tested includes:
replacing the first data stream file with a directory file mounted by a mirror image container;
and restarting the directory file mounted in the mirror image container in the database file system to obtain a first response text of the application to be tested.
Optionally, the playing back the second data stream file to obtain a second response text includes:
identifying a protocol format file type of the second data stream file;
calling a corresponding flow playback player according to the protocol format file type;
and playing back the second data stream file by using the flow playback player to obtain a second response text.
A second aspect of the present invention provides a data traffic testing apparatus, comprising:
the receiving module is used for receiving a flow recording playback request of the application to be tested, which is sent by the tested service system;
the analysis module is used for analyzing the flow recording and playback request to obtain a first data stream file of the application to be tested and backing up the first data stream file to a database file system;
the mirror image recovery module is used for performing database mirror image recovery on the first data stream file in the database file system to obtain a first response text of the application to be tested;
the flow recording module is used for monitoring the flow recording of the application to be tested to obtain a second data stream file and playing back the second data stream file to obtain a second response text;
and the comparison module is used for comparing the first response text with the second response text to generate test result data.
A third aspect of the invention provides an electronic device comprising a processor and a memory, the processor being configured to implement the data traffic testing method when executing a computer program stored in the memory.
A fourth aspect of the present invention provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the data traffic testing method.
In summary, in the data flow testing method, the device, the electronic device and the storage medium according to the present invention, on one hand, a first data stream file of an application to be tested is backed up to a database file system, before flow recording, database mirror image recovery is performed on data backed up to the database file system, then, flow recording of the application to be tested is monitored to obtain a second data stream file, and a second response text is obtained by playback according to the second data stream file, so that it is ensured that basic data before playback is consistent with basic data during recording, and accuracy of test result data returned by flow recording playback is improved; on the other hand, the first response text of the application to be tested is obtained by carrying out database mirror image recovery on the first data stream file, so that the consistency of data before recording and playback is ensured; finally, when the flow playback is carried out, the corresponding flow playback player is obtained according to the protocol format file type to carry out the playback on the second data stream file to obtain a second response text, so that the efficiency of obtaining the second response text is improved.
Drawings
Fig. 1 is a flowchart of a data traffic testing method according to an embodiment of the present invention.
Fig. 2 is a structural diagram of a data flow rate testing apparatus according to a second embodiment of the present invention.
Fig. 3 is a schematic structural diagram of an electronic device according to a third embodiment of the present invention.
The following detailed description will further illustrate the invention in conjunction with the above-described figures.
Detailed Description
In order that the above objects, features and advantages of the present invention can be more clearly understood, a detailed description of the present invention will be given below with reference to the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present invention and features of the embodiments may be combined with each other without conflict.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
Example one
Fig. 1 is a flowchart of a data traffic testing method according to an embodiment of the present invention.
In this embodiment, the data traffic testing method may be applied to an electronic device, and for an electronic device that needs to perform a data traffic test, the data traffic testing function provided by the method of the present invention may be directly integrated on the electronic device, or may be run in the electronic device in the form of a Software Development Kit (SDK).
As shown in fig. 1, the data traffic testing method specifically includes the following steps, and the order of the steps in the flowchart may be changed and some steps may be omitted according to different requirements.
And S11, receiving a flow recording playback request of the application to be tested sent by the tested service system.
In this embodiment, the flow recording and replaying request is used to request the server to perform a flow test on the application to be tested, and specifically, when the flow recording and replaying request of the application to be tested sent by the tested service system is received, the application to be tested is identified, and a regression test of flow recording and replaying is performed on the application to be tested, where the regression test mainly returns test result data after testing the recorded flow and the replayed flow.
And S12, analyzing the flow recording and playback request to obtain a first data stream file of the application to be tested, and backing up the first data stream file to a database file system.
In this embodiment, the flow recording playback request includes the first data stream file of the application to be tested, specifically, the first data stream file refers to an original data stream file of the application to be tested, and after the flow recording playback request is analyzed to obtain the first data stream file of the application to be tested, the first data stream file is stored in the database file system, that is, data backup is performed on the first data stream file, so that integrity of the first data stream file is ensured.
And S13, performing database mirror image recovery on the first data stream file in the database file system to obtain a first response text of the application to be tested.
In this embodiment, the database mirroring refers to that the database automatically backs up the entire database or a part of data in the database to another file system as required to obtain backup data, and when mirror image restoration needs to be performed on the database, the backup data is reintroduced into the database, so that the backup data is restored to a state before backup, consistency of data before backup and after backup is ensured, and accuracy of obtaining the first response text of the application to be tested is improved.
Optionally, the performing data mirror recovery on the first data stream file in the database file system to obtain the first response text of the application to be tested includes:
replacing the first data stream file with a directory file mounted by a mirror image container;
and restarting the directory file mounted in the mirror image container in the database file system to obtain a first response text of the application to be tested.
In this embodiment, the first response text of the application to be tested is obtained by performing database mirror image recovery on the first data stream file, so that consistency of data before recording and playback is ensured.
S14, monitoring the flow recording of the application to be tested to obtain a second data stream file, and playing back according to the second data stream file to obtain a second response text.
In this embodiment, when recording traffic, the traffic of the application to be tested in the running process is monitored, the traffic is recorded to obtain a second data stream file, and after the recording is finished, the traffic of the second data stream file is played back to obtain a second response text.
Optionally, the playing back the second data stream file to obtain a second response text includes:
identifying a protocol format file type of the second data stream file;
calling a corresponding flow playback player according to the protocol format file type;
and playing back the second data stream file by using the flow playback player to obtain a second response text.
In this embodiment, in the process of monitoring the flow recording of the application to be tested, the second data stream file is stored as a parsable protocol format file type, and when the flow playback is performed, only a corresponding flow playback player needs to be obtained according to the protocol format file type to perform playback on the second data stream file to obtain a second response text, so that the efficiency of obtaining the second response text is improved.
And S15, comparing the first response text with the second response text to generate test result data.
In this embodiment, since recording and playback belong to different time points, and data in a database may change in a time period in which the different time points are located, when performing flow playback, performing database mirror image recovery on the first data stream file in the database file system to obtain a first response text of the application to be tested, monitoring flow recording of the application to be tested to obtain a second data stream file, performing playback according to the second data stream file to obtain a second response text, and performing mirror image recovery on the database to an initial state, so that basic data of the first response text and basic data of the second response text are kept consistent, thereby improving accuracy of test result data.
Optionally, the comparing the first response text with the second response text, and generating test result data includes:
converting the first response text into a first character string and converting the second response text into a second character string;
identifying format types of the first response text and the second response text;
comparing the first character string with the second character string according to the format type to obtain a comparison result;
when the comparison result is that the first character string is consistent with the second character string, generating test result data of the application to be tested, which is tested successfully; or
And when the comparison result is that the first character string is inconsistent with the second character string, the application to be tested fails to test the test result data.
In this embodiment, when the basic data of the first response text and the second response text are consistent, performing a regression test on the first and second response texts, detecting whether the first and second response texts are consistent, and then returning the test result data, in order to improve the accuracy of the test result data, converting the first response text into a first character string according to a preset first format, and converting the second response text into a second character string according to a preset second format, and performing full string comparison on the first character string and the second character string, determining that the first response text is inconsistent with the second response text as long as one character string of the first character string is inconsistent with that of the second character string, and improving the accuracy of test result data through full string comparison.
Further, when the format type is a Json format type, the comparing the first character string with the second character string according to the format type, and obtaining a comparison result includes:
parsing the first response text into a first directory tree and parsing the second response text into a second directory tree;
traversing first data of each node of each layer from a root node of the first directory tree, and judging whether the first data of each node of each layer of the first directory tree is the same as second data of the same node of the same layer of the second directory tree;
when the first data of each node of each layer of the first directory tree is the same as the second data of the same node of the same layer of the second directory tree, generating a comparison result that the first character string is consistent with the second character string; or
And when the first data of any node of any layer of the first directory tree is different from the second data of the same node of the same layer of the second directory tree, generating a comparison result that the first character string is inconsistent with the second character string.
Further, the traversing the first data of each node of each layer from the root node of the first directory tree comprises:
judging whether each layer has a plurality of child nodes;
when a plurality of child nodes exist in each layer, sequencing the child nodes according to a preset rule, and determining the node sequenced at the first as an initial node;
and traversing the first data of each node of each layer in turn from the initial node of each layer.
In this embodiment, whether the first response text is consistent with the second response text is determined by traversing all the child nodes of each layer by layer, so that the phenomenon of missing in comparison in the process of comparing the first response text with the second response text is avoided, and the accuracy of returned test result data is improved.
Further, when the format type is an XML format type, the comparing the first character string with the second character string according to the format type to obtain a comparison result includes:
converting the first response text into a first DOM tree, and converting the second response text into a second DOM tree;
judging whether the layer number of the first DOM tree is the same as that of the second DOM tree or not;
comparing third data of each layer of the first DOM tree with fourth data of the same layer of the second DOM tree when the layer number of the first DOM tree is the same as that of the second DOM tree;
when the third data of each layer of the first DOM tree is the same as the fourth data of the same layer of the second DOM tree, generating a comparison result that the first character string is consistent with the second character string; or
And when the third data of any layer of the first DOM tree is different from the fourth data of the same layer of the second DOM tree, generating a comparison result that the first character string is inconsistent with the second character string.
In this embodiment, because different formats of the response texts are different, different comparison methods are adopted for different formats of the response texts, when the format types of the first response text and the second response text are Json format types, the first response text is analyzed into a first directory tree, the second response text is analyzed into a second directory tree, whether the first directory book and the second directory tree are consistent or not is compared, and test result data is returned; when the format types of the first response text and the second response text are XML format types, the first response text is converted into a first DOM tree, the second response text is converted into a second DOM tree, whether the first DOM tree is consistent with the second DOM tree is compared, test result data are returned, the first DOM tree and the second DOM tree are converted into different trees according to the formats of different file types, the hierarchical relation of the trees is utilized for comparison, the phenomenon of data comparison omission is avoided, and the accuracy of the returned test result data is improved.
In the embodiment, different comparison methods are adopted according to different formats of the response text, so that the test result data is returned, and the accuracy of the returned test result data is improved.
Further, the method further comprises:
and when the layer number of the first DOM tree is different from that of the second DOM tree, generating test result data that the first response text is inconsistent with the second response text.
In this embodiment, when the number of layers of the first DOM tree is different from the number of layers of the second DOM tree, it is determined that the first DOM tree is inconsistent with the second DOM tree, and test result data can be quickly returned to determine that the first response text is inconsistent with the second response text, so that the efficiency of generating test result data is improved.
In the embodiment, when the data stream file to be tested is subjected to flow recording playback, because the recording and playback may be at different time points, and data in the database is changed a lot in the time period between the different time points, and data inconsistency causes inaccuracy in the test result data returned by the flow recording playback to the regression test, before the flow recording of the application to be tested, the first data stream file to be tested is backed up into the database file system, before the flow recording, the data backed up into the database file system is subjected to database mirror image recovery, then the flow recording of the application to be tested is monitored to obtain a second data stream file, and a second response text is obtained by the playback according to the second data stream file, so that the consistency between the basic data before playback and the basic data during recording is ensured, the accuracy of the test result data returned by the flow recording and playback is improved.
In summary, the data traffic testing method according to this embodiment receives a traffic recording playback request of an application to be tested, which is sent by a tested service system; analyzing the flow recording and playback request to obtain a first data stream file of the application to be tested, and backing up the first data stream file to a database file system; performing database mirror image recovery on the first data stream file in the database file system to obtain a first response text of the application to be tested; monitoring the flow recording of the application to be tested to obtain a second data stream file, and playing back the second data stream file to obtain a second response text; and comparing the first response text with the second response text to generate test result data.
In this embodiment, on one hand, a first data stream file to be tested is backed up to a database file system, before flow recording, database mirror image recovery is performed on data backed up to the database file system, then flow recording of the to-be-tested application is monitored to obtain a second data stream file, and a second response text is obtained according to playback of the second data stream file, so that it is ensured that basic data before playback is consistent with basic data during recording, and accuracy of test result data returned by flow recording playback is improved; on the other hand, the first response text of the application to be tested is obtained by carrying out database mirror image recovery on the first data stream file, so that the consistency of data before recording and playback is ensured; finally, when the flow playback is carried out, the corresponding flow playback player is obtained according to the protocol format file type to carry out the playback on the second data stream file to obtain a second response text, so that the efficiency of obtaining the second response text is improved.
Example two
Fig. 2 is a structural diagram of a data flow rate testing apparatus according to a second embodiment of the present invention.
In some embodiments, the data traffic testing device 20 may include a plurality of functional modules composed of program code segments. Program code for various program segments in the data flow testing apparatus 20 may be stored in a memory of the electronic device and executed by the at least one processor to perform data flow testing (described in detail in fig. 1).
In this embodiment, the data traffic testing apparatus 20 may be divided into a plurality of functional modules according to the functions performed by the data traffic testing apparatus. The functional module may include: the system comprises a receiving module 201, a parsing module 202, an image recovery module 203, a traffic recording module 204 and a comparison module 205. The module referred to herein is a series of computer program segments capable of being executed by at least one processor and capable of performing a fixed function and is stored in memory. In the present embodiment, the functions of the modules will be described in detail in the following embodiments.
The receiving module 201 is configured to receive a traffic recording and playback request of an application to be tested, which is sent by a tested service system.
In this embodiment, the flow recording and replaying request is used to request the server to perform a flow test on the application to be tested, and specifically, when the flow recording and replaying request of the application to be tested sent by the tested service system is received, the application to be tested is identified, and a regression test of flow recording and replaying is performed on the application to be tested, where the regression test mainly returns test result data after testing the recorded flow and the replayed flow.
The analysis module 202 is configured to analyze the flow recording playback request to obtain a first data stream file of the application to be tested, and backup the first data stream file to a database file system.
In this embodiment, the flow recording playback request includes the first data stream file of the application to be tested, specifically, the first data stream file refers to an original data stream file of the application to be tested, and after the flow recording playback request is analyzed to obtain the first data stream file of the application to be tested, the first data stream file is stored in the database file system, that is, data backup is performed on the first data stream file, so that integrity of the first data stream file is ensured.
The mirror image recovery module 203 is configured to perform database mirror image recovery on the first data stream file in the database file system to obtain a first response text of the application to be tested.
In this embodiment, the database mirroring refers to that the database automatically backs up the entire database or a part of data in the database to another file system as required to obtain backup data, and when mirror image restoration needs to be performed on the database, the backup data is reintroduced into the database, so that the backup data is restored to a state before backup, consistency of data before backup and after backup is ensured, and accuracy of obtaining the first response text of the application to be tested is improved.
Optionally, the performing, by the image recovery module 203, data image recovery on the first data stream file in the database file system to obtain a first response text of the application to be tested includes:
replacing the first data stream file with a directory file mounted by a mirror image container;
and restarting the directory file mounted in the mirror image container in the database file system to obtain a first response text of the application to be tested.
In this embodiment, the first response text of the application to be tested is obtained by performing database mirror image recovery on the first data stream file, so that consistency of data before recording and playback is ensured.
And the flow recording module 204 is configured to monitor the flow recording of the application to be tested to obtain a second data stream file, and play back the second data stream file to obtain a second response text.
In this embodiment, when recording traffic, the traffic of the application to be tested in the running process is monitored, the traffic is recorded to obtain a second data stream file, and after the recording is finished, the traffic of the second data stream file is played back to obtain a second response text.
Optionally, the playing back, by the traffic recording module 204, the second response text according to the second data stream file includes:
identifying a protocol format file type of the second data stream file;
calling a corresponding flow playback player according to the protocol format file type;
and playing back the second data stream file by using the flow playback player to obtain a second response text.
In this embodiment, in the process of monitoring the flow recording of the application to be tested, the second data stream file is stored as a parsable protocol format file type, and when the flow playback is performed, only a corresponding flow playback player needs to be obtained according to the protocol format file type to perform playback on the second data stream file to obtain a second response text, so that the efficiency of obtaining the second response text is improved.
A comparison module 205, configured to compare the first response text with the second response text, and generate test result data.
In this embodiment, since recording and playback belong to different time points, and data in a database may change in a time period in which the different time points are located, when performing flow playback, performing database mirror image recovery on the first data stream file in the database file system to obtain a first response text of the application to be tested, monitoring flow recording of the application to be tested to obtain a second data stream file, performing playback according to the second data stream file to obtain a second response text, and performing mirror image recovery on the database to an initial state, so that basic data of the first response text and basic data of the second response text are kept consistent, thereby improving accuracy of test result data.
Optionally, the comparing module 205 compares the first response text with the second response text, and generating test result data includes:
converting the first response text into a first character string and converting the second response text into a second character string;
identifying format types of the first response text and the second response text;
comparing the first character string with the second character string according to the format type to obtain a comparison result;
when the comparison result is that the first character string is consistent with the second character string, generating test result data of the application to be tested, which is tested successfully; or
And when the comparison result is that the first character string is inconsistent with the second character string, the application to be tested fails to test the test result data.
In this embodiment, when the basic data of the first response text and the second response text are consistent, performing a regression test on the first and second response texts, detecting whether the first and second response texts are consistent, and then returning the test result data, in order to improve the accuracy of the test result data, converting the first response text into a first character string according to a preset first format, and converting the second response text into a second character string according to a preset second format, and performing full string comparison on the first character string and the second character string, determining that the first response text is inconsistent with the second response text as long as one character string of the first character string is inconsistent with that of the second character string, and improving the accuracy of test result data through full string comparison.
Further, when the format type is a Json format type, the comparing the first character string with the second character string according to the format type, and obtaining a comparison result includes:
parsing the first response text into a first directory tree and parsing the second response text into a second directory tree;
traversing first data of each node of each layer from a root node of the first directory tree, and judging whether the first data of each node of each layer of the first directory tree is the same as second data of the same node of the same layer of the second directory tree;
when the first data of each node of each layer of the first directory tree is the same as the second data of the same node of the same layer of the second directory tree, generating a comparison result that the first character string is consistent with the second character string; or
And when the first data of any node of any layer of the first directory tree is different from the second data of the same node of the same layer of the second directory tree, generating a comparison result that the first character string is inconsistent with the second character string.
Further, the traversing the first data of each node of each layer from the root node of the first directory tree comprises:
judging whether each layer has a plurality of child nodes;
when a plurality of child nodes exist in each layer, sequencing the child nodes according to a preset rule, and determining the node sequenced at the first as an initial node;
and traversing the first data of each node of each layer in turn from the initial node of each layer.
In this embodiment, whether the first response text is consistent with the second response text is determined by traversing all the child nodes of each layer by layer, so that the phenomenon of missing in comparison in the process of comparing the first response text with the second response text is avoided, and the accuracy of returned test result data is improved.
Further, when the format type is an XML format type, the comparing the first character string with the second character string according to the format type to obtain a comparison result includes:
converting the first response text into a first DOM tree, and converting the second response text into a second DOM tree;
judging whether the layer number of the first DOM tree is the same as that of the second DOM tree or not;
comparing third data of each layer of the first DOM tree with fourth data of the same layer of the second DOM tree when the layer number of the first DOM tree is the same as that of the second DOM tree;
when the third data of each layer of the first DOM tree is the same as the fourth data of the same layer of the second DOM tree, generating a comparison result that the first character string is consistent with the second character string; or
And when the third data of any layer of the first DOM tree is different from the fourth data of the same layer of the second DOM tree, generating a comparison result that the first character string is inconsistent with the second character string.
In this embodiment, because different formats of the response texts are different, different comparison methods are adopted for different formats of the response texts, when the format types of the first response text and the second response text are Json format types, the first response text is analyzed into a first directory tree, the second response text is analyzed into a second directory tree, whether the first directory book and the second directory tree are consistent or not is compared, and test result data is returned; when the format types of the first response text and the second response text are XML format types, the first response text is converted into a first DOM tree, the second response text is converted into a second DOM tree, whether the first DOM tree is consistent with the second DOM tree is compared, test result data are returned, the first DOM tree and the second DOM tree are converted into different trees according to the formats of different file types, the hierarchical relation of the trees is utilized for comparison, the phenomenon of data comparison omission is avoided, and the accuracy of the returned test result data is improved.
In the embodiment, different comparison methods are adopted according to different formats of the response text, so that the test result data is returned, and the accuracy of the returned test result data is improved.
Further, when the layer number of the first DOM tree is different from the layer number of the second DOM tree, generating test result data as the first response text is inconsistent with the second response text.
In this embodiment, when the number of layers of the first DOM tree is different from the number of layers of the second DOM tree, it is determined that the first DOM tree is inconsistent with the second DOM tree, and test result data can be quickly returned to determine that the first response text is inconsistent with the second response text, so that the efficiency of generating test result data is improved.
In the embodiment, when the data stream file to be tested is subjected to flow recording playback, because the recording and playback may be at different time points, and data in the database is changed a lot in the time period between the different time points, and data inconsistency causes inaccuracy in the test result data returned by the flow recording playback to the regression test, before the flow recording of the application to be tested, the first data stream file to be tested is backed up into the database file system, before the flow recording, the data backed up into the database file system is subjected to database mirror image recovery, then the flow recording of the application to be tested is monitored to obtain a second data stream file, and a second response text is obtained by the playback according to the second data stream file, so that the consistency between the basic data before playback and the basic data during recording is ensured, the accuracy of the test result data returned by the flow recording and playback is improved.
To sum up, the data traffic testing apparatus of this embodiment receives a traffic recording playback request of an application to be tested sent by a tested service system; analyzing the flow recording and playback request to obtain a first data stream file of the application to be tested, and backing up the first data stream file to a database file system; performing database mirror image recovery on the first data stream file in the database file system to obtain a first response text of the application to be tested; monitoring the flow recording of the application to be tested to obtain a second data stream file, and playing back the second data stream file to obtain a second response text; and comparing the first response text with the second response text to generate test result data.
In this embodiment, on one hand, a first data stream file to be tested is backed up to a database file system, before flow recording, database mirror image recovery is performed on data backed up to the database file system, then flow recording of the to-be-tested application is monitored to obtain a second data stream file, and a second response text is obtained according to playback of the second data stream file, so that it is ensured that basic data before playback is consistent with basic data during recording, and accuracy of test result data returned by flow recording playback is improved; on the other hand, the first response text of the application to be tested is obtained by carrying out database mirror image recovery on the first data stream file, so that the consistency of data before recording and playback is ensured; finally, when the flow playback is carried out, the corresponding flow playback player is obtained according to the protocol format file type to carry out the playback on the second data stream file to obtain a second response text, so that the efficiency of obtaining the second response text is improved.
EXAMPLE III
Fig. 3 is a schematic structural diagram of an electronic device according to a third embodiment of the present invention. In the preferred embodiment of the present invention, the electronic device 3 comprises a memory 31, at least one processor 32, at least one communication bus 33 and a transceiver 34.
It will be appreciated by those skilled in the art that the configuration of the electronic device shown in fig. 3 does not constitute a limitation of the embodiment of the present invention, and may be a bus-type configuration or a star-type configuration, and the electronic device 3 may include more or less other hardware or software than those shown, or a different arrangement of components.
In some embodiments, the electronic device 3 is an electronic device capable of automatically performing numerical calculation and/or information processing according to instructions set or stored in advance, and the hardware thereof includes but is not limited to a microprocessor, an application specific integrated circuit, a programmable gate array, a digital processor, an embedded device, and the like. The electronic device 3 may also include a client device, which includes, but is not limited to, any electronic product that can interact with a client through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device, for example, a personal computer, a tablet computer, a smart phone, a digital camera, and the like.
It should be noted that the electronic device 3 is only an example, and other existing or future electronic products, such as those that can be adapted to the present invention, should also be included in the scope of the present invention, and are included herein by reference.
In some embodiments, the memory 31 is used for storing program codes and various data, such as the data traffic testing device 20 installed in the electronic device 3, and realizes high-speed and automatic access to programs or data during the operation of the electronic device 3. The Memory 31 includes a Read-Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), a One-time Programmable Read-Only Memory (OTPROM), an electronically Erasable rewritable Read-Only Memory (Electrically-Erasable Programmable Read-Only Memory (EEPROM)), an optical Read-Only disk (CD-ROM) or other optical disk Memory, a magnetic disk Memory, a tape Memory, or any other medium readable by a computer capable of carrying or storing data.
In some embodiments, the at least one processor 32 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same or different functions, including one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The at least one processor 32 is a Control Unit (Control Unit) of the electronic device 3, connects various components of the electronic device 3 by using various interfaces and lines, and executes various functions and processes data of the electronic device 3 by running or executing programs or modules stored in the memory 31 and calling data stored in the memory 31.
In some embodiments, the at least one communication bus 33 is arranged to enable connection communication between the memory 31 and the at least one processor 32 or the like.
Although not shown, the electronic device 3 may further include a power supply (such as a battery) for supplying power to each component, and optionally, the power supply may be logically connected to the at least one processor 32 through a power management device, so as to implement functions of managing charging, discharging, and power consumption through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device 3 may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The integrated unit implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, an electronic device, or a network device) or a processor (processor) to execute parts of the methods according to the embodiments of the present invention.
In a further embodiment, in conjunction with fig. 2, the at least one processor 32 may execute an operating device of the electronic device 3 and various installed applications (such as the data traffic testing device 20), program codes, and the like, for example, the above modules.
The memory 31 has program code stored therein, and the at least one processor 32 can call the program code stored in the memory 31 to perform related functions. For example, the modules illustrated in fig. 2 are program codes stored in the memory 31 and executed by the at least one processor 32, so as to implement the functions of the modules for the purpose of data traffic testing.
In one embodiment of the invention, the memory 31 stores a plurality of instructions that are executed by the at least one processor 32 to implement data traffic testing functions.
Specifically, the at least one processor 32 may refer to the description of the relevant steps in the embodiment corresponding to fig. 1, and details are not repeated here.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or that the singular does not exclude the plural. A plurality of units or means recited in the present invention may also be implemented by one unit or means through software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A method for data traffic testing, the method comprising:
receiving a flow recording playback request of an application to be tested, which is sent by a tested service system;
analyzing the flow recording and playback request to obtain a first data stream file of the application to be tested, and backing up the first data stream file to a database file system;
performing database mirror image recovery on the first data stream file in the database file system to obtain a first response text of the application to be tested;
monitoring the flow recording of the application to be tested to obtain a second data stream file, and playing back the second data stream file to obtain a second response text;
and comparing the first response text with the second response text to generate test result data.
2. The data traffic testing method according to claim 1, wherein the comparing the first response text with the second response text to generate test result data includes:
converting the first response text into a first character string and converting the second response text into a second character string;
identifying format types of the first response text and the second response text;
comparing the first character string with the second character string according to the format type to obtain a comparison result;
when the comparison result is that the first character string is consistent with the second character string, generating test result data of the application to be tested, which is tested successfully; or
And when the comparison result is that the first character string is inconsistent with the second character string, the application to be tested fails to test the test result data.
3. The data traffic testing method according to claim 2, wherein when the format type is a Json format type, the comparing the first character string with the second character string according to the format type to obtain a comparison result includes:
parsing the first response text into a first directory tree and parsing the second response text into a second directory tree;
traversing first data of each node of each layer from a root node of the first directory tree, and judging whether the first data of each node of each layer of the first directory tree is the same as second data of the same node of the same layer of the second directory tree;
when the first data of each node of each layer of the first directory tree is the same as the second data of the same node of the same layer of the second directory tree, generating a comparison result that the first character string is consistent with the second character string; or
And when the first data of any node of any layer of the first directory tree is different from the second data of the same node of the same layer of the second directory tree, generating a comparison result that the first character string is inconsistent with the second character string.
4. The data traffic testing method of claim 3, wherein traversing the first data for each node of each level starting from the root node of the first directory tree comprises:
judging whether each layer has a plurality of child nodes;
when a plurality of child nodes exist in each layer, sequencing the child nodes according to a preset rule, and determining the node sequenced at the first as an initial node;
and traversing the first data of each node of each layer in turn from the initial node of each layer.
5. The data traffic testing method according to claim 2, wherein when the format type is an XML format type, the comparing the first character string and the second character string according to the format type to obtain a comparison result includes:
converting the first response text into a first DOM tree, and converting the second response text into a second DOM tree;
judging whether the layer number of the first DOM tree is the same as that of the second DOM tree or not;
comparing third data of each layer of the first DOM tree with fourth data of the same layer of the second DOM tree when the layer number of the first DOM tree is the same as that of the second DOM tree;
when the third data of each layer of the first DOM tree is the same as the fourth data of the same layer of the second DOM tree, generating a comparison result that the first character string is consistent with the second character string; or
And when the third data of any layer of the first DOM tree is different from the fourth data of the same layer of the second DOM tree, generating a comparison result that the first character string is inconsistent with the second character string.
6. The data traffic testing method according to claim 1, wherein the performing data mirror recovery on the first data stream file in the database file system to obtain the first response text of the application to be tested comprises:
replacing the first data stream file with a directory file mounted by a mirror image container;
and restarting the directory file mounted in the mirror image container in the database file system to obtain a first response text of the application to be tested.
7. The data traffic testing method according to claim 1, wherein the obtaining a second response text by playing back according to the second data stream file comprises:
identifying a protocol format file type of the second data stream file;
calling a corresponding flow playback player according to the protocol format file type;
and playing back the second data stream file by using the flow playback player to obtain a second response text.
8. A data flow testing apparatus, the apparatus comprising:
the receiving module is used for receiving a flow recording playback request of the application to be tested, which is sent by the tested service system;
the analysis module is used for analyzing the flow recording and playback request to obtain a first data stream file of the application to be tested and backing up the first data stream file to a database file system;
the mirror image recovery module is used for performing database mirror image recovery on the first data stream file in the database file system to obtain a first response text of the application to be tested;
the flow recording module is used for monitoring the flow recording of the application to be tested to obtain a second data stream file and playing back the second data stream file to obtain a second response text;
and the comparison module is used for comparing the first response text with the second response text to generate test result data.
9. An electronic device, characterized in that the electronic device comprises a processor and a memory, the processor being configured to implement the data traffic testing method according to any one of claims 1 to 7 when executing a 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 a data traffic testing method according to any one of claims 1 to 7.
CN202011552435.9A 2020-12-24 2020-12-24 Data flow testing method and device, electronic equipment and storage medium Pending CN112527568A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011552435.9A CN112527568A (en) 2020-12-24 2020-12-24 Data flow testing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011552435.9A CN112527568A (en) 2020-12-24 2020-12-24 Data flow testing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112527568A true CN112527568A (en) 2021-03-19

Family

ID=74976276

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011552435.9A Pending CN112527568A (en) 2020-12-24 2020-12-24 Data flow testing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112527568A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114900251A (en) * 2022-05-27 2022-08-12 北京天融信网络安全技术有限公司 Test system, method and device and electronic equipment
CN115242804A (en) * 2022-06-10 2022-10-25 河南信大网御科技有限公司 Pseudo-executive random number detection method

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114900251A (en) * 2022-05-27 2022-08-12 北京天融信网络安全技术有限公司 Test system, method and device and electronic equipment
CN114900251B (en) * 2022-05-27 2023-11-28 北京天融信网络安全技术有限公司 Test system, test method, test device and electronic equipment
CN115242804A (en) * 2022-06-10 2022-10-25 河南信大网御科技有限公司 Pseudo-executive random number detection method

Similar Documents

Publication Publication Date Title
CN108959059B (en) Test method and test platform
US20150169431A1 (en) Process for displaying test coverage data during code reviews
CN113946499A (en) Micro-service link tracking and performance analysis method, system, equipment and application
CN112101803A (en) Business process monitoring method, device, system, equipment and medium
CN110537170B (en) Method, system and computer readable storage device for analyzing large scale data processing jobs
CN113312153B (en) Cluster deployment method and device, electronic equipment and storage medium
CN112527568A (en) Data flow testing method and device, electronic equipment and storage medium
CN111881014A (en) System test method, device, storage medium and electronic equipment
CN111754123A (en) Data monitoring method and device, computer equipment and storage medium
CN112000574A (en) Pressure testing method, device, equipment and storage medium
CN116560893B (en) Computer application program operation data fault processing system
CN115878400A (en) Test method, test apparatus, computer device, storage medium, and program product
CN111209138A (en) Operation and maintenance method and device of data storage system
CN115185825A (en) Interface test scheduling method and device
CN113973068A (en) Chaos test method and device, chaos test platform and storage medium
CN114692382B (en) Management method and device for nuclear power simulation model development data and computer equipment
CN117234827B (en) Multi-platform automatic test method and system based on domestic graphic processor
CN112667597B (en) Algorithm model full life cycle management tool system and implementation method thereof
CN117312174B (en) Program error path detection method, device, equipment and readable storage medium
CN117421153B (en) Automatic testing system and method for railway wagon fault image recognition model
CN113282282B (en) Business requirement form publishing method and device, electronic equipment and storage medium
CN111737132B (en) Method, system, electronic device and storage medium for issuing project code data
CN114741318A (en) Pressure measurement method, device, equipment and medium based on user pressure measurement request
CN114416845A (en) Big data testing method and device, electronic equipment and storage medium
CN112905470A (en) Interface calling method and device, computer equipment and medium

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