Interface test method and device based on traffic recording, equipment and storage medium

Through the interface testing method based on traffic recording, interface traffic data is automatically recorded and filtered, and interface testing is carried out, which solves the problem of manual writing interfaces and data sources in the existing interface testing methods, and efficient and automated interface testing is realized, which improves testing efficiency and quality.

CN119690824APending Publication Date: 2025-03-25KANG JIAN INFORMATION TECH (SHENZHEN) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411628949.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

The existing interface testing methods have problems such as manual interface writing, difficulty in data source, easy to miss interfaces, distorted test data structure, huge manpower investment, and inability to centrally manage test case libraries, resulting in high cost and low efficiency of interface testing.

Method used

The interface testing method based on traffic recording is adopted, interface traffic data is recorded through the traffic recording tool, data is filtered using preset data filtering rules, interface to be tested, and interface test is generated based on preset interface testing instructions.

Benefits of technology

This method can automatically capture and record interface interactions, reduce the workload of manually writing interfaces, improve the authenticity and accuracy of test data, quickly locate key and abnormal interfaces, improve the pertinence and efficiency of tests, automate the execution of test processes, shorten the test cycle, and ensure the consistency and reliability of test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690824A_ABST
    Figure CN119690824A_ABST
Patent Text Reader

Abstract

The invention provides an interface testing method and device based on traffic recording, equipment and a storage medium, and relates to the technical field of computers. According to the method, the interface traffic data is recorded through the traffic recording tool, interface interaction can be automatically captured and recorded, the workload of manually compiling the interface is reduced, and the authenticity and accuracy of the test data are improved. According to the method, the interface traffic data is filtered through the preset data filtering rule, key and abnormal interfaces can be quickly positioned, so that the test resources can be applied to potential problem points more intensively, and the pertinence and efficiency of the test are improved. The to-be-tested interface is tested based on the preset interface test instruction, the test process can be automatically executed, manual intervention is reduced, the test period is shortened, meanwhile, the consistency and reliability of test results are ensured, and therefore the interface test efficiency and quality are overall improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an interface testing method, device, equipment and storage medium based on traffic recording. Background Art

[0002] Interface testing is indispensable in the current software testing process. In order to ensure the overall quality of healthcare-related projects and reduce the risk of failures in the launch of healthcare service systems, interface testing is frequently used in large quantities during the regression testing phase to complete the acceptance of historical functions.

[0003] At present, different companies have different opinions on the regression testing methods from the interface perspective, and they are all over the place, but there are common problems such as the need to manually write interfaces, difficulty in finding data sources, easy omission of interfaces leading to missed tests, distorted test data structure, huge human investment in writing, inability to centrally manage the test case library, and editing in multiple locations. These problems lead to high investment costs for interface testing and low project delivery efficiency.

[0004] Therefore, how to improve the efficiency of interface testing has become a technical problem that needs to be solved urgently. Summary of the invention

[0005] The present application provides an interface testing method, apparatus, device and storage medium based on traffic recording, aiming to improve the efficiency of interface testing.

[0006] In a first aspect, the present application provides an interface testing method based on traffic recording, and the interface testing method based on traffic recording comprises the following steps:

[0007] Based on the traffic recording tool, record the interface traffic data;

[0008] Based on a preset data filtering rule, the interface traffic data is filtered to obtain at least one interface to be tested;

[0009] Based on the preset interface test instruction, the interface to be tested is tested to generate an interface test result.

[0010] In a second aspect, the present application further provides an interface testing device based on traffic recording, the interface testing device based on traffic recording comprising:

[0011] Data recording module, used to record interface traffic data based on traffic recording tools;

[0012] A data filtering module, used to filter the interface traffic data based on preset data filtering rules to obtain at least one interface to be tested;

[0013] The interface test module is used to test the interface to be tested based on a preset interface test instruction and generate an interface test result.

[0014] In a third aspect, the present application also provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the interface testing method based on traffic recording as described above are implemented.

[0015] In a fourth aspect, the present application also provides a computer-readable storage medium, on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the interface testing method based on traffic recording as described above are implemented.

[0016] The present application provides an interface testing method, device, computer equipment and storage medium based on traffic recording. The method of the present application includes recording interface traffic data based on a traffic recording tool; filtering the interface traffic data based on a preset data filtering rule to obtain at least one interface to be tested; testing the interface to be tested based on a preset interface test instruction to generate an interface test result. In the above manner, the present application records interface traffic data through a traffic recording tool, which can automatically capture and record interface interactions, reduce the workload of manually writing interfaces, and improve the authenticity and accuracy of test data. By filtering the interface traffic data through preset data filtering rules, critical and abnormal interfaces can be quickly located, so that test resources can be more concentratedly applied to potential problem points, improving the pertinence and efficiency of the test. By testing the interface to be tested based on a preset interface test instruction, the test process can be automatically executed, manual intervention can be reduced, and the test cycle can be shortened, while ensuring the consistency and reliability of the test results, thereby improving the efficiency and quality of the interface test as a whole. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 A flow chart of a first embodiment of an interface testing method based on traffic recording provided by the present application;

[0019] Figure 2 A schematic diagram of an interface test process based on traffic recording provided in an embodiment of the present application;

[0020] Figure 3 It is a structural schematic diagram of a first embodiment of an interface testing device based on traffic recording provided by the present application;

[0021] Figure 4 It is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application.

[0022] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0024] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.

[0025] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

[0026] Please refer to Figure 1 , Figure 1 A flow chart of a first embodiment of an interface testing method based on traffic recording provided in the present application.

[0027] like Figure 1 As shown, the interface testing method based on traffic recording includes steps S101 to S103.

[0028] S101. Record interface traffic data based on traffic recording tools;

[0029] In one embodiment, before starting to record traffic, it is necessary to clarify the purpose and requirements of recording traffic, such as performance testing, fault diagnosis, data backup, security analysis, etc., so as to determine the interface type (such as HTTP, HTTPS, Dubbo, etc.) and key data points (such as request header, response header, request body, response body, etc.) that need to be recorded.

[0030] In one embodiment, a suitable traffic recording tool is selected according to the traffic recording requirements, deployed on the corresponding server, and the properties of the traffic recording tool are configured to monitor specific ports or services. For example, data filtering rules of the traffic recording tool can be set to ensure that only the required traffic is recorded to reduce unnecessary data capture.

[0031] In one embodiment, the deployment location of the traffic recording tool is determined based on the interface type corresponding to the interface traffic data; when the interface type is a Hypertext Transfer Protocol HTTP interface type, the traffic recording tool is deployed on a gateway server to record the HTTP interface traffic data; when the interface type is a distributed service framework Dubbo interface type, the traffic recording tool is deployed on an application server to record the Dubbo interface traffic data.

[0032] Generally, when the interface type is HTTP, traffic is usually transmitted through a Web server. The gateway server, as the entry point for traffic, can capture all HTTP requests and responses entering and leaving the application. Dubbo is a distributed service framework, usually used for remote calls between services. The application server is the host of the Dubbo service and can capture detailed information about the service call.

[0033] In one embodiment, a traffic recording environment is built on the server based on a traffic recording tool (such as goreplay), an HTTP interface can be built on the gateway server to record traffic, and a Dubbo interface needs to be built on the application server to record traffic.

[0034] For example, a traffic recording tool is deployed on the gateway server, such as Fiddler, Zuul, Nginx's Lua script, etc. The tool is configured to capture HTTP requests and responses, including request headers, response headers, request bodies, and response bodies.

[0035] For example, a tool capable of capturing Dubbo traffic is deployed on the application server, such as SkyWalking, Apache Dubbo's monitoring center, etc. The tool is configured to capture metadata, request parameters, return values, etc. of service calls.

[0036] In one embodiment, the traffic recording tool can be configured as needed, filters can be set to capture calls to specific services, and the performance of the traffic recording tool can be optimized to ensure that it does not negatively impact the performance of the server.

[0037] For example, you can use the command line to start the traffic recording tool: sudo gor --input-raw:80 --output-file MyRequest.gor to record the data into a gor file.

[0038] Furthermore, based on the interface traffic data, interface information of at least one first interface is obtained; based on the interface testing requirements of the user end, the interface information of the first interface is screened to determine at least one interface to be tested and at least one interface to be intercepted; based on the interface to be tested and the interface to be intercepted, the data filtering rules are written.

[0039] In one embodiment, the interface to be tested includes a basic application interface, middleware, a specified domain name interface, and the like.

[0040] Exemplarily, the basic application interface refers to the core functional interface in the application, such as user login, data query, transaction processing, etc. The testing of the basic application interface can include functional testing, performance testing, and security testing. Among them, functional testing needs to ensure that the interface returns the correct data and status code as expected. Performance testing is used to evaluate the performance of the interface under high load, such as response time and throughput. Security testing is used to check the authentication and authorization mechanism of the interface to ensure that there are no security vulnerabilities.

[0041] Exemplarily, middleware is software located between the client and the server, used to process requests and responses, such as message queues, cache services, etc. Middleware testing can include integration testing, reliability testing, and performance testing. Among them, integration testing ensures that the middleware is correctly integrated with applications and other middleware; reliability testing is used to test the failover and recovery capabilities of the middleware; performance testing is used to evaluate the performance of the middleware under high concurrent requests.

[0042] For example, the designated domain name interface is usually integrated with a specific third-party service or external API, such as a payment gateway, social media platform, etc. The testing of the designated domain name interface can include compatibility testing, dependency testing, and security testing. Among them, compatibility testing is used to ensure the compatibility of the interface with third-party services; dependency testing is used to evaluate the impact of the availability and response time of third-party services on the application; security testing is used to check the encryption and authentication mechanisms during data transmission.

[0043] In one embodiment, the interfaces to be intercepted include OPTIONS requests, offline application interfaces, and interfaces to be migrated.

[0044] For example, OPTIONS requests are used to describe the communication options of the target resource, and are usually used for cross-origin resource sharing (CORS). Intercepting OPTIONS requests can prevent unnecessary OPTIONS requests, reduce potential security risks, reduce unnecessary network requests, and improve application performance. Generally, rules can be set in web servers (such as Nginx, Apache) to intercept all OPTIONS requests.

[0045] Exemplarily, a decommissioned application interface is an old interface that is no longer used or has been replaced by a new interface. Intercepting decommissioned application interfaces can reduce the maintenance work of old interfaces and reduce maintenance costs. At the same time, it can prevent the old interface from generating inconsistent data and maintain data consistency. Generally, rules can be set in the API gateway to redirect or reject requests for decommissioned interfaces.

[0046] Exemplarily, the interface to be migrated refers to the interface that is planned to be migrated to a new system or platform but has not yet been fully migrated. Intercepting the interface to be migrated can ensure the integrity and consistency of the data during the migration process, and ensure seamless service and service continuity during the migration. Generally, API management tools (such as Apigee, AWS API Gateway) can be used to manage traffic during the migration process and gradually transfer requests from the old interface to the new interface.

[0047] Optionally, when dealing with these interfaces to be tested and intercepted, you can combine automated testing, monitoring, and security tools to achieve effective management and control. Through these strategies, you can ensure the stability, security, and performance of the interface, while providing support for smooth migration and upgrade of the system.

[0048] In one embodiment, the interface traffic data may include an interface name, a request method (such as GET, POST), request parameters, a response status code, etc. According to the interface test requirements of the user end, the interface information of the first interface is filtered out from the acquired interface traffic data, such as the matching of fields such as the interface name and the request method. In the filtered interface information, according to the test requirements (such as the function, importance, security, etc. of the interface), it is determined which interfaces need to be tested (interfaces to be tested) and which interfaces need to be intercepted (interfaces to be intercepted). Based on the interfaces to be tested and the interfaces to be intercepted, data filtering rules are written to determine which data packets should be allowed to pass and which should be intercepted or recorded.

[0049] Exemplarily, the data filtering rules may include rules for interfaces to be tested and rules for interfaces to be intercepted. The rules for interfaces to be tested may allow all requests sent to the interfaces to be tested to pass through, and record all response data returned from the interfaces to be tested. The rules for interfaces to be intercepted are used to intercept all requests sent to the interfaces to be intercepted, and record the request details; at the same time, as needed, it may also be necessary to intercept the responses returned from the interfaces to be intercepted.

[0050] S102, filtering the interface traffic data based on a preset data filtering rule to obtain at least one interface to be tested;

[0051] In one embodiment, before performing data filtering, data filtering rules need to be preset according to the characteristics of the interface to be tested. The data filtering rules may include interface name matching, request method, request parameters, response status code, request header information, and timestamp.

[0052] Exemplarily, interface name matching specifies the interface name or path to be filtered. Request method specifies the HTTP methods supported by the interface, such as GET, POST, PUT, etc. Request parameters are filtered according to the parameters required by the interface, such as specific query parameters or request body content. Response status code specifies the expected response status code, such as 200, 404, etc. Request source: specifies the source IP or domain name of the request. Request header information is filtered according to specific fields in the request header, such as User-Agent, Authorization, etc. Timestamp specifies the time range of the request to capture traffic within a specific time period.

[0053] Exemplarily, using preset rules, network monitoring tools such as Wireshark, tcpdump, etc. can be used to capture network traffic and apply filtering rules. Application performance can be monitored using application performance monitoring (APM) tools such as New Relic, Dynatrace, etc., and data can be filtered according to the rules. API management tools such as Apigee, AWS API Gateway, etc. can be used to manage API traffic and apply preset filtering rules. Log analysis tools such as ELK Stack (Elasticsearch, Logstash, Kibana) can be used to analyze log data and extract relevant information according to the rules.

[0054] In one embodiment, after filtering, flow data of at least one interface to be tested may be obtained, and such data may be used for performance testing, function verification, security checking, compatibility testing, and error analysis.

[0055] Among them, performance testing is used to evaluate the performance indicators of the interface, such as response time and throughput. Functional verification is used to ensure that the interface returns the correct data and status code as expected. Security checking is used to check whether the interface has potential security vulnerabilities or abnormal behavior. Compatibility testing is used to ensure the compatibility of the interface with third-party services or clients. Error analysis is used to identify and analyze errors or anomalies in interface requests.

[0056] In one embodiment, during the filtering process, it may be necessary to adjust the filtering rules according to the actual situation to optimize the filtering effect. For example, dynamically adjust the rules: dynamically adjust the filtering rules according to the real-time monitoring data to adapt to the changing traffic pattern. Feedback loop: Feedback the test results into the rule preset to continuously optimize the accuracy and efficiency of the filtering rules. Anomaly detection: Use machine learning algorithms to detect abnormal traffic and automatically update the filtering rules.

[0057] S103: Based on a preset interface test instruction, test the interface to be tested and generate an interface test result.

[0058] In one embodiment, the interface test instruction is preset according to the characteristics and requirements of the interface to be tested. The interface test instruction may include information such as request structure, expected response, test data, test scenario, and test frequency.

[0059] Exemplarily, request construction refers to defining the HTTP method (GET, POST, PUT, DELETE, etc.), URL, request header, query parameters, and request body of the request. Expected response refers to setting the expected response status code, response header, response body structure and content. Test data refers to the input data prepared for testing, including normal values, boundary values, and abnormal values. Test scenarios refer to defining different test scenarios, such as success paths, abnormal paths, performance tests, security tests, etc. Test frequency refers to setting the frequency and concurrency of the test to simulate different load conditions.

[0060] Generally, you can use automated testing tools, programming language libraries, continuous integration / continuous deployment (CI / CD), cloud testing services and other tools to execute interface testing instructions and test the interface to be tested.

[0061] Specifically, you can use tools such as Postman, JMeter, and SoapUI to automatically execute test instructions. Use programming libraries such as Python's requests library and Java's HttpClient to manually write test scripts. Integrate interface testing in the CI / CD process to ensure that testing is automatically executed after each code submission or deployment. Use cloud testing platforms such as BlazeMeter and LoadRunner Cloud to perform large-scale load and performance testing.

[0062] Furthermore, based on the interface information of the interface to be tested, at least one interface test case is screened to obtain a test case set; based on a preset test execution time and the test case set, the interface test instruction corresponding to the interface to be tested is generated.

[0063] In one embodiment, interface information of the interface to be tested is extracted from the interface document or code, which may include interface definition, request parameters, request examples, response structure, business rules, etc.

[0064] Specifically, the interface definition includes the URL, HTTP methods (GET, POST, PUT, DELETE, etc.). Request parameters include path parameters, query parameters, and request body parameters. Request examples refer to sample data provided for a request. The response structure includes the expected structure and data type for successful and error responses. Business rules refer to the business logic and rules followed by the interface.

[0065] In one embodiment, test cases are designed based on the interface information, and these test cases should cover test items such as functional testing, boundary value testing, exception testing, security testing, and performance testing.

[0066] Specifically, functional testing is used to verify whether the interface returns the correct data and status code as expected. Boundary value testing is used to check the interface's processing of boundary input values. Exception testing is used to simulate incorrect input or abnormal conditions to verify the robustness of the interface. Security testing is used to test the interface's security features such as authentication, authorization, and data encryption. Performance testing is used to evaluate the performance of the interface under high load.

[0067] For example, Figure 2 As shown, at least one representative test case set is selected from the designed test cases. These test case sets can cover the critical paths and ensure that key business processes are covered; priorities need to be considered and the priorities of test cases are determined based on business impact and risk assessment; diversity needs to be ensured, including positive and negative test cases.

[0068] Exemplarily, the timing of test execution is determined, including the test window, test frequency, and test duration. Specifically, the test window refers to the time period for determining the test to avoid the peak period of the production environment. The test frequency refers to setting the frequency of the test, such as a one-time test or a periodic test. The test duration refers to setting the duration of the test to ensure the comprehensiveness of the test.

[0069] In one embodiment, based on a preset test execution time and a test case set, interface test instructions are generated, and these instructions include test environment configuration, test data preparation, test script writing, and test execution sequence.

[0070] Specifically, test environment configuration is used to specify the environment in which the test will be executed, such as the development environment, test environment, or pre-production environment. Test data preparation is used to prepare test data for each test case, including normal values, boundary values, and abnormal values. Test script writing is used to write test scripts using automated testing tools or programming languages. Test execution order is used to determine the execution order of test cases, especially for test cases with dependencies.

[0071] Furthermore, based on the preset interface test instruction, the interface test case corresponding to the interface to be tested is called, the interface test is performed on the interface to be tested, and the interface test result is obtained; when there is a failed test case in the interface test result, a test case error message is generated.

[0072] In one embodiment, when executing the interface test, it is necessary to prepare the test environment, including the data center, server, and any services required for the test, and at the same time, it is necessary to prepare the test data required by all test cases, including static data and dynamically generated data, etc. In addition, it is necessary to check whether the automated test script has been updated and deployed according to the preset test instructions.

[0073] In one embodiment, the test cases can be executed by an automated testing tool, and for test cases that cannot be automated, the test can be manually executed and the results recorded. In addition, according to the test requirements, multiple test cases can be executed to simulate high concurrency scenarios.

[0074] In one embodiment, during test execution, test progress is monitored and a test report is generated.

[0075] Specifically, you can use test monitoring tools to track test execution in real time. Record the request details sent to the interface to be tested, including the request header, request body, and request parameters; record the response details returned from the interface to be tested, including the status code, response header, response body, and response time; record the start and end time of each test case to calculate the response time. Record the execution results of each test case, including success, failure, and error information, and generate a detailed test report based on the test records, including test coverage, defect statistics, and performance indicators.

[0076] In one embodiment, after the test is completed, the test results are analyzed, including successful cases to confirm whether the test cases return the correct response as expected; and failed cases to identify test cases that did not work as expected and record the reasons for the failure.

[0077] In one embodiment, the test results are analyzed to determine the performance and stability of the interface. Specifically, performance analysis, error analysis, trend analysis, and security analysis may be included. Performance analysis is used to analyze response time and throughput to determine whether performance requirements are met; error analysis is used to analyze error logs to identify interface failure points; trend analysis is used to analyze performance trends by comparing historical test data; and security analysis is used to evaluate the security of the interface and identify potential security vulnerabilities.

[0078] In one embodiment, when there is a failed test case, detailed error information is generated, including error screenshots, error logs, failure reasons, and impact analysis.

[0079] Specifically, provide error screenshots of failed test cases; record detailed error logs, including error type, error message, and stack trace; analyze the cause of the failure, which may be a code defect, configuration error, or environmental problem; evaluate the impact of the failure on the business process and provide possible solutions.

[0080] In one embodiment, an error report may be created to generate an error report containing details of failed test cases, and the development and testing teams may be notified via email, message, or notification function of a CI / CD tool.

[0081] Furthermore, based on the interface test result, an abnormal test result of the interface to be tested is obtained; when the abnormal test result does not match the expected abnormal result, based on the abnormal traffic data, the data filtering rule is adjusted to filter the interface traffic data that matches the abnormal test result.

[0082] Among them, expected abnormal results can be preset based on historical data, business logic, security requirements or performance standards.

[0083] In one embodiment, abnormal test results are collected from the interface test, which may include error responses, abnormal behaviors, performance issues, etc. The actual abnormal test results are compared with the expected abnormal results. If the actual abnormal test results do not match the expected ones, it means that there is abnormal traffic that is not captured by the filtering rules, or the filtering rules are too strict or loose. The abnormal traffic data is analyzed in depth, such as checking request parameters, response status codes, request header information, timestamps, etc., to determine why the actual results are inconsistent with the expected results.

[0084] In one embodiment, the data filtering rules are adjusted according to the analysis results. For example, new filtering conditions are added, or existing conditions are modified to ensure that interface traffic data that matches the abnormal test results can be filtered out. The adjusted filtering rules are applied to the data capture and analysis process, for example, updating the filtering settings in the network monitoring tool, application performance monitoring (APM) tool, API management tool or log analysis tool.

[0085] In one embodiment, based on the result of the retest, if there is still a mismatch, the filtering rules are adjusted to establish a feedback loop to continuously optimize the filtering rules until the test results match expectations.

[0086] The present embodiment provides an interface testing method based on traffic recording. The present application method records interface traffic data through a traffic recording tool, which can automatically capture and record interface interactions, reduce the workload of manually writing interfaces, and improve the authenticity and accuracy of test data. By filtering interface traffic data through preset data filtering rules, critical and abnormal interfaces can be quickly located, so that test resources can be more concentratedly applied to potential problem points, improving the pertinence and efficiency of testing. By testing the interface to be tested based on preset interface test instructions, the test process can be automatically executed, manual intervention can be reduced, and the test cycle can be shortened. At the same time, the consistency and reliability of the test results can be ensured, thereby improving the efficiency and quality of interface testing as a whole.

[0087] See also Figure 3 , Figure 3 It is a structural schematic diagram of a first embodiment of an interface testing device based on traffic recording provided in the present application, and the interface testing device based on traffic recording is used to execute the aforementioned interface testing method based on traffic recording.

[0088] like Figure 3 As shown, the interface testing device 200 based on traffic recording includes: a data recording module 201, a data filtering module 202 and an interface testing module 203.

[0089] The data recording module 201 is used to record the interface traffic data based on the traffic recording tool;

[0090] The data filtering module 202 is used to filter the interface traffic data based on a preset data filtering rule to obtain at least one interface to be tested;

[0091] The interface testing module 203 is used to test the interface to be tested based on a preset interface testing instruction and generate an interface testing result.

[0092] In one embodiment, the traffic recording-based interface testing device 200 further includes a filtering rule writing module, including:

[0093] An interface information acquisition unit, configured to acquire interface information of at least one first interface based on the interface traffic data;

[0094] An interface screening unit, configured to screen the interface information of the first interface based on the interface test requirements of the user terminal, and determine at least one interface to be tested and at least one interface to be intercepted;

[0095] A rule writing unit is used to write the data filtering rule based on the interface to be tested and the interface to be intercepted.

[0096] In one embodiment, the interface to be tested includes a basic application interface, a middleware, and a specified domain name interface;

[0097] The interfaces to be intercepted include OPTIONS requests, offline application interfaces, and interfaces to be migrated.

[0098] In one embodiment, the traffic recording-based interface testing device 200 further includes an interface testing instruction generating module, including:

[0099] A test case screening unit, used to screen at least one interface test case based on the interface information of the interface to be tested to obtain a test case set;

[0100] The interface test instruction generating unit is used to generate the interface test instruction corresponding to the interface to be tested based on a preset test execution time and the test case set.

[0101] In one embodiment, the interface testing module 203 includes:

[0102] An interface test result acquisition unit, configured to call the interface test case corresponding to the interface to be tested based on the preset interface test instruction, perform an interface test on the interface to be tested, and obtain the interface test result;

[0103] The use case error information generating unit is used to generate use case error information when there is a failed test case in the interface test result.

[0104] In one embodiment, the traffic recording-based interface testing device 200 further includes a traffic recording tool deployment module, including:

[0105] A deployment location determining unit, configured to determine a deployment location of the traffic recording tool based on an interface type corresponding to the interface traffic data;

[0106] The traffic recording tool is deployed in a first unit, which is used to deploy the traffic recording tool on a gateway server to record HTTP interface traffic data when the interface type is a Hypertext Transfer Protocol HTTP interface type;

[0107] The traffic recording tool deploys a second unit, which is used to deploy the traffic recording tool on the application server to record Dubbo interface traffic data when the interface type is a distributed service framework Dubbo interface type.

[0108] In one embodiment, the traffic recording-based interface testing device 200 further includes a rule adjustment module, including:

[0109] An abnormal test result obtaining unit, used for obtaining an abnormal test result of the interface to be tested based on the interface test result;

[0110] A rule adjustment unit is used to adjust the data filtering rule based on the abnormal traffic data when the abnormal test result does not match the expected abnormal result, so as to filter the interface traffic data that matches the abnormal test result.

[0111] It should be noted that technical personnel in the relevant field can clearly understand that for the convenience and conciseness of description, the specific working process of the above-described device and each module can refer to the corresponding process in the aforementioned interface testing method embodiment based on traffic recording, and will not be repeated here.

[0112] The apparatus provided in the above embodiment may be implemented in the form of a computer program. The computer program may be Figure 4 Runs on the computer device shown.

[0113] See also Figure 4 , Figure 4 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device may be a server.

[0114] See also Figure 4 The computer device includes a processor, a memory and a network interface connected through a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.

[0115] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any interface test method based on traffic recording.

[0116] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.

[0117] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any interface testing method based on traffic recording.

[0118] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0119] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0120] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:

[0121] Based on the traffic recording tool, record the interface traffic data;

[0122] Based on a preset data filtering rule, the interface traffic data is filtered to obtain at least one interface to be tested;

[0123] Based on the preset interface test instruction, the interface to be tested is tested to generate an interface test result.

[0124] In one embodiment, before implementing the data filtering based on the preset data filtering rules to filter the interface traffic data and obtain at least one interface to be tested, the processor is further configured to implement:

[0125] Based on the interface traffic data, obtaining interface information of at least one first interface;

[0126] Based on the interface test requirements of the user terminal, the interface information of the first interface is screened to determine at least one interface to be tested and at least one interface to be intercepted;

[0127] The data filtering rules are written based on the interface to be tested and the interface to be intercepted.

[0128] In one embodiment, the interface to be tested includes a basic application interface, a middleware, and a specified domain name interface;

[0129] The interfaces to be intercepted include OPTIONS requests, offline application interfaces, and interfaces to be migrated.

[0130] In one embodiment, before implementing the testing of the interface to be tested based on the preset interface test instruction and generating the interface test result, the processor is used to implement:

[0131] Based on the interface information of the interface to be tested, screening at least one interface test case to obtain a test case set;

[0132] Based on the preset test execution time and the test case set, the interface test instruction corresponding to the interface to be tested is generated.

[0133] In one embodiment, when the processor implements the test of the interface to be tested based on the preset interface test instruction and generates the interface test result, it is used to implement:

[0134] Based on the preset interface test instruction, calling the interface test case corresponding to the interface to be tested, performing an interface test on the interface to be tested, and obtaining the interface test result;

[0135] When there are failed test cases in the interface test results, a test case error message is generated.

[0136] In one embodiment, before implementing the recording of interface traffic data based on the traffic recording tool, the processor is further configured to implement:

[0137] Determining a deployment location of the traffic recording tool based on an interface type corresponding to the interface traffic data;

[0138] When the interface type is a Hypertext Transfer Protocol (HTTP) interface type, deploying the traffic recording tool on a gateway server to record HTTP interface traffic data;

[0139] When the interface type is a distributed service framework Dubbo interface type, the traffic recording tool is deployed on an application server to record Dubbo interface traffic data.

[0140] In one embodiment, after implementing the test of the interface to be tested based on the preset interface test instruction and generating the interface test result, the processor is further configured to implement:

[0141] Based on the interface test result, obtaining an abnormal test result of the interface to be tested;

[0142] When the abnormal test result does not match the expected abnormal result, the data filtering rule is adjusted based on the abnormal traffic data to filter the interface traffic data that matches the abnormal test result.

[0143] A computer-readable storage medium is also provided in an embodiment of the present application, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and the processor executes the program instructions to implement any one of the interface testing methods based on traffic recording provided in the embodiments of the present application.

[0144] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc., equipped on the computer device.

[0145] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. An interface testing method based on traffic recording, characterized in that: The method comprises: Based on the traffic recording tool, record the interface traffic data; Based on a preset data filtering rule, the interface traffic data is filtered to obtain at least one interface to be tested; Based on the preset interface test instruction, the interface to be tested is tested to generate an interface test result.

2. The interface testing method based on traffic recording according to claim 1 is characterized in that: Before filtering the interface traffic data based on a preset data filtering rule to obtain at least one interface to be tested, the method further includes: Based on the interface traffic data, obtaining interface information of at least one first interface; Based on the interface test requirements of the user terminal, the interface information of the first interface is screened to determine at least one interface to be tested and at least one interface to be intercepted; The data filtering rules are written based on the interface to be tested and the interface to be intercepted.

3. The interface testing method based on traffic recording according to claim 2 is characterized in that: The interfaces to be tested include basic application interface, middleware, and specified domain name interface; The interfaces to be intercepted include OPTIONS requests, offline application interfaces, and interfaces to be migrated.

4. The interface testing method based on traffic recording according to claim 1 is characterized in that: The method of testing the interface to be tested based on the preset interface test instruction and generating the interface test result includes: Based on the interface information of the interface to be tested, screening at least one interface test case to obtain a test case set; Based on the preset test execution time and the test case set, the interface test instruction corresponding to the interface to be tested is generated.

5. The interface testing method based on traffic recording according to claim 4 is characterized in that: The step of testing the interface to be tested based on the preset interface test instruction and generating an interface test result includes: Based on the interface test instruction, calling the interface test case corresponding to the interface to be tested, performing an interface test on the interface to be tested, and obtaining the interface test result; When there are failed test cases in the interface test results, a test case error message is generated.

6. The interface testing method based on traffic recording according to claim 1, characterized in that: Before recording the interface traffic data based on the traffic recording tool, the method further includes: Determining a deployment location of the traffic recording tool based on an interface type corresponding to the interface traffic data; When the interface type is a Hypertext Transfer Protocol (HTTP) interface type, deploying the traffic recording tool on a gateway server to record HTTP interface traffic data; When the interface type is a distributed service framework Dubbo interface type, the traffic recording tool is deployed on an application server to record Dubbo interface traffic data.

7. The interface testing method based on traffic recording according to claim 1 is characterized in that: After the interface to be tested is tested based on the preset interface test instruction and the interface test result is generated, the method further includes: Based on the interface test result, obtaining an abnormal test result of the interface to be tested; When the abnormal test result does not match the expected abnormal result, the data filtering rule is adjusted based on the abnormal traffic data to filter the interface traffic data that matches the abnormal test result.

8. An interface testing device based on traffic recording, characterized in that: The interface testing device based on traffic recording comprises: Data recording module, used to record interface traffic data based on traffic recording tools; A data filtering module, used to filter the interface traffic data based on preset data filtering rules to obtain at least one interface to be tested; The interface test module is used to test the interface to be tested based on a preset interface test instruction and generate an interface test result.

9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the interface testing method based on traffic recording as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the interface testing method based on traffic recording as described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Automatic test system and automatic test server

    CN113704090A

  • Automatic test case generation method and device

    CN115061924A

  • Test case generation method and device, equipment and storage medium

    CN115904950A

  • Service gateway test method and device, storage medium and product

    CN116418711A

  • Unified interface and tracing tool for network function virtualization architecture

    US20230081333A1