Downlink interface test method and device, storage medium and program product

By comparing the request data and response data of the interaction data to be tested in the downlink interface with the request data and the expected interaction data, the problems of inefficient testing and omission in the prior art are solved, and a more comprehensive data coverage and efficient testing process are achieved.

CN119402384APending Publication Date: 2025-02-07ZHEJIANG ZEEKR INTELLIGENT TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411532477.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

The existing technology is inefficient when testing downlink interfaces, is prone to errors, and cannot fully cover all data. Especially when the data structure is complex and the number is large, a large amount of assertion code is required to write, which is inefficient in testing.

Method used

By obtaining the interaction data to be tested and expected interaction data of the target downlink interface, comparing the request data and response data, and confirming that the comparison results are consistent, it is determined that the function of the downlink interface is normal. Optionally, the interactive data template collection is used to maintain the expected interaction data of different test scenarios, and the corresponding expected interaction data is selected according to the test scenario identification for comparison.

Benefits of technology

It realizes the test scope covering the fields in the request data and response data contained in the interactive data to be tested, effectively avoiding the problem of test omissions, improving the testing efficiency, simple logic and reusable.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119402384A_ABST
    Figure CN119402384A_ABST
Patent Text Reader

Abstract

One or more embodiments of the present specification provide a downlink interface test method and device, a storage medium and a program product, the method comprising: obtaining to-be-tested interaction data of a target downlink interface and corresponding expected interaction data, both the to-be-tested interaction data and the expected interaction data comprise request data and response data corresponding to the downlink interface; comparing the request data and the response data included in the to-be-tested interaction data and the expected interaction data; and under the condition of determining that the comparison result is consistent, determining that the function of the target downlink interface is normal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present specification relate to the field of operation and maintenance technology, and in particular, to a method, device, storage medium, and program product for testing a downlink interface. Background Art

[0002] In software architectures such as microservices, when one system (upstream system) calls the interface of another system (downstream system), data flows from the upstream system to the downstream system. In this case, the interface provided by the downstream system is called the downstream interface. For the operation and maintenance testers of the upstream system, considering the functional division between systems, coupling requirements, and test efficiency, they often do not choose to directly simulate the downstream interface request for targeted testing, but focus on whether the data transmitted from the upstream system to the downstream system is correct and consistent.

[0003] In the related art, the correctness and consistency are usually checked manually by checking the interface documents. However, this method is inefficient and prone to errors. Alternatively, automated tools are used to assert some key fields of the data between the upstream system and the downstream system. However, this verification method cannot fully cover all data and is prone to test omissions. Especially when the data structure is complex and the number is large, a large amount of assertion code needs to be written, and the test efficiency is low. Summary of the invention

[0004] In view of this, one or more embodiments of this specification provide the following technical solutions:

[0005] According to a first aspect of one or more embodiments of this specification, a method for testing a downlink interface is provided, the method comprising:

[0006] Acquire the interaction data to be tested and the corresponding expected interaction data of the target downlink interface, wherein the interaction data to be tested and the expected interaction data both include the request data and the response data corresponding to the downlink interface;

[0007] Comparing the request data and the response data included in the interaction data to be tested and the expected interaction data;

[0008] When it is determined that the comparison results are consistent, it is determined that the function of the target downlink interface is normal.

[0009] Optionally, the target downlink interface corresponds to at least one expected interaction data, each expected interaction data corresponds to a different test scenario of the target downlink interface, and each expected interaction data is maintained in an interaction data template set; the step of obtaining the interaction data to be tested and the corresponding expected interaction data of the target downlink interface includes:

[0010] Acquire the interaction data to be tested of the target downlink interface, wherein the interaction data to be tested includes a corresponding test scenario identifier;

[0011] According to the test scenario identifier, expected interaction data matching the test scenario identifier is selected from the interaction data template set.

[0012] Optionally, the interactive data template set further maintains expected format data corresponding to each expected interactive data, and the expected format data defines the data format of the request data and the response data in the corresponding expected interactive data; the comparing the interactive data to be tested with the request data and the response data contained in the expected interactive data includes:

[0013] Comparing the request data and the response data included in the interaction data to be tested and the selected expected interaction data;

[0014] Parsing the data formats of the request data and the response data in the interaction data to be tested and converting them into corresponding format data to be tested; and comparing the format data to be tested with expected format data corresponding to the selected expected interaction data in the interaction data template set.

[0015] Optionally, determining that the comparison results are consistent includes:

[0016] Determine that any one of a first comparison result between the interaction data to be tested and the selected expected interaction data, and a second comparison result between the format data to be tested and the selected expected format data is consistent; or,

[0017] It is determined that a first comparison result between the interaction data to be tested and the selected expected interaction data, and a second comparison result between the format data to be tested and the expected format data are consistent.

[0018] Optionally, the method further includes:

[0019] Acquire newly added expected interaction data, wherein the newly added expected interaction data includes a corresponding target test scenario identifier;

[0020] In the case that there is no target expected interaction data matching the target test scenario identifier in the interaction data template set, adding the newly added expected interaction data to the interaction data template set;

[0021] If there is target expected interaction data matching the target test scenario identifier in the interaction data template set, and the target expected interaction data is inconsistent with the newly added expected interaction data, updating the newly added expected interaction data to the target expected interaction data;

[0022] If target expected interaction data matching the target test scenario identifier exists in the interaction data template set, and the target expected interaction data is consistent with the newly added expected interaction data, the interaction data template set is not processed.

[0023] Optionally, the method further includes:

[0024] Setting the ignored fields in the request data and the response data;

[0025] According to the ignored fields, the fields that match between the interaction data to be tested and the expected interaction data are ignored, and new interaction data to be tested and expected interaction data are generated based on other fields to participate in comparison processing.

[0026] Optionally, the method further includes:

[0027] In the case where the target downlink interface corresponds to a plurality of expected interaction data, acquiring each interaction data to be tested respectively based on multi-threading technology;

[0028] The comparison results between each interaction data to be tested and the corresponding expected interaction data are combined, and a test report for the target downlink interface is generated based on the combined comparison results.

[0029] According to a second aspect of one or more embodiments of this specification, an electronic device is proposed, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor implements the steps of the method described in the first aspect by running the executable instructions.

[0030] According to a third aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in the first aspect are implemented.

[0031] According to a fourth aspect of one or more embodiments of the present specification, a computer program product is provided, comprising a computer program / instruction, which implements the steps of the method described in the first aspect when executed by a processor.

[0032] In the technical solution provided in this specification, by comparing the interaction data to be tested of the target downstream interface with the request data and response data contained in the corresponding expected interaction data, the test scope is covered to each field in the request data and response data contained in the interaction data to be tested, effectively avoiding the problem of test omissions; in addition, compared with the assertion verification method, the comparison-based verification method between the interaction data to be tested and the expected interaction data is simple in logic and reusable, and can still ensure high test efficiency in the test scenario faced with large amounts of complex data. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the embodiments or prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work.

[0034] Figure 1 It is a schematic diagram of the architecture of a downlink interface test system provided by an exemplary embodiment;

[0035] Figure 2 It is a flowchart of a method for testing a downlink interface provided by an exemplary embodiment;

[0036] Figure 3 It is an interactive schematic diagram of another method for testing a downlink interface provided by an exemplary embodiment;

[0037] Figure 4 is a schematic diagram of an interactive data template set provided by an exemplary embodiment;

[0038] Figure 5 It is a schematic diagram of a process of updating an interactive data template set provided by an exemplary embodiment;

[0039] Figure 6 is a flow chart of comparing interaction data to be tested with expected interaction data provided by an exemplary embodiment;

[0040] Figure 7 It is a schematic diagram of a flow chart of generating a test report provided by an exemplary embodiment;

[0041] Figure 8 is a schematic structural diagram of an electronic device provided by an exemplary embodiment;

[0042] Fig. 9 It is a structural diagram of a downlink interface device provided by an exemplary embodiment. DETAILED DESCRIPTION

[0043] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are only examples of devices and methods consistent with some aspects of the present invention.

[0044] The terms used in the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The singular forms "a", "the" and "the" used in the present invention and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0045] It should be understood that although the terms first, second, third, etc. may be used in the present invention to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present invention, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0046] Figure 1 FIG. 1 is a schematic diagram of the architecture of a downlink interface test system provided by an exemplary embodiment. Figure 1 As shown, the system includes an upstream system 102 and a downstream system 104 .

[0047] As the generator or initial processor of data, the upstream system 102 can pass the corresponding data to the downstream system 104. Among them, the upstream system can call the downstream interface of the downstream system 104, and record the request data sent to the downstream interface and the response data received from the downstream interface as the corresponding interaction data to be tested. At the same time, the upstream system 102 can also record the expected interaction data corresponding to the above interaction data to be tested, so as to realize the functional test of the above downstream interface. Specifically, it can be determined whether the interaction data to be tested meets the expectations by comparing whether the interaction data to be tested and the expected interaction data are consistent. If the two are consistent, it means that the interaction data to be tested meets the expectations and the function of the above downstream interface is normal; correspondingly, if the two are inconsistent, it means that the interaction data to be tested does not meet the expectations and the function of the above downstream interface is abnormal. Among them, for the interaction data to be tested of each downstream interface, compared with the upstream interface that only needs to verify the response data, the downstream interface also needs to verify whether the request data and the response data meet the expectations. Specifically, the above functional test can be handed over to the automation engineering deployed locally by the upstream system or other automation platforms independent of the upstream system for execution, and this specification does not limit this.

[0048] As the data receiver of the upstream system 102 , the downstream system 104 can receive the data through its own downstream interface for further processing or storage, and can also return the corresponding response data to the upstream system 102 , thereby realizing a data interaction between the upstream system 102 and the downstream system 104 .

[0049] Of course, the so-called upstream and downstream terms can be used to describe the dependencies and data flows between components or systems, and their specific meanings may vary depending on the software architecture. For example, in the Microservices Architecture, the upstream system refers to the service that initiates a request in the service call chain, and the downstream system refers to the service that receives the request and provides a response. Specifically, if service A calls service B, then service A can be called the upstream system of service B, and service B can be called the downstream system of service A. For another example, in the Client-Server Architecture, the upstream system can refer to the client because it initiates a request to the server, and the downstream system can refer to the server because it processes the client's request and returns a response. In short, this specification does not limit the software architecture to which the upstream system and the downstream system belong.

[0050] Figure 2 This is a flow chart of a method for testing a downlink interface provided by an exemplary embodiment, the method specifically comprising the following steps:

[0051] Step S202: Acquire the interaction data to be tested and the corresponding expected interaction data of the target downlink interface, wherein the interaction data to be tested and the expected interaction data both include request data and response data corresponding to the downlink interface.

[0052] When the upstream system needs to test whether the target downstream interface of the downstream system can receive and send data in an expected manner, it can first obtain the interaction data to be tested and the corresponding expected interaction data of the target downstream interface. The upstream system can record the interaction data generated between the upstream system and the downstream system based on each downstream interface, and extract the request data and response data for the target downstream interface in an automated manner as the interaction data to be tested. The expected interaction data refers to the request data and response data that the upstream system can obtain that meet expectations when the target downstream interface functions normally.

[0053] It should be noted that the above-mentioned interaction data to be tested and the expected interaction data can be expressed in formats such as JavaScript Object Notation (JSON), eXtensible Markup Language (XML), YAML Ain't Markup Language (YAML) according to actual needs, and this is not limited in this specification.

[0054] In addition, the above-mentioned target downlink interface can be a single downlink interface or a collection of multiple different downlink interfaces, which is not limited in this specification.

[0055] The expected interaction data corresponding to the interaction data to be tested may be obtained through a pre-maintained interaction data template set.

[0056] In one embodiment, the target downlink interface may correspond to at least one expected interaction data, and each expected interaction data may correspond to a different test scenario of the target downlink interface, and each expected interaction data is maintained in an interaction data template set. After acquiring the interaction data to be tested, the corresponding test scenario identifier may be determined from the interaction data to be tested, and the expected interaction data matching the test scenario identifier may be selected from the interaction data template set according to the test scenario identifier as the expected interaction data corresponding to the interaction data to be tested. Among them, the same downlink interface may be designed with a variety of test scenarios according to actual needs, and each test scenario may correspond one-to-one to the expected interaction data in the interaction data template set. The interaction data template set, as a container for storing the expected interaction data, may be stored in different forms such as file directories, tables, and databases, which is not limited in this specification.

[0057] by Figure 3 For example, in the scenario of vehicle-cloud interaction, the vehicle can exchange data and communicate with the cloud platform through wireless communication technology. In this case, the cloud platform sends a message to the receiving end (i.e., the receiver) inside the vehicle through the telematics service provider (TSP) system. Figure 3 In the case where an operation instruction is issued by the cloud platform (on the vehicle side), the data flow corresponding to the operation instruction is "cloud platform->TSP system->vehicle side". For the cloud platform, the cloud platform acts as an upstream system while the TSP system acts as a downstream system and provides a corresponding downstream system for it. Therefore, the cloud platform can perform corresponding automated verification on the interactive data generated by the downstream interface provided by the TSP system to quickly determine whether the downstream interface provided by the TSP system can normally receive and process the operation instruction from the cloud platform. Specifically, the cloud platform can create a vehicle task to execute the instruction issuance operation for the corresponding TSP system in the vehicle task, and enable the TSP system to receive the above operation instruction through the corresponding downstream interface, wherein the above downstream interface may include an instruction notification interface for receiving instructions, an account registration interface, and the like.

[0058] For different vehicle models, the cloud platform can be configured with different TSP channels, and the operation instructions can be sent to the corresponding TSP system through different TSP channels. Different TSP systems may perform different operations for the same or different instruction information, and return different response information, which leads to different expected interaction data of the downstream interfaces of different TSP systems. For this purpose, the cloud platform can create corresponding vehicle tasks for different vehicle models, such as Figure 3In the A-type vehicle task, B-type vehicle task, ... X-type vehicle task, each vehicle task can call the downlink interface of different TSP systems through the corresponding TSP channel, for example Figure 3 By issuing an operation instruction in the A-type vehicle task, the receiving instruction notification interface of the TSP1 system is activated, or by issuing an operation instruction in the B-type vehicle task, the receiving instruction notification interface of the TSP2 system is activated, and so on.

[0059] Of course, even the same target downstream interface may trigger different processing methods due to different request data, and then return different response data. Therefore, the concept of test scenario can be used to summarize and manage the expected interaction data involved in the downstream interface, that is, to stipulate that each test scenario corresponds to one expected interaction data. Still taking the above-mentioned car-cloud interaction scenario as an example, assuming that the above-mentioned cloud platform is connected to 6 TSP systems, each TSP system provides 2 downstream interfaces, namely, receiving instruction notification interface and registration interface. Among them, 3 test scenarios are designed for the receiving instruction notification interface, namely, issuing push task instructions, issuing configuration synchronization instructions, and issuing withdrawal instructions. The registration interface is separately designed with an account registration scenario. The combination of them can determine the following 24 test scenarios;

[0060]

[0061] The interactive data template set of the cloud platform can record the corresponding expected interactive data based on the above test scenarios, so as to improve the interactive data to be tested that can be tested by the cloud platform, and avoid the abnormal situation that the corresponding expected interactive data is not found after the interactive data to be tested is obtained. At the same time, each expected interactive data can be recorded with a corresponding test scenario identifier, so that the interactive data template set can quickly determine the expected interactive data that matches it according to the test scenario identifier of the interactive data to be tested.

[0062] In addition, if Figure 4 As shown, in addition to recording the expected interaction data of different test scenarios, the above interaction data template set can also record the expected format data corresponding to each expected interaction data. The expected format data can define the data format of the request data and the response data in the corresponding expected interaction data, thereby serving as supplementary description information for the expected interaction data and expanding the comparison dimension between the above interaction data to be tested and the above expected interaction data. For example, there is an expected interaction data in JSON format, and contains the following JSON fragment:

[0063]

[0064] Then, by converting the above expected interaction data into JSON Schema (JSON mode) format, the corresponding expected format data can be obtained, and its content includes the following JSON Schema fragment:

[0065]

[0066]

[0067] It can be understood by those skilled in the art that JSON Schema, as an independent format, although still essentially a JSON file, can be used to describe and verify the JSON data structure compared to the expected interaction data. Therefore, the JSON fragment of the expected format data only indicates that the value of the field user_id (user ID) is 1234, and the value of the field user_name (user name) is Zhang San, but no further description is given for the specific type of each field value; and the JSON Schema fragment corresponding to the expected format data describes that the value of the field user_id (user ID) is an integer type, and the value of the field user_name (user name) is a string type. Among them, the specific comparison method of the expected interaction data and the expected format data will be discussed in step S204 below, so this specification will not be described in detail here.

[0068] The above test scenarios are not fixed, but will continue to expand according to changes in upstream and downstream functions, or modify the expected interaction data based on existing test scenarios. This specification can update the interaction data template set based on the newly added expected interaction data, thereby ensuring that the expected interaction data obtained from the interaction data template set is real-time and accurate.

[0069] In one embodiment, the system may obtain newly added expected interaction data, and the newly added expected interaction data includes a corresponding target test scenario identifier, and then attempt to match the target expected interaction data corresponding to the target test scenario identifier in the interaction data template set, and at least one of the following situations occurs:

[0070] The first case: there is no target expected interaction data matching the target test scenario identifier in the above interaction data template set. In this case, it means that the newly added expected interaction data corresponds to a new test scenario not recorded in the interaction data template set, and the newly added expected interaction data can be added to the above interaction data template set;

[0071] The second situation: the above-mentioned interaction data template set contains target expected interaction data that matches the above-mentioned target test scenario identifier, and the above-mentioned target expected interaction data is inconsistent with the above-mentioned newly added expected interaction data. In this case, it means that the newly added expected interaction data corresponds to the historical test scenario recorded in the interaction data template set. When the corresponding data content changes, the above-mentioned newly added expected interaction data can be updated to the above-mentioned target expected interaction data. In other words, the newly added expected interaction data will replace the original target expected interaction data and serve as the new target expected interaction data.

[0072] The third situation: the above-mentioned interaction data template set contains target expected interaction data that matches the above-mentioned target test scenario identifier, and the above-mentioned target expected interaction data is consistent with the above-mentioned newly added expected interaction data. In this case, it means that the above-mentioned newly added expected interaction data has been added to the interaction data template set, and therefore no additional processing is required for the above-mentioned interaction data template set.

[0073] Among them, the data consistency between the above-mentioned target expected interaction data and the above-mentioned newly added expected interaction data can be judged based on the comparison method of function libraries such as deepdiff and json_tool. Its advantage is that the implementation process is simple and does not require the consistency of the content of the target expected interaction data and the newly added expected interaction data in order; or, through a cryptographic hash function such as Message Digest Algorithm 5 (MD5) and Secure Hash Algorithm 3 (SHA-3), the hash value of each expected interaction data is pre-calculated and recorded, and when the hash values ​​of the target expected interaction data and the newly added expected interaction data are consistent, it is determined that the two belong to the same data. Its advantage is that the comparison speed is fast.

[0074] In addition, in combination with the expected format data that can be converted from the expected interaction data in the previous article, the target expected interaction data in the first case and the second case above can perform the same processing on the corresponding expected format data during the process of adding or updating the target expected interaction data to the interaction data template set.

[0075] Combine the following Figure 5 The following is an introduction to the updating method of the interactive data template set. The method specifically comprises the following steps:

[0076] Step S502: determine whether there is an interactive data template set.

[0077] In one embodiment, assuming that the above data template set is a file directory of a specified path, the upstream system can pre-determine whether there is a file directory corresponding to the above specified path before updating the interactive data template set. If so, execute step S506, otherwise execute S504.

[0078] Step S504: creating an interactive data template set.

[0079] In one embodiment, a file directory may be created as the above-mentioned interaction data template set.

[0080] Step S506, obtaining a set of downlink interface test scenarios corresponding to the newly added expected interaction data, and looping through them.

[0081] In one embodiment, for each newly acquired expected interaction data, the target test scenario identifier contained in each data may be extracted in a traversal manner and participate in subsequent steps S508 to S520.

[0082] Step S508: Compare each newly added expected interaction data with the expected interaction data in the interaction data template set according to the test scenario identifier.

[0083] Step S510, determining whether the traversed newly added expected interaction data matches the target expected interaction data.

[0084] In one embodiment, an attempt can be made to match the target expected interaction data corresponding to the above-mentioned target test scenario identifier in the interaction data template set. If the target expected interaction data matching the target test scenario identifier exists in the interaction data template set, step S516 is executed, otherwise step S512 is executed.

[0085] Step S512, converting the traversed newly added expected interaction data into expected format data.

[0086] In one embodiment, it is determined that the target expected interaction data does not exist in the interaction data template set, which meets the first situation mentioned above. At this time, an automated script such as Python can be run to convert the request data and response data of the corresponding downstream interface in the newly added expected interaction data into expected format data.

[0087] Step S514: adding the traversed newly added expected interaction data and the corresponding expected format data to the interaction data template set.

[0088] In one embodiment, assuming that the newly added expected interaction data corresponds to JSON and the expected format data corresponds to a JSON Schema file, both of them can be added together to the file directory corresponding to the interaction data template set.

[0089] Step S516, determining whether the target expected interaction data is consistent with the traversed newly added expected interaction data.

[0090] In one embodiment, when there is target expected interaction data in the interaction data template set, it is possible to further determine whether the target expected interaction data is consistent with the newly added expected interaction data based on the tool library such as the above-mentioned DeepDiff. If they are consistent, no further operation is performed on the interaction data template set, otherwise step S518 is executed.

[0091] Step S518, obtaining corresponding request data and response data, and converting them into expected format data.

[0092] This step is basically the same as step S512, so it will not be described again in this specification.

[0093] Step S520: update the traversed newly added expected interaction data and the corresponding expected interaction data to target expected interaction data and the corresponding expected interaction data respectively.

[0094] In one embodiment, assuming that the newly added expected interaction data corresponds to JSON and the expected format data corresponds to a JSON Schema file, the two can replace the expected interaction data and the corresponding expected format data corresponding to the same target test scenario identifier in the interaction data template set.

[0095] Step S204: compare the request data and the response data included in the interaction data to be tested and the expected interaction data.

[0096] After obtaining the interaction data to be tested and the corresponding expected interaction data, the request data and response data of the two can be compared to see if they are consistent, and a first comparison result can be obtained. As mentioned above, when the interaction data template set maintains the expected format data of each expected interaction data, the data formats of the request data and response data in the interaction data to be tested can be parsed and converted into the corresponding format data to be tested, and the format data to be tested can be compared with the expected format data corresponding to the selected expected interaction data in the interaction data template set, and a second comparison result can be obtained.

[0097] The comparison operation between the above-mentioned interaction data to be tested and the above-mentioned expected interaction data, as well as the comparison operation between the above-mentioned format data to be tested and the expected format data in the interaction data template set can be implemented by a comparison tool library that encapsulates assertion classes and assertion methods, such as the DeepDiff library or json_tool library with the DeepDiff method. At the same time, on this basis, additional comparison classes containing the above-mentioned tool library can be defined to reuse the comparison logic for different expected interaction data and expected format data. Among them, the first comparison result is essentially a comparison test between the fields and field values ​​in the interaction data, and the second comparison result can be a comparison test between the types of fields and field values, that is, the second comparison result can avoid the special situation that the first comparison result misjudges two interaction data with the same value but different types as consistent. The accuracy of the comparison result is effectively improved. Overall, the idea of ​​comparing different data realizes the assertion of each field contained in the request data and the response data, and makes certain guarantees for the data correctness and consistency of the interface. At the same time, batch verification of the request data and response data of the downstream interface can be realized by comparison, thereby improving the test efficiency.

[0098] The solution of this specification can also pre-process the request data and response data in the interaction data to be tested and the expected interaction data to eliminate the content that has no effect on the comparison process or even has a negative impact, and finally obtain new interaction data to be tested and new expected interaction data with smaller data volume.

[0099] In one embodiment, the ignored fields in the request data and the response data can be pre-set, such as timestamp, installationOrderId, date, etc., whose values ​​change with each execution of the automation script. The fields that match the interaction data to be tested and the expected interaction data are ignored according to the ignored fields, and new interaction data to be tested and the expected interaction data are generated based on other fields. In the process of matching the ignored fields, the case of the letters in the field names can be unified to improve the matching rate, and all ignored fields are stored in a specified list or array. In this embodiment, since the values ​​of the ignored fields themselves are random, a large number of first comparison results are erroneously converted from consistent to inconsistent during the comparison of the interaction data. Therefore, the ignored fields in the interaction data to be tested and the expected interaction data can be ignored, and other fields outside the ignored fields can be used as new interaction data to be tested and the expected interaction data with a smaller data volume, thereby improving the overall comparison speed of the two. Of course, the above-mentioned ignored fields can be customized by the user, or they can be learned based on machine learning technology using deep learning models and other methods to learn historical interaction data, and automatically determine the fields with frequently changing content in the request data and response data as ignored fields.

[0100] Combine the following Figure 6 , a method for comparing the interaction data to be tested with the expected interaction data is introduced. The method comprises the following steps:

[0101] Step S602 , using the encapsulated assertion method, taking the actual interaction data to be tested actual_json and the test scenario identifier scenario as parameters, to execute AssertTool.compare_json_and_jsonschema(actual_json, scenario).

[0102] In one embodiment, assuming that the actual interaction data to be tested actual_json in JSON format and the corresponding test scenario identifier scenario are obtained, the subsequent steps can be triggered by defining a static method compare_json_and_jsonschema(actual_json, scenario) in a custom tool class AssertTool.

[0103] Step S604, determining the corresponding expected interaction data json_model and expected format data jsonschema_model from the interaction data template set according to the test scenario.

[0104] In one embodiment, the above method compare_json_and_jsonschema(actual_json, scenario) instructs the upstream system to search for the expected interaction data json_model (including corresponding request data and response information) and expected interaction data jsonschema_model of the downstream interface corresponding to the test scenario scenario from the interaction data template set according to the test scenario identifier scenario of the interaction data to be tested, and locate the corresponding json file storage address.

[0105] Step S606, open the file stream, and obtain json_model and jsonschema_model based on the json.load method.

[0106] In one embodiment, based on the determined storage locations of the expected interaction data json_model and the expected interaction data jsonschema_model, the contents of the two may be read in the form of a file stream through json.load.

[0107] Step S608, taking actual_json as a parameter, using a json to jsonschema tool to obtain the actual format data jsonschema to be tested.

[0108] In one embodiment, the interaction data to be tested actual_json in JSON format may be converted into format data to be tested in jsonschema format using a corresponding format conversion formula.

[0109] like Figure 6 As shown, the detection operation of the target downstream interface is divided into a comparison process of the interaction data to be tested actual_json and the expected interaction data json_model (ie, steps S610 to S618), and a comparison process of the format data to be tested actual_jsonschema and the expected format data jsonschema_model (ie, steps S620 to S624).

[0110] Step S610, calling the ignored field processing tool, process_json(actual_json, ignore_list), to obtain new interaction data to be tested actual_json_new.

[0111] Step S612, call the ignored field processing tool, process_json(json_model,ignore_list), to obtain new expected interaction data Json_model_new.

[0112] In one embodiment, in order to avoid the influence of ignored field values ​​such as timestamp and date on the comparison between the interaction data actual_json to be tested and the expected interaction data json_model, they can be centrally recorded in the preset ignored field list ignore_list. Then, through the custom ignored field filtering tool process_json(json, ignore_list), the interaction data actual_json to be tested and the expected interaction data json_model can be deeply traversed, and all fields that do not hit ignore_list can be recorded during the filtering process, and finally a new interaction data actual_json_new to be tested and the expected interaction data json_model_new can be output.

[0113] Step S614, calling the comparison function in the tool library and assigning a value.

[0114] Json_compare_result=DeepDiff(actual_json, json_model, view="tree", ignore_order=True, ignore_string_case=True).

[0115] In one embodiment, a comparison tool, the DeepDiff method under the deepdiff library, is introduced to compare the complex interaction data to be tested actual_json_new with the expected interaction data json_model_new. The method can set the depth of comparison, which defaults to 0.2, and is more friendly to dictionary nesting and list nesting structures. Among them, the parameters "ignore_order=True" and "ignore_string_case=True" are used to ignore the field order and content case of the two compared parties, respectively. The result set Json_compare_result of the assigned method result can be used to characterize the differences between the interaction data to be tested actual_json_new and the expected interaction data json_model_new as a standard reference.

[0116] Step S616, determining whether the first comparison result is consistent based on the assigned value.

[0117] In one embodiment, if the value of the result set json_compare_result is empty, that is, equal to {}, then it can be determined that the first comparison result is consistent, and S626 is executed; otherwise, it is determined that the first comparison result is inconsistent, and S618 is executed.

[0118] Step S618: The downstream interface functions abnormally in the test scenario.

[0119] In one embodiment, since there are differences between the interaction data actual_json_new to be tested and the expected interaction data json_model_new, it means that the request data and / or response data contained in the interaction data to be tested and the expected interaction data must have differences in field elements or field values, that is, the above-mentioned downlink interface must have anomalies in the process of receiving or sending data.

[0120] Step S620, call the comparison function in the tool library and assign a value

[0121] jsonschema_compare_result=DeepDiff(actual_jsonschema,jsonschema_model,view="tree",ign ore_order=True,ignore_string_case=True).

[0122] In one embodiment, a comparison tool, the DeepDiff method under the deepdiff library, is introduced to compare the complex structured format data actual_jsonschema_new to be tested with the expected format data jsonschema_model_new. The result set jsonschema_compare_result assigned with the method result can be used to characterize the differences between the format data actual_jsonschema_new to be tested and the expected format data jsonschema_model_new as a standard reference.

[0123] Step S622, determining whether the second comparison result is consistent according to the assigned value.

[0124] In one embodiment, if the value of the result set jsonschema_compare_result is empty, that is, equal to {}, then it can be determined that the second comparison result is consistent, and S626 is executed; otherwise, it is determined that the second comparison result is inconsistent, and S624 is executed.

[0125] Step S624: The downstream interface functions abnormally in the test scenario.

[0126] In one embodiment, since there are differences between the format data actual_jsonschema_new to be tested and the expected format data jsonschema_model_new, it means that the request data and / or response data contained in the format data to be tested and the expected format data must have differences in field elements or field types, that is, the above-mentioned downlink interface must have an exception in the process of receiving or sending data.

[0127] Step S626: The downstream interface functions normally in the test scenario.

[0128] In one embodiment, when the first comparison result and the second comparison result are both consistent, it can be considered that the downlink interface receives or sends data normally in the test scenario.

[0129] Step S206: When it is determined that the comparison results are consistent, it is determined that the function of the target downlink interface is normal.

[0130] After obtaining the first comparison result between the interaction data to be tested and the selected expected interaction data, if the first comparison result indicates that the two are consistent, then it can be determined that the function of the above-mentioned target downlink interface is normal, otherwise it indicates that the function of the above-mentioned target downlink interface is abnormal.

[0131] As mentioned above, in the case where the second comparison result exists, the detection logic of the target downstream interface can be adjusted according to actual needs.

[0132] In one embodiment, it can be determined that any of the first comparison results between the above-mentioned interaction data to be tested and the selected expected interaction data, and the second comparison results between the above-mentioned format data to be tested and the selected expected format data are consistent. In this embodiment, in order to quickly test the basic functional status of the downstream interface, the upstream system can simultaneously calculate the first comparison result and the second comparison result and determine that the function of the target downstream interface is normal when any comparison result is preferentially consistent. Alternatively, when the upstream system tests the basic functional status of the downstream interface with low requirements, any comparison result that is consistent or inconsistent can be regarded as basically normal or as having certain risks.

[0133] In another embodiment, it is determined that the first comparison result between the interaction data to be tested and the selected expected interaction data, and the second comparison result between the format data to be tested and the expected format data are consistent. In this embodiment, in order to ensure that the basic functional state of the downstream interface is completely normal, that is, the data transmitted to the downstream system has correctness and consistency, the upstream system can wait until the first comparison result and the second comparison result are consistent before determining that the function of the target downstream interface is normal.

[0134] In addition, after the comparison results of the target downstream interface in different test scenarios are obtained in batches, a test report can be generated based on the multiple comparison results.

[0135] In one embodiment, when there are multiple expected interaction data corresponding to the target downlink interface, each interaction data to be tested is obtained based on multi-threading technology, and the comparison results between each interaction data to be tested and the corresponding expected interaction data are combined, and then a test report for the target downlink interface is generated based on the combined comparison results. The test report can be displayed in the form of a workbook, image, web page, etc., so as to quickly analyze and locate the problems in the downlink interface. And the method of obtaining the interaction data to be tested and the corresponding comparison results in each thread is as follows: Figure 6 The descriptions in the above embodiments are consistent with those in the corresponding embodiments, and are not limited to these in the present specification.

[0136] by Figure 7 Take the example of the above vehicle-cloud interaction scenario, and introduce the process of generating a test report, which includes the following steps:

[0137] Step S702: Create a workbook as a test report.

[0138] In one embodiment, the number of threads to be created can be determined. In the above-mentioned cloud platform, the number of threads can be the number of connected TSP systems; for the main thread, the common Excel library can be used to create a new workbook as a test report, select the default worksheet, and use one or more of the downstream interface test scenario, actual interaction data to be tested, expected interaction data, actual format data to be tested, expected format data, first comparison result, and second comparison result as the header of the above-mentioned worksheet.

[0139] Step S704: acquiring the interaction data to be tested corresponding to each test scenario based on the multi-threading technology.

[0140] In one embodiment, each thread can construct functional data for the downstream interface. For example, thread 1 Figure 3 Thread 1 creates a vehicle task of model A and issues an operation instruction. Thread 2 creates a vehicle task of model B and issues an operation instruction. Each thread obtains the request data and response data of the downstream interface of the corresponding TSP system through parsing and processing, which is the interaction data to be tested.

[0141] Step S706: Combine the comparison results obtained from each thread and add them to the test report.

[0142] In one embodiment, each thread can obtain the corresponding assertion result and comparison result through a comparison tool library that encapsulates the assertion class and the assertion method, and assemble it into a piece of information according to the format of the above-mentioned header and add the assembled information to the above-mentioned worksheet. During the adding process, it can be converted according to the corresponding content to improve the readability of the test report. For example, if the first comparison result is consistent, it is recorded as a passed test. If the comparison fails, it is recorded as the actual comparison result. The second comparison result is the same.

[0143] Figure 8 is a schematic structural diagram of a device provided by an exemplary embodiment. Figure 8 At the hardware level, the device includes a processor 802, an internal bus 804, a network interface 806, a memory 808, and a non-volatile memory 810, and may also include hardware required for other functions. One or more embodiments of this specification may be implemented based on software, such as the processor 802 reading the corresponding computer program from the non-volatile memory 810 into the memory 808 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0144] Corresponding to the above-mentioned embodiment of the test method of the downlink interface, this specification also provides an embodiment of a test device of the downlink interface. Fig. 9 , the test device of the downstream interface may include:

[0145] The expected interaction data acquisition unit 902 is used to acquire the interaction data to be tested and the corresponding expected interaction data of the target downlink interface, wherein the interaction data to be tested and the expected interaction data both include the request data and the response data corresponding to the downlink interface.

[0146] The data comparison unit 904 is configured to compare the request data and the response data included in the interaction data to be tested and the expected interaction data.

[0147] The test result determination unit 906 is used to determine that the function of the target downlink interface is normal when it is determined that the comparison results are consistent.

[0148] Optionally, the target downlink interface corresponds to at least one expected interaction data, each expected interaction data corresponds to a different test scenario of the target downlink interface, and each expected interaction data is maintained in an interaction data template set; the expected interaction data acquisition unit 902 is specifically used for:

[0149] Acquire the interaction data to be tested of the target downlink interface, wherein the interaction data to be tested includes a corresponding test scenario identifier;

[0150] According to the test scenario identifier, expected interaction data matching the test scenario identifier is selected from the interaction data template set.

[0151] Optionally, the interactive data template set further maintains expected format data corresponding to each expected interactive data, and the expected format data defines the data format of the request data and the response data in the corresponding expected interactive data; the data comparison unit 904 is specifically used to:

[0152] Comparing the request data and the response data included in the interaction data to be tested and the selected expected interaction data;

[0153] Parsing the data formats of the request data and the response data in the interaction data to be tested and converting them into corresponding format data to be tested; and comparing the format data to be tested with expected format data corresponding to the selected expected interaction data in the interaction data template set.

[0154] Optionally, the test result determination unit 906 is specifically configured to:

[0155] Determine that any one of a first comparison result between the interaction data to be tested and the selected expected interaction data, and a second comparison result between the format data to be tested and the selected expected format data is consistent; or,

[0156] It is determined that a first comparison result between the interaction data to be tested and the selected expected interaction data, and a second comparison result between the format data to be tested and the expected format data are consistent.

[0157] Optionally, the device further comprises:

[0158] An interaction data template set updating unit, used to obtain newly added expected interaction data, wherein the newly added expected interaction data includes a corresponding target test scenario identifier;

[0159] In the case that there is no target expected interaction data matching the target test scenario identifier in the interaction data template set, adding the newly added expected interaction data to the interaction data template set;

[0160] If there is target expected interaction data matching the target test scenario identifier in the interaction data template set, and the target expected interaction data is inconsistent with the newly added expected interaction data, updating the newly added expected interaction data to the target expected interaction data;

[0161] If target expected interaction data matching the target test scenario identifier exists in the interaction data template set, and the target expected interaction data is consistent with the newly added expected interaction data, the interaction data template set is not processed.

[0162] Optionally, the device further comprises:

[0163] an ignore field setting unit, used for setting the ignore fields in the request data and the response data;

[0164] According to the ignored fields, the fields that match between the interaction data to be tested and the expected interaction data are ignored, and new interaction data to be tested and expected interaction data are generated based on other fields to participate in comparison processing.

[0165] Optionally, the device further comprises:

[0166] A test report generating unit, configured to obtain each to-be-tested interaction data based on a multi-threading technology respectively when the target downlink interface corresponds to a plurality of expected interaction data;

[0167] The comparison results between each interaction data to be tested and the corresponding expected interaction data are combined, and a test report for the target downlink interface is generated based on the combined comparison results.

[0168] Based on the same concept as the above method, this specification also provides an electronic device, including: a processor; a memory for storing processor executable instructions; wherein the processor implements the steps of the method described in any of the above embodiments by running the executable instructions.

[0169] Based on the same concept as the above method, this specification also provides a computer-readable storage medium on which computer instructions are stored. When the instructions are executed by a processor, the steps of the method described in any of the above embodiments are implemented.

[0170] Based on the same concept as the above method, this specification also provides a computer program product, including a computer program / instruction, which implements the steps of the method described in any of the above embodiments when executed by a processor.

[0171] Although the present invention includes many specific implementation details, these should not be interpreted as limiting the scope of any invention or the scope of protection claimed, but are mainly used to describe the features of the specific embodiments of specific inventions. Certain features described in multiple embodiments of the present invention may also be implemented in combination in a single embodiment. On the other hand, the various features described in a single embodiment may also be implemented separately in multiple embodiments or in any suitable sub-combination. In addition, although features may work in certain combinations as described above and even initially claimed as such, one or more features from the claimed combination may be removed from the combination in some cases, and the claimed combination may point to a sub-combination or a variation of a sub-combination.

[0172] Similarly, although operations are depicted in a particular order in the accompanying drawings, this should not be understood as requiring that these operations be performed in the particular order shown or performed sequentially, or requiring that all illustrated operations be performed to achieve the desired results. In some cases, multitasking and parallel processing may be advantageous. In addition, the separation of various system modules and components in the above-described embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product, or packaged into multiple software products.

[0173] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recited in the claims can be performed in a different order and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the particular order or sequential order shown to achieve the desired results. In some implementations, multitasking and parallel processing may be advantageous.

[0174] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for testing a downlink interface, characterized in that: The method comprises: Acquire the interaction data to be tested and the corresponding expected interaction data of the target downlink interface, wherein the interaction data to be tested and the expected interaction data both include the request data and the response data corresponding to the downlink interface; Comparing the request data and the response data included in the interaction data to be tested and the expected interaction data; When it is determined that the comparison results are consistent, it is determined that the function of the target downlink interface is normal.

2. The method according to claim 1, characterized in that: The target downlink interface corresponds to at least one expected interaction data, each expected interaction data corresponds to a different test scenario of the target downlink interface, and each expected interaction data is maintained in an interaction data template set; The step of obtaining the interaction data to be tested and the corresponding expected interaction data of the target downlink interface includes: Acquire the interaction data to be tested of the target downlink interface, wherein the interaction data to be tested includes a corresponding test scenario identifier; According to the test scenario identifier, expected interaction data matching the test scenario identifier is selected from the interaction data template set.

3. The method according to claim 2, characterized in that The interactive data template set also maintains expected format data corresponding to each expected interactive data, and the expected format data defines the data format of the request data and the response data in the corresponding expected interactive data; the comparing the interactive data to be tested with the request data and the response data contained in the expected interactive data includes: Comparing the request data and the response data included in the interaction data to be tested and the selected expected interaction data; Parsing the data formats of the request data and the response data in the interaction data to be tested and converting them into corresponding format data to be tested; and comparing the format data to be tested with expected format data corresponding to the selected expected interaction data in the interaction data template set.

4. The method according to claim 3, characterized in that The determining that the comparison results are consistent includes: Determine that any one of a first comparison result between the interaction data to be tested and the selected expected interaction data, and a second comparison result between the format data to be tested and the selected expected format data is consistent; or, It is determined that a first comparison result between the interaction data to be tested and the selected expected interaction data, and a second comparison result between the format data to be tested and the expected format data are consistent.

5. The method according to claim 2, characterized in that: The method further comprises: Acquire newly added expected interaction data, wherein the newly added expected interaction data includes a corresponding target test scenario identifier; In the case that there is no target expected interaction data matching the target test scenario identifier in the interaction data template set, adding the newly added expected interaction data to the interaction data template set; If there is target expected interaction data matching the target test scenario identifier in the interaction data template set, and the target expected interaction data is inconsistent with the newly added expected interaction data, updating the newly added expected interaction data to the target expected interaction data; If target expected interaction data matching the target test scenario identifier exists in the interaction data template set, and the target expected interaction data is consistent with the newly added expected interaction data, the interaction data template set is not processed.

6. The method according to claim 1, characterized in that The method further comprises: Setting the ignored fields in the request data and the response data; According to the ignored fields, the fields that match between the interaction data to be tested and the expected interaction data are ignored, and new interaction data to be tested and expected interaction data are generated based on other fields to participate in comparison processing.

7. The method according to claim 1, characterized in that The method further comprises: In the case where the target downlink interface corresponds to a plurality of expected interaction data, acquiring each interaction data to be tested respectively based on multi-threading technology; The comparison results between each interaction data to be tested and the corresponding expected interaction data are combined, and a test report for the target downlink interface is generated based on the combined comparison results.

8. An electronic device, characterized in that: include: processor; A memory for storing processor-executable instructions; wherein the processor implements the steps of the method according to any one of claims 1 to 7 by executing the executable instructions.

9. A computer-readable storage medium, characterized in that: Computer instructions are stored thereon, and when the instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer program product, characterized in that The method comprises a computer program / instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.