Method, device, electronic equipment and medium for building a test environment

By receiving execution instructions and copying test tool image files, and automatically configuring the test environment, the problem of manual configuration in the existing technology is solved, and the construction efficiency is improved and resource consumption is reduced.

CN114036065BActive Publication Date: 2025-08-22NEW H3C BIG DATA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111449239.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-30
Publication Date
2025-08-22
Estimated Expiration
2041-11-30

AI Technical Summary

Technical Problem

In the prior art, building a test environment requires testing engineers to manually configure parameters for each test equipment, which makes it more time-consuming.

Method used

By receiving execution instructions to build a test environment, the pre-configured test tool image file is retrieved based on the configuration indicators, and copying it to generate the same number of test instances to achieve automated configuration.

Benefits of technology

There is no need to manually configure parameters for each test device, which improves the efficiency of testing environment construction and reduces resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114036065B_ABST
    Figure CN114036065B_ABST
Patent Text Reader

Abstract

The present application discloses a method, apparatus, electronic device, and medium for setting up a test environment. By applying the technical solution of the present application, during the process of setting up the test environment, the number of test instances to be configured can be first determined, and the pre-established test tool image file of the corresponding tool version can be directly copied into a corresponding number of multiple image files, so that the corresponding test instances can be directly configured in the test environment based on the multiple image files. This can eliminate the disadvantage of high resource consumption caused by testers manually creating each test device before completing the test environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to data communication technology, and in particular to a method, device, electronic device, and medium for building a test environment. Background Art

[0002] With the advancement of internet technology, the number of people accessing the internet continues to increase annually. The rise of various mobile applications has necessitated that today's software not only fulfill basic functions but also handle large or sudden requests. For test engineers, basic functional testing is no longer sufficient to cover these scenarios, making performance testing particularly important.

[0003] Generally speaking, performance testing involves setting up the test execution environment. This involves installing the test tools, creating multiple virtual machines as test devices, and modifying the network configuration of each test device to ensure intercommunication. Configuration tool files within these virtual machines are modified based on the different roles of the test devices. In one approach, the test environment can consist of one virtual machine acting as the master, responsible for distributing test scripts and collecting test results, while the remaining virtual machines serve as slaves, responsible for executing the test scripts.

[0004] However, there is a problem in the method of installing the test execution environment in the related art. That is, when there are multiple test devices, the test engineer needs to manually configure the corresponding parameters for each test device to complete the construction of the test environment. Understandably, this method is time-consuming. Summary of the Invention

[0005] The embodiments of the present application provide a method, device, electronic device and medium for setting up a test environment. The embodiments of the present application are used to solve the problem in the related art that test engineers need to manually configure corresponding parameters for each test device to complete the test environment setting, which leads to high time consumption.

[0006] According to one aspect of an embodiment of the present application, a method for building a test environment is provided. The method is applied to a server cluster and includes:

[0007] Receiving an execution instruction for setting up a test environment, the execution instruction including configuring a first number of to-be-configured test instances and corresponding configuration indicators in the test environment;

[0008] Based on the configuration indicator, a corresponding test tool image file is retrieved, where the test tool image file is an image file of the test tool with completed parameter configuration;

[0009] If it is determined that the first number is multiple, multiple test instances equal to the first number are generated based on the copy of the test tool image file.

[0010] Optionally, in another embodiment of the present application, retrieving a corresponding test tool image file based on the configuration indicator includes:

[0011] Determining, based on the configuration indicator, a test instance type corresponding to the test instance to be configured, where the test instance type corresponds to one of a master test instance and a slave test instance;

[0012] A test tool image file corresponding to the test instance type is retrieved from a preset storage area of ​​the server.

[0013] Optionally, in another embodiment of the present application, retrieving a corresponding test tool image file based on the configuration indicator includes:

[0014] Based on the configuration indicators, determine the test tool type and version number corresponding to the test instance to be configured;

[0015] A test tool image file corresponding to the test tool type and the version number is retrieved from a preset storage area of ​​the server.

[0016] Optionally, in another embodiment of the present application, after retrieving the corresponding test tool image file based on the configuration indicator, the method further includes:

[0017] If a monitoring configuration instruction is obtained, a monitoring parameter image file is retrieved from a preset storage area of ​​the server, where the monitoring parameter image file is used to configure a corresponding monitoring function for the test instance to be configured;

[0018] Using the monitoring parameter image file, respectively configure the parameters of the monitoring function of the test instance to be configured;

[0019] The test tool image file configured with the monitoring function is configured in the test environment.

[0020] Optionally, in another embodiment of the present application, before obtaining the execution instruction for building the test environment, the method further includes:

[0021] Configure the environment variable parameters of the basic test environment to obtain the initial test environment;

[0022] In the initial test loop, a first initial image file is generated according to the Dockerfile syntax rules;

[0023] Configuring basic parameters of each test tool type and basic parameters of each version of each test tool type for the first initial image file, respectively, to obtain a second number of second initial image files, wherein each second initial image file corresponds to a version of a test tool type;

[0024] The test tool image file is generated based on the second number of second initial image files.

[0025] Optionally, in another embodiment of the present application, generating the test tool image file based on the second number of second initial image files includes:

[0026] Configuring test tool parameters for each second initial image file respectively to obtain a corresponding master test tool image file and a slave test tool image file;

[0027] The master test tool image file and the slave test tool image file are combined as the test tool image file, and stored in a preset storage area of ​​the server.

[0028] Optionally, in another embodiment of the present application, after generating the first initial image file, the method further includes:

[0029] Configuring basic parameters for implementing a monitoring function on the first initial image file to obtain a monitoring parameter image file;

[0030] The monitoring parameter image file is stored in a preset storage area of ​​the server.

[0031] Optionally, in another embodiment of the present application, the test tool type includes: JMeter tool.

[0032] According to one aspect of an embodiment of the present application, a device for building a test environment is provided, which is applied to a server cluster and includes:

[0033] An acquisition module is configured to receive an execution instruction for setting up a test environment, wherein the execution instruction includes configuring a first number of to-be-configured test instances and corresponding configuration indicators in the test environment;

[0034] a calling module configured to call a corresponding test tool image file based on the configuration indicator, wherein the test tool image file is an image file of the test tool with completed parameter configuration;

[0035] The determination module is configured to generate a plurality of test instances equal to the first quantity based on the copy of the test tool image file if it is determined that the first quantity is multiple.

[0036] According to another aspect of the embodiments of the present application, an electronic device is provided, including:

[0037] a memory for storing executable instructions; and

[0038] The display is used to execute the executable instructions with the memory to complete the operation of any of the above-mentioned methods for building a test environment.

[0039] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided for storing computer-readable instructions, which, when executed, perform the operations of any of the above-mentioned methods for building a test environment.

[0040] In the present application, an execution instruction for setting up a test environment can be received, and the execution instruction includes configuring a first number of test instances to be configured and corresponding configuration indicators in the test environment; based on the configuration indicators, the corresponding test tool image file is retrieved, and the test tool image file is an image file of the test tool that has completed parameter configuration; if it is determined that the first number is multiple, the test tool image file is copied to generate multiple test tool image files that are the same as the first number. By applying the technical solution of the present application, in the process of setting up the test environment, the number of test instances to be configured can be first determined, and the pre-established test tool image file of the corresponding tool version can be directly copied into a corresponding number of multiple image files, so that the corresponding test instances can be directly configured in the test environment according to the multiple image files. This can thereby achieve the disadvantage of high resource consumption caused by the tester not having to manually create each test device to complete the test environment construction.

[0041] The technical solution of the present application is further described in detail below through the accompanying drawings and examples. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present application and, together with the description, serve to explain the principles of the present application.

[0043] The present application can be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:

[0044] Figure 1 A schematic diagram of a method for building a test environment proposed in this application;

[0045] Figure 2 A flow chart for testing and analyzing data proposed in this application;

[0046] Figure 3 A schematic diagram of the process of setting up a test environment proposed in this application;

[0047] Figure 4A schematic diagram of the structure of the electronic device for building a test environment proposed in this application;

[0048] Figure 5 This is a schematic diagram of the structure of the electronic equipment for building a test environment proposed in this application. DETAILED DESCRIPTION

[0049] Various exemplary embodiments of the present application will now be described in detail with reference to the accompanying drawings. It should be noted that unless otherwise specifically stated, the relative arrangements of components and steps, numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present application.

[0050] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.

[0051] The following description of at least one exemplary embodiment is merely illustrative in nature and is not intended to limit the present disclosure, its application, or uses.

[0052] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.

[0053] It should be noted that like reference numerals and letters refer to like items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0054] In addition, the technical solutions between the various embodiments of the present application can be combined with each other, but it must be based on the fact that ordinary technicians in this field can implement it. When the combination of technical solutions is mutually contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0055] It should be noted that all directional indications in the embodiments of the present application (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the various components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.

[0056] The following combination Figure 1-Figure 3 The following describes a method for setting up a test environment according to an exemplary embodiment of the present application. It should be noted that the following application scenarios are only provided to facilitate understanding of the spirit and principles of the present application, and the embodiments of the present application are not limited in this respect. On the contrary, the embodiments of the present application can be applied to any applicable scenario.

[0057] Furthermore, the present application also proposes a method, device, electronic device and medium for building a test environment.

[0058] Figure 1 The following schematically shows a flow chart of a method for building a test environment according to an embodiment of the present application. Figure 1 As shown, the method is applied to a server cluster and includes:

[0059] S101, receiving an execution instruction for setting up a test environment, where the execution instruction includes configuring a first number of to-be-configured test instances and corresponding configuration indicators in the test environment.

[0060] With the advancement of internet technology, the number of people accessing the internet continues to grow annually. The rise of various mobile applications has enabled more and more everyday events to be handled online. This means that today's software must not only perform basic functions but also handle large or sudden requests. For test engineers, basic functional testing is no longer sufficient to cover these scenarios, making performance testing particularly important.

[0061] Generally speaking, performance testing can be divided into Figure 2 The following are several stages. Among them, setting up the test environment is an indispensable step. The environment includes two aspects: the environment of the object under test and the test execution environment.

[0062] To avoid interference with performance test results, the test execution environment is typically built in a relatively isolated environment, adhering to the following requirements: High-performance CPU, memory, hard disk, and network resources; firewalls, antivirus software, and other tools that could interfere with performance testing; and, in addition to the operating system, only testing tools, monitoring tools, and necessary auxiliary tools are installed. Because the pressure exerted by a single testing tool is limited, a distributed testing environment is required when performance requirements are high. This requires one or more servers or virtual machines.

[0063] Furthermore, the method and steps for building a test environment in the related art are as follows, wherein the test tools are Java tools and JMeter tools as examples:

[0064] Step 1: Install Java and JMeter tools on the server where the operating system has been installed;

[0065] Step 2: Clone multiple virtual machines as test devices, and have testers modify the network configurations of these test devices to ensure they can communicate with each other;

[0066] Step 3: Modify the JMeter configuration files on the test devices based on their roles. In one approach, one test device can be the master, responsible for distributing test scripts and collecting test results, while the remaining test devices can be slaves, responsible for executing test scripts.

[0067] Step 4: Install and configure monitoring tools (such as Prometheus, Grafana, InfluxDB, etc.), record the configuration of these tools, and fill in the configuration elements of the JMeter script; finally, start all tools and execute the test script.

[0068] Step 5: Complete the construction of the test environment.

[0069] However, there is a problem in the method of installing the test execution environment in the related art. That is, when there are multiple test devices, the test engineer needs to manually configure the corresponding parameters for each test device to complete the construction of the test environment. Understandably, this method is time-consuming.

[0070] It should be noted that the test instance to be configured in the embodiment of the present application can be a master test instance or a slave test instance. The test instance to be configured generates the corresponding test device after executing the corresponding script. This application does not limit this.

[0071] In one embodiment, the test device proposed in this application can be one or more servers or virtual machines with Kubernetes / Docker installed. The test instance can be a pod under the Kubernetes / Docker system. In this embodiment, the test device can be automatically configured by copying the configuration tool image file and using it to generate the corresponding pod.

[0072] S102 , based on the configuration indicator, retrieve a corresponding test tool image file, where the test tool image file is an image file of a test tool with completed parameter configuration.

[0073] The test tool image files in the embodiments of the present application are image files that have been completed in advance by the tester and have successfully configured the parameters of each test tool. It is understandable that, for example, for setting up a test environment using the JMeter tool, the image files of JMeter Master and JMeter Slave have been written.

[0074] It should be noted that the test tool image files can be stored in a storage area on the server, with each image file being assigned an identifier. This identifier indicates the type and version of the test tool to which the image file corresponds. For example, for the JMeter test tool, each image file can be assigned an identifier for JMeter 1.0, JMeter 2.0, and so on. For the JAVA test tool, each image file can be assigned an identifier for JAVA 1.0, JAVA 2.0, and so on.

[0075] It is understandable that in each process of building a test environment, the server can select a test tool image file based on the business indicators of the building (for example, which language and version of the test environment to build).

[0076] In one method, the image file can be the following file:

[0077] Base image file: An image file with the base operating system and compilation environment installed. The base operating system is Linux, and the compilation tool is Java.

[0078] JMeter Image File: Create JMeter images based on the base image. Create JMeter Master and JMeter Slave based on JMeter roles. If different JMeter versions are required, you can create JMeterMaster 1.0 / 2.0 / 3.0 and JMeter Slave 1.0 / 2.0 / 3.0 respectively.

[0079] Monitor image file: Based on the base image, a monitor image can be created to implement the monitoring function.

[0080] It should be noted that, in one approach, the creation of the above-mentioned image file can be achieved through Dockerfile in Docker technology.

[0081] Test tool image files can be stored in an image repository. Once the image is created, you can use it to create a Pod that generates Kubernetes resources, or the test execution environment, according to the YAML file format used in Kubernetes. For test environments that require high concurrency and high load, Kubernetes can be used to expand the number of Pods and configure multiple test execution machines.

[0082] S103: If it is determined that the first quantity is multiple, copy the test tool image file to generate multiple test tool image files equal to the first quantity.

[0083] It is understandable that if there are multiple test devices to be configured, the present application can directly copy the test tool image file to generate multiple corresponding test instances. For example, if there are three test devices to be set up, the server can directly copy the test tool image file to obtain three test instances. This allows the test devices to be configured directly based on these three test instances.

[0084] In one approach, the method for setting up a test environment proposed in this application can be based on a Kubernetes cluster environment with Kubernetes infrastructure components, the Calico network plug-in, and basic virtualization tools such as Docker installed, along with a B / S architecture application and several server-side scripts and files. The application is divided into two parts: the client and the Java backend.

[0085] On the user side, users can create a new test task through the browser page, upload the test script and data files, select the test tool version (for example, Java and JMeter tools, etc.), set the number of test devices at the same time, and then start the test.

[0086] Furthermore, during the test execution, the user can view the real-time resource utilization of the test equipment through the page function portal; after the test is completed, the test results can be viewed through the page. In addition, the Java backend can process various operations from the user through the interface and execute the corresponding scripts in the server.

[0087] Among them, the embodiment of the present application can store the test scripts and data files in the working directory of the server, select the container image of the tool according to the tool version number selected by the user; and according to the number of test devices set by the user, after the user clicks to start execution, create 1 JMeter Master test device and several Slave test devices, execute the test script, and generate a monitoring Pod.

[0088] It should be noted that after the test is completed, the server provides an interface for the user to view the results. The server stores variable files, Dockerfiles for creating container images, YAML files for generating K8S resources, and scripts for executing various tasks.

[0089] Optionally, in the method for setting up a test environment proposed in this application, the following steps may be performed on the user side:

[0090] Step 1: Use Vue.js to develop front-end applications and provide users with operation pages.

[0091] Step 2: Click Create Test Task, fill in basic information, select the test tool version and the number of test devices. When uploading the test script, the page calls the upload file API provided by the Java backend. The function of this API is explained in the Java backend.

[0092] Step 3: Click Save Test Task. The page calls the task saving API. The function of this API is explained in the Java backend.

[0093] Step 4: Click to start the test task. A waiting prompt will appear on the page and the details button will become clickable.

[0094] Step 5: Click the Details button. A new tab will appear in the browser. The access address format is: node address:port number. The Grafana chart page will appear. Users can view the resource usage of the test device and cluster environment at different time intervals.

[0095] Step 6: After the execution is completed, the View Results button on the page becomes clickable, and the user can click it to view the test execution results.

[0096] In the present application, an execution instruction for setting up a test environment can be received, and the execution instruction includes configuring a first number of test instances to be configured and corresponding configuration indicators in the test environment; based on the configuration indicators, the corresponding test tool image file is retrieved, and the test tool image file is an image file of the test tool that has completed parameter configuration; if it is determined that the first number is multiple, the test tool image file is copied to generate multiple test tool image files that are the same as the first number. By applying the technical solution of the present application, in the process of setting up the test environment, the number of test instances to be configured can be first determined, and the pre-established test tool image file of the corresponding tool version can be directly copied into a corresponding number of multiple image files, so that the corresponding test instances can be directly configured in the test environment according to the multiple image files. This can thereby achieve the disadvantage of high resource consumption caused by the tester not having to manually create each test device to complete the test environment construction.

[0097] In one optional method, the corresponding test tool image file is retrieved based on the configuration indicators, including:

[0098] Determine, based on the configuration indicator, a test instance type corresponding to the test instance to be configured, where the test instance type corresponds to one of a master test instance and a slave test instance;

[0099] Retrieve the test tool image file corresponding to the test instance type from the preset storage area of ​​the server.

[0100] In one optional method, the corresponding test tool image file is retrieved based on the configuration indicators, including:

[0101] Based on the configuration indicators, determine the test tool type and version number corresponding to the test instance to be configured;

[0102] The test tool image file corresponding to the test tool type and version number is retrieved from the preset storage area of ​​the server.

[0103] In one approach, when retrieving the corresponding test tool image file, the present application can determine the test tool type (i.e., whether it is a master test instance or slave test instances and the corresponding number), test tool type (i.e., what type of test tool, such as JAVA or JMeter, etc.), and corresponding version number (e.g., version 1.0 or version 2.0, etc.) of the test instance to be configured through user-generated configuration indicators. The corresponding test tool image file is then selected based on the indicators.

[0104] For example, the server can first determine through configuration indicators that the test instance to be built is a test environment of the JMeter 1.0 test tool type, and requires the construction of a master test instance and five slave test instances. The server can then retrieve the master and slave test tool image files corresponding to JMeter 1.0 from its own storage area. It can then copy the slave test tool image files corresponding to JMeter 1.0 into five slave test instances, thereby completing the test environment construction.

[0105] In an optional method, after retrieving the corresponding test tool image file based on the configuration indicator, the following method is also included:

[0106] If the monitoring configuration instruction is obtained, the monitoring parameter image file is retrieved from the preset storage area of ​​the server. The monitoring parameter image file is used to configure the corresponding monitoring function for the test instance to be configured;

[0107] Use the monitoring parameter image file to configure the monitoring function parameters for each test instance to be configured;

[0108] Deploy the test tool image file with monitoring functions configured in the test environment.

[0109] Continuing with the above example, the server can first determine through configuration indicators that the test instance to be built is a test environment of the JMeter 1.0 test tool type, and requires the construction of a master test instance and five slave test instances. The server can then retrieve the master and slave test tool image files corresponding to JMeter 1.0 from its own storage area. It can then copy the slave test tool image files corresponding to JMeter 1.0 into five slave test instances, thereby completing the test environment.

[0110] Furthermore, this application can also configure monitoring functions for test instances. The monitoring function is used to monitor the resource usage of test devices and nodes in the overall test environment. This allows users to view the resource usage of test devices and nodes in real time through the page during test execution.

[0111] Monitoring functions can be configured by installing and configuring Prometheus, Grafana, and InfluxDB parameters on the test instance, and then creating a monitoring parameter image file. It should be noted that each version of a test tool corresponds to a monitoring parameter image file. This allows the test device to subsequently monitor resource usage of various test devices and nodes in the test environment based on the monitoring parameter image file.

[0112] In an optional method, before obtaining the execution instruction for setting up the test environment, the following is also included:

[0113] Configure the environment variable parameters of the basic test environment to obtain the initial test environment;

[0114] In the initial test cycle, the first initial image file is generated according to the Dockerfile syntax rules;

[0115] Configuring basic parameters of each test tool type and basic parameters of each version of each test tool type for the first initial image file, respectively, to obtain a second number of second initial image files, wherein each second initial image file corresponds to a version of a test tool type;

[0116] A test tool image file is generated based on the second number of second initial image files.

[0117] In an optional manner, generating a test tool image file based on the second number of second initial image files includes:

[0118] Configuring test tool parameters for each second initial image file respectively to obtain a corresponding master test tool image file and a slave test tool image file;

[0119] The main test tool image file and the slave test tool image file are merged into a test tool image file, and stored in a preset storage area of ​​the server.

[0120] In one approach, in the process of generating a test tool image file, embodiments of the present application can first configure the environment variables required for setting up the test environment to obtain an initial test environment. Then, according to the syntax rules of Dockerfile, a corresponding Dockerfile is written, and then the first initial image file is generated using basic Docker commands.

[0121] Furthermore, in an embodiment of the present application, based on the first initial image file, a Dockerfile for the main test instance and a Dockerfile for the slave test instance can be written respectively, and basic parameters of different versions of test tool types (such as JMeter tools or JAVA tools, etc.) can be installed to generate corresponding multiple second initial image files. It can be understood that each second initial image file corresponds to a version under a test tool type.

[0122] Furthermore, according to the different roles of the master test instance and the slave test instance, corresponding test tool parameters (including master test instance parameters and slave test instance parameters) are set for each second initial image file. Finally, through the docker command, the test tool image file with different identifiers is packaged and generated.

[0123] In one embodiment, the test tool image file in the embodiment of the present application can be a YAML file, and the corresponding K8S resources are generated from it. The server will then develop a script to process the test file, create a working directory, and save the script and data files. A script to process the variable file will also be developed to save the tool version and the number of test devices to the parameter file. A task processing script will also be developed to process the test script and files, read the variables in the parameter file, arrange and execute the YAML file, generate K8S resources, execute the test, and save the test results. Finally, the end processing script will be executed to provide the Java backend with instructions for the end of task execution.

[0124] In an optional manner, after generating the first initial image file, the method further includes:

[0125] Configuring basic parameters for implementing a monitoring function on the first initial image file to obtain a monitoring parameter image file;

[0126] The monitoring parameter image file is stored in a preset storage area of ​​the server.

[0127] In one optional method, the test tool type includes: JMeter tool.

[0128] In one approach, in the process of generating a test tool image file, embodiments of the present application can first configure the environment variables required for setting up the test environment to obtain an initial test environment. Then, according to the syntax rules of Dockerfile, a corresponding Dockerfile is written, and then the first initial image file is generated using basic Docker commands.

[0129] Furthermore, after generating the first initial image file, the first initial image file can be configured with basic parameters for implementing the monitoring function (including Prometheus parameters, Grafana parameters, and InfluxDB parameters) to obtain a monitoring parameter image file, and the monitoring parameter image file can be stored in the preset storage area of ​​the server.

[0130] In an optional way, such as Figure 3 FIG. 1 is a flow chart of a method for building a test environment proposed in this application, which is applied to a server cluster and includes:

[0131] Among them, the present application can configure the environmental variable parameters of the basic test environment to obtain the initial test environment, and in the initial test loop, generate a first initial image file through the Dockerfile syntax rules, and then configure the basic parameters of each test tool type for the first initial image file, as well as the basic parameters of each version under each test tool type, to obtain a second number of second initial image files, wherein each second initial image file corresponds to a version under a test tool type, and finally, based on the second number of second initial image files, generate a test tool image file.

[0132] Furthermore, the server can also configure test tool parameters for each second initial image file respectively, and after obtaining the corresponding main test tool image file and slave test tool image file, merge the main test tool image file and the slave test tool image file as a test tool image file, and store them in the preset storage area of ​​the server.

[0133] Furthermore, in an embodiment of the present application, execution instructions for setting up a test environment can also be obtained. Setting up the test environment includes configuring a first number of test instances to be configured, and obtaining configuration indicators corresponding to the test environment, and calling the corresponding test tool image file based on the configuration indicators. The test tool image file is an image file of the test tool that has completed parameter configuration. If it is determined that the first number is multiple, the test tool image file is copied to generate multiple test tool image files of the same number as the first number, so that the first number of test tool image files can be subsequently configured into the test environment.

[0134] By applying the technical solution of this application, during the process of setting up a test environment, the number of test instances to be configured can be first determined, and then the pre-established test tool image file of the corresponding tool version can be directly copied into a corresponding number of multiple image files, so that the corresponding test instances can be directly configured in the test environment based on the multiple image files. This eliminates the need for testers to manually create each test device to complete the test environment, which results in high resource consumption.

[0135] In another embodiment of the present application, Figure 4 As shown, the present application also provides a device for building a test environment. The device is applied to a server cluster and includes:

[0136] An acquisition module is configured to receive an execution instruction for setting up a test environment, wherein the execution instruction includes configuring a first number of to-be-configured test instances and corresponding configuration indicators in the test environment;

[0137] a calling module configured to call a corresponding test tool image file based on the configuration indicator, wherein the test tool image file is an image file of the test tool with completed parameter configuration;

[0138] The determination module is configured to generate a plurality of test instances equal to the first quantity based on the copy of the test tool image file if it is determined that the first quantity is multiple.

[0139] Optionally, in another embodiment of the present application, the calling module 202 may be configured to perform the following steps:

[0140] Determining, based on the configuration indicator, a test instance type corresponding to the test instance to be configured, where the test instance type corresponds to one of a master test instance and a slave test instance;

[0141] A test tool image file corresponding to the test instance type is retrieved from a preset storage area of ​​the server.

[0142] Optionally, in another embodiment of the present application, the calling module 202 may be configured to perform the following steps:

[0143] Based on the configuration indicators, determine the test tool type and version number corresponding to the test instance to be configured;

[0144] A test tool image file corresponding to the test tool type and the version number is retrieved from a preset storage area of ​​the server.

[0145] Optionally, in another embodiment of the present application, the calling module 202 may be configured to perform the following steps:

[0146] If a monitoring configuration instruction is obtained, a monitoring parameter image file is retrieved from a preset storage area of ​​the server, where the monitoring parameter image file is used to configure a corresponding monitoring function for the test instance to be configured;

[0147] Using the monitoring parameter image file, respectively configure the parameters of the monitoring function of the test instance to be configured;

[0148] The test tool image file configured with the monitoring function is configured in the test environment.

[0149] Optionally, in another embodiment of the present application, the calling module 202 may be configured to perform the following steps:

[0150] Configure the environment variable parameters of the basic test environment to obtain the initial test environment;

[0151] In the initial test loop, a first initial image file is generated according to the Dockerfile syntax rules;

[0152] Configuring basic parameters of each test tool type and basic parameters of each version of each test tool type for the first initial image file, respectively, to obtain a second number of second initial image files, wherein each second initial image file corresponds to a version of a test tool type;

[0153] The test tool image file is generated based on the second number of second initial image files.

[0154] Optionally, in another embodiment of the present application, the calling module 202 may be configured to perform the following steps:

[0155] Configuring test tool parameters for each second initial image file respectively to obtain a corresponding master test tool image file and a slave test tool image file;

[0156] The master test tool image file and the slave test tool image file are merged into the test tool image file, and stored in a preset storage area of ​​the server.

[0157] Optionally, in another embodiment of the present application, the calling module 202 may be configured to perform the following steps:

[0158] Configuring basic parameters for implementing a monitoring function on the first initial image file to obtain a monitoring parameter image file;

[0159] The monitoring parameter image file is stored in a preset storage area of ​​the server.

[0160] Optionally, in another embodiment of the present application, the test tool type includes: JMeter tool.

[0161] Figure 5 3 is a block diagram of a logical structure of an electronic device according to an exemplary embodiment. For example, the electronic device 300 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0162] In an exemplary embodiment, a non-temporary computer-readable storage medium including instructions is also provided, such as a memory including instructions, the above instructions can be executed by an electronic device processor to complete the above network monitoring method, the method comprising: receiving an execution instruction for setting up a test environment, the execution instruction comprising configuring a first number of test instances to be configured and corresponding configuration indicators in the test environment; based on the configuration indicators, retrieving the corresponding test tool image file, the test tool image file being an image file of a test tool that has completed parameter configuration; if it is determined that the first number is multiple, generating multiple test instances that are the same as the first number based on the test tool image file. Optionally, the above instructions can also be executed by the processor of the electronic device to complete the other steps involved in the above exemplary embodiment. For example, the non-temporary computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a tape, a floppy disk, an optical data storage device, etc.

[0163] In an exemplary embodiment, an application / computer program product is also provided, comprising one or more instructions, which can be executed by a processor of an electronic device to complete the above-mentioned network monitoring method, the method comprising: receiving an execution instruction for setting up a test environment, the execution instruction comprising configuring a first number of test instances to be configured and corresponding configuration indicators in the test environment; based on the configuration indicators, retrieving the corresponding test tool image file, the test tool image file being an image file of a test tool that has completed parameter configuration; if it is determined that the first number is multiple, generating multiple test instances equal to the first number based on the copy of the test tool image file. Optionally, the above-mentioned instructions can also be executed by a processor of an electronic device to complete the other steps involved in the above-mentioned exemplary embodiment.

[0164] Figure 5 This is an example diagram of a computer device 30. Those skilled in the art will appreciate that Figure 5This is merely an example of the computer device 30 and does not constitute a limitation of the computer device 30 . The computer device 30 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the computer device 30 may also include input and output devices, network access devices, buses, etc.

[0165] The processor 302 may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, or the processor 302 may be any conventional processor. The processor 302 is the control center of the computer device 30 and connects various components of the entire computer device 30 using various interfaces and lines.

[0166] The memory 301 can be used to store computer-readable instructions 303. The processor 302 implements various functions of the computer device 30 by running or executing the computer-readable instructions or modules stored in the memory 301 and accessing the data stored in the memory 301. The memory 301 may mainly include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function (such as a sound playback function or an image playback function); the data storage area may store data generated based on the use of the computer device 30. In addition, the memory 301 may include a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, a read-only memory (ROM), a random access memory (RAM), or other non-volatile / volatile storage devices.

[0167] If the modules integrated into computer device 30 are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the present invention can also implement all or part of the processes in the above-mentioned method embodiments by instructing the relevant hardware through computer-readable instructions. The computer-readable instructions can be stored in a computer-readable storage medium. When executed by a processor, the computer-readable instructions can implement the steps of each of the above-mentioned method embodiments.

[0168] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0169] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A method for building a test environment, characterized in that: Applicable to server clusters, including: Receiving an execution instruction for setting up a test environment, the execution instruction including configuring a first number of to-be-configured test instances and corresponding configuration indicators in the test environment; Based on the configuration indicator, a corresponding test tool image file is retrieved, where the test tool image file is an image file of the test tool with completed parameter configuration; If it is determined that the first number is multiple, generating multiple test instances equal to the first number based on the test tool image file copy; Before receiving the execution instruction for setting up the test environment, the method further includes: Configure the environment variable parameters of the basic test environment to obtain the initial test environment; In the initial test environment, generating a first initial image file according to Dockerfile syntax rules; Configuring basic parameters of each test tool type and basic parameters of each version of each test tool type for the first initial image file, respectively, to obtain a second number of second initial image files, wherein each second initial image file corresponds to a version of a test tool type; generating the test tool image file based on the second number of second initial image files; The generating the test tool image file based on the second number of second initial image files includes: Configuring test tool parameters for each second initial image file respectively to obtain a corresponding master test tool image file and a slave test tool image file; The master test tool image file and the slave test tool image file are merged into the test tool image file, and stored in a preset storage area of ​​the server.

2. The method according to claim 1, wherein The retrieving a corresponding test tool image file based on the configuration indicator includes: Determining, based on the configuration indicator, a test instance type corresponding to the test instance to be configured, where the test instance type corresponds to one of a master test instance and a slave test instance; A test tool image file corresponding to the test instance type is retrieved from a preset storage area of ​​the server.

3. The method according to claim 1 or 2, wherein: The retrieving a corresponding test tool image file based on the configuration indicator includes: Based on the configuration indicators, determine the test tool type and version number corresponding to the test instance to be configured; A test tool image file corresponding to the test tool type and the version number is retrieved from a preset storage area of ​​the server.

4. The method according to claim 1, wherein After retrieving the corresponding test tool image file based on the configuration indicator, the method further includes: If a monitoring configuration instruction is obtained, a monitoring parameter image file is retrieved from a preset storage area of ​​the server, where the monitoring parameter image file is used to configure a corresponding monitoring function for the test instance to be configured; Using the monitoring parameter image file, respectively configure the parameters of the monitoring function of the test instance to be configured; Configure the test tool image file with the monitoring function configured in the test environment.

5. The method according to claim 1, wherein After generating the first initial image file, the method further includes: Configuring basic parameters for implementing a monitoring function on the first initial image file to obtain a monitoring parameter image file; The monitoring parameter image file is stored in a preset storage area of ​​the server.

6. The method according to claim 3, wherein The test tool types include: JMeter tool.

7. A device for building a test environment, characterized in that: Applicable to server clusters, including: An acquisition module is configured to configure environmental variable parameters for a basic test environment to obtain an initial test environment; in the initial test environment, a first initial image file is generated through Dockerfile syntax rules; basic parameters of each test tool type are configured for the first initial image file, as well as basic parameters of each version under each test tool type, to obtain a second number of second initial image files, wherein each second initial image file corresponds to a version under a test tool type; a test tool image file is generated based on the second number of second initial image files; an execution instruction for setting up a test environment is received, wherein the execution instruction includes configuring a first number of test instances to be configured and corresponding configuration indicators in the test environment; a calling module configured to call a corresponding test tool image file based on the configuration indicator, wherein the test tool image file is an image file of the test tool with completed parameter configuration; a determining module configured to, if determining that the first number is multiple, generate multiple test instances equal to the first number based on the test tool image file copy; The acquisition module is specifically configured to: Configuring test tool parameters for each second initial image file respectively to obtain a corresponding master test tool image file and a slave test tool image file; The master test tool image file and the slave test tool image file are combined as the test tool image file, and stored in a preset storage area of ​​the server.

8. An electronic device, characterized in that: include: a memory for storing executable instructions; as well as, A processor is configured to execute the executable instructions with the memory to complete the operation of the method for building a test environment as described in any one of claims 1-6.

9. A computer-readable storage medium for storing computer-readable instructions, characterized in that: When the instruction is executed, the operation of the method for building a test environment according to any one of claims 1 to 6 is performed.

Citation Information

Patent Citations

  • Jmeter-based distributed performance test method and device, equipment and storage medium

    CN110417613A