Multi-environment monitoring test method and system based on online traffic script generation
Through the multi-environment monitoring and testing method generated based on online traffic scripts, automatic processing and deployment of test scripts solves the problem of inefficiency in the existing technology, realizes real-time monitoring and early warning of the online environment, reduces costs, and improves efficiency. stability and testing efficiency.
Patent Information
- Application Number
- CN202110140357.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-02
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2041-02-02
AI Technical Summary
The existing interface monitoring and testing solution is inefficient and cannot monitor multiple online environments in real time, resulting in online risks and requiring a large amount of manual maintenance scripts, which increases costs.
A multi-environment monitoring and testing method based on online traffic script generation is used to automatically obtain and analyze online interface data, generate scripts and deploy them to different environments to achieve real-time monitoring and early warning and reduce manual writing workload.
It realizes real-time monitoring and early warning of the online environment, reduces labor costs, improves testing efficiency, ensures online stability, and provides staged fault analysis reports.
Smart Images

Figure CN114840406B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer communication, and in particular to a multi-environment monitoring test method and system based on online traffic script generation. Background Art
[0002] The current society cannot do without numerous software. The application of software has penetrated into all walks of life. There are various application software in the fields closely related to life such as home, medical health, education, finance, service industry and tourism industry. Because of these various application software, the scope of service, service mode and service quality have been greatly improved, which greatly improves people's quality of life.
[0003] The existing interface monitoring test solution uses the interface test framework to write scripts, deploy them and generate corresponding test reports. People who write test scripts need to have a certain level of coding skills. Some business interface use cases are highly reusable and require a lot of repetitive work. When the interface changes, interface script maintenance is required, which is inefficient and generates a lot of labor costs. When the interface test script is deployed, it is impossible to monitor important scenarios and multiple online environments in real time, causing online risks. Summary of the invention
[0004] To overcome the above problems, the purpose of the present invention is to provide a multi-environment monitoring and testing method based on online traffic script generation to analyze online traffic data and ensure online stability. It does not require manual script writing and can monitor online conditions in real time.
[0005] The present invention adopts the following scheme to implement: a multi-environment monitoring test method based on online traffic script generation, characterized in that: the test method comprises the following steps:
[0006] Step S1, obtaining online traffic, that is, checking the interface data of the project according to the data returned by the online external call to the project interface, and obtaining the interface data called online;
[0007] Step S2, online traffic data analysis is to analyze the online interface data;
[0008] Step S3, verification script generation, i.e. filling script data according to the interface framework of online traffic data analysis;
[0009] Step S4, the synchronization script matches the automatically generated script to the server where the script is stored according to the domain name;
[0010] Step S5, domain name configuration is for the online environment to be monitored by the synchronization script;
[0011] Step S6, executing the test, that is, performing the operations below the script according to the online environment corresponding to the script configuration, and configuring the corresponding dialing test time.
[0012] Furthermore, the step S2 further specifically includes the following steps:
[0013] Step S21, regularly counting user interface requests within a preset time, obtaining all interface requests, distinguishing interface requests according to domain names, and then counting interface requests with the same domain name, sorting them according to the number of calls, and defining the top 25%-35% of the interfaces as core interfaces;
[0014] Step S22: Obtain the corresponding request URL and domain name, and save the request URL and domain name into the corresponding database table;
[0015] Step S23: define a special use case value to facilitate reverse use case operation, generate values that conform to the type and values that do not conform to the parameter type in combination with the interface parameters in the request data, and assign these type values through the special use case value;
[0016] Step S24: classify the interface request parameters into common parameter names and other parameter names.
[0017] Furthermore, the step S3 further specifically includes the following steps:
[0018] Step S31, filling the configuration file is to write the front-end configuration information and the domain name obtained by the online traffic into the config file to become a static constant;
[0019] Step S32: Use case data preparation is to write the URL and request data analyzed from online traffic data into the script framework;
[0020] Step S33, generating a case use case, that is, generating a case use case according to the parameters and the URL request;
[0021] Step S34, sending a request and receiving a result, that is, sending an interface request according to the generated case use case;
[0022] Step S35, assert the result of the API data to be received, determine whether the use case is an error, and save the result of the assertion to the corresponding database;
[0023] Step S36: Return the test result to the user.
[0024] Furthermore, the step S6 further specifically includes the following steps:
[0025] Step S61, dial test task configuration, that is, daily execution of the script is dial test, script execution time configuration and result pusher configuration;
[0026] Step S62: Sending scripts to different environments, i.e., deploying scripts to servers in different environments according to environment configurations;
[0027] Step S63, loading the dial test configuration, i.e. reading the dial test time configured by the user;
[0028] Step S64, generating a test timing task according to the configuration, that is, generating a test timing task according to the dialing time and frequency;
[0029] Step S65, executing the script, i.e. executing the script according to the scheduled task;
[0030] Step S66, parsing the test report is to save the test report to the database and determine whether the core result is wrong. If yes, the test report is pushed to the result pusher. If not, the alarm service is triggered and the error information is pushed to the core result pusher.
[0031] The present invention also provides a multi-environment monitoring test system based on online traffic script generation, characterized in that: the test system includes an online traffic acquisition module, an online traffic data analysis module, a verification script generation module, a synchronization script module, a domain name configuration module and an execution test module;
[0032] The online traffic acquisition module is used to view the interface data of the project based on the data returned by the online external call to the project interface;
[0033] The online traffic data analysis module is used to analyze the online interface request data;
[0034] The verification script generation module can fill in script data according to the interface framework of the online traffic data analysis module;
[0035] The synchronization script module is used to match the automatically generated script to the server where the script is stored according to the domain name;
[0036] The domain name configuration module is used for the online environment to be monitored by the synchronization script module;
[0037] The execution test module can perform operations below the script according to the online environment corresponding to the script configuration, and configure the corresponding dial test time.
[0038] Furthermore, the online traffic data analysis module further comprises: a distinguishing unit, a storage unit, an assigning unit and a classification unit;
[0039] The distinguishing unit is used to perform regular statistics on user interface requests within a preset time, obtain all interface requests, distinguish interface requests according to domain names, and then perform data statistics on interface requests with the same domain name, sort them according to the number of calls, and define the top 25%-35% of the interfaces as core interfaces;
[0040] The storage unit is used to obtain the corresponding request URL and domain name, and save the request URL and domain name in the corresponding database table;
[0041] The assignment unit, by defining a special use case value, facilitates reverse use case operation, generates values that conform to the type and values that do not conform to the parameter type in combination with the interface parameters in the request data, and assigns these type values through the special use case value;
[0042] The classification unit is used to classify the interface request parameters into common parameter names and other parameter names.
[0043] Furthermore, the verification script generation module further includes: a configuration file filling unit, a use case data preparation unit, a case use case generation unit, a request sending unit, a result receiving unit, an API data assertion unit and a test result return unit;
[0044] The filling configuration config file unit is used to write the front-end configuration information and the domain name obtained by the online traffic into the config file to become a static constant;
[0045] The use case data preparation unit is used to write the URL and request data analyzed from the online traffic data into the script framework;
[0046] The case generation unit can generate case use cases according to parameters and URL requests;
[0047] The sending request and receiving result unit can send an interface request according to the generated case use case;
[0048] The assertion API data unit is used to assert the received result, determine whether the use case reports an error, and save the assertion result to the corresponding database;
[0049] The test result returning unit is used to return the test result to the user.
[0050] Furthermore, the test execution module further includes: a dial test task configuration unit, a script distribution unit to different environments, a dial test configuration unit, a test timing task generation unit according to the configuration, a script execution unit and a test report analysis unit;
[0051] The dial test task configuration unit is used for daily script execution as dial test, script execution time configuration and result pusher configuration;
[0052] The scripts are sent to different environment units, and the scripts are deployed to servers in different environments according to the environment configuration;
[0053] The loading dial test configuration unit is used to read the dial test time configured by the user;
[0054] The test timing task generating unit according to the configuration is used to generate the test timing task according to the dialing test time and frequency;
[0055] The script execution unit is used to execute the script according to the scheduled task;
[0056] The test report parsing unit is used to save the test report to the database and determine whether the core result is wrong. If yes, the test report is pushed to the result pusher. If not, the alarm service is triggered and the error information is pushed to the core result pusher.
[0057] The beneficial effects of the present invention are as follows: the present invention can reduce the workload and time of script writing and reduce labor costs; unify script specifications to facilitate internal maintenance and understanding of scripts within the team; unify the basic script use case generation ideas to facilitate understanding and use case maintenance; perform real-time monitoring and early warning online, and perform real-time monitoring and configuration push for abnormal data to ensure online stability; can perform periodic abnormal data collection and analysis, and can provide a periodic online quality failure analysis report for the product, from which it can be intuitively seen that within the corresponding time period, the causes of the most failures and the corresponding time intervals, so as to facilitate better secondary failure analysis; can perform multi-environment testing on the same project to ensure the stability of the project in different regions and on different servers; the present invention can ensure online stability, is highly efficient, can save labor costs, and improve testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 It is a schematic flow chart of the method of the present invention.
[0059] Figure 2 Diagram for assigning values to parameter types.
[0060] Figure 3 A diagram for classifying interface request parameters.
[0061] Figure 4 Generate flowcharts for automated scripts.
[0062] Figure 5 A schematic diagram for generating case use cases.
[0063] Figure 6A flowchart for executing the test.
[0064] Figure 7 It is a system principle block diagram of the present invention. DETAILED DESCRIPTION
[0065] The present invention will be further described below in conjunction with the accompanying drawings.
[0066] See also Figure 1 As shown, the multi-environment monitoring test method based on online traffic script generation of the present invention comprises the following steps:
[0067] Step S1, obtaining online traffic, that is, checking the interface data of the project according to the data returned by the online external call to the project interface, and obtaining the interface data called online;
[0068] Step S2, online traffic data analysis is to analyze the online interface data;
[0069] Step S3, verification script generation, i.e. filling script data according to the interface framework of online traffic data analysis;
[0070] Step S4, the synchronization script matches the automatically generated script to the server where the script is stored according to the domain name;
[0071] Step S5, domain name configuration is for the online environment to be monitored by the synchronization script;
[0072] Step S6, executing the test, that is, performing the operations below the script according to the online environment corresponding to the script configuration, and configuring the corresponding dialing test time.
[0073] The present invention will be further described below in conjunction with a specific embodiment:
[0074] The multi-environment monitoring test method based on online traffic script generation of the present invention includes:
[0075] Get online traffic: Check the project's interface data based on the data returned by the external online call to the project interface. Get the interface data called online. The data returned by the project interface is ngnix data, Ngnix data: http proxy server ngnix, check the data returned by the online project interface through the proxy server, the data includes: log original text, HTTP status code, domain name, requested URI, etc. By matching keywords, get useful data, including domain name, requested URI, get domain name, request url, parameters, parameter values.
[0076] Online traffic data analysis: Analyze online interface request data.
[0077] First: Regularly count user interface requests within a preset time, obtain all interface requests, the preset time can preferably be within a week, but not limited to this, distinguish interface requests according to domain names, and then count the interface requests with the same domain name, sort them according to the number of calls, and define the top 25%-35% as core interfaces. The best core interface can be ranked in the 30% range, but not limited to this, and the remaining 70% is defined as other interfaces.
[0078] Second: Get the corresponding request URL and domain name, and save the request URL and domain name to the corresponding database table.
[0079] Third: Request data analysis
[0080] 1) Generate special use case values of 0, Null, and None for each parameter definition to facilitate reverse use case operations;
[0081] 2) Combine the interface parameters in the request data to generate some values that conform to the type and values that do not conform to the parameter type to ensure the robustness of the code. Interface parameter types include: object, string, boolean, integer, Long, array, number, and assign special use cases to these types of values, such as Figure 2 As shown:
[0082] 3) Classify the interface request parameters into common parameter names and other parameter names. Common parameter names include: page, index, size, type, limit, offset. Other parameter names are stored according to the id corresponding to the url. Figure 3 As shown:
[0083] Verify script generation: Fill in script data according to the existing interface framework.
[0084] like Figure 4 As shown, an automatic script generation flowchart is provided:
[0085] 1) Fill in the configuration file: write the front-end configuration information, such as user name, password and other user information and the domain name automatically obtained by online traffic into the config file to become a static constant;
[0086] 2) Use case data preparation: write the URL and request data analyzed from online traffic data into the script framework;
[0087] 3) Generate case examples: Generate case examples based on parameters and URL requests. Figure 5 As shown;
[0088] 4) Send request and receive result: send interface request according to the generated use case;
[0089] 5) Assert API data: assert the received results, determine whether the use case reports an error, and save the assertion results to the corresponding database;
[0090] 6) Test result return: Return the test result to the user.
[0091] Synchronize scripts: Match the automatically generated scripts to the projects according to the domain names and upload them to the corresponding servers where the scripts are saved.
[0092] Domain name configuration: Domain name configuration refers to the online environment that the script wants to monitor.
[0093] like Figure 6 As shown, execute the test: send the script according to the environment corresponding to the script configuration, and configure the corresponding dial test time. That is, send the script to the servers in different environments, then build the test task according to the dial test time, automatically execute the script, and return the test results to the user:
[0094] 1) Dial test task configuration: daily script execution is dial test, script execution time configuration, result pusher configuration, including: core interface pusher and other pushers, script execution environment configuration;
[0095] 2) Send scripts to different environments: Deploy scripts to servers in different environments based on environment configuration;
[0096] 3) Load the dial test configuration: read the dial test time configured by the user;
[0097] 4) Generate test timing tasks according to configuration: Generate test timing tasks according to dial test time and frequency;
[0098] 5) Execute script: execute the script according to the scheduled task;
[0099] 6) Analyze the test report: Save the test report to the database and determine whether the core result is wrong. If not, push the test report to the result pusher. If it is a core result error, trigger the alarm service and push the error information to the core result pusher.
[0100] See also Figure 7 As shown, the present invention also provides a multi-environment monitoring test system based on online traffic script generation, the test system includes an online traffic acquisition module, an online traffic data analysis module, a verification script generation module, a synchronization script module, a domain name configuration module and an execution test module;
[0101] The online traffic acquisition module is used to view the interface data of the project based on the data returned by the online external call to the project interface;
[0102] The online traffic data analysis module is used to analyze the online interface request data;
[0103] The verification script generation module can fill in script data according to the interface framework of the online traffic data analysis module;
[0104] The synchronization script module is used to match the automatically generated script to the server where the script is stored according to the domain name;
[0105] The domain name configuration module is used for the online environment to be monitored by the synchronization script module;
[0106] The execution test module can perform operations below the script according to the online environment corresponding to the script configuration, and configure the corresponding dial test time.
[0107] The online traffic data analysis module further includes: a distinguishing unit, a storage unit, an assignment unit and a classification unit;
[0108] The distinguishing unit is used to perform regular statistics on user interface requests within a preset time, obtain all interface requests, distinguish interface requests according to domain names, and then perform data statistics on interface requests with the same domain name, sort them according to the number of calls, and define the top 25%-35% of the interfaces as core interfaces;
[0109] The storage unit is used to obtain the corresponding request URL and domain name, and save the request URL and domain name in the corresponding database table;
[0110] The assignment unit, by defining a special use case value, facilitates reverse use case operation, generates values that conform to the type and values that do not conform to the parameter type in combination with the interface parameters in the request data, and assigns these type values through the special use case value;
[0111] The classification unit is used to classify the interface request parameters into common parameter names and other parameter names.
[0112] The verification script generation module further includes: a filling configuration config file unit, a use case data preparation unit, a case use case generation unit, a request sending unit, a result receiving unit, an API data assertion unit and a test result return unit;
[0113] The filling configuration config file unit is used to write the front-end configuration information and the domain name obtained by the online traffic into the config file to become a static constant;
[0114] The use case data preparation unit is used to write the URL and request data analyzed from the online traffic data into the script framework;
[0115] The case generation unit can generate case according to parameters and URL requests;
[0116] The sending request and receiving result unit can send an interface request according to the generated case use case;
[0117] The assertion API data unit is used to assert the received result, determine whether the use case reports an error, and save the assertion result to the corresponding database;
[0118] The test result returning unit is used to return the test result to the user.
[0119] The test execution module further includes: a dial test task configuration unit, a script distribution unit to different environments, a dial test configuration unit, a test timing task generation unit according to the configuration, a script execution unit and a test report analysis unit;
[0120] The dial test task configuration unit is used for daily script execution as dial test, script execution time configuration and result pusher configuration;
[0121] The scripts are sent to different environment units, and the scripts are deployed to servers in different environments according to the environment configuration;
[0122] The loading dial test configuration unit is used to read the dial test time configured by the user;
[0123] The test timing task generating unit according to the configuration is used to generate the test timing task according to the dialing test time and frequency;
[0124] The script execution unit is used to execute the script according to the scheduled task;
[0125] The test report parsing unit is used to save the test report to the database and determine whether the core result is wrong. If yes, the test report is pushed to the result pusher. If not, the alarm service is triggered and the error information is pushed to the core result pusher.
[0126] The present invention is to liberate the manpower generated by manual script writing, improve the stability and quality of the code, make the code closer to the user, and consider using automatically generated scripts instead of manual script writing. In order to monitor the online situation in real time and make the monitoring data closer to the user, we can analyze the online traffic. First, analyze the interface and split the core interface and other interfaces. Second, analyze the online traffic data and capture useful request data. Automatic script generation is performed based on this information, and the automated script is automatically deployed online for real-time monitoring, thereby ensuring online stability. This automated testing is efficient, can save labor costs, and improve testing efficiency.
[0127] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.
Claims
1. A multi-environment monitoring test method based on online traffic script generation, Features: The test method comprises the following steps: Step S1, obtaining online traffic, that is, checking the interface data of the project according to the data returned by the online external call project interface, and obtaining the interface data of the online call; Step S2, online traffic data analysis is to analyze the online interface data; Step S3, verification script generation, i.e. filling script data according to the interface framework of online traffic data analysis; Step S4, the synchronization script matches the automatically generated script to the server where the script is stored according to the domain name; Step S5, domain name configuration is for the online environment to be monitored by the synchronization script; Step S6, executing the test, i.e., performing the operations below the script according to the online environment corresponding to the script configuration, and configuring the corresponding dialing test time; The step S2 further specifically includes the following steps: Step S21, regularly counting user interface requests within a preset time, obtaining all interface requests, distinguishing interface requests according to domain names, and then counting interface requests with the same domain name, sorting them according to the number of calls, and defining the top 25%-35% of the interfaces as core interfaces; Step S22: Obtain the corresponding request URL and domain name, and save the request URL and domain name into the corresponding database table; Step S23: define special use case values to facilitate reverse use case operations, generate values that conform to the parameter type and values that do not conform to the parameter type in combination with the interface parameters in the request data, and assign these type values through special use case values; Step S24: classify the interface request parameters into common parameter names and other parameter names.
2. According to the multi-environment monitoring test method based on online traffic script generation according to claim 1, Features: The step S3 further specifically includes the following steps: Step S31, filling the configuration file is to write the front-end configuration information and the domain name obtained by the online traffic into the config file to become a static constant; Step S32: Use case data preparation is to write the URL and request data analyzed from online traffic data into the script framework; Step S33, generating a case use case, that is, generating a case use case according to the parameters and the URL request; Step S34, sending a request and receiving a result, that is, sending an interface request according to the generated case use case; Step S35, assert the result of the API data to be received, determine whether the use case is an error, and save the result of the assertion to the corresponding database; Step S36: Return the test result to the user.
3. According to the multi-environment monitoring test method based on online traffic script generation according to claim 1, Features: The step S6 further specifically includes the following steps: Step S61, dial test task configuration, that is, daily execution of the script is dial test, script execution time configuration and result pusher configuration; Step S62: Sending scripts to different environments, i.e., deploying scripts to servers in different environments according to environment configurations; Step S63, loading the dial test configuration, i.e. reading the dial test time configured by the user; Step S64, generating a test timing task according to the configuration, that is, generating a test timing task according to the dialing time and frequency; Step S65, executing the script, i.e. executing the script according to the scheduled task; Step S66, parsing the test report is to save the test report to the database and determine whether the core result is wrong. If yes, the test report is pushed to the result pusher. If not, the alarm service is triggered and the error information is pushed to the core result pusher.
4. A multi-environment monitoring test system based on online traffic script generation, Features: The test system includes an online traffic acquisition module, an online traffic data analysis module, a verification script generation module, a synchronization script module, a domain name configuration module and an execution test module; The online traffic acquisition module is used to view the interface data of the project based on the data returned by the online external call to the project interface; The online traffic data analysis module is used to analyze the online interface request data; The verification script generation module can fill in script data according to the interface framework of the online traffic data analysis module; The synchronization script module is used to match the automatically generated script to the server where the script is stored according to the domain name; The domain name configuration module is used for the online environment to be monitored by the synchronization script module; The execution test module can perform script operations according to the online environment corresponding to the script configuration and configure the corresponding dial test time; The online traffic data analysis module further includes: a distinguishing unit, a storage unit, an assignment unit and a classification unit, wherein the distinguishing unit is used to perform regular statistics on user interface requests within a preset time, obtain all interface requests, distinguish interface requests according to domain names, and then perform data statistics on interface requests with the same domain name, and sort them according to the number of calls, and define the interfaces in the top 25%-35% range as core interfaces; The storage unit is used to obtain the corresponding request URL and domain name, and save the request URL and domain name in the corresponding database table; The assignment unit, by defining a special use case value, facilitates reverse use case operation, generates values that conform to the parameter type and values that do not conform to the parameter type in combination with the interface parameters in the request data, and assigns these type values through the special use case value; The classification unit is used to classify the interface request parameters into common parameter names and other parameter names.
5. The multi-environment monitoring test system based on online traffic script generation according to claim 4, Features: The verification script generation module further includes: a filling configuration config file unit, a use case data preparation unit, a case use case generation unit, a request sending unit, a result receiving unit, an API data assertion unit and a test result return unit; The filling configuration config file unit is used to write the front-end configuration information and the domain name obtained by the online traffic into the config file to become a static constant; The use case data preparation unit is used to write the URL and request data analyzed from the online traffic data into the script framework; The case generation unit can generate case use cases according to parameters and URL requests; The sending request and receiving result unit can send an interface request according to the generated case use case; The assertion API data unit is used to assert the received result, determine whether the use case reports an error, and save the assertion result to the corresponding database; The test result returning unit is used to return the test result to the user.
6. The multi-environment monitoring test system based on online traffic script generation according to claim 4, Features: The test execution module further includes: a dial test task configuration unit, a script distribution unit to different environments, a dial test configuration unit, a test timing task generation unit according to the configuration, a script execution unit and a test report analysis unit; The dial test task configuration unit is used for daily script execution as dial test, script execution time configuration and result pusher configuration; The scripts are sent to different environment units, and the scripts are deployed to servers in different environments according to the environment configuration; The loading dial test configuration unit is used to read the dial test time configured by the user; The test timing task generating unit according to the configuration is used to generate the test timing task according to the dialing test time and frequency; The script execution unit is used to execute the script according to the scheduled task; The test report parsing unit is used to save the test report to the database and determine whether the core result is wrong. If yes, the test report is pushed to the result pusher. If not, the alarm service is triggered and the error information is pushed to the core result pusher.
Citation Information
Patent Citations
Automatic testing system and method based on parallel ports
CN105335293A
Network application system with active performance test and passive shunt control and implementation method thereof
CN107332715A
Automated monitoring method and terminal based on funnel model
CN108664405A
Pressure testing method and device and medium
CN111949504A
Method for generating interface test script and related equipment thereof
CN112286815A
