CN117435509A - Dynamic comparison method, dynamic comparison device and storage medium for interface data - Google Patents

Dynamic comparison method, dynamic comparison device and storage medium for interface data Download PDF

Info

Publication number
CN117435509A
CN117435509A CN202311757109.5A CN202311757109A CN117435509A CN 117435509 A CN117435509 A CN 117435509A CN 202311757109 A CN202311757109 A CN 202311757109A CN 117435509 A CN117435509 A CN 117435509A
Authority
CN
China
Prior art keywords
data
interface
field
comparison
fields
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.)
Granted
Application number
CN202311757109.5A
Other languages
Chinese (zh)
Other versions
CN117435509B (en
Inventor
冯绍文
陈晓锋
方朋朋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Zhicheng Software Technology Service Co ltd
Shenzhen Smart City Technology Development Group Co ltd
Original Assignee
Shenzhen Zhicheng Software Technology Service Co ltd
Shenzhen Smart City Technology Development Group 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 Shenzhen Zhicheng Software Technology Service Co ltd, Shenzhen Smart City Technology Development Group Co ltd filed Critical Shenzhen Zhicheng Software Technology Service Co ltd
Priority to CN202311757109.5A priority Critical patent/CN117435509B/en
Publication of CN117435509A publication Critical patent/CN117435509A/en
Application granted granted Critical
Publication of CN117435509B publication Critical patent/CN117435509B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a dynamic comparison method, dynamic comparison equipment and a computer readable storage medium of interface data, belonging to the field of software testing. The method comprises the following steps: acquiring first data returned by a first interface and second data returned by a second interface; dynamically sequencing the first data and the second data according to the field names and the field values in the first data and the second data to obtain sequencing results; and performing field comparison based on the sorting result, and determining a comparison result. According to the data consistency testing method and device, the interface data which need to be subjected to consistency testing are subjected to dynamic sequencing and then are compared to obtain the comparison result, the comparison result can intuitively show the data difference, and the efficiency of the data consistency testing is improved.

Description

Dynamic comparison method, dynamic comparison device and storage medium for interface data
Technical Field
The present invention relates to the field of software testing, and in particular, to a dynamic comparison method, a dynamic comparison device, and a computer readable storage medium for interface data.
Background
Software testing is a process used to verify the correctness, integrity, security, and quality of software. In the software testing process, in order to verify the consistency and correctness of data among different system components, data consistency testing may be performed.
In the related data consistency test scheme, a JS object numbered musical notation (JavaScript Object Notation, JSON) comparison tool or a file comparison tool is generally used to perform static comparison on fields returned by interfaces. However, when the sequences of the fields returned by the interfaces are inconsistent, the conventional JSON comparison tool or file comparison tool cannot fully compare all fields with different sequences and the same name because the fields with different names cannot be effectively filtered.
Therefore, a new data comparison method is needed so that the differences of the same name fields and the differences of the different name fields can be clearly presented.
The foregoing is merely provided to facilitate an understanding of the principles of the present application and is not admitted to be prior art.
Disclosure of Invention
The main objective of the present application is to provide a dynamic comparison method, a dynamic comparison device and a computer readable storage medium for interface data, which are aimed at solving the problem that the traditional test method cannot perform sufficient comparison on data and intuitively present data differences.
In order to achieve the above object, the present application provides a dynamic comparison method of interface data, the dynamic comparison method of interface data includes the following steps:
acquiring first data returned by a first interface and second data returned by a second interface;
dynamically sequencing the first data and the second data according to the field names and the field values in the first data and the second data to obtain sequencing results;
and performing field comparison based on the sorting result, and determining a comparison result.
Optionally, the step of dynamically ordering the first data and the second data includes:
screening the homonymous data fields in the first data and the second data, and arranging according to the field names and the appointed sequence of the ordering rule to generate a homonymous data set;
screening different name and value data fields in the first data and the second data, and arranging according to the field values and the appointed sequence of the ordering rule to generate a value data set;
screening data fields with different names and different values in the first data and the second data, and arranging according to the appointed sequence of the ordering rule to generate a difference data set;
and sequentially generating sequencing results corresponding to the first data and the second data based on the same-name data set, the same-value data set and the difference data set.
Optionally, the step of performing field comparison based on the sorting result includes:
directly comparing the same-name data sets of the sequencing results to generate a same-name field comparison result;
comparing the same-value data set and the difference data set of the sequencing result through a fuzzy comparison algorithm to generate a field comparison result with different names;
and combining the comparison result of the same name field and the comparison result of the different name fields to generate a data sequence after comparison.
Optionally, after the step of dynamically sorting the first data and the second data to obtain the sorting result, the method further includes:
judging whether the length of the data field of the sequencing result reaches a preset field length threshold value or not;
and if the length of the data field of the sequencing result reaches the threshold value, marking an important field of the sequencing result based on a preset comparison logic, and comparing the important field of the sequencing result based on the important field.
Optionally, the step of determining the comparison result includes:
marking data with different field values according to the compared data sequences, and generating data field value difference points;
counting the compared data sequences to generate statistical information;
and outputting the difference points and the statistical information through a visualization tool to obtain the comparison result.
Optionally, the step of counting the aligned data sequences and generating statistical information includes:
carrying out statistical index calculation on the compared data sequences to obtain statistical index data;
and summarizing the statistical index data to generate the statistical information.
Optionally, the step of acquiring the first data returned by the first interface and the second data returned by the second interface includes:
constructing and packaging a data request message header and a data request message body according to interface protocol specifications of the first interface and the second interface, and generating a data request message;
initiating a data request according to the data request message;
receiving a response message of the data request;
analyzing the response message according to the interface protocol specifications of the first interface and the second interface to obtain header information;
extracting target data from the response message according to the head information to acquire the target data;
and analyzing the target data according to the format of the response message and the interface protocol specifications of the first interface and the second interface, and acquiring the first data and the second data.
Optionally, after the step of determining the comparison result, the method further includes:
according to the comparison result, an access mode and a data volume are obtained;
determining a caching strategy according to the access mode and the data volume;
and setting the cache capacity according to the cache strategy and storing the comparison result into a cache.
In addition, in order to achieve the above object, the present application further provides a dynamic alignment device for interface data, where the dynamic alignment device includes: the system comprises a memory, a processor and a dynamic comparison program of interface data stored on the memory and capable of running on the processor, wherein the dynamic comparison program of the interface data is configured to realize the steps of the dynamic comparison method of the interface data.
In addition, in order to achieve the above object, the present application further provides a computer readable storage medium having stored thereon a dynamic alignment program of interface data, which when executed by a processor, implements the steps of the dynamic alignment method of interface data as described above.
According to the method and the device, the acquired interface data are dynamically ordered, the sequence of the data fields is flexibly adjusted according to the field names and the field values of the interface return data, the conditions of inconsistent field sequences, different field names and different field values are processed, the ordered data are compared, the data are fully compared, the comparison result is visually output, the data difference is visually presented, and the efficiency of the data consistency test is improved.
Drawings
FIG. 1 is a flow chart of a first embodiment of a dynamic alignment method for interface data according to the present application;
FIG. 2 is a detailed flowchart of step S200 in the first embodiment of the dynamic comparison method of interface data in the present application;
FIG. 3 is a schematic flow chart of an application scenario of a first embodiment of a dynamic comparison method of interface data in the present application;
FIG. 4 is a flow chart of a second embodiment of a dynamic alignment method for interface data according to the present application;
FIG. 5 is a flow chart of a third embodiment of a method for dynamic alignment of interface data according to the present application;
FIG. 6 is a flowchart of a fourth embodiment of a method for dynamic alignment of interface data according to the present application;
fig. 7 is a schematic structural diagram of a device for dynamically comparing interface data of a hardware running environment according to an embodiment of the present application.
The realization, functional characteristics and advantages of the present application will be further described with reference to the embodiments, referring to the attached drawings.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
According to the method and the device, the data returned by the interface are acquired, and the dynamic ordering is carried out according to the field names and the field values, so that the situations of inconsistent field sequences, different field names and different field values are flexibly and adaptively processed. After the sequence of the data fields is flexibly adjusted, the data are compared based on the ordered data and the comparison result is output, so that the data are compared in a sufficient ratio, the data difference is visually presented, and the efficiency of the data consistency test is improved.
In order to better understand the above technical solution, exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Software testing is a process used to verify the correctness, integrity, security, and quality of software, and is an audit or comparison process between actual and expected outputs. Data consistency testing is a critical task in software testing to verify consistency and correctness of data among different system components. Such testing ensures that data to data is consistent, avoiding data collisions and incorrect data computation results due to data inconsistencies.
In the related data consistency test scheme, a JS object numbered musical notation (JavaScript Object Notation, JSON) comparison tool or a file comparison tool is used for static comparison of fields returned by two interfaces, and comparison work is only carried out according to the existing data field sequence. However, the sequence of the fields returned by the two interfaces may not be consistent, and the conventional JSON comparison tool or file comparison tool cannot fully compare all the fields with different sequences and the same name, and the comparison result is intuitively presented.
It follows that the related data consistency test schemes suffer from inefficiency. In order to solve the above problems, the embodiments of the present application provide a method for dynamically comparing interface data, which aims to achieve improvement of data consistency testing efficiency by dynamically ordering acquired interface data and then comparing the interface data and generating a comparison result.
First embodiment
In this embodiment, a method for dynamically comparing interface data provided in the present application is further explained based on the flow chart shown in fig. 1.
The interface refers to a method of exchanging information between different systems, and is a "portal" of a program or system through which the program or system can exchange information or services with the outside world.
Referring to fig. 1, the dynamic comparison method of interface data includes:
step S100: acquiring first data returned by a first interface and second data returned by a second interface;
in this embodiment, first, data required for alignment needs to be acquired. And respectively acquiring the data returned by different interfaces through the call of the different interfaces, wherein the acquired data is the data to be compared.
As an alternative implementation manner of obtaining the interface data, when obtaining the interface data, a header of the data request message and a body of the data request message may be constructed and encapsulated according to the protocol specification of the interface, so as to generate the data request message and initiate the data request. And then receiving the response message of the request and analyzing according to the interface protocol to acquire the head information of the response message. And after extracting the returned data based on the header information, analyzing the returned data according to the format of the response message and the protocol specification to acquire the interface data.
In this embodiment, due to the nature of the interfaces, available technology, etc., different protocols and communication modes may be used by different interfaces, for example, the web services interface may use the HTTP protocol and the enterprise-level integrated application interface may use the SOAP protocol. In order to achieve the purpose of calling the interface, a request message meeting the protocol requirements is constructed according to the communication protocol specification used by the interface, for example, a SOAP protocol uses a SOAP message and the like, and the message is sent to a data source according to the communication mode of the communication protocol to request to acquire data.
The data source inserts the data requested by the interface into the response message after receiving the request message, and returns the data to the interface. After receiving the response message, the interface analyzes the response message according to the protocol specification to obtain the header information of the response message. Metadata about the response, such as information of content type received by the interface end, data caching strategy and the like, and descriptive information about the response, such as data type, data length, data coding, transmission coding and the like, can be provided in the header information. And positioning the required data in the response message body based on the content in the header information, and extracting the data content provided by the data source. And finally, analyzing the extracted data content according to the format of the response message and the protocol specification of the interface to acquire the required data.
Illustratively, interface a and interface B are both interfaces using the HTTP protocol, and according to the HTTP protocol specification, interface A, B constructs a user data request message and sends it to the corresponding database. The request includes HTTP methods, such as GET, POST, etc., target URL, request header, and request body. The corresponding database receives the request from interface A, B for user data, generates an HTTP response, inserts the user data into the response message, and returns the response message to interface A, B. After receiving the response message returned by the corresponding database, the interface A, B parses the response message according to the HTTP protocol specification, and extracts the data a from the response message respectively: { "username": "John", "age": "25", "sex": "Male", "email": "[email protected]", "phone": "12345", "height": "180" }, data b: { "num": "26", "email": "[email protected]", "name": "John", "phone": "12345", "status": "180", "hobby": "swim" }.
Optionally, the method for returning data by the interface further comprises polling, subscribing and the like.
As another alternative embodiment for obtaining the interface data, when obtaining the interface data, a polling time interval may be set for the interface first, then a data request is initiated, and the response information is processed to obtain part of the data. The interface may use a round-robin structure, such as a while-loop, to implement a polling operation, and according to a preset time interval, access the interface continuously and send a request to obtain the interface data.
Step S200: dynamically sequencing the first data and the second data according to the field names and the field values in the first data and the second data to obtain sequencing results;
in this embodiment, the field order of the returned data may be different due to the different interfaces or data sources of the returned data. In order to achieve sufficient comparison of data, the data needs to be dynamically ordered according to field names and field values in the data, based on an ordering rule, for example, according to a dictionary order arrangement or according to a preset ordering rule arrangement.
As an alternative implementation of dynamic ordering, referring to fig. 2, when dynamically ordering the acquired interface data, the same-name data fields in the data to be compared are screened out first, and are arranged according to the field names and the specified sequence of the ordering rule, so as to generate a same-name data set; secondly, screening out different name and value data fields in the data, and arranging according to the field values and the appointed sequence of the ordering rule to generate a value data set; then, screening out data fields with different names and different values in the data, and arranging according to the appointed sequence of the ordering rule to generate a difference data set; and finally, sequentially generating the ordered data sequence based on the homonymous data set, the homonymous data set and the difference data set.
In this embodiment, the data fields with the same name in the data to be sorted are first selected, and the data are stored in a data structure capable of sorting, such as an array, a list, a dictionary, or the like. According to the scale and actual demand of the data, selecting a proper sorting algorithm, for example, when the data volume is smaller, selecting insert sorting can quickly obtain sorting results, and when the data volume is too large, selecting sorting algorithms such as quick sorting, heap sorting and the like to improve sorting efficiency. And finally, sorting the screened homonymous data according to a sorting rule to generate a homonymous data set.
After the order of the homonymous data fields is arranged, the homonymous data fields in the residual data are ordered. The remaining data fields are first screened for different named and valued data fields, which are also stored in a data structure that can be ordered. And selecting a sorting algorithm according to factors such as the scale of the data and the actual demand. And finally, according to the ordering rule of the same-value data fields, ordering the same-value data fields to generate a same-value data set.
And screening and storing the remaining data fields with different names and different values, and selecting a sorting algorithm to sort according to a sorting rule to generate a difference data set.
Finally, in order to realize dynamic ordering of the data and maintain association with the original data, the data sets generated in the steps are recombined according to the sequence of the data fields with the same name, the data fields with the same value and the data fields with different names and different values to generate an ordering result corresponding to the original data, and the dynamic ordering is completed.
Illustratively, the homonymous data fields are ordered according to a multi-level ordering rule. The multi-level ordering rules may use other fields as a basis for ordering. First ordered by first field, then if there is the same value, then ordered by second field, and so on. For example, if there are name and age fields, it is required to sort in ascending order of names, and if the names are the same, sort in descending order of ages.
Optionally, the ordering rule of the fields of the same name data may also be ordering according to a default order of field names or a custom ordering rule, for example, ordering according to a specified field order, etc.
Illustratively, the same-value data fields are ordered according to the data type of the field values, and the field values of the same data type are ordered according to the dictionary order. For example, the field values are sorted according to the data type of the field values, in the order of character string, number, date, and for the field values of the same data type, the field values are sorted according to the dictionary order.
Optionally, the sorting rule of the fields with different names and the same value may also be that the fields with the same value are sorted according to the alphabetical order of the field names, if other fields exist as sorting basis, additional sorting criteria are provided according to other fields for sorting, and so on.
Illustratively, the ordering rule for the fields of different values for different names is an ascending order according to the alphabetical order of the field names. For example, if the field names and the field values of the two sets of data are different, the two sets of data are respectively ordered according to the alphabetical order of the field names, and the different field names are arranged in ascending order.
Optionally, the sorting rule of the fields with different names and different values may be sorting according to the data type of the field values, or customizing the priority of the fields, sorting according to the customized priority order, and so on.
For ease of understanding, the present solution is described below in terms of a specific application scenario.
In this scenario, data a and data b are the data returned by the interfaces described above.
And (3) sorting the data a and the data b, wherein the sorting rule of the fields with the same name is to sort the field names according to the dictionary sequence, the sorting rule of the fields with different names and the same value is to sort the fields according to the data types of the field values and the sequence of the character strings and the numerical values, and the sorting rule of the fields with different names and the different values is to sort the fields according to the alphabetical sequence of the field names. Firstly, screening out the data fields email and phone with the same name in the data a and the data b, arranging the email fields in front and arranging the phone fields in back according to the rule requirement, and generating a data set with the same name. And secondly, screening out data fields with different names and same values in the data a and the data b, wherein the same field values are John and 180, the field names are usernames and names and heights and status respectively, and the usernames and the names are arranged in front and the heights and status fields are arranged in back according to the ordering rule to generate a same-value data set. Next, screening out data fields with different names and different values in the data a and the data b, namely, age and sex, num and hobby, and sorting the data fields according to the alphabetical order of the data names, wherein the age field is arranged before the sex, and the hobby field is arranged before the num field, so as to generate a data set with different names and different values. And finally, combining the data sets, outputting the data a as data c, and outputting the data b as data d to finish dynamic sequencing. The output data c is: { "email": "[email protected]", "phone": "12345", "username": "John", "height": "180", "age": "25", "sex": "rule" }, the output data d is: { "email": "[email protected]", "phone": "12345", "name": "John", "status": "180", "hobby": "swim", "num": "26"}.
Step S300: and performing field comparison based on the sorting result, and determining a comparison result.
In this embodiment, the device selects an appropriate alignment tool based on the sorting result, runs the alignment tool by writing an appropriate alignment program or script, for example, a JSON alignment tool or other file alignment tool, and performs field alignment on the data. And generating a comparison result after field comparison, processing the comparison result, and outputting the comparison result to a user, and intuitively presenting the comparison result so as to achieve the purpose of determining the comparison result.
As an alternative implementation of field comparison, when fields are compared, the same-name data sets in the sequencing result are directly compared at first to generate a same-name field comparison result; secondly, comparing the same-value data set and the difference data set of the sequencing result through a fuzzy comparison algorithm to generate a comparison result of different name fields; and finally, combining the field comparison result with the same name and the field comparison result with different names to generate a data sequence after comparison.
Illustratively, data c and data d are aligned. And comparing the field values of the two fields to obtain a comparison result, wherein the field values of the email field are different and the field values of the phone field are the same.
And determining that the usernames and the name fields actually belong to the same field by a fuzzy comparison algorithm for the usernames field of the data c and the name field of the data d, and comparing the field values of the usernames and the name field to obtain a comparison result with the same field value. Similarly, the height field, the status field and the fields with different names and different values are compared according to a fuzzy comparison algorithm to generate a comparison result.
In this embodiment, the same name data field and the different name data field are compared respectively. And for the same-name data fields, only comparing field values of the same-name fields in the same-name data set to generate comparison results of the same-name fields. For different fields in the same-value data set and the difference data set, because field names of the different fields are considered to be different due to the difference of naming methods of the fields by different data sources, a fuzzy comparison algorithm, for example, an N-gram algorithm, is adopted to compare data fields with similar field names, and a comparison result of the different fields is generated. And finally, combining the comparison results of the same name field and the different name fields to generate a data sequence after comparison.
Optionally, the comparison method of the data fields further comprises hash comparison and manual comparison and the like.
As another alternative embodiment of field alignment, a hash alignment method may be used when field alignment is performed. And respectively applying a hash algorithm to each field, such as MD5, SHA-1 and the like, calculating hash values of the fields, comparing the hash values of the two groups of data, if the hash values are the same, indicating that the field contents are the same, and if the hash values are different, indicating that the field contents are different, and completing comparison.
In an alternative scheme for determining the comparison result in this embodiment, when field comparison is completed and a comparison result is generated, firstly, according to the compared data sequence, marking data with different field values and generating a data field value difference point; then, the data sequences after comparison are counted to generate statistical information; and finally, outputting the difference points and the statistical information through a visualization tool to obtain the comparison result.
In this embodiment, the data fields with different field values after the comparison are marked, and the marking method includes additionally displaying the fields or highlighting the fields with red, etc., and by the marks, the difference points of the comparison are generated. And carrying out statistics on the generated data sequences, such as matching data quantity, unmatched data quantity, fuzzy matching data quantity and the like, so as to generate statistical information. And the difference points and the statistical information are used as display forms of comparison results, and are visually output to a user through a method of visualization tools such as a three-dimensional graph, a histogram, a table and the like, so that the comparison results of the comparison process are intuitively generated and presented.
For example, for the comparison result of data c and data d, it is assumed that the statistical information is the same field number of field values and the field number of fuzzy comparison. Firstly, marking the difference fields email of two groups of data to be red, marking the fields num, age, six, hobby and the like to be yellow, displaying the field number with the same field value as 3 through a visualization tool, and the field number in fuzzy comparison to be 2, generating a pie chart, and visually presenting the pie chart to a user for the user to check.
In the technical solution disclosed in this embodiment, referring to fig. 3, fig. 3 is a schematic flow chart of a specific application scenario in this embodiment. And acquiring data by calling an interface, adjusting the field sequence of the acquired interface data by dynamic sequencing, and finally comparing based on the sequenced data to generate a comparison result and visually presenting the comparison result to a user. The data comparison method and device not only achieve the full comparison of the data, but also intuitively present the comparison result, and improve the efficiency of the data consistency test.
Second embodiment
Based on the same inventive concept, the present solution also provides a second embodiment. In this embodiment, a method for dynamically comparing interface data of the present application will be further explained based on the flow chart shown in fig. 4.
When the data volume returned by the interface is too large, the comparison work becomes tedious and complicated, the comparison time is correspondingly prolonged, and a great amount of data intuitively presents the key point that a user cannot grasp the data field, so that the problem of low comparison efficiency is also caused.
Referring to fig. 4, after the step of dynamically ordering the first data and the second data to obtain the comparison result, the method further includes:
step S250: judging whether the length of a data field of the sequencing result reaches a preset field length threshold value or not;
and if the length of the data field of the sequencing result reaches the threshold value, marking an important field of the sequencing result based on a preset comparison logic, and comparing the important field of the sequencing result based on the important field.
In this embodiment, a data field length value is preset as a threshold value. If the length of the data field to be compared does not exceed the threshold value, the data quantity to be compared is the data quantity which can be completely received by the user, and the data to be compared is not processed; if the length of the data field to be compared exceeds the threshold value, the data field to be compared is excessively large in data quantity, and certain processing is carried out on the data to be compared so as to improve the efficiency of comparison work.
If the field quantity of the data to be compared reaches a threshold value, a specific comparison target is needed, and according to preset comparison logic, such as a more focused field name, the data to be compared is subjected to key marking or screening and filtering processing so as to ensure that the comparison work can grasp the focused point of the user. After the data to be compared is processed, only the important fields marked by the heavy points are compared and a comparison result is generated.
Illustratively, assuming a threshold of 100, the preset alignment logic specifies that only the name and salary fields are of interest. The data field quantity of the data a and the data b after dynamic sequencing exceeds the threshold value, and in order to efficiently perform data comparison, the name and the salary fields in the data a and the data b are marked, only the two fields are compared, and a comparison result is generated and output to a user.
In the technical scheme disclosed by the embodiment, under the condition that the length of the data field is too long, the comparison work is optimized, the data field focused by the user is compared with the comparison work, the workload of the equipment is reduced, the time is saved, the user can intuitively know the difference of the key fields, and the efficiency of the data consistency test is improved from another angle.
Third embodiment
Based on the same inventive concept, the present solution also provides a third embodiment. In this embodiment, a method for dynamically comparing interface data provided in the present application is further explained based on the flowchart shown in fig. 5.
Referring to fig. 5, after the step of determining the comparison result, the method further includes:
step S400: according to the comparison result, an access mode and a data volume are obtained;
in this embodiment, in order to reduce the overhead of repeated comparison, the comparison result needs to be cached in the device. Firstly, the access mode and the access quantity of the mobile terminal are acquired according to the comparison result. As an alternative embodiment to obtaining the access pattern, its access pattern may be determined by logging. And obtaining the access mode of the comparison result by analyzing the information such as the accessed frequency, the using frequency and the like in the log record.
Optionally, the method for obtaining the access mode further includes: user behavior analysis, user feedback, and the like.
As another alternative implementation manner for obtaining the access mode, the user behavior mode, such as the search behavior, the clicking behavior, and the like, of the user is analyzed through a user behavior analysis tool or a data mining technology, and the access mode of the current comparison result is determined.
Step S500: determining a caching strategy according to the access mode and the data volume;
in this embodiment, in order to adapt to different application scenarios and requirements, an appropriate cache policy needs to be determined according to the access mode and the data size of the comparison result. For example, if the comparison result shows the characteristic that the most commonly used data is likely to be used recently and the data volume is stable, the least recently used (Least Recently Used, LRU) caching strategy is selected, and if the comparison result shows the characteristic that the part of data is frequently accessed and the other part of data is rarely accessed, the least commonly used (Least Frequently Used, LFU) caching strategy is used.
Step S600: and setting the cache capacity according to the cache strategy and storing the comparison result into a cache.
In this embodiment, the maximum capacity of the cache is set according to the cache policy, and this capacity may be fixed or dynamically adjusted to meet the requirements of different periods for the cache. After the buffer capacity is set, the comparison result is buffered to the device, so that the result can be directly obtained from the buffer when the same data are compared later.
The comparison result c is generated after the data a and the data b are compared, and if the comparison result c needs to be accessed frequently, an LFU cache policy is selected, so that frequently accessed data items are effectively reserved, and the hit rate is improved. Based on the cache strategy determined by the comparison result and the size of the comparison result, the cache capacity of the comparison result is set, and the comparison result is cached in the device, so that the efficiency optimization of the data consistency test is realized.
In the technical scheme disclosed by the embodiment, the comparison result is cached in the equipment by determining the cache strategy and setting the cache capacity, and when the same comparison request occurs again, the comparison result is directly read from the cache, so that the comparison speed and response time are improved, the system load is reduced, the efficiency optimization of the data consistency test is realized to a certain extent, and the user experience is enhanced.
Fourth embodiment
Based on the same inventive concept, the present solution also provides a third embodiment. In this embodiment, a method for dynamically comparing interface data provided in the present application is further explained based on the flow chart shown in fig. 6.
Referring to fig. 6, the step of generating statistical information of the comparison result includes:
step S310: carrying out statistical index calculation on the compared data sequences to obtain statistical index data;
in this embodiment, it is first necessary to determine aspects of the comparison work that need to be measured and evaluated according to the specific purpose of the comparison and the expected result, and these aspects can be defined as statistical indicators. Based on a preset statistical index, data related to the data sequences after comparison needs to be collected, for example, in order to calculate the accurate matching rate of the data, the number of correctly matched data fields and the total number of data fields need to be collected; in order to calculate the fuzzy matching rate of data, the number of data fields of fuzzy matching, the number of total data fields, and the like need to be collected. And according to a preset statistical index, calculating based on the data of the compared data sequences to obtain statistical index data.
The statistical indexes are an accurate matching rate, a non-matching rate and a fuzzy matching rate, the accurate matching rate is calculated through the number of data fields which are matched correctly/the number of total data fields, the non-matching rate is calculated through the number of data fields which are not matched/the number of total data fields, the fuzzy matching rate is calculated through the number of data fields which are matched in fuzzy mode/the number of total data fields, and statistical values such as the accurate matching rate, the non-matching rate, the fuzzy matching rate and the like are obtained through calculation respectively.
Optionally, the preset statistical index may also be a missing rate, an error rate, a mismatch rate, and the like.
Preferably, the step of presetting the statistical index further includes: and according to the importance and the priority of the comparison task, proper weights are allocated to each index so as to reflect the contribution degree of different indexes to the overall comparison performance.
Step S320: and summarizing the statistical index data to generate the statistical information.
In this embodiment, each piece of statistical index data is extracted and summarized into a storable data structure, such as an index table or a dictionary, and each piece of statistical value is added to the data structure by means of key value pairs or rows and columns, so as to ensure the definition and accuracy of the data. Meanwhile, the data is summarized conveniently for displaying the generated statistical information by using the visualization tool.
In the technical scheme disclosed in the embodiment, statistical index data is obtained by carrying out statistical index calculation on the compared data sequences, the comparison result of the data fields is quantized, and a measurement standard is provided for a user so as to evaluate and analyze the comparison result. By summarizing and generating the statistical information, the method can help users evaluate the comparison performance, provides convenience for subsequent statistical information visualization, further can evaluate the credibility and reliability of the data source, and improves the data management efficiency and the efficiency of data consistency test to a certain extent.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a dynamic comparison device for interface data of a hardware running environment according to an embodiment of the present application.
As shown in fig. 7, the dynamic alignment device for interface data may include: a processor 1001, such as a central processing unit (Central Processing Unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, a memory 1005. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display, an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WIreless-FIdelity (WI-FI) interface). The Memory 1005 may be a high-speed random access Memory (Random Access Memory, RAM) Memory or a stable nonvolatile Memory (NVM), such as a disk Memory. The memory 1005 may also optionally be a storage device separate from the processor 1001 described above.
Those skilled in the art will appreciate that the structure shown in fig. 7 does not constitute a limitation of the dynamic alignment apparatus for interface data, and may include more or fewer components than shown, or may combine certain components, or may be a different arrangement of components.
As shown in fig. 7, a memory 1005, which is a storage medium, may include an operating system, a data storage module, a network communication module, a user interface module, and a dynamic alignment program for interface data.
In the dynamic comparison device of interface data shown in fig. 7, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the dynamic comparison device of the interface data may be disposed in the dynamic comparison device of the interface data, where the dynamic comparison device of the interface data invokes a dynamic comparison program of the interface data stored in the memory 1005 through the processor 1001, and executes the dynamic comparison method of the interface data provided in the embodiment of the present application.
In addition, the embodiment of the application also provides a computer readable storage medium, wherein the computer readable storage medium stores a dynamic comparison program of interface data, and the dynamic comparison program of the interface data realizes the steps of the dynamic comparison method of the interface data when being executed by a processor.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system 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 system. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present application are merely for describing, and do not represent advantages or disadvantages of the embodiments.
From the above description of embodiments, it will be clear to a person skilled in the art that the above embodiment method may be implemented by means of software plus a necessary general hardware platform, but may of course also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) as described above, including several instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method described in the embodiments of the present application.
The foregoing description is only of the preferred embodiments of the present application, and is not intended to limit the scope of the claims, and all equivalent structures or equivalent processes using the descriptions and drawings of the present application, or direct or indirect application in other related technical fields are included in the scope of the claims of the present application.

Claims (10)

1. The dynamic comparison method of the interface data is characterized by comprising the following steps of:
acquiring first data returned by a first interface and second data returned by a second interface;
dynamically sequencing the first data and the second data according to the field names and the field values in the first data and the second data to obtain sequencing results;
and performing field comparison based on the sorting result, and determining a comparison result.
2. The method of dynamic alignment of interface data of claim 1, wherein the step of dynamically ordering the first data and the second data comprises:
screening the homonymous data fields in the first data and the second data, and arranging according to the field names and the appointed sequence of the ordering rule to generate a homonymous data set;
screening different name and value data fields in the first data and the second data, and arranging according to the field values and the appointed sequence of the ordering rule to generate a value data set;
screening data fields with different names and different values in the first data and the second data, and arranging according to the appointed sequence of the ordering rule to generate a difference data set;
and sequentially generating sequencing results corresponding to the first data and the second data based on the same-name data set, the same-value data set and the difference data set.
3. The method for dynamically comparing interface data according to claim 2, wherein the step of comparing fields based on the sorting result comprises:
directly comparing the same-name data sets of the sequencing results to generate a same-name field comparison result;
comparing the same-value data set and the difference data set of the sequencing result through a fuzzy comparison algorithm to generate a field comparison result with different names;
and combining the comparison result of the same name field and the comparison result of the different name fields to generate a data sequence after comparison.
4. The method for dynamically comparing interface data according to claim 2, wherein after the step of dynamically sorting the first data and the second data to obtain the sorting result, further comprises:
judging whether the length of the data field of the sequencing result reaches a preset field length threshold value or not;
and if the length of the data field of the sequencing result reaches the threshold value, marking an important field of the sequencing result based on a preset comparison logic, and comparing the important field of the sequencing result based on the important field.
5. A method of dynamically aligning interface data as recited in claim 3 wherein the step of determining the alignment result comprises:
marking data with different field values according to the compared data sequences, and generating data field value difference points;
counting the compared data sequences to generate statistical information;
and outputting the difference points and the statistical information through a visualization tool to obtain the comparison result.
6. The method for dynamically aligning interface data according to claim 5, wherein the step of counting the aligned data sequences and generating statistical information comprises:
carrying out statistical index calculation on the compared data sequences to obtain statistical index data;
and summarizing the statistical index data to generate the statistical information.
7. The method for dynamically comparing interface data according to claim 1, wherein after the step of determining the comparison result, further comprises:
according to the comparison result, an access mode and a data volume are obtained;
determining a caching strategy according to the access mode and the data volume;
and setting the cache capacity according to the cache strategy and storing the comparison result into a cache.
8. The method for dynamically comparing interface data according to claim 1, wherein the step of acquiring the first data returned by the first interface and the second data returned by the second interface comprises:
constructing and packaging a data request message header and a data request message body according to interface protocol specifications of the first interface and the second interface, and generating a data request message;
initiating a data request according to the data request message;
receiving a response message of the data request;
analyzing the response message according to the interface protocol specifications of the first interface and the second interface to obtain header information;
extracting target data from the response message according to the head information to acquire the target data;
and analyzing the target data according to the format of the response message and the interface protocol specifications of the first interface and the second interface, and acquiring the first data and the second data.
9. A dynamic alignment apparatus for interface data, the dynamic alignment apparatus comprising: memory, a processor and a dynamic alignment program of interface data stored on the memory and executable on the processor, the dynamic alignment program of interface data being configured to implement the steps of the dynamic alignment method of interface data as claimed in any one of claims 1 to 8.
10. A computer-readable storage medium, wherein a dynamic alignment program of interface data is stored on the computer-readable storage medium, the dynamic alignment program of interface data implementing the steps of the dynamic alignment method of interface data according to any one of claims 1 to 8 when executed by a processor.
CN202311757109.5A 2023-12-20 2023-12-20 Dynamic comparison method, dynamic comparison device and storage medium for interface data Active CN117435509B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311757109.5A CN117435509B (en) 2023-12-20 2023-12-20 Dynamic comparison method, dynamic comparison device and storage medium for interface data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311757109.5A CN117435509B (en) 2023-12-20 2023-12-20 Dynamic comparison method, dynamic comparison device and storage medium for interface data

Publications (2)

Publication Number Publication Date
CN117435509A true CN117435509A (en) 2024-01-23
CN117435509B CN117435509B (en) 2024-04-02

Family

ID=89553885

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311757109.5A Active CN117435509B (en) 2023-12-20 2023-12-20 Dynamic comparison method, dynamic comparison device and storage medium for interface data

Country Status (1)

Country Link
CN (1) CN117435509B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108733662A (en) * 2017-04-13 2018-11-02 北京京东尚科信息技术有限公司 Method, apparatus, electronic equipment and the readable storage medium storing program for executing of comparison of data consistency
CN113642311A (en) * 2021-08-12 2021-11-12 北京奇艺世纪科技有限公司 Data comparison method and device, electronic equipment and storage medium
CN115221201A (en) * 2022-06-25 2022-10-21 平安银行股份有限公司 Data processing method of asynchronous thread and related device
WO2023093607A1 (en) * 2021-11-23 2023-06-01 天翼数字生活科技有限公司 Offline data fuzzy search method and apparatus, device and medium
CN116701406A (en) * 2023-07-07 2023-09-05 中国平安人寿保险股份有限公司 Data comparison method and device, computer equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108733662A (en) * 2017-04-13 2018-11-02 北京京东尚科信息技术有限公司 Method, apparatus, electronic equipment and the readable storage medium storing program for executing of comparison of data consistency
CN113642311A (en) * 2021-08-12 2021-11-12 北京奇艺世纪科技有限公司 Data comparison method and device, electronic equipment and storage medium
WO2023093607A1 (en) * 2021-11-23 2023-06-01 天翼数字生活科技有限公司 Offline data fuzzy search method and apparatus, device and medium
CN115221201A (en) * 2022-06-25 2022-10-21 平安银行股份有限公司 Data processing method of asynchronous thread and related device
CN116701406A (en) * 2023-07-07 2023-09-05 中国平安人寿保险股份有限公司 Data comparison method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN117435509B (en) 2024-04-02

Similar Documents

Publication Publication Date Title
CN109902708B (en) Recommendation model training method and related device
CN108446210B (en) System performance measurement method, storage medium and server
CN110070117B (en) Data processing method and device
CN108833458B (en) Application recommendation method, device, medium and equipment
JP4180638B2 (en) Analysis method and apparatus
CN103577413A (en) Search result ordering method and system and search result ordering optimization method and system
CN112162977B (en) MES-oriented mass data redundancy removing method and system
CN113268403B (en) Time series analysis and prediction method, device, equipment and storage medium
CN113468034A (en) Data quality evaluation method and device, storage medium and electronic equipment
CN110489142B (en) Evaluation method and device for equipment software upgrading, storage medium and terminal
CN113360300B (en) Interface call link generation method, device, equipment and readable storage medium
CN117435509B (en) Dynamic comparison method, dynamic comparison device and storage medium for interface data
US7797136B2 (en) Metrics to evaluate process objects
CN117763316A (en) High-dimensional data dimension reduction method and dimension reduction system based on machine learning
CN110955774B (en) Word frequency distribution-based character classification method, device, equipment and medium
CN111782774B (en) Method and device for recommending problems
CN107844536A (en) The methods, devices and systems of application program selection
CN114780589A (en) Multi-table connection query method, device, equipment and storage medium
CN113779116B (en) Object ordering method, related equipment and medium
CN111209428A (en) Image retrieval method, device, equipment and computer readable storage medium
CN113901770A (en) Report generation method based on random forest model and related equipment
CN110471586B (en) Project recommendation method, apparatus, computer device and storage medium
CN113780666A (en) Missing value prediction method and device and readable storage medium
CN112927092A (en) Method, device and equipment for predicting claim settlement trend and storage medium
CN111026661A (en) Method and system for comprehensively testing usability of software

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
GR01 Patent grant
GR01 Patent grant