CN114860577A - Test method, test device, readable medium and electronic equipment - Google Patents

Test method, test device, readable medium and electronic equipment Download PDF

Info

Publication number
CN114860577A
CN114860577A CN202210346576.8A CN202210346576A CN114860577A CN 114860577 A CN114860577 A CN 114860577A CN 202210346576 A CN202210346576 A CN 202210346576A CN 114860577 A CN114860577 A CN 114860577A
Authority
CN
China
Prior art keywords
directory
container
test
host machine
mapping
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.)
Withdrawn
Application number
CN202210346576.8A
Other languages
Chinese (zh)
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 Jindi Technology Co Ltd
Original Assignee
Beijing Jindi 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 Jindi Technology Co Ltd filed Critical Beijing Jindi Technology Co Ltd
Priority to CN202210346576.8A priority Critical patent/CN114860577A/en
Publication of CN114860577A publication Critical patent/CN114860577A/en
Withdrawn legal-status Critical Current

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/362Software debugging

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Test And Diagnosis Of Digital Computers (AREA)

Abstract

The disclosure relates to the technical field of Docker containers, in particular to a testing method, a testing device, a readable medium and electronic equipment. According to the testing method, when a basic mirror image is constructed, port numbers and directories of a host machine which are mapped with a container are deployed, wherein the directories comprise a testing directory used for storing a testing file and a configuration directory used for storing a container configuration file. When the test code needs to be modified or a new test code needs to be tested, the test code under the test directory of the host machine can be directly modified, or the original test code is replaced by the new test code under the test directory of the host machine, so that the test code running in the container can be changed, the test code can be debugged, and the new test code can be tested without reconstructing the container. Therefore, adopt this technical scheme who openly provides to test, convenient to use, labour saving and time saving.

Description

Test method, test device, readable medium and electronic equipment
Technical Field
The disclosure relates to the technical field of Docker containers, in particular to a test method, a test device, a readable medium and electronic equipment.
Background
Docker is an open-source application container engine, and aims to provide an automatic application deployment solution, which enables developers to package their applications and dependency packages into a portable container, namely a lightweight virtual machine. In the prior art, when testing by using the Docker technology, test codes and dependency packages are generally packaged and encapsulated into a container. Therefore, the following problems exist in using the solutions provided by the prior art for code testing: after the container is created, the test code cannot be modified, and cannot be debugged, so that the use is inconvenient; when a new test code needs to be tested, the new test code needs to be packaged, and a new container needs to be constructed, which is time-consuming and labor-consuming.
Disclosure of Invention
The purpose of the present disclosure is to provide a testing method, apparatus, readable medium and electronic device, which have solved the problem that after a container is created, a test code cannot be modified, the test code cannot be debugged, and the use is inconvenient; and when a new test code needs to be tested, the new test code needs to be packaged to construct a new container, which is time-consuming and labor-consuming.
In order to achieve the above object, the present disclosure provides a test method, the method including:
constructing a basic mirror image, wherein the basic mirror image comprises a basic environment for container operation, the basic environment comprises a port number and a directory for mapping a host machine and a container, the directory comprises a test directory and a configuration directory, the test directory is used for storing a test file, and the configuration directory is used for storing a configuration file of the container;
copying a test file to the test directory of the host machine, mapping the port number of the host machine and the port number of the container, mapping the directory of the host machine and the directory of the container, and starting the container to test to obtain a test result of the test file;
wherein the mapping the directory of the host machine and the directory of the container comprises: and mapping the test directory of the host machine and the test directory of the container, and mapping the configuration directory of the host machine and the configuration directory of the container.
Optionally, there are at least two test files, the basic mirror image includes at least two basic environments in which the containers operate, each container corresponds to the test file one to one, and the basic environments include a port number and a directory of the host machine that are mapped with each container;
the step of copying the test file to the test directory of the host machine, mapping the port number of the host machine and the port number of the container, mapping the test directory of the host machine and the test directory of the container, and starting the container to test to obtain the test result of the test file comprises the following steps: copying each test file to a target test directory of the host machine, mapping each port number of the host machine with the port number of each container, mapping each directory of the host machine with the directory of each container, and starting the container corresponding to each test file to test to obtain a test result of each test file, wherein the target test directory is the test directory mapped to the host machine by the container corresponding to each test file;
wherein the step of mapping each directory of the host with the directory of each container comprises: and mapping each test directory of the host machine and the test directory of each container, and mapping each configuration directory of the host machine and the configuration directory of each container.
Optionally, the configuration file includes: the mapping relation between the port number of the host machine corresponding to the container and the container domain name, wherein the container domain name is a domain name used for accessing the container; the method further comprises the following steps:
and the container domain name is proxied to the IP address of the host machine, so that a tester can access the host machine through the container domain name.
Optionally, the directory further includes a log directory for storing a log file generated by the container running the test file;
the step of mapping the directory of the host machine with the directory of the container further comprises: and mapping the log directory of the host machine and the log directory of the container.
The embodiment of the present disclosure further provides a testing apparatus, which includes:
the system comprises a mirror image construction module, a base mirror image construction module and a storage module, wherein the mirror image construction module is used for constructing a base mirror image, the base mirror image comprises a base environment for container operation, the base environment comprises a port number and a directory for mapping a host machine and a container, the directory comprises a test directory and a configuration directory, the test directory is used for storing a test file, and the configuration directory is used for storing a configuration file of the container;
the container testing module is used for copying a test file to the test directory of the host machine, mapping the port number of the host machine and the port number of the container, mapping the directory of the host machine and the directory of the container, and starting the container to test to obtain a test result of the test file;
wherein the mapping the directory of the host machine and the directory of the container comprises: and mapping the test directory of the host machine and the test directory of the container, and mapping the configuration directory of the host machine and the configuration directory of the container.
Optionally, there are at least two test files, the basic mirror image includes at least two basic environments in which the containers operate, each container corresponds to the test file one to one, and the basic environments include a port number and a directory of the host machine that are mapped with each container;
the container testing module is further configured to copy each test file to a target testing directory of the host machine, map each port number of the host machine with a port number of each container, map each directory of the host machine with a directory of each container, and start the container corresponding to each test file to perform testing, so as to obtain a testing result of each test file, where the target testing directory is a testing directory in which the container corresponding to each test file is mapped to the host machine;
wherein mapping each directory of the host with the directory of each container comprises: and mapping each test directory of the host machine and the test directory of each container, and mapping each configuration directory of the host machine and the configuration directory of each container.
Optionally, the configuration file includes: the mapping relation between the port number of the host machine corresponding to the container and the container domain name, wherein the container domain name is a domain name used for accessing the container; the test device further comprises:
and the proxy module is used for proxying the container domain name to the IP address of the host machine so that a tester can access the host machine through the container domain name.
Optionally, the directory further includes a log directory for storing a log file generated by the container running the test file;
the mapping the directory of the host machine and the directory of the container further comprises: and mapping the log directory of the host machine and the log directory of the container.
Embodiments of the present disclosure also provide a non-transitory computer-readable storage medium having stored thereon a computer program that, when executed by a processor, implements the steps of the above-described method.
An embodiment of the present disclosure further provides an electronic device, including:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to implement the steps of the above method.
According to the technical scheme, when the basic mirror image is constructed, the port number and the directory which are mapped with the container of the host are deployed, and the directory comprises a test directory for storing the test file and a configuration directory for storing the container configuration file. When the test code needs to be modified or a new test code needs to be tested, the test code under the test directory of the host machine can be directly modified, or the original test code is replaced by the new test code under the test directory of the host machine, so that the test code for operating the container can be changed. Therefore, by the technical scheme, debugging of the test codes and testing of the new test codes are realized without reconstructing the container. Therefore, the test is carried out through the technical scheme, the use is convenient, and the time and the labor are saved.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the disclosure without limiting the disclosure. In the drawings:
fig. 1 is a flowchart of a testing method provided in an embodiment of the present disclosure.
Fig. 2 is a diagram of a directory deployment structure of a host according to an embodiment of the present disclosure.
Fig. 3 is a block diagram of a testing apparatus according to an embodiment of the disclosure.
Fig. 4 is a block schematic diagram of an electronic device provided in an embodiment of the present disclosure.
Detailed Description
The following detailed description of specific embodiments of the present disclosure is provided in connection with the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating the present disclosure, are given by way of illustration and explanation only, not limitation.
It should be noted that all actions of acquiring signals, information or data in the present disclosure are performed under the premise of complying with the corresponding data protection regulation policy of the country of the location and obtaining the authorization given by the owner of the corresponding device.
The embodiment of the disclosure provides a test method. FIG. 1 is a flow chart illustrating a testing method according to an embodiment of the present disclosure. As shown in fig. 1, the method comprises the steps of:
step S10, constructing a basic mirror image, wherein the basic mirror image comprises a basic environment for container operation, the basic environment comprises a port number and a directory for a host machine to map with the container, the directory comprises a test directory and a configuration directory, the test directory is used for storing test files, and the configuration directory is used for storing configuration files of the container.
In specific implementation, a basic image, such as imageX, of a container (test case) operation is constructed, and a root directory is planned and deployed, for example: and/home/work/contacts. Contract host directory (for mapping with container directory), for example: com/8001. Where 8001 is the port number that the container maps to the host. The host machine directory comprises a test directory and a host machine configuration directory. The test directory of the host is used for mapping with the test directory of the container, and is used for storing a test file (static resource), such as/home/work/contacts/om 2.tyqf.com/8001/web. Similarly, the configuration directory of the host is used for mapping with the configuration directory of the container, and is used for storing a configuration file of the container, such as nginx configuration inside the container, for example,/home/work/contacts/om 2. tyqf.com/8001/conf. The internal structure of the host may be as shown in fig. 2.
Step S20, copying the test file to the test directory of the host machine, mapping the port number of the host machine and the port number of the container, mapping the directory of the host machine and the directory of the container, and starting the container to test to obtain the test result of the test file.
Wherein the mapping the directory of the host machine and the directory of the container comprises: and mapping the test directory of the host machine and the test directory of the container, and mapping the configuration directory of the host machine and the configuration directory of the container.
For more clarity of the description of step S20, following the example of step S10, step S20 is: deploying a test file (test case resource) to a test directory (/ home/work/contacts/om 2.tyqf.com/8001/web) of a host machine; and mapping the port number of the host machine and the port number of the container by adopting the following codes, mapping the test directory of the host machine and the test directory of the container, mapping the configuration directory of the host machine and the configuration directory of the container, and starting the container for testing to obtain the test result of the test file.
docker run-d--name om-tyqf-com-8001-p 8001:80
-v/home/work/containers/om2.tyqf.com/conf:/home/jindi/tyfw/nginx/default.d
-v/home/work/containers/om2.tyqf.com/8001/web:/home/jindi/data/wwwimageX:latest
According to the technical scheme, when the basic mirror image is constructed, the port number and the directory which are mapped with the container of the host are deployed, and the directory comprises a test directory for storing the test file and a configuration directory for storing the container configuration file. When the test code needs to be modified or a new test code needs to be tested, the test code under the test directory of the host machine can be directly modified, or the original test code is replaced by the new test code under the test directory of the host machine, so that the test code for operating the container can be changed. Therefore, by the technical scheme, debugging of the test codes and testing of new test codes are realized without reconstructing a container. Therefore, the test is carried out through the technical scheme, the use is convenient, and the time and the labor are saved.
Referring again to fig. 2, in order to analyze the test result, optionally, the directory further includes a log directory for storing a log file generated by the container running the test file. In step S20, the step of mapping the directory of the host with the directory of the container further includes: and mapping the log directory of the host machine and the log directory of the container.
The log directory of the host is used for mapping with the log directory of the container, and is used for storing a log file generated by the container running the test file, such as/home/work/contacts/om 2. tyqf.com/8001/logs. The code for step S20 to initiate the container for testing is as follows:
docker run-d--name om-tyqf-com-8001-p 8001:80
-v/home/work/containers/om2.tyqf.com/conf:/home/jindi/tyfw/nginx/default.d
-v/home/work/containers/om2.tyqf.com/8001/web:/home/jindi/data/www
-v/home/work/containers/om2.tianyanqifu.com/8001/logs:/home/jindi/tyfw/logsimageX:latest
through the technical scheme, the log directory is arranged to store the log file generated by the container running test file, so that a user can conveniently analyze and check the test result.
Based on the technical scheme, a plurality of (at least two) test files can be tested in parallel, and based on the basic mirror image, a plurality of containers can be constructed, the containers are used for operating the test files, and each container corresponds to the test file one to one.
Step S10 is: and constructing a basic mirror image, wherein the basic mirror image comprises at least two basic environments in which the containers run, each container corresponds to the test file one by one, and the basic environments comprise port numbers and catalogs of the host machine, which are mapped with each container.
For example, assuming that there are 3 test files, 3 containers are required when the 3 test files are tested in parallel. Step S10 includes: building a base image of the container (test case) operation, such as imageX, and planning deployment of a root directory, for example: and/home/work/contacts. When the 3 test files are 3 code branches of a project, the deployment directory of the project can be planned to be/home/work/contacts/om 2. tyqf.com. The deployment directory structure for this project is shown in FIG. 2: 8001. 8002, 8003 are port numbers of the host to which 3 containers are mapped, respectively. The directories of the 3 containers mapped to the host are respectively: com/8001,/home/work/contacts/om 2.tyqf.com/8002,/home/work/contacts/om 2. tyqf.com/8003. The test directory of the host mapped by the test directory of the 3 containers is used for storing each test file, for example: com/8001/web,/home/work/contacts/om 2.tyqf.com/8002/web,/home/work/contacts/om 2. tyqf.com/8003/web. The configuration directories of the hosts mapped by the configuration directories of the 3 containers are respectively used for storing the configuration files of the containers, and the configuration files are, for example: com/8001/conf,/home/work/associates/om 2.tyqf.com/8002/conf,/home/work/associates/om 2. tyqf.com/8003/conf.
Similarly, in order to analyze the test result, optionally, the directory further includes a log directory for storing a log file generated by each container running each test file. Then, the log directory of the host mapped by the log directory of 3 containers is used to store the log file generated by each container running each test file, for example: com/8001/logs,/home/work/associates/om 2. tyqf.com/8002/logs,/home/work/associates/om 2. tyqf.com/8003/logs.
Step S20 is: copying each test file to a target test directory of the host machine, mapping each port number of the host machine and the port number of each container, mapping each directory of the host machine and the directory of each container, and starting the container corresponding to each test file to test to obtain a test result of each test file, wherein the target test directory maps the container corresponding to each test file to the test directory of the host machine.
Wherein the step of mapping each directory of the host with the directory of each container comprises: and mapping each test directory of the host machine and the test directory of each container, and mapping each configuration directory of the host machine and the configuration directory of each container.
To illustrate step S20 more clearly, following the example of step S10, step S20 is: 3 test files (test case resources) are respectively deployed under 3 test directories (/ home/work/associates/om 2.tyqf.com/8001/web,/home/work/associates/om 2.tyqf.com/8002/web,/home/work/associates/om 2.tyqf.com/8003/web) of the host computer; mapping each port number of the host machine with the port number of each container, mapping each test directory of the host machine with the test directory of each container, mapping each configuration directory of the host machine with the configuration directory of each container, and starting the containers for testing to obtain the test result of the test file (the code is the same as the code, and is omitted here).
Similarly, in order to analyze the test result, when the directory further includes a log directory for storing a log file generated by the container running the test file, in step S20, the step of mapping each directory of the host with the directory of each container further includes: and mapping each log directory of the host machine with the log directory of each container.
Through the technical scheme, when the basic mirror image is constructed, the port number and the directory of the host machine mapped by the containers are deployed, each container corresponds to the test file, each test file is copied to the target test directory of the host machine, the container corresponding to each test file is started to test, and the test result of each test file can be obtained. In the prior art, when testing a plurality of test files, a mirror image is constructed for each test file, and a container is constructed based on each mirror image and each test file. According to the technical scheme provided by the disclosure, when a plurality of test files are tested, only one basic mirror image is constructed, and a plurality of containers are constructed on the basis of the basic mirror image and the plurality of test files. Therefore, compared with the prior art, the technical scheme provided by the disclosure can share hardware resources, and the hardware cost expenditure can be reduced along with the increase of the test files.
Optionally, the configuration file includes: and the port number of the host machine corresponding to the container is in a mapping relation with a container domain name, and the container domain name is a domain name used for accessing the container. The method further comprises the following steps: and the container domain name is proxied to the IP address of the host machine, so that a tester can access the host machine through the container domain name.
For example, three container domain names, such as om2.test1.tyqf.com, om2.test2.tyqf.com, and om2.test3.tyqf.com, can be mapped to ports 8001, 8002, 8003 of the host, respectively, for the above-mentioned 3 containers by configuring the nginx reverse proxy. Proxy 3 container domain names om2.test1.tyqf.com, om2.test2.tyqf.com, om2.test3.tyqf.com to the IP address of the host.
By the technical scheme, each container domain name is mapped with each port of the host machine, and each container domain name is proxied to the IP address of the host machine. The tester can access the host machine through the container domain name, after the host machine receives the access request, the host machine can access the service provided by the container according to the port number of the host machine through the corresponding relation between the port number of the host machine and the container according to the port number of the host machine, and the test file is tested to obtain the test result.
Based on the inventive concept, the embodiment of the disclosure further provides a testing device. FIG. 3 is a block diagram illustrating a testing device according to an embodiment of the present disclosure. As shown in fig. 3, the test apparatus includes:
the mirror image building module 10 is configured to build a basic mirror image, where the basic mirror image includes a basic environment in which a container operates, the basic environment includes a port number and a directory, where the host and the container are mapped, the directory includes a test directory and a configuration directory, the test directory is used to store a test file, and the configuration directory is used to store a configuration file of the container.
The container testing module 20 is configured to copy a test file to the test directory of the host, map the port number of the host with the port number of the container, map the directory of the host with the directory of the container, and start the container to test to obtain a test result of the test file.
Wherein the mapping the directory of the host machine and the directory of the container comprises: and mapping the test directory of the host machine and the test directory of the container, and mapping the configuration directory of the host machine and the configuration directory of the container.
According to the technical scheme, when the basic mirror image is constructed, the port number and the directory which are mapped with the container of the host are deployed, and the directory comprises a test directory for storing the test file and a configuration directory for storing the container configuration file. When the test code needs to be modified or a new test code needs to be tested, the test code under the test directory of the host machine can be directly modified, or the original test code is replaced by the new test code under the test directory of the host machine, so that the test code for operating the container can be changed. Therefore, by the technical scheme, debugging of the test codes and testing of the new test codes are realized without reconstructing the container. Therefore, the test is carried out through the technical scheme, the use is convenient, and the time and the labor are saved.
In order to analyze the test result, optionally, the directory further includes a log directory for storing a log file generated by the container running the test file. The mapping the directory of the host machine and the directory of the container further comprises: and mapping the log directory of the host machine and the log directory of the container.
Through the technical scheme, the log directory is arranged to store the log file generated by the container running test file, so that a user can conveniently analyze and check the test result.
Based on the above technical solution, optionally, a plurality of (at least two) test files may also be tested in parallel, and based on the basic mirror image, a plurality of containers may be constructed, the plurality of containers are used to run the plurality of test files, and each of the containers corresponds to the test file one to one.
At this time, the image construction module is specifically configured to construct a basic image, where the basic image includes at least two basic environments in which the containers operate, each container corresponds to the test file one to one, and the basic environment includes a port number and a directory of the host machine, which are mapped to each container.
Similarly, in order to analyze the test result, optionally, the directory further includes a log directory for storing a log file generated by the container running the test file.
At this time, the container testing module is specifically configured to copy each test file to a target testing directory of the host machine, map each port number of the host machine with a port number of each container, map each directory of the host machine with a directory of each container, and start the container corresponding to each test file to perform testing, so as to obtain a testing result of each test file, where the target testing directory is a directory in which the container corresponding to each test file is mapped to the testing directory of the host machine.
Wherein mapping each directory of the host with the directory of each container comprises: and mapping each test directory of the host machine and the test directory of each container, and mapping each configuration directory of the host machine and the configuration directory of each container.
Similarly, in order to analyze the test result, when the directory further includes a log directory for storing a log file generated by the container running the test file, the step of mapping each directory of the host with the directory of each container further includes: and mapping each log directory of the host machine with the log directory of each container.
Through the technical scheme, when the basic mirror image is constructed, the port number and the directory of the host machine mapped by the containers are deployed, each container corresponds to the test file, each test file is copied to the target test directory of the host machine, the container corresponding to each test file is started to test, and the test result of each test file can be obtained. In the prior art, when testing a plurality of test files, a mirror image is constructed for each test file, and a container is constructed based on each mirror image and each test file. According to the technical scheme provided by the disclosure, when a plurality of test files are tested, only one basic mirror image is constructed, and a plurality of containers are constructed on the basis of the basic mirror image and the plurality of test files. Therefore, compared with the prior art, the technical scheme provided by the disclosure can share hardware resources, and the hardware cost expenditure can be reduced along with the increase of the test files.
Optionally, the configuration file includes: and the port number of the host machine corresponding to the container is in a mapping relation with a container domain name, and the container domain name is a domain name used for accessing the container. The test device further comprises: and the proxy module is used for proxying the container domain name to the IP address of the host machine so that a tester can access the host machine through the container domain name.
By the technical scheme, each container domain name is mapped with each port of the host machine, and each container domain name is proxied to the IP address of the host machine. The tester can access the host machine through the container domain name, after the host machine receives the access request, the host machine can access the service provided by the container according to the port number of the host machine through the corresponding relation between the port number of the host machine and the container according to the port number of the host machine, and the test file is tested to obtain the test result.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 4 is a block diagram illustrating an electronic device 1900 according to an example embodiment. For example, the electronic device 1900 may be provided as a server. Referring to fig. 4, an electronic device 1900 includes a processor 1922, which may be one or more in number, and a memory 1932 for storing computer programs executable by the processor 1922. The computer program stored in memory 1932 may include one or more modules that each correspond to a set of instructions. Further, the processor 1922 may be configured to execute the computer program to perform the testing method described above.
Additionally, electronic device 1900 may also include a power component 1926 and a communication component 1950, the power component 1926 may be configured to perform power management of the electronic device 1900, and the communication component 1950 may be configured to enable communication, e.g., wired or wireless communication, of the electronic device 1900. In addition, the electronic device 1900 may also include input/output (I/O) interfaces 1958. The electronic device 1900 may operate based on an operating system, such as Windows Server, stored in memory 1932 TM ,Mac OS X TM ,Unix TM ,Linux TM And so on.
In another exemplary embodiment, a computer readable storage medium comprising program instructions which, when executed by a processor, implement the steps of the test method described above is also provided. For example, the non-transitory computer readable storage medium may be the memory 1932 described above that includes program instructions executable by the processor 1922 of the electronic device 1900 to perform the testing methods described above.
In another exemplary embodiment, a computer program product is also provided, which comprises a computer program executable by a programmable apparatus, the computer program having code portions for performing the above-mentioned test method when executed by the programmable apparatus.
The preferred embodiments of the present disclosure are described in detail with reference to the accompanying drawings, however, the present disclosure is not limited to the specific details of the above embodiments, and various simple modifications may be made to the technical solution of the present disclosure within the technical idea of the present disclosure, and these simple modifications all belong to the protection scope of the present disclosure.
It should be noted that, in the foregoing embodiments, various features described in the above embodiments may be combined in any suitable manner, and in order to avoid unnecessary repetition, various combinations that are possible in the present disclosure are not described again.
In addition, any combination of various embodiments of the present disclosure may be made, and the same should be considered as the disclosure of the present disclosure, as long as it does not depart from the spirit of the present disclosure.

Claims (10)

1. A method of testing, the method comprising:
constructing a basic mirror image, wherein the basic mirror image comprises a basic environment for container operation, the basic environment comprises a port number and a directory for mapping a host machine and a container, the directory comprises a test directory and a configuration directory, the test directory is used for storing a test file, and the configuration directory is used for storing a configuration file of the container;
copying a test file to the test directory of the host machine, mapping the port number of the host machine and the port number of the container, mapping the directory of the host machine and the directory of the container, and starting the container to test to obtain a test result of the test file;
wherein the mapping the directory of the host machine and the directory of the container comprises: and mapping the test directory of the host machine and the test directory of the container, and mapping the configuration directory of the host machine and the configuration directory of the container.
2. The test method according to claim 1, wherein there are at least two test files, the base image includes at least two base environments in which the containers operate, each container corresponds to the test file one by one, and the base environments include port numbers and directories of the hosts that map with each container;
the step of copying the test file to the test directory of the host machine, mapping the port number of the host machine and the port number of the container, mapping the test directory of the host machine and the test directory of the container, and starting the container to test to obtain the test result of the test file comprises the following steps: copying each test file to a target test directory of the host machine, mapping each port number of the host machine with the port number of each container, mapping each directory of the host machine with the directory of each container, and starting the container corresponding to each test file to test to obtain a test result of each test file, wherein the target test directory is the test directory mapped to the host machine by the container corresponding to each test file;
wherein the step of mapping each directory of the host with the directory of each container comprises: and mapping each test directory of the host machine and the test directory of each container, and mapping each configuration directory of the host machine and the configuration directory of each container.
3. The test method according to claim 1 or 2, wherein the configuration file comprises: the mapping relation between the port number of the host machine corresponding to the container and the container domain name, wherein the container domain name is a domain name used for accessing the container; the method further comprises the following steps:
and the container domain name is proxied to the IP address of the host machine, so that a tester can access the host machine through the container domain name.
4. The testing method according to claim 1 or 2, wherein the directory further comprises a log directory for storing a log file generated by the container running the test file;
the step of mapping the directory of the host machine with the directory of the container further comprises: and mapping the log directory of the host machine and the log directory of the container.
5. A test apparatus, characterized in that the test apparatus comprises:
the system comprises a mirror image construction module, a base mirror image construction module and a storage module, wherein the mirror image construction module is used for constructing a base mirror image, the base mirror image comprises a base environment for container operation, the base environment comprises a port number and a directory for mapping a host machine and a container, the directory comprises a test directory and a configuration directory, the test directory is used for storing a test file, and the configuration directory is used for storing a configuration file of the container;
the container testing module is used for copying a test file to the test directory of the host machine, mapping the port number of the host machine and the port number of the container, mapping the directory of the host machine and the directory of the container, and starting the container to test to obtain a test result of the test file;
wherein the mapping the directory of the host machine and the directory of the container comprises: and mapping the test directory of the host machine and the test directory of the container, and mapping the configuration directory of the host machine and the configuration directory of the container.
6. The testing device according to claim 5, wherein there are at least two of the testing files, the base image includes at least two base environments in which the containers operate, each container corresponds to one of the testing files, and the base environments include port numbers and directories of the hosts that map with each container;
the container testing module is further configured to copy each test file to a target testing directory of the host machine, map each port number of the host machine with a port number of each container, map each directory of the host machine with a directory of each container, and start the container corresponding to each test file to perform testing, so as to obtain a testing result of each test file, where the target testing directory is a testing directory in which the container corresponding to each test file is mapped to the host machine;
wherein mapping each directory of the host with the directory of each container comprises: and mapping each test directory of the host machine and the test directory of each container, and mapping each configuration directory of the host machine and the configuration directory of each container.
7. The testing device of claim 5 or 6, wherein the configuration file comprises: the mapping relation between the port number of the host machine corresponding to the container and the container domain name, wherein the container domain name is a domain name used for accessing the container; the test device further comprises:
and the proxy module is used for proxying the container domain name to the IP address of the host machine so that a tester can access the host machine through the container domain name.
8. The testing device of claim 5 or 6, wherein the directory further comprises a log directory for storing log files generated by the container running the test files;
the mapping the directory of the host machine and the directory of the container further comprises: and mapping the log directory of the host machine and the log directory of the container.
9. A non-transitory computer readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 4.
10. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 1 to 4.
CN202210346576.8A 2022-03-31 2022-03-31 Test method, test device, readable medium and electronic equipment Withdrawn CN114860577A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210346576.8A CN114860577A (en) 2022-03-31 2022-03-31 Test method, test device, readable medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210346576.8A CN114860577A (en) 2022-03-31 2022-03-31 Test method, test device, readable medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN114860577A true CN114860577A (en) 2022-08-05

Family

ID=82628728

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210346576.8A Withdrawn CN114860577A (en) 2022-03-31 2022-03-31 Test method, test device, readable medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN114860577A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116126737A (en) * 2023-04-11 2023-05-16 阿里云计算有限公司 Container testing method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
RICKY饭团: "docker容器中的nginx反向代理宿主机", pages 1 - 2, Retrieved from the Internet <URL:https://www.jianshu.com/p/31407c286214> *
WALDENZ: "docker run -v 挂载数据卷", pages 1, Retrieved from the Internet <URL:https://blog.csdn.net/enter89/article/details/90295701> *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116126737A (en) * 2023-04-11 2023-05-16 阿里云计算有限公司 Container testing method and device
CN116126737B (en) * 2023-04-11 2023-09-26 阿里云计算有限公司 Container testing method and device

Similar Documents

Publication Publication Date Title
CN106326088B (en) Method and device for realizing construction of test object and device for realizing service configuration test
CN106502905A (en) A kind of method of testing of application program, apparatus and system
US9348771B1 (en) Cloud-based instrument driver system
WO2019085290A1 (en) Test preparation method and apparatus, terminal device, and storage medium
KR102274178B1 (en) Emulating test distributed application on server
CN109683997B (en) Method for accessing application program interface through sandbox, sandbox and sandbox equipment
CN112395039A (en) Management method and device for Kubernetes cluster
US9645874B2 (en) Analyzing OpenManage integration for troubleshooting log to determine root cause
CN113037891B (en) Access method and device for stateful application in edge computing system and electronic equipment
CN116610332A (en) Cloud storage deployment method and device and readable storage medium
CN114860577A (en) Test method, test device, readable medium and electronic equipment
CN112769706A (en) Componentized routing method and system
CN117270873A (en) Real-time compiling method, device, equipment and medium based on Android application
CN117573338A (en) Resource allocation method and device and electronic equipment
CN117041111A (en) Vehicle cloud function test method and device, electronic equipment and storage medium
CN111683091A (en) Method, device, equipment and storage medium for accessing cloud host console
CN104683178B (en) A kind of test method and system of the more DUT of identical IP address
CN110764959A (en) Deployment method and device of test environment of server
CN115686535A (en) Inspection method and device for Kubernets cluster and application
CN114116030A (en) Operating system running method and device, electronic equipment and storage medium
CN114756435A (en) Log reading method, server, computer device and storage medium
CN113918423A (en) Cloud platform monitoring method and device and application thereof
CN113704120A (en) Data transmission method, device, equipment and storage medium
CN113760442A (en) Application running and accessing method, device and equipment
CN111082984A (en) Method and device for simulating login of network equipment to carry out command line interaction

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
WW01 Invention patent application withdrawn after publication
WW01 Invention patent application withdrawn after publication

Application publication date: 20220805