CN111338945A - Method and device for building test environment - Google Patents
Method and device for building test environment Download PDFInfo
- Publication number
- CN111338945A CN111338945A CN202010110817.XA CN202010110817A CN111338945A CN 111338945 A CN111338945 A CN 111338945A CN 202010110817 A CN202010110817 A CN 202010110817A CN 111338945 A CN111338945 A CN 111338945A
- Authority
- CN
- China
- Prior art keywords
- virtual machine
- target program
- directory
- development
- setting
- 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.)
- Pending
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 57
- 238000000034 method Methods 0.000 title claims abstract description 35
- 238000011161 development Methods 0.000 claims abstract description 47
- 230000001360 synchronised effect Effects 0.000 claims abstract description 37
- 241001425718 Vagrans egista Species 0.000 description 8
- 230000006870 function Effects 0.000 description 4
- 238000010586 diagram Methods 0.000 description 2
- 230000001133 acceleration Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3664—Environments for testing or debugging software
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)
- Debugging And Monitoring (AREA)
Abstract
The invention provides a method and a device for building a test environment, wherein the method comprises the following steps: creating a virtual machine for testing a target program on a host machine for developing the target program; determining a synchronization directory of the virtual machine; taking the synchronous catalog as a development catalog of the target program; and setting the host machine and the virtual machine to share the synchronous directory. The invention provides a method and a device for building a test environment, which can reduce problems generated during testing in the test environment.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for building a test environment.
Background
In the internet era, the importance of rapid product iteration is self-evident to every company enterprise, with each step of development, testing, and deployment being particularly important.
In the prior art, a development environment of a program and a test environment of the program often have many differences, and due to the differences, many problems exist when the test environment is tested.
Disclosure of Invention
The embodiment of the invention provides a method and a device for building a test environment, which can reduce the problems generated during testing in the test environment.
In a first aspect, an embodiment of the present invention provides a method for building a test environment, including:
creating a virtual machine for testing a target program on a host machine for developing the target program;
determining a synchronization directory of the virtual machine;
taking the synchronous catalog as a development catalog of the target program;
and setting the host machine and the virtual machine to share the synchronous directory.
Alternatively,
the taking the synchronization directory as a development directory of the target program includes:
and saving a development file for developing the target program into the synchronous directory.
Alternatively,
the method further comprises the following steps:
configuring a network of the virtual machines to a bridge mode.
Alternatively,
the method further comprises the following steps:
and setting the port of the host machine on the virtual machine.
Alternatively,
after the setting the port of the host machine on the virtual machine, further comprising:
when the port of the host machine receives an access request sent from the outside, the access request is sent to the virtual machine, so that the virtual machine responds to the access request.
In a second aspect, an embodiment of the present invention provides an apparatus for building a test environment, including:
the system comprises a creating module, a testing module and a control module, wherein the creating module is used for creating a virtual machine for testing a target program on a host machine for developing the target program;
the synchronous directory determining module is used for determining a synchronous directory of the virtual machine;
the development catalog setting module is used for setting the synchronous catalog as a development catalog of the target program;
and the sharing module is used for setting the host machine and the virtual machine to share the synchronous directory.
Alternatively,
and the development catalog setting module is used for storing a development file for developing the target program into the synchronous catalog.
Alternatively,
the apparatus further comprises:
and the network setting module is used for configuring the network of the virtual machine into a bridge mode.
Alternatively,
the apparatus further comprises:
and the port setting module is used for setting the port of the host machine on the virtual machine.
Alternatively,
the apparatus further comprises:
the request sending module is used for sending the access request to the virtual machine when the port of the host machine receives the access request sent from the outside so as to enable the virtual machine to respond to the access request.
In the embodiment of the invention, the test environment and the development environment are both on the same host, and the virtual machine and the host used for testing share one synchronous directory which is used as the development directory of the target program, that is, various files in the development process are stored in the synchronous directory, and when testing, the virtual machine can directly obtain the required files from the synchronous directory, thereby ensuring the consistency of the development environment and the test environment, greatly reducing the difference between the development environment and the test environment, and further greatly reducing the problems generated when testing in the test environment.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flow chart of a method for building a test environment according to an embodiment of the present invention;
FIG. 2 is a flow chart of another method for building a test environment according to an embodiment of the present invention;
fig. 3 is a schematic diagram of an apparatus for building a test environment according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer and more complete, the technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention, and based on the embodiments of the present invention, all other embodiments obtained by a person of ordinary skill in the art without creative efforts belong to the scope of the present invention.
As shown in fig. 1, an embodiment of the present invention provides a method for building a test environment, including:
step 101: creating a virtual machine for testing a target program on a host machine for developing the target program;
step 102: determining a synchronization directory of the virtual machine;
step 103: taking the synchronous catalog as a development catalog of the target program;
step 104: and setting the host machine and the virtual machine to share the synchronous directory.
In the embodiment of the invention, the test environment and the development environment are both on the same host, and the virtual machine and the host used for testing share one synchronous directory which is used as the development directory of the target program, that is, various files in the development process are stored in the synchronous directory, and when testing, the virtual machine can directly obtain the required files from the synchronous directory, thereby ensuring the consistency of the development environment and the test environment, greatly reducing the difference between the development environment and the test environment, and further greatly reducing the problems generated when testing in the test environment.
In the embodiment of the invention, the target program is developed on the host machine, and the target program is tested on the host machine, so that the consistency of the development environment and the test environment is ensured from a hardware level. The host machine and the virtual machine share the same synchronous directory, and the synchronous directory is also a development directory of a target program, so that the consistency of a development environment and a test environment is ensured in the aspect of a software environment.
In the embodiment of the present invention, in the process of creating a virtual machine, the following commands may be implemented: box ═ dev _ study.
The name of the virtual machine may be set by the following commands: vm, hostname is "for _ dev". When creating multiple virtual machines, it is necessary to identify each virtual machine by its name.
In the embodiment of the present invention, step 103 may be implemented by the following commands:
config.vm.synced_folder"E:/project-space","/vagrant_data"。
in an embodiment of the present invention, the taking the synchronization directory as the development directory of the target program includes:
and saving a development file for developing the target program into the synchronous directory.
Many development files are required in the process of developing the target program, and are also generated, and are saved in a synchronous directory, wherein the synchronous directory is the development directory of the target program.
In an embodiment of the invention, the method further comprises:
configuring a network of the virtual machines to a bridge mode.
In the embodiment of the present invention, the network of the virtual machine may be configured in a bridge mode and a host mode, and in the bridge mode, the virtual machine may be accessed by a device that is in the same local area network as the host of the virtual machine. In the host mode, the host of the virtual machine and the virtual machine can access each other through a network.
In the embodiment of the invention, the network of the virtual machine is configured to be in a bridge mode, so that the equipment of the same local area network can access the virtual machine. When the devices in the same local area network are required to be matched in the development process and the test process, the devices in the same local area network can directly access the virtual machine, so that the development process and the test process are more convenient.
Specifically, the network of virtual machines may be configured in bridge mode by:
config.vm.network"public_network",ip:"192.168.33.10"。
in an embodiment of the invention, the method further comprises:
and setting the port of the host machine on the virtual machine.
In the embodiment of the invention, the port of the host machine is arranged on the virtual machine, so that the external equipment can directly access the virtual machine on the host machine through the port of the host machine.
In the embodiment of the present invention, the port of the host may be set on the virtual machine by the following commands:
config.vm.network"forwarded_port",guest:80,host:8080。
after the setting the port of the host machine on the virtual machine, further comprising:
when the port of the host machine receives an access request sent from the outside, the access request is sent to the virtual machine, so that the virtual machine responds to the access request.
In the embodiment of the present invention, when the 8080 port of the host receives an access request sent from the outside, the access request is sent to the 80 service of the virtual machine, so that the virtual machine responds to the access request.
As shown in fig. 2, an embodiment of the present invention provides a method for building a test environment, including:
step 201: creating a virtual machine for testing a target program on a host machine where the target program is developed.
Specifically, the virtual machine may be created by a Vagrant.
Specifically, the method comprises the following steps of firstly installing the vagrant environment:
1. and downloading and installing the virtualbox, and installing and deploying according to the official document.
2. Downloading and installing the vagrant, and installing official documents for installation and deployment.
It should be noted that the versions of the vagrant and the viratalbox are collocated to ensure that the local operating system selects the corresponding version, and VT-X/AMD-V hardware acceleration is started in the Windows system.
3. Downloading the virtual machine image of the vagrant, wherein the virtual machine image of the vagrant is a box file. After the download is completed, a command is executed to the current download directory, variable box add { name of virtual machine to be created } { downloaded mirror name }
Such as, a virtual box add centros-study centros-7-x 86-64-Vagrant-1710-01. VirtualBox
After the command is executed, a file named vagrantfile is created in the current directory.
Various configurations of the virtual machine can be realized through the file of the vagrantfile, such as: step 205 and step 206 may be implemented by a vanrantofile's file.
The specification of the virtual machine such as a CPU and a kernel of the virtual machine can be configured, SSH (Secure Shell) configuration can be performed, and basic configuration of the vagrant can be performed through the vagrantfile file.
The virtual machine can be operated by the following commands based on the Vagrant:
step 202: a synchronization directory of the virtual machine is determined.
Specifically, a new directory may be created as the synchronization directory, or an existing directory may be used as the synchronization directory.
Step 203: and taking the synchronous directory as a development directory of the target program.
In particular, if a development catalog already exists, the development catalog may be treated as a synchronization catalog in step 202.
Step 204: and setting the host machine and the virtual machine to share the synchronous directory.
Specifically, the host machine and the virtual machine can share the synchronous directory through the step.
Step 205: the network of virtual machines is configured in bridge mode.
Specifically, the host may directly access the virtual machine.
Step 206: and setting the port of the host machine on the virtual machine.
Step 207: when the port of the host machine receives an access request sent from the outside, the access request is sent to the virtual machine, so that the virtual machine responds to the access request.
Specifically, when accessing the virtual machine, the external device may be the same as the host, which is very convenient.
In the embodiment of the invention, the target program can be terraform-provider.
After the virtual machine is realized, the virtual machine is started, after the virtual machine is started successfully, the xshell or other tools are used for connecting the virtual machine, the synchronous directory is checked, and after the development files of the target program are synchronized in the synchronous directory, the test can be carried out.
In the embodiment of the invention, the virtual machine is created locally, and the local file and the virtual machine file are associated by using a mapping mode. The effects of local development and virtual machine testing are realized, the development testing process is simplified, and the efficiency is improved.
As shown in fig. 3, an embodiment of the present invention provides an apparatus for building a test environment, including:
a creating module 301, configured to create, on a host machine that develops a target program, a virtual machine that is used for testing the target program;
a synchronization directory determination module 302, configured to determine a synchronization directory of the virtual machine;
a development catalog setting module 303, configured to set the synchronization catalog as a development catalog of the target program;
a sharing module 304, configured to set the host and the virtual machine to share the synchronization directory.
In an embodiment of the present invention, the development directory setting module is configured to save a development file for developing the target program into the synchronization directory.
In an embodiment of the present invention, the apparatus further comprises:
and the network setting module is used for configuring the network of the virtual machine into a bridge mode.
In an embodiment of the present invention, the apparatus further comprises:
and the port setting module is used for setting the port of the host machine on the virtual machine.
In an embodiment of the present invention, the apparatus further comprises:
the request sending module is used for sending the access request to the virtual machine when the port of the host machine receives the access request sent from the outside so as to enable the virtual machine to respond to the access request.
It is understood that the illustrated structure of the embodiment of the present invention does not constitute a specific limitation on the apparatus for constructing a test environment. In other embodiments of the invention, the means for building a test environment may comprise more or fewer components than shown, or some components may be combined, some components may be split, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Because the information interaction, execution process, and other contents between the units in the device are based on the same concept as the method embodiment of the present invention, specific contents may refer to the description in the method embodiment of the present invention, and are not described herein again.
The present invention also provides a computer readable medium storing instructions for causing a computer to perform a method of setting up a test environment as described herein. Specifically, a system or an apparatus equipped with a storage medium on which software program codes that realize the functions of any of the above-described embodiments are stored may be provided, and a computer (or a CPU or MPU) of the system or the apparatus is caused to read out and execute the program codes stored in the storage medium.
In this case, the program code itself read from the storage medium can realize the functions of any of the above-described embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
Examples of the storage medium for supplying the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (e.g., CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD + RW), a magnetic tape, a nonvolatile memory card, and a ROM. Alternatively, the program code may be downloaded from a server computer via a communications network.
Further, it should be clear that the functions of any one of the above-described embodiments may be implemented not only by executing the program code read out by the computer, but also by causing an operating system or the like operating on the computer to perform a part or all of the actual operations based on instructions of the program code.
Further, it is to be understood that the program code read out from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion unit connected to the computer, and then causes a CPU or the like mounted on the expansion board or the expansion unit to perform part or all of the actual operations based on instructions of the program code, thereby realizing the functions of any of the above-described embodiments.
It should be noted that not all steps and modules in the above flows and system structure diagrams are necessary, and some steps or modules may be omitted according to actual needs. The execution order of the steps is not fixed and can be adjusted as required. The system structure described in the above embodiments may be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by a plurality of physical entities, or some components in a plurality of independent devices may be implemented together.
In the above embodiments, the hardware unit may be implemented mechanically or electrically. For example, a hardware element may comprise permanently dedicated circuitry or logic (such as a dedicated processor, FPGA or ASIC) to perform the corresponding operations. The hardware elements may also comprise programmable logic or circuitry, such as a general purpose processor or other programmable processor, that may be temporarily configured by software to perform the corresponding operations. The specific implementation (mechanical, or dedicated permanent, or temporarily set) may be determined based on cost and time considerations.
While the invention has been shown and described in detail in the drawings and in the preferred embodiments, it is not intended to limit the invention to the embodiments disclosed, and it will be apparent to those skilled in the art that various combinations of the code auditing means in the various embodiments described above may be used to obtain further embodiments of the invention, which are also within the scope of the invention.
Claims (10)
1. The method for building the test environment is characterized by comprising the following steps:
creating a virtual machine for testing a target program on a host machine for developing the target program;
determining a synchronization directory of the virtual machine;
taking the synchronous catalog as a development catalog of the target program;
and setting the host machine and the virtual machine to share the synchronous directory.
2. The method of claim 1,
the taking the synchronization directory as a development directory of the target program includes:
and saving a development file for developing the target program into the synchronous directory.
3. The method of claim 1,
further comprising:
configuring a network of the virtual machines to a bridge mode.
4. The method according to any one of claims 1 to 3,
further comprising:
and setting the port of the host machine on the virtual machine.
5. The method of claim 4,
after the setting the port of the host machine on the virtual machine, further comprising:
when the port of the host machine receives an access request sent from the outside, the access request is sent to the virtual machine, so that the virtual machine responds to the access request.
6. Set up test environment's device which characterized in that includes:
the system comprises a creating module, a testing module and a control module, wherein the creating module is used for creating a virtual machine for testing a target program on a host machine for developing the target program;
the synchronous directory determining module is used for determining a synchronous directory of the virtual machine;
the development catalog setting module is used for setting the synchronous catalog as a development catalog of the target program;
and the sharing module is used for setting the host machine and the virtual machine to share the synchronous directory.
7. The apparatus of claim 6,
and the development catalog setting module is used for storing a development file for developing the target program into the synchronous catalog.
8. The apparatus of claim 6,
further comprising:
and the network setting module is used for configuring the network of the virtual machine into a bridge mode.
9. The apparatus according to any one of claims 6 to 8,
further comprising:
and the port setting module is used for setting the port of the host machine on the virtual machine.
10. The apparatus of claim 9,
further comprising:
the request sending module is used for sending the access request to the virtual machine when the port of the host machine receives the access request sent from the outside so as to enable the virtual machine to respond to the access request.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010110817.XA CN111338945A (en) | 2020-02-24 | 2020-02-24 | Method and device for building test environment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010110817.XA CN111338945A (en) | 2020-02-24 | 2020-02-24 | Method and device for building test environment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111338945A true CN111338945A (en) | 2020-06-26 |
Family
ID=71183590
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010110817.XA Pending CN111338945A (en) | 2020-02-24 | 2020-02-24 | Method and device for building test environment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111338945A (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107995064A (en) * | 2017-12-14 | 2018-05-04 | 云南电网有限责任公司玉溪供电局 | Test platform building method based on virtualization technology |
CN108763090A (en) * | 2018-05-31 | 2018-11-06 | 上海陆家嘴国际金融资产交易市场股份有限公司 | Test environment dispositions method, device, computer equipment and storage medium |
-
2020
- 2020-02-24 CN CN202010110817.XA patent/CN111338945A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107995064A (en) * | 2017-12-14 | 2018-05-04 | 云南电网有限责任公司玉溪供电局 | Test platform building method based on virtualization technology |
CN108763090A (en) * | 2018-05-31 | 2018-11-06 | 上海陆家嘴国际金融资产交易市场股份有限公司 | Test environment dispositions method, device, computer equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Lowe | Mastering vmware vsphere 5 | |
US9465625B2 (en) | Provisioning of operating environments on a server in a networked environment | |
EP3518099B1 (en) | Installation of operating system | |
US7499991B2 (en) | Autonomic application server unneeded process disablement | |
US11418566B2 (en) | Adding and removing virtual disks remotely to a streaming machine | |
CN113741914B (en) | Operating system installation mechanism | |
US9959136B2 (en) | Optimizations and enhancements of application virtualization layers | |
US11762644B2 (en) | Agentless installation for building deployments | |
US12026494B2 (en) | Dynamic automation of prerequisite component deployment in disconnected environments | |
CN115658235A (en) | Cluster deployment method, computing device and storage medium | |
CN114860272A (en) | Operating system installation method, computing device and storage medium | |
JP4759941B2 (en) | Boot image providing system and method, boot node device, boot server device, and program | |
CN115051846A (en) | Deployment method of K8S cluster based on super fusion platform and electronic equipment | |
US10776132B1 (en) | System and method for preboot device driver provisioning for remotely-staged operating system | |
CN116775061A (en) | Deployment method, device, equipment and storage medium of micro-service application | |
CN111338945A (en) | Method and device for building test environment | |
CN111324496A (en) | Method and device for detecting bare machine | |
CN110661679B (en) | Method and device for testing network card, computer storage medium and terminal | |
CN111008043A (en) | Server starting method of cloud platform and terminal | |
CN115700465B (en) | Mobile electronic equipment and application method thereof | |
US12014185B2 (en) | Unified boot image for multiple operating systems | |
CN114726719B (en) | Network element operating system deployment method and device, electronic equipment and storage medium | |
CN115509590B (en) | Continuous deployment method and computer equipment | |
US20230164114A1 (en) | System and method for managing and securing an enterprise network associated with an organization | |
CN115857968A (en) | Operating system installation method and device |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200626 |
|
RJ01 | Rejection of invention patent application after publication |