CN108694117B - Method and device for managing test environment based on container technology - Google Patents

Method and device for managing test environment based on container technology Download PDF

Info

Publication number
CN108694117B
CN108694117B CN201710232336.4A CN201710232336A CN108694117B CN 108694117 B CN108694117 B CN 108694117B CN 201710232336 A CN201710232336 A CN 201710232336A CN 108694117 B CN108694117 B CN 108694117B
Authority
CN
China
Prior art keywords
container
test
time
lookup table
test container
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710232336.4A
Other languages
Chinese (zh)
Other versions
CN108694117A (en
Inventor
逯晓斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201710232336.4A priority Critical patent/CN108694117B/en
Publication of CN108694117A publication Critical patent/CN108694117A/en
Application granted granted Critical
Publication of CN108694117B publication Critical patent/CN108694117B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Abstract

The invention provides a method and a device for managing a test environment based on a container technology, electronic equipment and a readable storage medium, which solve the problem of resource management of the test environment by realizing automatic start and stop of the test environment. The method comprises the following steps: maintaining a container monitoring lookup table, wherein the container monitoring lookup table includes one or more entries corresponding to the created one or more test containers, respectively, and each entry includes timeout time, container status, and last access time of the corresponding test container; in response to receiving an access request for a particular test container, querying a container snoop lookup table to determine a status of the particular test container; in response to the status of a particular test receptacle being closed: starting a specific test container, updating the state corresponding to the specific test container in the container monitoring lookup table to be active, and updating the corresponding last access time to be the current time; and routing the access to the particular test container.

Description

Method and device for managing test environment based on container technology
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for managing a test environment, electronic equipment and a readable storage medium.
Background
Software application testing is an important link in a software development process, corresponding testing environments need to be provided according to various different testing requirements, and resource management of the testing environments is challenging for a testing system which simultaneously provides a large amount of testing services of a plurality of development projects.
In order to provide a corresponding test environment for a test requirement at the same time, in the prior art, a virtual machine test system is generally used to assign a virtual machine test environment to a tester, and the tester maintains the environment. A virtual machine may be a software implementation of a computing device with complete hardware system functionality, running in a completely isolated environment, and may include its own operating system to execute various types of applications to provide various functions and services, thus providing test environment independence for testers through the use of a virtual machine test environment. Fig. 1 illustrates a system architecture of virtual machine technology.
When a tester starts testing, the tester firstly applies for a testing virtual machine to a testing system, and the tester configures a testing environment for the testing virtual machine according to the testing requirement after the testing virtual machine is started. Generally, the test environment for the application needs to be consistent with the online environment, however, the manually configured test environment in the prior art may have a version different from that of the online environment, which reduces the completeness of the test. In addition, many test requirements simultaneously need to correspondingly provide test virtual machines with complete resources, and in the test environment scheme in the prior art, a specified number of test virtual machines are generally manually allocated, and the virtual machines still occupy resources all the time even when not executing a computing task, so that the resources of idle virtual machines cannot be recovered, which causes a great deal of waste of resources, and limits the capability of the system to provide test services, which makes the resource management of the test environment an urgent problem to be solved.
Disclosure of Invention
In view of this, the present invention provides a method, an apparatus, an electronic device, and a readable storage medium for managing a test environment based on a container technology, which solve the problem of resource management of the test environment by implementing automatic start and stop of the test environment.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of managing a test environment based on container technology.
The method for managing the test environment based on the container technology comprises the following steps:
maintaining a container snoop lookup table, wherein the container snoop lookup table comprises one or more entries corresponding to the created one or more test containers respectively, and each entry comprises timeout time, container state, and last access time of the corresponding test container; in response to receiving an access request for a particular test container, querying the container snoop lookup table to determine a status of the particular test container; in response to the status of the particular test receptacle being closed: starting the specific test container, updating the state corresponding to the specific test container in the container monitoring lookup table to be active, and updating the corresponding last access time to be the current time; and routing the access to the particular test container.
Alternatively, the method further comprises: in response to the status of the particular test container being active, updating a last access time in the container snoop lookup table corresponding to the particular test container to a current time.
Alternatively, the method further comprises: after routing access to the particular test container, updating a last access time in the container snoop lookup table corresponding to the particular test container to a current time in response to each operation on the particular test container.
Alternatively, the creation of the test container comprises: receiving a creation request for creating a test container, wherein the creation request comprises a container address, a selection of a test environment image and an application to be tested; packaging the selected test environment mirror image and the application to be tested to create a test container; and adding an entry for the created test container to the container snoop look-up table, wherein a corresponding timeout time is set to a predetermined time, a corresponding state is set to off, and a last access time is set to a current time.
Alternatively, the create request further comprises a timeout time, and the method further comprises setting the timeout time in the corresponding entry in the container snoop look-up table to the timeout time in the create request instead of the predetermined time.
Alternatively, the method further comprises: after a test container is created, the test container is started and the state in the corresponding entry in the container snoop lookup table is set to active.
Alternatively, the method further comprises: and accessing the test container lookup table at a specified time interval, and closing the test containers which are not operated beyond the response time in the test containers with the corresponding states as activities.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an apparatus for managing a test environment based on container technology.
The device for managing the test environment based on the container technology comprises: a maintenance module, configured to maintain a container monitoring lookup table, where the container monitoring lookup table includes one or more entries corresponding to one or more created test containers, respectively, and each entry includes a timeout time, a container state, and a last access time of the corresponding test container; an access module to: in response to receiving an access request for a particular test container, querying the container snoop lookup table to determine a status of the particular test container; in response to the status of the particular test receptacle being closed: starting the specific test container, updating the state corresponding to the specific test container in the container monitoring lookup table to be active, and updating the corresponding last access time to be the current time; and routing the access to the particular test container.
Alternatively, the access module is further to: in response to the status of the particular test container being active, updating a last access time in the container snoop lookup table corresponding to the particular test container to a current time.
Alternatively, the access module is further to: after routing access to the particular test container, updating a last access time in the container snoop lookup table corresponding to the particular test container to a current time in response to each operation on the particular test container.
Alternatively, the apparatus further comprises a creation module to: receiving a creation request for creating a test container, wherein the creation request comprises a container address, a selection of a test environment image and an application to be tested; packaging the selected test environment mirror image and the application to be tested to create a test container; and adding an entry for the created test container to the container snoop look-up table, wherein a corresponding timeout time is set to a predetermined time, a corresponding state is set to off, and a last access time is set to a current time.
Alternatively, the create request further includes a timeout time, and the create module is further to set the timeout time in the corresponding entry in the container snoop lookup table to the timeout time in the create request instead of the predetermined time.
Alternatively, the creation module is further to: after a test container is created, the test container is started and the state in the corresponding entry in the container snoop lookup table is set to active.
Alternatively, the apparatus further comprises a reduction module to: and accessing the test container lookup table at a specified time interval, and closing the test containers which are not operated beyond the response time in the test containers with the corresponding states as activities.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided an electronic device for a method of managing a test environment based on container technology.
An electronic device of an embodiment of the present invention includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the one processor to cause the at least one processor to perform a method of managing a test environment based on container technology according to an embodiment of the present invention.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided a non-transitory computer-readable storage medium.
A non-transitory computer-readable storage medium of an embodiment of the present invention stores computer instructions for causing the computer to perform a method of managing a test environment based on container technology of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: because the technical means of monitoring the test container to realize resource recovery and instant allocation of the test container is adopted, the test container is automatically closed when the test container is not used for a long time so as to reduce resource occupation and is quickly started when the test container needs to be accessed, the technical problem that the virtual machine resource is occupied for a long time and cannot be recovered and managed due to fixed allocation of the test virtual machine is solved, the technical effect of effectively managing and utilizing the resource is further achieved, the utilization efficiency of the resource of a single device is improved, the test environment investment is reduced, and the single device can support the test environment with the quantity far more than that of the virtual machine; by utilizing the second-level starting technology of the container technology, the resource recovery and allocation of the test environment cannot influence the use experience; through the mirror image concept of the container technology, the test environment mirror image of the application to be tested is directly configured aiming at the online environment, and the integrity problem caused by the difference between the test environment configured by a tester and the online test environment is avoided.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 illustrates a system architecture of virtual machine technology according to the prior art;
FIG. 2 illustrates a system architecture for container technology;
FIG. 3 is a schematic diagram of a system implementing a container technology based testing environment, according to an embodiment of the present invention;
FIG. 4 is a flow diagram of a test container creation process according to an embodiment of the invention;
FIG. 5 is a flow diagram of a test container access process according to an embodiment of the invention;
FIG. 6 is a schematic diagram of the main steps of a method of managing a test environment based on container technology, according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of the main modules of an apparatus for managing a test environment based on container technology according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a computer system suitable for implementing the terminal device or the server according to the embodiment of the present application.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The technical scheme of the embodiment of the invention is a test environment management technology realized based on an LXC (Linux Containers, Linux software Containers), namely a container technology for short. Fig. 2 illustrates a system architecture for container technology. The container technology is a user space interface of the Linux kernel container function, and packages application software into a software container, wherein the container contains the code of the software, and an operating system core and a library required by the software to run. By using the characteristic, the test environment mirror image can be preset according to the actual on-line operation environment, and the test environment mirror image created according to each requirement can be simply and conveniently managed through the mirror image library to be selected by a tester. Meanwhile, the container technology creates an independent sandbox operating environment for the encapsulated Application, and specifically allocates hardware resources to the software container through a uniform namespace (namespace) and a common Application Programming Interface (API), which makes the creation and operation of the container very simple and efficient. By the characteristic, the application to be tested and the required test environment can be packaged into the test container in a mirror image mode effectively and simply, and each operation on the test container is easy to realize. The packaging characteristics of the container are very advantageous for application testing, which ensures that the application has a consistent operating environment at any time and on different devices. The Linux kernel provides cgroups (control group) functions, provides a resource management means required for implementing virtualization by using a container technology, achieves partitioning of resources, and provides a namespace partitioning function, so that an operating system environment accessible to an application is partitioned into independent sections, and each section comprises an independent process number, network resources, a user ID (Identification, identifier), and a mounted file system. The container technology may provide an independent operating system environment, i.e., container, for applications using Cgroups and namespace functions. By comparing fig. 1 and fig. 2, the Hypervisor software layer is not needed in the container system architecture, which makes the container itself extremely light-weighted, and increases the speed of container creation. In the container technology architecture, a software Docker is used to manage the runtime environment. Thus, the virtual machine system described in FIG. 1 operates as if it were emulating an entire device, such as a server, and starts up with a full operating system, such as Linux; while the container directly utilizes the kernel of the host system in a similar manner to the application program, and such a mechanism is different that the container has a start-up and shut-down speed of the order of seconds, hereinafter, a method, an apparatus, an electronic device, and a readable storage medium for managing a test environment based on a container technology according to the present invention will be described in detail with reference to the accompanying drawings. The container encapsulating the application to be tested and the test environment required for its operation is referred to herein as a test container.
FIG. 3 is a schematic diagram of a system 300 implementing a managed test environment based on container technology, according to an embodiment of the invention. The system 300 includes: DNS server 310, gateway 320, and test server 330. Among them, the gateway 320 has an agent module 321 and a listening module 322 therein, which are configured to implement the method for managing a test environment based on container technology of the present invention. The DNS server 310 is a server for implementing DNS service. A DNS (Domain Name System) is a distributed database that maps Domain names and IP addresses, and enables users to conveniently access a network. DNS uses TCP and UDP ports 53 and currently the limit for the length of the domain name per stage is 63 characters, the total length of the domain name cannot exceed 253 characters. Gateway 320 is the interface device of system 300 with the user who needs to create or access the test environment. The test server 330 is a device for hosting created test containers, which hosts a container cluster of a plurality of test containers including the test container 331, the test containers 332, … …, and the test container 33N. The test server 330 may manage the container cluster through various container management software, such as docker swarm, kubernets, messes, etc., that provides a container cluster API to interface with the gateway. The container cluster API provides functions to support the creation, start, close, etc. functions of test containers, as well as other communication functions. Gateway 320 performs address management for each test container in the container cluster to facilitate tester access to the desired test container. Although the device hosting the container cluster is depicted in fig. 3 as a single test server 330, in other embodiments, hosting the container cluster may be implemented with other computing devices, multiple computing devices. The test container creation, access, and reduction process of the system 300 according to the present embodiment will be described below with reference to the drawings.
FIG. 4 is a flow diagram of a test container creation process of system 300 according to an embodiment of the invention. In S410, a test container is created by the gateway 320. The proxy module 321 in the gateway 320 provides a create page that the creator who needs to create the test container can access to create the test container using the address of the access gateway 320. The creator may be a developer of the application or may be a specialized tester. Specifically, the creator provides the container address in the create page and optionally a timeout time. The container address is an address in the form of a domain name that is used to conveniently identify the test performed by the test container. The timeout may be set based on test requirements or requirements for resource utilization, among other factors. In the case where the creator does not provide the timeout, the default value of the timeout is 30 minutes. When the started test container is not used beyond the set timeout period, the system 300 will close the test container to achieve dynamic throttling.
Meanwhile, in this page, the creator selects a test environment image required by the application to be tested from the image library of the test environment. The test environment images are configured according to the environment of various applications running on the line actually without self configuration of a creator, so that the version consistency of the test environment and the online environment is ensured. Each test environment image is identified by a test environment image ID. The selection of the test environment image may be made according to test requirements such as: simply debugging the application, such as page operation, input and output, and the like; responses to a large number of concurrent situations, such as responses to concurrent, multiple requests; pressure testing, and the like. Corresponding application environments can be provided for the applications to be tested, for example, a Java application environment containing JDK, tomcat, nginx and the like can be provided for a Java application, and an application environment containing nginx, php can be provided for a php application. The same application to be tested may also correspond to different test environments according to the test requirements.
Meanwhile, in the page, the creator may provide the application to be tested by providing the source code library address of the application to be tested. In the embodiment, the developed application is managed and tested conveniently through the application source code library. In an alternative embodiment, the creator may also provide the application package directly.
Next, the agent module 321 provides the test image ID corresponding to the test environment image selected by the creator, the source code library address of the application to be tested, and a create container instruction (specified by the container cluster API) to the container cluster API to create and start the test container therethrough. The container cluster API returns a response of successful start to the agent module 321 in case of successful creation and start, and a container ID and an access link identifying the created test container. The access link includes an intranet IP and port of the test container. In the event of a test container creation failure, the container cluster API returns a response to the proxy module 321 that the launch failed, and the create page presents failure information to the creator. The creator may refresh the create page repeating the create test container step described above or terminating the creation process.
Then, in S420, the proxy module 321 of the gateway 320 adds the domain name resolution of the created test container through the DNS server 310. The gateway 320 manages the access link of the created test container to enable access to the test container. In particular, a container access look-up table is maintained in the agent module 321, each entry in the table corresponding to a respective test container, each entry comprising: a container ID, a container address, and an access link for the container. After receiving a response from the container cluster API that the creation was successful, the proxy module 321 of the gateway sends the container address to the DNS server 310 to establish application domain name resolution, and sends the container ID and timeout time to the listener module 322. By establishing domain name resolution, the test container may be accessed with the system 300 by entering the container address of the test container to be accessed in the browser.
Then, in S430, the listening module 322 adds a record of the created test container. In particular, a container snoop look-up table is maintained in snoop module 322, where each entry in the table corresponds to a corresponding test container as a record of the test container. Wherein each entry comprises: container ID, timeout time, container status, and last access time. The container status indicates whether the test container is currently in an active or closed state. The snoop module 322 receives the container ID and the timeout time, adds an entry corresponding to the container ID to the lookup table, sets the corresponding last access time to the current time, and sets the corresponding state to active. And then sends a record complete response to the agent module.
Then, in S440, after the agent module receives the record completion response, the creator is presented with a prompt that the test container has been successfully created through the creation page. At this point, the creation process of the test container is complete. The access procedure of the test container will be described with reference to fig. 5.
FIG. 5 is a flow diagram of a test container access process of system 300 according to an embodiment of the invention. In S510, an access request for a particular test receptacle is received from a computing device of a tester. A tester may enter a container address of a test container to be accessed in a browser of their computing device to communicate with system 300 to access the test container. The tester may be the creator of the test container or may be another tester. The tester's computing device obtains the IP address corresponding to the container address through DNS server 310, and sends an access request containing the application address to gateway 320 to which the IP address points. The proxy module 321 of the gateway 320 receives the access request. The container ID corresponding to the container address is obtained by querying the container access lookup table and an access instruction containing the container ID is sent to the snoop module 322.
Then, in S520, the listening module 322 receives the access command and determines whether the test container is in an active state. In particular, the snoop module 322 snoops the lookup table with a query container to obtain the status corresponding to the container ID.
When the status corresponding to the container ID is active, go to S530. The listening module 322 updates the last access time corresponding to the container ID to the current time, and returns a container started response to the agent module, and proceeds to S540.
When the state corresponding to the container ID is closed, the process proceeds to S525. The snoop module 322 returns a container not initiated response to the proxy module 321. In some embodiments, the agent module 321 may feed back the starting progress of the test container to the tester at any time, so that the tester obtains a continuous and smooth system response. The snoop module 321 sends the container ID and the activation instruction (specified by the container cluster API) to the container cluster API. After the test container corresponding to the container ID is started, the container cluster API returns an activation success response to the monitoring module 321, the process proceeds to S530, the monitoring module 322 updates the last access time corresponding to the container ID to the current time, returns a container started response to the proxy module, and proceeds to S540.
In S540, the agent module 321 routes the access to the test container corresponding to the container ID. In particular, the agent module 321 establishes a communication link between the tester's computing device and the test container, enabling the tester to perform various operations on the test container to perform application testing. For each operation that the tester performs on the test container, the agent module 321 sends an operation identifier to the monitoring module 322, and updates the last access time corresponding to the test container in the container monitoring lookup table to the current time. By this mechanism, snooping of the test container is achieved to facilitate further dynamic reduction of the test container, which will be described in detail below.
When the test container corresponding to the container ID fails to start, the container cluster API returns an activation failure response to the monitoring module 322, and the monitoring module 322 returns a start failure response to the proxy module 321, and the process proceeds to S535. In S535, the agent module 321 presents a prompt to the tester that the test container failed to start, and the start-up process ends. The tester may choose to innovate the access page again, i.e., reinitiate the process of accessing the test container. The tester may also request personnel maintaining the system 300 to troubleshoot the fault.
Next, a dynamic narrowing process of the test container will be described. The snoop module 322 scans the container snoop look-up table at specified time intervals (e.g., every 30 seconds/minute/every 30 minutes, etc.), makes a determination of each entry in the table, and determines whether there are any unused test containers in the active test containers that exceed the timeout time. Specifically, for each entry whose state is active, the last access time and the timeout time are summed and compared with the current time, and the container ID corresponding to the entry whose summed result has reached or exceeded the current time is queried. The monitoring module 322 sends the queried container ID and closing instruction (specified by the container cluster API) to the container cluster API, and when receiving a closing success response from the container cluster API, the monitoring module 322 sets the corresponding state in the container state lookup table as closed, thereby completing the dynamic reduction process for the test container. Similarly, each scan will reduce unused test containers over time, thereby enabling dynamic reduction. In the event a close failure response is received from the container cluster API, the snoop module 322 may repeat instructing the container cluster API to close the specified test container and, once a preset number of retries is exceeded, stop the curtailment process and alert personnel maintaining the system 300. According to the method for managing the test environment based on the container technology, the catalog of the container is directly hung on the catalog of the host, so that data cannot be lost when the test container is closed or even damaged, and the safety of the data is ensured.
A process of creating, accessing, and dynamically reducing test containers according to embodiments of the present invention has been described. Although the agent module and the listener module are described as separate modules in this embodiment, in other embodiments, the agent module and the listener module may be implemented as a single module or as more separate modules, and are not necessarily provided in the gateway.
In the present embodiment, the method for testing environment of the present invention is implemented by using gateway and DNS server, and in other embodiments, the method for managing testing environment based on container technology of the present invention can be implemented by using any system, device, and technology capable of implementing access to a testing container, which can be conceived by those skilled in the art.
According to the method for managing the test environment based on the container technology, the technical means of monitoring the test container to realize resource recovery and instant allocation of the test container is adopted, the test container is automatically closed when being not used due to overtime, so that the resource occupation is reduced, and the test container is quickly started when needing to be accessed, so that the technical problem that the virtual machine resource is occupied for a long time and cannot be recovered and managed due to fixed allocation of the test virtual machine is solved, the technical effect of effective management and utilization of the resource is further achieved, the utilization efficiency of the resource of a single device is improved, the test environment investment is reduced, and the single device can support the test environment with the number far more than that the virtual machine can support; by utilizing the second-level starting technology of the container technology, the resource recovery and allocation of the test environment cannot influence the use experience; through the mirror image concept of the container technology, the test environment mirror image of the application to be tested is directly configured aiming at the online environment, and the integrity problem caused by the difference between the test environment configured by a tester and the online test environment is avoided.
Fig. 6 is a schematic diagram of the main steps of a method of managing a test environment based on container technology according to an embodiment of the present invention. The method of the invention relates to maintaining a container monitoring lookup table for the created test container, starting the specific test container when accessing the specific test container and updating the corresponding entry in the container monitoring lookup table.
In S61, a container snoop look-up table is maintained, wherein the container snoop look-up table includes one or more entries corresponding to the created one or more test containers, respectively, each entry including a timeout time, a container status, and a last access time of the corresponding test container. Wherein the creating of the test container comprises: receiving a creation request for creating a test container, wherein the creation request comprises a container address, a selection of a test environment image and an application to be tested; packaging the selected test environment mirror image and the application to be tested to create a test container; and adding an entry of the created test container to the container snoop look-up table, wherein a corresponding timeout time is set to a predetermined time (i.e., a default value of a preset timeout time), a corresponding state is set to off, and a last access time is set to a current time. In some embodiments, the create request further includes a timeout time, and the timeout time in the corresponding entry in the container snoop look-up table is set to the timeout time in the create request. After a test container is created, the test container is started and the state in the corresponding entry in the container snoop lookup table is set to active.
In S62, in response to receiving an access request for a particular test receptacle, the receptacle snoop lookup table is queried to determine the status of the particular test receptacle.
In S63, in response to the status of the particular test container being closed, the particular test container is activated and the status in the container snoop lookup table corresponding to the particular test container is updated as active. In determining the status of the particular test receptacle, the last access time in the receptacle snoop lookup table corresponding to the particular test receptacle is updated to the current time in response to the status of the particular test receptacle being active. Then, the corresponding last access time is updated to the current time.
In S63, the access is routed to the particular test container. After routing access to the particular test container, the last access time in the container snoop lookup table corresponding to the particular test container is updated to the current time in response to each operation on the particular test container. In addition, the method of the present invention also includes shrinking the test container. Specifically, the test container look-up table is accessed at a specified time interval, and the test containers which are not operated beyond the response time in the test containers with the corresponding states as activities are closed.
Fig. 7 is a schematic diagram of main blocks of an apparatus for managing a test environment based on a container technology according to an embodiment of the present invention.
As shown in fig. 7, the apparatus 70 for managing a test environment based on container technology according to an embodiment of the present invention mainly includes: a maintenance module 701, an access module 702, a creation module 703, and a reduction module 704. The maintaining module 701 may be configured to maintain a container snoop lookup table, where the container snoop lookup table includes one or more entries corresponding to the created one or more test containers, respectively, and each entry may include a timeout time, a container status, and a last access time of the corresponding test container.
The access module 702 may be configured to: in response to receiving an access request for a particular test receptacle, the receptacle snoop lookup table is queried to determine a status of the particular test receptacle. The access module 702 may be further operable to: in response to the specific test container being closed, starting the specific test container, updating a state corresponding to the specific test container in the container listening lookup table to be active, and updating a corresponding last access time to be a current time; in response to the status of the particular test container being active, updating a last access time in the container snoop lookup table corresponding to the particular test container to a current time. The access module 702 may be further operable to: routing the access to the particular test receptacle. The access module 702 may be further operable to: after routing access to the particular test container, updating a last access time in the container snoop lookup table corresponding to the particular test container to a current time in response to each operation on the particular test container.
The creation module 703 may be configured to: a create request to create a test container is received, wherein the create request includes a container address, a selection of a test environment image, and an application to be tested. The creating module 703 may be further configured to: packaging the selected test environment image and the application to be tested to create a test container. The creating module 703 may be further configured to: adding an entry for the created test container to the container snoop look-up table, wherein a corresponding timeout time is set to a predetermined time, a corresponding state is set to off, and a last access time is set to a current time. Wherein the create request further may include a timeout. The creating module 703 may be further configured to set the timeout time in the corresponding entry in the container snoop look-up table to the timeout time in the create request instead of the predetermined time. The creating module 703 may be further configured to: after a test container is created, the test container is started and the state in the corresponding entry in the container snoop lookup table is set to active.
The reduction module 704 may be configured to: and accessing the test container lookup table at a specified time interval, and closing the test containers which are not operated beyond the response time in the test containers with the corresponding states as activities.
From the above description, it can be seen that, because the technical means of monitoring the test container to realize resource recovery and instant allocation of the test container is adopted, the test container is automatically closed when the test container is not used for a long time to reduce resource occupation and is quickly started when the test container needs to be accessed, the technical problem that the virtual machine resource is occupied for a long time and cannot be recovered and managed due to fixed allocation of the test virtual machine is solved, the technical effect of effective management and utilization of resources is further achieved, the utilization efficiency of resources of a single device is improved, the test environment investment is reduced, and the single device supports a test environment which is far more than the supportable number of the virtual machine; by utilizing the second-level starting technology of the container technology, the resource recovery and allocation of the test environment cannot influence the use experience; through the mirror image concept of the container technology, the test environment mirror image of the application to be tested is directly configured aiming at the online environment, and the integrity problem caused by the difference between the test environment configured by a tester and the online test environment is avoided.
The invention also provides an electronic device and a readable storage medium according to the embodiment of the invention.
The electronic device of the present invention includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the one processor to cause the at least one processor to perform the method for managing a test environment based on container technology provided by the present invention.
The non-transitory computer readable storage medium of the present invention stores computer instructions for causing the computer to perform the method of managing a test environment based on container technology provided by the present invention.
Referring now to FIG. 8, shown is a block diagram of a computer system 800 suitable for use in implementing a terminal device of an embodiment of the present application. The terminal device shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 8, the computer system 800 includes a Central Processing Unit (CPU)801 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)802 or a program loaded from a storage section 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data necessary for the operation of the system 800 are also stored. The CPU 801, ROM 802, and RAM 803 are connected to each other via a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
The following components are connected to the I/O interface 805: an input portion 806 including a keyboard, a mouse, and the like; an output section 807 including a signal such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 808 including a hard disk and the like; and a communication section 809 including a network interface card such as a LAN card, a modem, or the like. The communication section 809 performs communication processing via a network such as the internet. A drive 810 is also connected to the I/O interface 805 as necessary. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 810 as necessary, so that a computer program read out therefrom is mounted on the storage section 808 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 809 and/or installed from the removable medium 811. The computer program executes the above-described functions defined in the system of the present application when executed by the Central Processing Unit (CPU) 801.
It should be noted that the computer readable medium shown in the present application may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present application may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a sending module, an obtaining module, a determining module, and a first processing module. The names of these modules do not form a limitation on the modules themselves in some cases, and for example, the sending module may also be described as a "module sending a picture acquisition request to a connected server".
As another aspect, the present application also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: maintaining a container snoop lookup table, wherein the container snoop lookup table comprises one or more entries corresponding to the created one or more test containers respectively, and each entry comprises timeout time, container state, and last access time of the corresponding test container; in response to receiving an access request for a particular test container, querying the container snoop lookup table to determine a status of the particular test container; in response to the status of the particular test receptacle being closed: starting the specific test container, updating the state corresponding to the specific test container in the container monitoring lookup table to be active, and updating the corresponding last access time to be the current time; and routing the access to the particular test container. Alternatively, the apparatus further comprises: in response to the state of the specific test container being active, updating a last access time in the container listening look-up table corresponding to the specific test container to a current time; after routing access to the particular test container, updating a last access time in the container snoop lookup table corresponding to the particular test container to a current time in response to each operation on the particular test container. Alternatively, the creation of the test container comprises: receiving a creation request for creating a test container, wherein the creation request comprises a container address, a selection of a test environment image and an application to be tested; packaging the selected test environment mirror image and the application to be tested to create a test container; and adding an entry for the created test container to the container snoop look-up table, wherein a corresponding timeout time is set to a predetermined time, a corresponding state is set to off, and a last access time is set to a current time. Alternatively, the create request further comprises a timeout time, and the method further comprises setting the timeout time in the corresponding entry in the container snoop look-up table to the timeout time in the create request instead of the predetermined time. Alternatively, the apparatus further comprises: after creating a test container, starting the test container and setting a state in a corresponding entry in the container snoop lookup table as active; and accessing the test container lookup table at a specified time interval, and closing the test containers which are not operated beyond the response time in the test containers with the corresponding states as activities.
According to the scheme of the embodiment of the invention, because the technical means of monitoring the test container to realize resource recovery and instant allocation of the test container is adopted, the test container is automatically closed when the test container is not used for a long time so as to reduce resource occupation and is quickly started when the test container needs to be accessed, the technical problem that the virtual machine resource is occupied for a long time and cannot be recovered and managed due to fixed allocation of the test virtual machine is solved, the technical effect of effectively managing and utilizing the resource is further achieved, the utilization efficiency of the resource of a single device is favorably improved, the test environment investment is reduced, and the single device supports the test environment with the number far more than that the virtual machine can support; by utilizing the second-level starting technology of the container technology, the resource recovery and allocation of the test environment cannot influence the use experience; through the mirror image concept of the container technology, the test environment mirror image of the application to be tested is directly configured aiming at the online environment, and the integrity problem caused by the difference between the test environment configured by a tester and the online test environment is avoided.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (16)

1. A method for managing a test environment based on container technology, comprising:
a test server manages a container cluster comprising test containers through container management software, the test server providing a container cluster API to interface with a gateway, wherein,
the functions provided by the container cluster API support the creation, starting and closing of test containers;
the gateway realizes that:
maintaining a container snoop lookup table, wherein the container snoop lookup table comprises one or more entries corresponding to the created one or more test containers respectively, and each entry comprises timeout time, container state, and last access time of the corresponding test container;
in response to receiving an access request for a particular test container, querying the container snoop lookup table to determine a status of the particular test container;
in response to the status of the particular test receptacle being closed:
activating the specific test receptacle, and
updating the state in the container listening look-up table corresponding to the specific test container to be active and updating the corresponding last access time to be the current time; and routing the access to the particular test container.
2. The method of claim 1, further comprising:
in response to the status of the particular test container being active, updating a last access time in the container snoop lookup table corresponding to the particular test container to a current time.
3. The method of claim 1, further comprising: after routing access to the particular test container, updating a last access time in the container snoop lookup table corresponding to the particular test container to a current time in response to each operation on the particular test container.
4. The method of claim 1, wherein the creating of the test receptacle comprises:
receiving a creation request for creating a test container, wherein the creation request comprises a container address, a selection of a test environment image and an application to be tested;
packaging the selected test environment mirror image and the application to be tested to create a test container; and
adding an entry for the created test container to the container snoop look-up table, wherein a corresponding timeout time is set to a predetermined time, a corresponding state is set to off, and a last access time is set to a current time.
5. The method of claim 4, wherein the create request further comprises a timeout time, and wherein the method further comprises setting the timeout time in the corresponding entry in the container snoop lookup table to the timeout time in the create request instead of the predetermined time.
6. The method of claim 4, further comprising: after a test container is created, the test container is started and the state in the corresponding entry in the container snoop lookup table is set to active.
7. The method of claim 1, further comprising:
and accessing the test container lookup table at a specified time interval, and closing the test containers which are not operated beyond the response time in the test containers with the corresponding states as activities.
8. An apparatus for managing a test environment based on container technology, applied to a gateway, includes:
the gateway is in butt joint with a container cluster API provided by a test server, the test server manages a container cluster comprising a test container through container management software, and the test server supports the creation, starting and closing of the test container through a function provided by the container cluster API;
a maintenance module, configured to maintain a container monitoring lookup table, where the container monitoring lookup table includes one or more entries corresponding to one or more created test containers, respectively, and each entry includes a timeout time, a container state, and a last access time of the corresponding test container;
an access module to:
in response to receiving an access request for a particular test container, querying the container snoop lookup table to determine a status of the particular test container;
in response to the status of the particular test receptacle being closed:
activating the specific test receptacle, and
updating the state in the container listening look-up table corresponding to the specific test container to be active and updating the corresponding last access time to be the current time; and
routing the access to the particular test receptacle.
9. The apparatus of claim 8, wherein the access module is further configured to: in response to the status of the particular test container being active, updating a last access time in the container snoop lookup table corresponding to the particular test container to a current time.
10. The apparatus of claim 8, wherein the access module is further configured to: after routing access to the particular test container, updating a last access time in the container snoop lookup table corresponding to the particular test container to a current time in response to each operation on the particular test container.
11. The apparatus of claim 8, further comprising a creation module configured to:
receiving a creation request for creating a test container, wherein the creation request comprises a container address, a selection of a test environment image and an application to be tested;
packaging the selected test environment mirror image and the application to be tested to create a test container; and
adding an entry for the created test container to the container snoop look-up table, wherein a corresponding timeout time is set to a predetermined time, a corresponding state is set to off, and a last access time is set to a current time.
12. The apparatus of claim 11, wherein the create request further comprises a timeout time, and wherein the create module is further configured to set the timeout time in the corresponding entry in the container snoop lookup table to the timeout time in the create request instead of the predetermined time.
13. The apparatus of claim 11, wherein the creation module is further configured to: after a test container is created, the test container is started and the state in the corresponding entry in the container snoop lookup table is set to active.
14. The apparatus of claim 8, further comprising a reduction module to:
and accessing the test container lookup table at a specified time interval, and closing the test containers which are not operated beyond the response time in the test containers with the corresponding states as activities.
15. An electronic device for managing a test environment based on container technology, comprising:
one or more processors;
a storage device for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method recited in any of claims 1-7.
16. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN201710232336.4A 2017-04-11 2017-04-11 Method and device for managing test environment based on container technology Active CN108694117B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710232336.4A CN108694117B (en) 2017-04-11 2017-04-11 Method and device for managing test environment based on container technology

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710232336.4A CN108694117B (en) 2017-04-11 2017-04-11 Method and device for managing test environment based on container technology

Publications (2)

Publication Number Publication Date
CN108694117A CN108694117A (en) 2018-10-23
CN108694117B true CN108694117B (en) 2021-10-01

Family

ID=63842425

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710232336.4A Active CN108694117B (en) 2017-04-11 2017-04-11 Method and device for managing test environment based on container technology

Country Status (1)

Country Link
CN (1) CN108694117B (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109491762B (en) * 2018-11-09 2021-07-09 网易(杭州)网络有限公司 Container state control method and device, storage medium and electronic equipment
CN109542791B (en) * 2018-11-27 2019-11-29 湖南智擎科技有限公司 A kind of program large-scale concurrent evaluating method based on container technique
CN110083535A (en) * 2019-04-22 2019-08-02 网宿科技股份有限公司 A kind of method for testing software and device
CN110535717B (en) * 2019-08-16 2021-10-15 济南浪潮数据技术有限公司 Container detection method and device
CN110647469B (en) * 2019-09-24 2023-09-08 广州荔支网络技术有限公司 Micro-service testing method and device, computer equipment and storage medium
CN110838953B (en) * 2019-11-01 2021-08-17 北京字节跳动网络技术有限公司 Test method, test system, electronic equipment and storage medium
CN110851167B (en) * 2019-11-15 2022-06-10 腾讯科技(深圳)有限公司 Container environment updating method, device, equipment and storage medium
CN112346817A (en) * 2020-10-20 2021-02-09 北京健康之家科技有限公司 Container starting method and device, storage medium and computer equipment
CN112035221B (en) * 2020-11-03 2021-01-26 江苏苏宁银行股份有限公司 PaaS platform invalid container cleaning method and system based on timing scheduling
CN112532473B (en) * 2020-11-12 2023-09-01 苏宁金融科技(南京)有限公司 DNS-based multi-environment test access method and device
CN112559325B (en) * 2020-12-02 2024-02-23 海南车智易通信息技术有限公司 Application program testing system, method, computing device and readable storage medium
CN112650556A (en) * 2020-12-25 2021-04-13 芜湖雄狮汽车科技有限公司 Multitask concurrent testing method and device for vehicle
CN113347043B (en) * 2021-06-25 2022-11-22 武汉悦学帮网络技术有限公司 Gateway management method, device, gateway management platform and storage medium
CN113377665A (en) * 2021-06-25 2021-09-10 北京百度网讯科技有限公司 Container technology-based testing method and device, electronic equipment and storage medium
US11650860B2 (en) * 2021-08-02 2023-05-16 Dell Products L.P. Managing services across containers
CN114070883B (en) * 2021-11-12 2023-03-24 腾讯科技(深圳)有限公司 Test resource access method and device, electronic equipment and storage medium
CN114338388A (en) * 2021-12-31 2022-04-12 广东睿江云计算股份有限公司 LXC-based wireless CPE factory configuration method, device, equipment and medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106341438A (en) * 2015-07-10 2017-01-18 阿里巴巴集团控股有限公司 Request processing method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8862940B2 (en) * 2012-02-14 2014-10-14 Microsoft Corporation Integrated fuzzing

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106341438A (en) * 2015-07-10 2017-01-18 阿里巴巴集团控股有限公司 Request processing method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于Docker的跨主机容器集群自动伸缩设计与实现;肖俊;《中国优秀硕士学位论文全文数据库》;20160615(第06期);第l139-55页 *

Also Published As

Publication number Publication date
CN108694117A (en) 2018-10-23

Similar Documents

Publication Publication Date Title
CN108694117B (en) Method and device for managing test environment based on container technology
CN107566541B (en) Container network resource allocation method, system, storage medium and electronic device
US10341251B2 (en) Method and system for securely transmitting volumes into cloud
CN107534571B (en) Method, system and computer readable medium for managing virtual network functions
US9910765B2 (en) Providing testing environments for software applications using virtualization and a native hardware layer
US7823023B2 (en) Test framework for testing an application
US8671403B2 (en) Pre-creating virtual machines in a grid environment
US8151033B2 (en) Mechanism for virtual logical volume management
US11163669B1 (en) Measuring test coverage during phased deployments of software updates
US10416996B1 (en) System and method for translating affliction programming interfaces for cloud platforms
US9348646B1 (en) Reboot-initiated virtual machine instance migration
US9256463B2 (en) Method and apparatus to replicate stateful virtual machines between clouds
US8423734B2 (en) Making automated use of data volume copy service targets
US9130943B1 (en) Managing communications between client applications and application resources of on-premises and cloud computing nodes
US20180097791A1 (en) Method and system for securely transmitting volumes into cloud
JP2011233146A (en) Cloud platform architecture
US20190281112A1 (en) System and method for orchestrating cloud platform operations
CN108089913A (en) A kind of virtual machine deployment method of super emerging system
US11055108B2 (en) Network booting in a peer-to-peer environment using dynamic magnet links
CN108073423A (en) A kind of accelerator loading method, system and accelerator loading device
US10509688B1 (en) System and method for migrating virtual machines between servers
CN112468545A (en) Cloud host creation method, device, system, equipment and readable storage medium
CN109426544A (en) Virtual machine deployment method and device
US11762644B2 (en) Agentless installation for building deployments
Nielsen et al. Private cloud configuration with metaconfig

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant