Monitoring script generation method and device, monitoring method and device
By modifying the script template according to the target test case to generate the monitoring script, the problem of long monitoring script generation time in the existing technology is solved, and efficient and automated monitoring script generation and interface monitoring are realized.
Patent Information
- Application Number
- CN202010071174.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-01-21
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-01-21
AI Technical Summary
Existing monitoring scripts need to be written manually by technical personnel, resulting in long generation time and low efficiency.
By determining the target test cases corresponding to the module, modify the preset script template based on these test cases, generate monitoring scripts, and use automated testing to obtain test cases to shorten the generation time.
This method can significantly shorten the generation time of monitoring scripts, improve monitoring efficiency, and automatically generate monitoring scripts that adapt to interface changes, improving the accuracy and effectiveness of monitoring results.
Smart Images

Figure CN113220558B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a monitoring script generation method and device, and a monitoring method and device. Background Art
[0002] The interface may generate exceptions during the service provision process. In order to detect exceptions in time and provide users with stable services, it is necessary to monitor the interface through monitoring scripts.
[0003] Existing monitoring scripts are manually written by technicians, which takes a long time. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a monitoring script generation method and device, and a monitoring method and device, which can shorten the time for generating a monitoring script.
[0005] In a first aspect, an embodiment of the present invention provides a monitoring script generation method, comprising:
[0006] Determine a number of target test cases corresponding to the module; wherein the module corresponds to a number of target interfaces; the number of target test cases are composed of target test cases corresponding to each of the target interfaces;
[0007] Modify the preset script template according to the several target test cases to obtain the monitoring script of the module.
[0008] Preferably,
[0009] Determine several target test cases corresponding to the module, including:
[0010] According to pre-configured selection parameters and preset screening rules, a number of target test cases corresponding to the module are screened out from a number of test cases; wherein the selection parameters include: any one or more of the identifier of the module, the number of target test cases corresponding to the identifier of the module, the identifier of the target interface and the number of target test cases corresponding to the target interface.
[0011] Preferably,
[0012] The screening rule includes: the target test case is a test case that is successfully executed; and / or, the target test cases are selected in sequence according to the execution time of the test cases from recent to long.
[0013] Preferably,
[0014] Modify the preset script template according to the several target test cases to obtain the monitoring script of the module, including:
[0015] For each of the target test cases, execute:
[0016] Parsing the script template to obtain an HTTP (Hyper Text Transfer Protocol) request sampler;
[0017] Copy the HTTP Request Sampler;
[0018] According to the target test case, modify the copied HTTP request sampler;
[0019] Add the modified HTTP Request Sampler to the script template.
[0020] Preferably,
[0021] The target test case includes: input, assertion statement, message header, and cookie;
[0022] The copied HTTP request sampler includes: sampler parameters, BeanShell assertions, HTTP header manager, and HTTP Cookie manager;
[0023] According to the target test case, modify the copied HTTP request sampler, including:
[0024] modifying the sampler parameters according to the input;
[0025] Modifying the BeanShell assertion according to the assertion statement;
[0026] Modify the HTTP header manager according to the message header;
[0027] Modify the HTTP Cookie Manager according to the cookie;
[0028] Add the modified HTTP Request Sampler to the script template.
[0029] In a second aspect, an embodiment of the present invention provides a monitoring method, including:
[0030] Determine a number of target test cases corresponding to the module; wherein the module corresponds to a number of target interfaces; the number of target test cases are composed of target test cases corresponding to each of the target interfaces;
[0031] Modify the preset script template according to the several target test cases to obtain the monitoring script of the module;
[0032] The monitoring server is triggered so that the monitoring server obtains the monitoring script and monitors the plurality of target interfaces according to the monitoring script.
[0033] Preferably,
[0034] Further including:
[0035] Generate information of the monitoring script;
[0036] Sending the monitoring script to a remote repository;
[0037] The trigger monitoring server comprises:
[0038] The monitoring script information and pre-configured monitoring information are sent to the monitoring server, so that the monitoring server obtains the monitoring script from the remote warehouse according to the monitoring script information, and monitors the plurality of target interfaces according to the monitoring information and the monitoring script.
[0039] In a third aspect, an embodiment of the present invention provides a monitoring method, including:
[0040] According to the triggering of the monitoring device, the monitoring script of the module is obtained; wherein the monitoring script is obtained by the monitoring device determining a number of target test cases corresponding to the module, and modifying a preset script template according to the number of target test cases; the module corresponds to a number of target interfaces; the number of target test cases are composed of target test cases corresponding to each of the target interfaces;
[0041] According to the monitoring script, the plurality of target interfaces are monitored.
[0042] In a fourth aspect, an embodiment of the present invention provides a monitoring script generation device, including:
[0043] A determination module configured to determine a number of target test cases corresponding to the module; wherein the module corresponds to a number of target interfaces; the number of target test cases are composed of target test cases corresponding to each of the target interfaces;
[0044] The modification module is configured to modify a preset script template according to the plurality of target test cases to obtain a monitoring script for the module.
[0045] In a fifth aspect, an embodiment of the present invention provides a monitoring device, including:
[0046] A determination module configured to determine a number of target test cases corresponding to the module; wherein the module corresponds to a number of target interfaces; the number of target test cases are composed of target test cases corresponding to each of the target interfaces;
[0047] A modification module, configured to modify a preset script template according to the plurality of target test cases to obtain a monitoring script for the module;
[0048] The trigger module is configured to trigger the monitoring server so that the monitoring server obtains the monitoring script and monitors the plurality of target interfaces according to the monitoring script.
[0049] In a sixth aspect, an embodiment of the present invention provides a monitoring server, including:
[0050] An acquisition module is configured to acquire a monitoring script of a module according to a trigger of a monitoring device; wherein the monitoring script is obtained by the monitoring device determining a number of target test cases corresponding to the module and modifying a preset script template according to the number of target test cases; the module corresponds to a number of target interfaces; the number of target test cases are composed of target test cases corresponding to each of the target interfaces;
[0051] The monitoring module is configured to monitor the plurality of target interfaces according to the monitoring script.
[0052] In a seventh aspect, an embodiment of the present invention provides a monitoring system, comprising: the monitoring device described in any one of the above embodiments and the monitoring server described in any one of the above embodiments.
[0053] In an eighth aspect, an embodiment of the present invention provides an electronic device, including:
[0054] one or more processors;
[0055] a storage device for storing one or more programs,
[0056] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.
[0057] In a ninth aspect, an embodiment of the present invention provides a computer-readable medium having a computer program stored thereon, characterized in that when the program is executed by a processor, the method described in any of the above embodiments is implemented.
[0058] An embodiment of the above invention has the following advantages or beneficial effects: the method modifies the script template through the test case corresponding to the interface to generate a monitoring script. Compared with manual writing, the process takes less time to generate the monitoring script. At the same time, the test case can be obtained by automated testing, and there is no need to prepare data for modifying the script template, which can further shorten the time spent on generating the monitoring script.
[0059] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0061] Figure 1 is a flow chart of a monitoring script generation method provided by an embodiment of the present invention;
[0062] Figure 2 is a flow chart of a monitoring method applied to a monitoring device provided by an embodiment of the present invention;
[0063] Figure 3 is a flow chart of a monitoring method applied to a monitoring server provided by an embodiment of the present invention;
[0064] Figure 4 is a flow chart of a monitoring method applied to a monitoring system provided by an embodiment of the present invention;
[0065] Figure 5 is a schematic diagram of a monitoring script generating device provided by an embodiment of the present invention;
[0066] Figure 6 is a schematic diagram of a monitoring device provided by an embodiment of the present invention;
[0067] Figure 7 is a schematic diagram of a monitoring server provided by an embodiment of the present invention;
[0068] Figure 8 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0069] Fig. 9 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0070] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0071] Existing monitoring scripts are manually written by technicians, which takes a long time.
[0072] In view of this, an embodiment of the present invention provides a monitoring script generation method, such as Figure 1 As shown, the method includes:
[0073] Step 101: Determine a number of target test cases corresponding to a module; wherein a module corresponds to a number of target interfaces; and the number of target test cases are composed of target test cases corresponding to each target interface.
[0074] A module is a functional unit that can provide services to users, such as a shopping cart module, a search module, etc. A module may include one or more interfaces, for example, a shopping cart module includes interfaces such as delete and add.
[0075] Test cases are generated by the automated testing process. Test cases include: input, assertion statements, message headers, cookies, output, test case test results, test case module information, tester information, execution time, etc.
[0076] In actual application scenarios, it may be necessary to generate monitoring scripts corresponding to multiple modules. Since the method of generating monitoring scripts corresponding to each module is the same, for the convenience of description, the embodiments in this specification only take one module as an example.
[0077] Step 102: Modify the preset script template according to a number of target test cases to obtain a monitoring script for the module.
[0078] The script template is pre-set before executing the monitoring script generation method. The monitoring script can monitor the target interface corresponding to the module.
[0079] The method modifies the script template through the test case corresponding to the interface to generate a monitoring script. Compared with manual writing, the process takes less time to generate the monitoring script. At the same time, the test case can be obtained by automated testing, and there is no need to prepare data for modifying the script template, which can further shorten the time spent on generating the monitoring script.
[0080] In one embodiment of the present invention, the automated test is implemented based on TestNG, and the test scripts are written by testers.
[0081] The automated testing method is implemented based on TestNG. TestNG includes: DataProvider and TestClass. The test script is written by the tester, and the test script includes: constructing a custom HttpEntity object in DataProvider, setting the HTTP request message headers, cookies, URL (Uniform Resource Locator), document body, assertions and other information of the HttpEntity object; adding a tag to the TestClass method, setting the module information and tester information of the test case on the tag, and calling the executor in the test method to execute the HTTP request defined by the HttpEntity object.
[0082] The automated testing method based on TestNG includes the following steps:
[0083] TestNG reads DataProvider and obtains the HttpEntity object;
[0084] TestNG calls the test method of the test class and passes the HttpEntity object to the test method;
[0085] The test method of the test class calls the executor and passes the HttpEntity object to the executor;
[0086] The executor constructs an OkHttp Request based on the HttpEntity object and calls OkHttp to execute the http request;
[0087] OkHttp returns the response of the HTTP request;
[0088] The executor verifies whether the response of the HTTP request satisfies the assertion set by HttpEntity and returns the result to the test method of the test class;
[0089] After the test method of the test class is executed, TestNG collects the test case execution information and results as well as the tag information of the test method in the afterInvocation method;
[0090] TestNG saves the collected information into the database.
[0091] The information collected by TestNG can be used as test case information in the monitoring script generation process, and part of the information collected by TestNG can also be selected as test case information.
[0092] Among them, TestNG is an automated testing framework and OkHttp is an HTTP client.
[0093] In one embodiment of the present invention, determining a number of target test cases corresponding to a module includes:
[0094] According to pre-configured selection parameters and preset screening rules, several target test cases corresponding to the module are screened out from several test cases; wherein the selection parameters include: any one or more of the module identifier, the number of target test cases corresponding to the module identifier, the target interface identifier and the number of target test cases corresponding to the target interface.
[0095] In an embodiment of the present invention, several test cases generated by automated testing can be stored in a database. At this time, the method accesses the database according to selection parameters and screening rules to screen out target test cases from several test cases stored in the database. Specifically, mybatis can be used to access the database.
[0096] Like the selection parameters, the screening rules can also be pre-configured. If it is necessary to generate corresponding monitoring scripts for multiple modules, there are multiple module identifiers, and the module identifiers correspond to the identifiers of the target interfaces. For example, the configuration parameters include: module identifier 1, target interfaces A, B, and C corresponding to module identifier 1, the number of target test cases for module identifier 1 is 30, and the number of target test cases for target interfaces A, B, and C are 5, 10, and 15 respectively; module identifier 2, target interfaces D and E corresponding to module identifier 2, and the number of target test cases for target interfaces D and E are 10 and 15 respectively.
[0097] Taking module identification 2 as an example, the method needs to screen out 10 test cases of target interface D and 15 test cases of target interface E from a number of test cases stored in the database.
[0098] In actual application scenarios, several target test cases corresponding to the module can be periodically screened out from several test cases according to a pre-set cycle, and the script template can be modified based on these target test cases. In this way, the target test cases generated recently can be screened out, so that the modified monitoring script can adapt to the changes of the currently monitored interface, thereby improving the accuracy and effectiveness of the monitoring results. Of course, all test cases corresponding to the target interface can also be directly used as test cases for the target interface without screening, which will not be repeated here.
[0099] In one embodiment of the present invention, the screening rules specifically include: the target test case is a test case that has been successfully executed; and / or, the target test cases are selected in order of execution time from recent to long.
[0100] In actual application scenarios, test cases can be screened according to the information included in the test cases, for example, according to the test case test results, execution time or test case module information mentioned in the above embodiments, etc. The test case test results include: execution success or execution failure.
[0101] Since the test cases that have been successfully executed recently can better reflect the current functions of the system, in order to improve the effectiveness of monitoring, the test cases that have been successfully executed recently are given priority in the screening process.
[0102] In one embodiment of the present invention, a preset script template is modified according to several target test cases to obtain a monitoring script for a module, including:
[0103] For each target test case, execute:
[0104] Parse the script template and get the HTTP request sampler;
[0105] Copy HTTP Request Sampler;
[0106] Modify the copied HTTP request sampler according to the target test case;
[0107] Add the modified HTTP Request Sampler to the script template.
[0108] After the modified HTTP request samplers corresponding to several target test cases are added to the script template, a monitoring script is obtained.
[0109] In an embodiment of the present invention, the script template is a JMeter script template in an XML (Extensible Markup Language) format. The JMeter script template includes a thread group, and the HTTP request sampler is located in the thread group. The JMeter script template is modified by the target test case obtained by screening to obtain a monitoring script. The monitoring script can not only monitor the basic functions of the interface, but also monitor the complex functions of the interface based on the target test case.
[0110] In actual application scenarios, the monitoring script of the module can also be directly generated according to several target test cases, and this process does not involve modifying the script template. However, modifying the script template can shorten the time of generating the monitoring script.
[0111] In one embodiment of the present invention, the target test case includes: input, assertion statement, message header, cookie; the copied HTTP request sampler includes: sampler parameter, BeanShell assertion, HTTP header manager, HTTPCookie manager;
[0112] Modify the copied HTTP request sampler according to the target test case, including:
[0113] Based on the input, modify the sampler parameters;
[0114] Modify the BeanShell assertion according to the assertion statement;
[0115] Modify the HTTP header manager according to the message header;
[0116] Depending on the cookie, modify the HTTP Cookie Manager;
[0117] Add the modified HTTP Request Sampler to the script template.
[0118] The input of the use case includes: URL and body of HTTP request. The sampler parameters include: URL and body.
[0119] Modify the BeanShell assertions according to the assertion statements, including:
[0120] Add assertion statements to your BeanShell script for BeanShell assertions.
[0121] Modify the HTTP header manager according to the message header, including:
[0122] Add the message header as a child node to the HTTP Header Manager.
[0123] Depending on the cookie, modify the HTTP Cookie Manager to include:
[0124] Adds a cookie as a child to the HTTP Cookie Manager.
[0125] Add the modified HTTP Request sampler to the script template, including:
[0126] Add the modified HTTP Request Sampler to the Thread Group in the Script Template.
[0127] It should be noted that if there is only one target test case, the HTTP request sampler obtained by parsing can be directly modified according to the target test case without copying the HTTP request sampler.
[0128] like Figure 2 As shown, an embodiment of the present invention provides a monitoring method, which is applied to a monitoring device, including:
[0129] Step 201: Determine a number of target test cases corresponding to a module; wherein a module corresponds to a number of target interfaces; and the number of target test cases are composed of target test cases corresponding to each target interface.
[0130] Step 202: Modify the preset script template according to a number of target test cases to obtain a monitoring script for the module.
[0131] The monitoring method of the embodiment of the present invention is implemented based on the monitoring script obtained in the above embodiment. Therefore, step 201 is the same as step 101, and step 202 is the same as step 102. Step 201 and step 202 will not be explained here.
[0132] Step 203: triggering the monitoring server so that the monitoring server obtains a monitoring script and monitors a number of target interfaces according to the monitoring script.
[0133] The monitoring method is implemented based on a monitoring script. Since the monitoring script uses test cases in the generation process, the monitoring script can monitor the complex functions of the interface. In addition, the monitoring method does not require manual writing of the monitoring script, which can improve monitoring efficiency.
[0134] After obtaining the monitoring script, the monitoring script can be sent to the monitoring server, and a notification can be sent to the monitoring server so that the monitoring server can obtain the monitoring script from the monitoring device. However, storing the monitoring script in the monitoring device or the monitoring server will increase the interaction pressure between the monitoring device and the monitoring server, and it is not convenient for the unified management of the monitoring script.
[0135] In view of this, in one embodiment of the present invention, the monitoring method further includes: generating information of a monitoring script; sending the monitoring script to a remote warehouse;
[0136] Trigger monitoring server, including:
[0137] The monitoring script information and the pre-configured monitoring information are sent to the monitoring server, so that the monitoring server obtains the monitoring script from the remote warehouse according to the monitoring script information, and monitors several target interfaces according to the monitoring information and the monitoring script.
[0138] The embodiment of the present invention stores the monitoring script in a remote warehouse to facilitate unified management and reduce the operating pressure of the monitoring device and the monitoring server.
[0139] In the embodiment of the present invention, the purpose of sending the monitoring script information to the monitoring server is to enable the monitoring server to determine the monitoring script corresponding to the monitoring script information among several monitoring scripts. The monitoring information can be configured in the monitoring device together with the selection parameters, and can also be configured in the monitoring server.
[0140] The information of the monitoring script includes: module identification, target interface identification, etc. In actual application scenarios, the information of the monitoring script can also be sent to a remote warehouse, so that the remote warehouse stores the information of the monitoring script and the monitoring script in correspondence, so as to facilitate the monitoring server to search. At this time, the information of the monitoring script can also include the identification of the monitoring script.
[0141] Monitoring information, including: execution frequency of monitoring scripts, alarm triggering conditions, alarm email recipients, etc.
[0142] In the embodiment of the present invention, the remote repository may be a Git repository.
[0143] Send the monitoring script to the remote repository, including: sending the monitoring script to the Git repository through JGit.
[0144] Send the monitoring script to the Git repository through JGit, including: calling the Git.add() method, calling the Git.commit() method, calling Git.push() and setting the mandatory parameter to true.
[0145] Send monitoring script information and pre-configured monitoring information to the monitoring server, including:
[0146] The monitoring script information and pre-configured monitoring information are sent to the monitoring server through the HTTP interface.
[0147] like Figure 3 As shown, an embodiment of the present invention provides a monitoring method, which is applied to a monitoring server, comprising:
[0148] Step 301: Acquire the monitoring script of the module according to the trigger of the monitoring device; wherein, the monitoring script is obtained by modifying a preset script template according to several target test cases corresponding to the module determined by the monitoring device; the module corresponds to several target interfaces; and the several target test cases are composed of target test cases corresponding to each target interface.
[0149] Step 302: Monitor several target interfaces according to the monitoring script.
[0150] The monitoring method is implemented based on a monitoring script. Since the monitoring script uses test cases in the generation process, the monitoring script can monitor the complex functions of the interface. In addition, the monitoring method does not require manual writing of the monitoring script, which can improve monitoring efficiency.
[0151] In one embodiment of the present invention, according to the triggering of the monitoring device, the monitoring script of the module is obtained, which specifically includes:
[0152] Receiving monitoring script information and pre-configured monitoring information sent by the monitoring device;
[0153] Obtain the monitoring script from the remote repository based on the monitoring script information;
[0154] According to the monitoring script, several target interfaces are monitored, including:
[0155] Monitor several target interfaces according to monitoring information and monitoring scripts.
[0156] like Figure 4 As shown, an embodiment of the present invention provides a monitoring method, which is applied to a monitoring system. The method includes the following steps:
[0157] Step 401: The monitoring device determines a number of target test cases corresponding to a module; wherein the module corresponds to a number of target interfaces; and the number of target test cases are composed of target test cases corresponding to each target interface.
[0158] from Figure 4 It can be seen that the monitoring system includes: monitoring device, remote warehouse and monitoring server.
[0159] Step 402: The monitoring device modifies a preset script template according to a number of target test cases to obtain a monitoring script for the module.
[0160] Step 403: The monitoring device generates monitoring script information.
[0161] Step 404: The monitoring device sends the monitoring script to the remote warehouse.
[0162] Step 405: The monitoring device sends the monitoring script information and pre-configured monitoring information to the monitoring server.
[0163] Step 406: The monitoring server obtains the monitoring script from the remote warehouse according to the information of the monitoring script.
[0164] Step 407: The monitoring server monitors a number of target interfaces according to the monitoring information and the monitoring script.
[0165] The monitoring method is implemented based on a monitoring script. Since the monitoring script uses test cases in the generation process, the monitoring script can monitor the complex functions of the interface. In addition, the monitoring method does not require manual writing of the monitoring script, which can improve monitoring efficiency.
[0166] like Figure 5 As shown, an embodiment of the present invention provides a monitoring script generation device, including:
[0167] The determination module 501 is configured to determine a number of target test cases corresponding to the module; wherein the module corresponds to a number of target interfaces; and the number of target test cases is composed of target test cases corresponding to each target interface;
[0168] The modification module 502 is configured to modify a preset script template according to a number of target test cases to obtain a monitoring script for the module.
[0169] In one embodiment of the present invention, the determination module 501 is configured to filter out a number of target test cases corresponding to a module from a number of test cases based on pre-configured selection parameters and preset screening rules; wherein the selection parameters include: any one or more of the module identifier, the number of target test cases corresponding to the module identifier, the target interface identifier and the number of target test cases corresponding to the target interface.
[0170] In one embodiment of the present invention, the screening rules include: the target test case is a test case that is successfully executed; and / or, the target test cases are selected in order of execution time from recent to oldest.
[0171] In one embodiment of the present invention, the modification module 502 is configured to execute, for each target test case, the following steps: parsing the script template to obtain an HTTP request sampler; copying the HTTP request sampler; modifying the copied HTTP request sampler according to the target test case; and adding the modified HTTP request sampler to the script template.
[0172] In one embodiment of the present invention, the target test case includes: input, assertion statement, message header, cookie; the copied HTTP request sampler includes: sampler parameters, BeanShell assertion, HTTP header manager, HTTPCookie manager; the modification module 502 is configured to modify the sampler parameters according to the input; modify the BeanShell assertion according to the assertion statement; modify the HTTP header manager according to the message header; modify the HTTP Cookie manager according to the cookie; and add the modified HTTP request sampler to the script template.
[0173] like Figure 6 As shown, an embodiment of the present invention provides a monitoring device, including:
[0174] The determination module 601 is configured to determine a number of target test cases corresponding to the module; wherein the module corresponds to a number of target interfaces; and the number of target test cases is composed of target test cases corresponding to each target interface;
[0175] A modification module 602 is configured to modify a preset script template according to a number of target test cases to obtain a monitoring script for the module;
[0176] The trigger module 603 is configured to trigger the monitoring server so that the monitoring server obtains a monitoring script and monitors a number of target interfaces according to the monitoring script.
[0177] In one embodiment of the present invention, the trigger module 603 is configured to generate information of a monitoring script; send the monitoring script to a remote warehouse; and send the information of the monitoring script and pre-configured monitoring information to a monitoring server, so that the monitoring server obtains the monitoring script from the remote warehouse according to the information of the monitoring script, and monitors a number of target interfaces according to the monitoring information and the monitoring script.
[0178] like Figure 7 As shown, an embodiment of the present invention provides a monitoring server, including:
[0179] The acquisition module 701 is configured to acquire the monitoring script of the module according to the trigger of the monitoring device; wherein the monitoring script is obtained by the monitoring device determining a number of target test cases corresponding to the module, and modifying a preset script template according to the number of target test cases; the module corresponds to a number of target interfaces; and the number of target test cases are composed of target test cases corresponding to each target interface;
[0180] The monitoring module 702 is configured to monitor a number of target interfaces according to a monitoring script.
[0181] An embodiment of the present invention provides a monitoring system, comprising: a monitoring device according to any one of the above embodiments and a monitoring server according to any one of the above embodiments.
[0182] In one embodiment of the present invention, the monitoring system further includes: a remote warehouse.
[0183] An embodiment of the present invention provides an electronic device, including:
[0184] one or more processors;
[0185] a storage device for storing one or more programs,
[0186] When one or more programs are executed by one or more processors, the one or more processors implement the method of any of the above embodiments.
[0187] Figure 8 An exemplary system architecture 800 is shown to which the monitoring script generation method or monitoring script generation device or monitoring method or monitoring device according to the embodiments of the present invention may be applied.
[0188] like Figure 8 As shown, system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. Network 804 is used to provide a medium for communication links between terminal devices 801, 802, 803 and server 805. Network 804 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0189] Users can use terminal devices 801, 802, and 803 to interact with server 805 through network 804 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 801, 802, and 803, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0190] The terminal devices 801 , 802 , and 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0191] The server 805 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 801, 802, and 803. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.
[0192] It should be noted that the monitoring script generating method or monitoring method provided in the embodiment of the present invention is generally executed by the server 805 , and accordingly, the monitoring script generating device or monitoring device is generally arranged in the server 805 .
[0193] It should be understood that Figure 8 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0194] Reference below Fig. 9 , which shows a schematic diagram of the structure of a computer system 900 of a terminal device suitable for implementing an embodiment of the present invention. Fig. 9 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0195] like Fig. 9 As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the system 900 are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0196] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.
[0197] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, the above-mentioned functions defined in the system of the present invention are executed.
[0198] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0199] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0200] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a sending module, an acquisition module, a determination module, and a first processing module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the sending module may also be described as a "module for sending a picture acquisition request to the connected server."
[0201] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0202] Determine a number of target test cases corresponding to the module; wherein the module corresponds to a number of target interfaces; the number of target test cases is composed of target test cases corresponding to each target interface;
[0203] Modify the preset script template according to several target test cases to obtain the monitoring script of the module.
[0204] The computer-readable medium carries one or more programs. When the one or more programs are executed by a device, the device includes:
[0205] Determine a number of target test cases corresponding to the module; wherein the module corresponds to a number of target interfaces; the number of target test cases is composed of target test cases corresponding to each target interface;
[0206] Modify the preset script template according to several target test cases to obtain the monitoring script of the module;
[0207] The monitoring server is triggered so that the monitoring server obtains the monitoring script and monitors several target interfaces according to the monitoring script.
[0208] The computer-readable medium carries one or more programs. When the one or more programs are executed by a device, the device includes:
[0209] According to the triggering of the monitoring device, the monitoring script of the module is obtained; wherein the monitoring script is obtained by the monitoring device determining a number of target test cases corresponding to the module, and modifying a preset script template according to the number of target test cases; the module corresponds to a number of target interfaces; the number of target test cases is composed of target test cases corresponding to each target interface;
[0210] According to the monitoring script, monitor several target interfaces.
[0211] The embodiment of the present invention modifies the script template through the test case corresponding to the interface to generate a monitoring script. Compared with manual writing, the time spent on generating the monitoring script is short. At the same time, the test case can be obtained by automated testing, and there is no need to prepare data for modifying the script template, which can further shorten the time spent on generating the monitoring script.
[0212] In addition, since the monitoring script uses test cases during the generation process, the monitoring script can monitor the complex functions of the interface. Moreover, the monitoring method does not require manual writing of the monitoring script, which can improve the monitoring efficiency.
[0213] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A monitoring script generation method, characterized in that: include: Determine a number of target test cases corresponding to the module; wherein the module corresponds to a number of target interfaces; the number of target test cases are composed of target test cases corresponding to each of the target interfaces; Modify the preset script template according to the several target test cases to obtain the monitoring script of the module; the target test case includes: input, assertion statement, message header, cookie; specifically include: for each target test case, execute: parse the script template to obtain a Hypertext Transfer Protocol HTTP request sampler; copy the HTTP request sampler, and the copied HTTP request sampler includes: sampler parameters, BeanShell assertion, HTTP header manager, HTTP Cookie manager; modify the sampler parameters according to the input; modify the BeanShell assertion according to the assertion statement; modify the HTTP header manager according to the message header; modify the HTTP Cookie manager according to the cookie; add the modified HTTP request sampler to the script template.
2. The method according to claim 1, characterized in that The determination module corresponds to several target test cases, including: According to pre-configured selection parameters and preset screening rules, a number of target test cases corresponding to the module are screened out from a number of test cases; wherein the selection parameters include: any one or more of the identifier of the module, the number of target test cases corresponding to the identifier of the module, the identifier of the target interface and the number of target test cases corresponding to the target interface.
3. The method according to claim 2, characterized in that The screening rule includes: the target test case is a test case that is successfully executed; and / or, the target test cases are selected in sequence according to the execution time of the test cases from recent to long.
4. A monitoring method, characterized in that: include: Determine a number of target test cases corresponding to the module; wherein the module corresponds to a number of target interfaces; the number of target test cases are composed of target test cases corresponding to each of the target interfaces; Modify the preset script template according to the several target test cases to obtain the monitoring script of the module; the target test case includes: input, assertion statement, message header, cookie; specifically include: for each target test case, execute: parse the script template to obtain a Hypertext Transfer Protocol HTTP request sampler; copy the HTTP request sampler, and the copied HTTP request sampler includes: sampler parameters, BeanShell assertion, HTTP header manager, HTTP Cookie manager; modify the sampler parameters according to the input; modify the BeanShell assertion according to the assertion statement; modify the HTTP header manager according to the message header; modify the HTTP Cookie manager according to the cookie; add the modified HTTP request sampler to the script template; The monitoring server is triggered so that the monitoring server obtains the monitoring script and monitors the plurality of target interfaces according to the monitoring script.
5. The method according to claim 4, characterized in that Further including: Generate information of the monitoring script; Sending the monitoring script to a remote repository; The trigger monitoring server comprises: The monitoring script information and pre-configured monitoring information are sent to the monitoring server, so that the monitoring server obtains the monitoring script from the remote warehouse according to the monitoring script information, and monitors the plurality of target interfaces according to the monitoring information and the monitoring script.
6. A monitoring method, characterized in that: include: According to the triggering of the monitoring device, the monitoring script of the module is obtained; wherein, the monitoring script is obtained by the monitoring device determining several target test cases corresponding to the module, and modifying the preset script template according to the several target test cases; the target test case includes: input, assertion statement, message header, cookie; the step of obtaining the monitoring script of the module includes: for each of the target test cases, executing: parsing the script template to obtain a Hypertext Transfer Protocol HTTP request sampler; copying the HTTP request sampler, and the copied HTTP request sampler includes: sampler parameters, BeanShell assertions, HTTP header manager, HTTP Cookie manager; modifying the sampler parameters according to the input; modifying the BeanShell assertion according to the assertion statement; modifying the HTTP header manager according to the message header; modifying the HTTP Cookie manager according to the cookie; adding the modified HTTP request sampler to the script template; the module corresponds to several target interfaces; the several target test cases are composed of target test cases corresponding to each of the target interfaces; According to the monitoring script, the plurality of target interfaces are monitored.
7. A monitoring script generating device, characterized in that: include: A determination module configured to determine a number of target test cases corresponding to the module; wherein the module corresponds to a number of target interfaces; the number of target test cases are composed of target test cases corresponding to each of the target interfaces; A modification module is configured to modify a preset script template according to the target test cases to obtain a monitoring script of the module; the target test cases include: input, assertion statements, message headers, and cookies; specifically includes: for each target test case, executing: parsing the script template to obtain a Hypertext Transfer Protocol HTTP request sampler; copying the HTTP request sampler, and the copied HTTP request sampler includes: sampler parameters, BeanShell assertions, HTTP header manager, and HTTP Cookie manager; modifying the sampler parameters according to the input; modifying the BeanShell assertions according to the assertion statements; modifying the HTTP header manager according to the message header; modifying the HTTP Cookie manager according to the cookie; and adding the modified HTTP request sampler to the script template.
8. A monitoring device, characterized in that: include: A determination module configured to determine a number of target test cases corresponding to the module; wherein the module corresponds to a number of target interfaces; the number of target test cases are composed of target test cases corresponding to each of the target interfaces; A modification module is configured to modify a preset script template according to the target test cases to obtain a monitoring script of the module; the target test cases include: input, assertion statements, message headers, and cookies; specifically includes: for each target test case, executing: parsing the script template to obtain a Hypertext Transfer Protocol HTTP request sampler; copying the HTTP request sampler, and the copied HTTP request sampler includes: sampler parameters, BeanShell assertions, HTTP header manager, and HTTP Cookie manager; modifying the sampler parameters according to the input; modifying the BeanShell assertion according to the assertion statement; modifying the HTTP header manager according to the message header; modifying the HTTP Cookie manager according to the cookie; adding the modified HTTP request sampler to the script template; The trigger module is configured to trigger the monitoring server so that the monitoring server obtains the monitoring script and monitors the plurality of target interfaces according to the monitoring script.
9. A monitoring server, characterized in that: include: An acquisition module is configured to acquire a monitoring script of a module according to a trigger of a monitoring device; wherein the monitoring script is obtained by the monitoring device determining a number of target test cases corresponding to the module, and modifying a preset script template according to the target test cases; the target test cases include: input, assertion statements, message headers, and cookies; the step of obtaining the monitoring script of the module includes: for each of the target test cases, executing: parsing the script template to obtain a Hypertext Transfer Protocol HTTP request sampler; copying the HTTP request sampler, and the copied HTTP request sampler includes: sampler parameters, BeanShell assertions, HTTP header manager, and HTTP Cookie manager; modifying the sampler parameters according to the input; modifying the BeanShell assertion according to the assertion statement; modifying the HTTP header manager according to the message header; modifying the HTTP Cookie manager according to the cookie; adding the modified HTTP request sampler to the script template; the module corresponds to a number of target interfaces; the target test cases are composed of target test cases corresponding to each of the target interfaces; The monitoring module is configured to monitor the plurality of target interfaces according to the monitoring script.
10. A monitoring system, characterized in that: include: The monitoring device as claimed in claim 8 and the monitoring server as claimed in claim 9.
11. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
12. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Test method and device
CN107766226A
Test method and apparatus
CN108459953A
Auto-deployment and testing of system application test cases in remote server environments
US20160085666A1
Method and apparatus for security testing of application flows that cannot be automated through HTTP replay
US20180137286A1
