A Docker-based testing method, device, equipment and storage medium

By building a slave server management mapping table in the master server, selecting the target slave server and running code test cases in its idle test docker container, the problem of unreasonable resource allocation in the existing technology is solved, and the efficiency and security of code testing is achieved.

CN113900931BActive Publication Date: 2025-06-06DUOYI NETWORK CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111119179.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-24
Publication Date
2025-06-06
Estimated Expiration
2041-09-24

AI Technical Summary

Technical Problem

In large-scale code testing, the existing technology fails to allocate resources reasonably, resulting in long queues of codes and reducing testing efficiency.

Method used

By building a slave server management mapping table in the master server, selecting the target slave server, and running code test cases in the idle test docker container in the target slave server, the reasonable allocation of resources is achieved.

Benefits of technology

Shorten the code queue time, improve code testing efficiency, and reduce the risk of server attacks by allocating docker containers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113900931B_ABST
    Figure CN113900931B_ABST
Patent Text Reader

Abstract

The present invention discloses a docker-based testing method, including: obtaining a code test case from a master server, and based on a preset slave server management mapping table, selecting a target slave server according to the code test case, and sending the code test case to the target slave server; selecting an idle test docker container from a plurality of test docker containers constructed in the target slave server as a target test docker container; and finally running the code test case in the target test docker container to obtain a test result of the code test case. The present invention also discloses a docker-based testing device, equipment and storage medium. By adopting the embodiments of the present invention, reasonable allocation of slave server resources is achieved, code queuing time is shortened, and code testing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a docker-based testing method, device, equipment and storage medium. Background Art

[0002] Docker container is an open source application container engine that allows developers to package applications and dependent packages into a portable container in a unified way, and then publish it to any server with Docker engine installed. Since the container is completely sandboxed, each Docker container has an independent space and is easy to deploy and apply, which is suitable for testing a large amount of code.

[0003] In the prior art, the code is usually directly placed into a Docker container for running tests without considering resource allocation. In large-scale code testing, resources cannot be used reasonably, which easily leads to uneven resource utilization, resulting in long code queue time, thereby reducing test efficiency. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to provide a Docker-based testing method, apparatus, device and storage medium, which selects a target slave server based on a slave server management mapping table in a master server, and runs code test cases in an idle test Docker container in the target slave server, thereby achieving reasonable allocation of slave server resources, shortening code queuing time and improving code testing efficiency.

[0005] To achieve the above purpose, an embodiment of the present invention provides a docker-based testing method, including:

[0006] Build several test docker containers in the slave server;

[0007] Obtaining a code test case from a master server, and selecting a target slave server from a plurality of slave servers according to the code test case based on a preset slave server management mapping table, wherein the slave server management mapping table is pre-stored in the master server;

[0008] Sending the code test case to the target slave server;

[0009] Selecting an idle test Docker container from the plurality of test Docker containers of the target slave server as the target test Docker container;

[0010] Run the code test case in the target test docker container to obtain the test result of the code test case.

[0011] As an improvement of the above solution, the master server is constructed with a distributed docker container, and the sending of the code test case to the target slave server specifically includes:

[0012] The code test case is sent to the target slave server through the allocated docker container.

[0013] As an improvement of the above solution, the slave server management mapping table includes the resource utilization status of the slave server and the mapping relationship between the slave server and the code type;

[0014] Then, the preset slave server management mapping table is used to select a target slave server from a plurality of slave servers according to the code test case, specifically including:

[0015] Based on the mapping relationship between the slave server and the code type, and according to the current code type of the code test case, a slave server corresponding to the current code type is selected from a plurality of slave servers as a candidate slave server;

[0016] A target slave server is selected from the candidate slave servers according to the resource utilization status.

[0017] As an improvement of the above solution, the master server is constructed with an allocated docker container, and the slave server management mapping table also includes a mapping relationship between the allocated docker container and the slave server; then, sending the code test case to the target slave server specifically includes:

[0018] Based on the mapping relationship between the allocated Docker container and the slave server, according to the target slave server, selecting the allocated Docker container corresponding to the target slave server as the target allocated Docker container;

[0019] The code test case is sent to the target slave server through the target allocation docker container.

[0020] As an improvement of the above solution, the method further includes: when it is detected that the initial slave server is busy, based on the mapping relationship between the allocated docker container and the slave server, sending the code test case in the initial slave server to the allocated docker container corresponding to the initial slave server; wherein the initial slave server is the slave server that obtains the code test case;

[0021] Based on the mapping relationship between the allocated Docker container and the slave server, according to the allocated Docker container corresponding to the initial slave server, obtaining the slave server corresponding to the allocated Docker container;

[0022] Based on the slave server management mapping table and according to the code test case, a target slave server is selected from a number of slave servers corresponding to the allocated docker containers.

[0023] As an improvement of the above solution, after running the code test case in the test docker container and obtaining the test result of the code test case, the method further includes: updating the slave server management mapping table.

[0024] As an improvement of the above solution, the method further includes: storing the test result in a storage unit of the target slave server;

[0025] The test result is sent to the allocated docker container; the test result received by the allocated docker container is sent to the client through the master server; or the test result is sent to the client through the target slave server.

[0026] To achieve the above purpose, an embodiment of the present invention further provides a docker-based testing device, comprising:

[0027] The container building module is used to build several test docker containers in the slave server;

[0028] A slave server selection module is used to obtain code test cases from a master server, and based on a preset slave server management mapping table, select a target slave server from a plurality of slave servers according to the code test cases; wherein the slave server management mapping table is pre-stored in the master server;

[0029] A code sending module, used for sending the code test case to the target slave server;

[0030] A test container selection module, used to select an idle test Docker container from a plurality of test Docker containers of the target slave server as a target test Docker container;

[0031] The test result acquisition module is used to run the code test case in the target test Docker container to obtain the test result of the code test case.

[0032] To achieve the above objectives, an embodiment of the present invention also provides a Docker-based testing device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, it implements the Docker-based testing method described in any of the above embodiments.

[0033] To achieve the above objectives, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the Docker-based testing method as described in any of the above embodiments.

[0034] Compared with the prior art, the embodiment of the present invention discloses a docker-based testing method, device, equipment and storage medium, which obtains code test cases from the main server, and based on the preset slave server management mapping table, selects the target slave server according to the code test cases, and sends the code test cases to the target slave server; selects an idle test docker container from several test docker containers built in the target slave server as the target test docker container; finally, runs the code test case in the target test docker container to obtain the test result of the code test case. It can be seen that the embodiment of the present invention can achieve reasonable allocation of slave server resources, shorten code queuing time, and improve code testing efficiency by selecting the target slave server based on the slave server management mapping table in the main server, and running the code test case in the idle test docker container in the target slave server. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 It is a flow chart of a docker-based testing method provided by an embodiment of the present invention;

[0036] Figure 2 It is a structural block diagram of a docker-based testing device provided by an embodiment of the present invention;

[0037] Figure 3 It is a structural block diagram of a docker-based test device provided by an embodiment of the present invention. DETAILED DESCRIPTION

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

[0039] See also Figure 1 , Figure 1 It is a flowchart of a Docker-based testing method provided by an embodiment of the present invention.

[0040] Specifically, the Docker-based testing method includes:

[0041] S11. Build several test docker containers in the slave server;

[0042] S12, acquiring a code test case from a master server, and selecting a target slave server from a plurality of slave servers according to the code test case based on a preset slave server management mapping table, wherein the slave server management mapping table is pre-stored in the master server;

[0043] S13, sending the code test case to the target slave server;

[0044] S14, selecting an idle test docker container from the plurality of test docker containers of the target slave server as the target test docker container;

[0045] S15. Run the code test case in the target test docker container to obtain a test result of the code test case.

[0046] It is worth noting that the Docker-based testing method provided in the embodiment of the present invention can be executed by the main server or by an additional controller; the main server can be a single server, a server cluster composed of multiple servers, a virtual machine, or a container, which is not limited here; the slave server can be a single server, a server cluster composed of multiple servers, a virtual machine, or a container, which is not limited here.

[0047] Specifically, based on the slave server management mapping table preset in the master server, the target server is selected, and the code is run in the idle test docker container in the target slave server to obtain the test results, thereby realizing the rapid and reasonable deployment of slave server resources and the running test of code test cases. Several test docker containers are built in each slave server; code test cases are obtained from the client to the master server, and based on the slave server management mapping table pre-stored in the master server, according to the code test cases, the target slave server is selected from several slave servers and the code test cases are sent to the target slave server. Based on the queuing system of flask, after receiving the code test cases, the slave server writes the code test cases to a file. When there are idle core resources in the target slave server, the code test cases are put into the idle test docker container in the target slave server for compilation and operation to obtain the test results.

[0048] The embodiment of the present invention discloses a docker-based testing method, which obtains code test cases from a master server, and based on a preset slave server management mapping table, selects a target slave server according to the code test cases, and sends the code test cases to the target slave server; selects an idle test docker container from several test docker containers built in the target slave server as the target test docker container; and finally runs the code test case in the target test docker container to obtain the test result of the code test case. It can be seen that the embodiment of the present invention can achieve reasonable allocation of slave server resources, shorten code queuing time, and improve code testing efficiency by selecting a target slave server based on the slave server management mapping table in the master server, and running code test cases in an idle test docker container in the target slave server.

[0049] In one embodiment, a docker container is constructed and allocated in the master server, and the sending of the code test case to the target slave server in step S13 specifically includes:

[0050] The code test case is sent to the target slave server through the allocated docker container.

[0051] Specifically, a distribution docker container is constructed in the master server, and the communication between the master server and the slave server is realized by distributing the docker container. The code test cases in the master server are sent to the target slave server by distributing the docker container, and the test results or other information about the code test cases in the target slave server can be sent to the distribution docker container, thereby realizing the communication between the master server and the slave server. Since the docker container is relatively closed, the communication between the master and the slave server is established by distributing the docker container. When a slave server is attacked, since the master server is not directly connected to the slave server, the risk of the master server being attacked is reduced, and further, the risk of other slave servers being attacked is reduced, thereby improving the reliability and stability of the entire test system.

[0052] In one embodiment, the slave server management mapping table includes resource utilization status of the slave server and a mapping relationship between the slave server and the code type;

[0053] Then, the preset slave server management mapping table in step S12 selects a target slave server from a plurality of slave servers according to the code test case, specifically including steps S121 to S122:

[0054] S121, based on the mapping relationship between the slave server and the code type, according to the current code type of the code test case, selecting a slave server corresponding to the current code type from a plurality of slave servers as a candidate slave server;

[0055] S122. Select a target slave server from the candidate slave servers according to the resource utilization status.

[0056] Furthermore, the code type includes a code topic type and a code language type.

[0057] Specifically, the resource utilization status of each slave server (including CPU status, memory utilization, etc.) is recorded in the slave server management mapping table of the master server. The slave server management mapping table also includes a mapping relationship between slave servers and code types. Each slave server is configured to provide running test services for a specific code question type and code language type, thereby realizing the classified running of code test cases and being able to perform targeted resource allocation for the slave servers. Based on the mapping relationship between the slave server and the code type, according to the current code type (code question type and code language type) of the code test case, a slave server corresponding to the current code type is selected from a number of slave servers as a candidate slave server. Based on the core resources of the candidate slave server such as the busy status of the CPU and the memory utilization, a candidate slave server with a relatively idle CPU and a lower memory utilization is selected as the target slave server.

[0058] In one implementation, the master server is constructed with an allocated docker container, and the slave server management mapping table also includes a mapping relationship between the allocated docker container and the slave server; then, sending the code test case to the target slave server in step S13 specifically includes steps S131 to S132:

[0059] S131, based on the mapping relationship between the allocated docker container and the slave server, according to the target slave server, selecting the allocated docker container corresponding to the target slave server as the target allocated docker container;

[0060] S132. Send the code test case to the target slave server through the target allocation docker container.

[0061] Specifically, several allocation docker containers are constructed in the master server, and the slave server management mapping table also includes the mapping relationship between the allocation docker containers and the slave servers. From the mapping relationship between the slave servers and the code types, it can be seen that there is also a mapping relationship between the allocation docker containers and the code types. Based on the mapping relationship between the allocation docker containers and the slave servers, according to the target slave server, the allocation docker container corresponding to the target slave server is selected as the target allocation docker container, and the code test case is sent to the target slave server through the target allocation docker container, so as to realize the use of a specific allocation docker container to forward the code test case of a specific code type.

[0062] In one embodiment, the method further includes steps S16 to S18:

[0063] S16. When it is detected that the initial slave server is busy, based on the mapping relationship between the allocated docker container and the slave server, the code test case in the initial slave server is sent to the allocated docker container corresponding to the initial slave server; wherein the initial slave server is the slave server that obtains the code test case;

[0064] S17, based on the mapping relationship between the allocated docker container and the slave server, according to the allocated docker container corresponding to the initial slave server, obtaining the slave server corresponding to the allocated docker container;

[0065] S18. Based on the slave server management mapping table and according to the code test case, a target slave server is selected from a number of slave servers corresponding to the allocated docker containers.

[0066] It is worth noting that the code test cases sent by the client are not always sent to the master server, but may also be sent directly to the slave server, that is, the initial slave server includes but is not limited to the target slave server.

[0067] Exemplarily, assume that the code test case is sent directly from the client to the initial slave server, and the flask queuing system is running in the initial slave server for queuing operation. When the number of code queues in the initial slave server reaches a preset threshold, the initial slave server is determined to be busy. Therefore, the code test case is returned from the initial slave server to the allocated docker container corresponding to the initial slave server, and the candidate slave servers under the allocated docker container are selected according to the code type of the code test case. Then, the target slave server is selected in combination with the resource utilization status of each candidate slave server, and the test docker container in the target slave server is responsible for performing the code running test.

[0068] In one implementation, after running the code test case in the test docker container and obtaining the test result of the code test case in step S15, it also includes: updating the slave server management mapping table.

[0069] Specifically, during the execution of the code test cases, the resource utilization of the slave servers will change, and the slave server management mapping table in the master server needs to be updated. In addition, due to the scalability of the entire test system, a new docker container can be allocated in the master server and used to connect to the new slave server to expand the system to ensure that accurate data can be used to allocate resources to the slave servers. Therefore, the slave server management mapping table needs to be updated regularly or irregularly.

[0070] In one embodiment, the method further includes steps S191-S192:

[0071] S191, storing the test result in a storage unit of the target slave server;

[0072] S192, sending the test result to the allocated docker container; sending the test result received by the allocated docker container to the client through the master server; or sending the test result to the client through the target slave server.

[0073] Specifically, the test results are stored in the target slave server and returned to the client. There are two ways to return the test results to the client. The first is to send the test results to the assigned docker container in the master server, and the master server returns them to the client. The second is to return them directly to the client through the target slave server. Specific settings can be made according to actual conditions.

[0074] Compared with the prior art, the embodiment of the present invention can select a target slave server based on the slave server management mapping table in the master server, and run code test cases in an idle test docker container in the target slave server, thereby realizing reasonable allocation of slave server resources, shortening code queuing time, and improving code testing efficiency. At the same time, by setting up and allocating docker containers on the master server to realize communication between the master server and the slave server, the risk of attack on the master server and other slave servers is reduced when one of the slave servers is maliciously attacked.

[0075] See also Figure 2 , Figure 2 : is a structural block diagram of a docker-based test device provided in an embodiment of the present invention, wherein the docker-based test device 20 comprises:

[0076] The container construction module 21 is used to construct several test docker containers in the slave server;

[0077] A slave server selection module 22 is used to obtain a code test case to a master server, and select a target slave server from a plurality of slave servers according to the code test case based on a preset slave server management mapping table; wherein the slave server management mapping table is pre-stored in the master server;

[0078] A code sending module 23, used for sending the code test case to the target slave server;

[0079] A test container selection module 24, configured to select an idle test docker container from a plurality of test docker containers of the target slave server as a target test docker container;

[0080] The test result acquisition module 25 is used to run the code test case in the target test docker container to obtain the test result of the code test case.

[0081] It is worth noting that the master server can be a single server, a server cluster composed of multiple servers, a virtual machine, or a container, without limitation here; the slave server can be a single server, a server cluster composed of multiple servers, a virtual machine, or a container, without limitation here.

[0082] Specifically, the docker-based test device 20 selects the target server based on the slave server management mapping table preset in the master server, runs the code in the idle test docker container in the target slave server, obtains the test results, and realizes the rapid and reasonable deployment of slave server resources and the running test of code test cases. Build several test docker containers in each slave server; obtain code test cases from the client to the master server, based on the slave server management mapping table pre-stored in the master server, select the target slave server from several slave servers according to the code test cases and send the code test cases to the target slave server, based on the flask queuing system, after receiving the code test cases, the slave server writes the code test cases to a file, and when there are idle core resources in the target slave server, put the code test cases into the idle test docker container in the target slave server for compilation and operation to obtain the test results.

[0083] The embodiment of the present invention discloses a docker-based testing device, which obtains code test cases from a master server, and based on a preset slave server management mapping table, selects a target slave server according to the code test cases, and sends the code test cases to the target slave server; selects an idle test docker container from several test docker containers built in the target slave server as the target test docker container; and finally runs the code test case in the target test docker container to obtain the test result of the code test case. It can be seen that the embodiment of the present invention can achieve reasonable allocation of slave server resources, shorten code queuing time, and improve code testing efficiency by selecting a target slave server based on the slave server management mapping table in the master server and running code test cases in an idle test docker container in the target slave server.

[0084] In one embodiment, the device 20 further includes:

[0085] A code return module is used to send the code test case in the initial slave server to the allocated docker container corresponding to the initial slave server based on the mapping relationship between the allocated docker container and the slave server when it is detected that the initial slave server is busy; wherein the initial slave server is the slave server that obtains the code test case;

[0086] A server reselection module, configured to obtain a slave server corresponding to the allocated Docker container according to the allocated Docker container corresponding to the initial slave server based on a mapping relationship between the allocated Docker container and the slave server;

[0087] The target slave server reselection module is used to select a target slave server from a number of slave servers corresponding to the allocated Docker container based on the slave server management mapping table and according to the code test case.

[0088] In one embodiment, the device 20 further includes:

[0089] An updating module is used to update the slave server management mapping table.

[0090] In one embodiment, the device 20 further includes:

[0091] A storage module, used for storing the test result in a storage unit of the target slave server;

[0092] The result returning module is used to send the test result to the allocated docker container; send the test result received by the allocated docker container to the client through the main server; or send the test result to the client through the target slave server.

[0093] It is worth noting that the specific working process of the docker-based testing device 20 can refer to the working process of the docker-based testing method described in the above embodiment, which will not be repeated here.

[0094] See also Figure 3 , Figure 3 is a structural block diagram of a docker-based test device provided in an embodiment of the present invention. The docker-based test device 30 includes a processor 31, a memory 32, and a computer program stored in the memory 32 and configured to be executed by the processor 31. When the processor 31 executes the computer program, the steps in the above-mentioned docker-based test method embodiment are implemented, for example Figure 1 Alternatively, the processor 31 implements the functions of each module in the above-mentioned device embodiments, such as the container construction module 21, when executing the computer program.

[0095] Exemplarily, the computer program may be divided into one or more modules, which are stored in the memory 32 and executed by the processor 31 to complete the present invention. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the docker-based test device 30. For example, the computer program may be divided into a container construction module 21, a server selection module 22, a code sending module 23, a test container selection module 24, and a test result acquisition module 25, and the specific functions of each module are as follows:

[0096] The container construction module 21 is used to construct several test docker containers in the slave server;

[0097] A slave server selection module 22 is used to obtain a code test case to a master server, and select a target slave server from a plurality of slave servers according to the code test case based on a preset slave server management mapping table; wherein the slave server management mapping table is pre-stored in the master server;

[0098] A code sending module 23, used for sending the code test case to the target slave server;

[0099] A test container selection module 24, configured to select an idle test docker container from a plurality of test docker containers of the target slave server as a target test docker container;

[0100] The test result acquisition module 25 is used to run the code test case in the target test docker container to obtain the test result of the code test case.

[0101] The specific working process of each module can refer to the working process of the docker-based testing device 20 described in the above embodiment, which will not be repeated here.

[0102] The docker-based test device 30 may be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The docker-based test device 30 may include, but is not limited to, a processor 31 and a memory 32. Those skilled in the art will appreciate that the schematic diagram is merely an example of a battery status monitoring device and does not constitute a limitation on the docker-based test device 30. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the docker-based test device 30 may also include input and output devices, network access devices, buses, etc.

[0103] The processor 31 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor 31 is the control center of the docker-based test device 30, and uses various interfaces and lines to connect various parts of the entire docker-based test device 30.

[0104] The memory 32 can be used to store the computer program and / or module, and the processor 31 realizes various functions of the docker-based test device 30 by running or executing the computer program and / or module stored in the memory 32, and calling the data stored in the memory 32. The memory 32 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 32 can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0105] Wherein, if the module integrated by the docker-based test device 30 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0106] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A docker-based testing method, It is characterized in that include: Build several test docker containers in the slave server; Obtaining a code test case from a master server, and selecting a target slave server from a plurality of slave servers according to the code test case based on a preset slave server management mapping table, wherein the slave server management mapping table is pre-stored in the master server; Sending the code test case to the target slave server; Selecting an idle test Docker container from the plurality of test Docker containers of the target slave server as the target test Docker container; Run the code test case in the target test docker container to obtain the test result of the code test case; The master server is constructed with an allocation docker container, and the slave server management mapping table also includes a mapping relationship between the allocation docker container and the slave server; then, sending the code test case to the target slave server specifically includes: based on the mapping relationship between the allocation docker container and the slave server, according to the target slave server, selecting an allocation docker container corresponding to the target slave server as a target allocation docker container; sending the code test case to the target slave server through the target allocation docker container; When it is detected that the initial slave server is busy, based on the mapping relationship between the allocated docker container and the slave server, the code test case in the initial slave server is sent to the allocated docker container corresponding to the initial slave server, wherein the initial slave server is the slave server that obtains the code test case; based on the mapping relationship between the allocated docker container and the slave server, according to the allocated docker container corresponding to the initial slave server, the slave server corresponding to the allocated docker container is obtained; based on the slave server management mapping table, according to the code test case, a target slave server is selected from several slave servers corresponding to the allocated docker container.

2. The Docker-based testing method according to claim 1, It is characterized in that The master server is constructed with an allocated docker container, and the sending of the code test case to the target slave server specifically includes: The code test case is sent to the target slave server through the allocated docker container.

3. The docker-based testing method according to claim 1, It is characterized in that The slave server management mapping table includes resource utilization status of the slave server and a mapping relationship between the slave server and the code type; Then, the preset slave server management mapping table is used to select a target slave server from a plurality of slave servers according to the code test case, specifically including: Based on the mapping relationship between the slave server and the code type, and according to the current code type of the code test case, a slave server corresponding to the current code type is selected from a plurality of slave servers as a candidate slave server; A target slave server is selected from the candidate slave servers according to the resource utilization status.

4. The docker-based testing method according to claim 1, It is characterized in that After running the code test case in the test docker container and obtaining the test result of the code test case, the method further includes: updating the slave server management mapping table.

5. The docker-based testing method as claimed in claim 2, It is characterized in that Also includes: storing the test result in a storage unit of the target slave server; Sending the test results to the allocated docker container; The test result received by the allocated docker container is sent to the client through the main server; or, the test result is sent to the client through the target slave server.

6. A docker-based test device, It is characterized in that include: The container building module is used to build several test docker containers in the slave server; A slave server selection module is used to obtain code test cases from a master server, and based on a preset slave server management mapping table, select a target slave server from a plurality of slave servers according to the code test cases; wherein the slave server management mapping table is pre-stored in the master server; A code sending module, used for sending the code test case to the target slave server; A test container selection module, used to select an idle test Docker container from a plurality of test Docker containers of the target slave server as a target test Docker container; A test result acquisition module, used to run the code test case in the target test docker container to obtain the test result of the code test case; The code sending module is specifically used to: based on the mapping relationship between the allocated docker container and the slave server, according to the target slave server, select the allocated docker container corresponding to the target slave server as the target allocated docker container; send the code test case to the target slave server through the target allocated docker container; wherein the allocated docker container is constructed in the master server, and the slave server management mapping table also includes the mapping relationship between the allocated docker container and the slave server; The test container selection module is also used for: when it is detected that the initial slave server is busy, based on the mapping relationship between the allocated docker container and the slave server, sending the code test case in the initial slave server to the allocated docker container corresponding to the initial slave server, wherein the initial slave server is the slave server that obtains the code test case; based on the mapping relationship between the allocated docker container and the slave server, according to the allocated docker container corresponding to the initial slave server, obtaining the slave server corresponding to the allocated docker container; based on the slave server management mapping table, according to the code test case, selecting the target slave server from a number of slave servers corresponding to the allocated docker container.

7. A docker-based test device, It is characterized in that It comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, it implements the Docker-based testing method as described in any one of claims 1 to 5.

8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the Docker-based testing method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Test method and device, electronic equipment, system and storage medium

    CN111159046A

  • Test method and device based on container technology, electronic equipment and storage medium

    CN113377665A