Disclosure of Invention
The application aims to provide a software testing method, a software testing device, software testing equipment and a software testing storage medium, so that an environment deployment process is simplified when a new software version is tested, testing efficiency is improved, and the overall development progress is accelerated.
In order to solve the technical problem, the application provides the following technical scheme:
a software testing method, comprising:
establishing soft connection of an installation package to be used, wherein the installation package to be used at least comprises an installation package of a first version of software to be detected;
configuring a testing basic environment;
creating a snapshot of a system state based on the soft connection and the test base environment;
when a test request for a second version of the software to be tested exists, recovering the system state based on the snapshot, wherein the second version is any version of the software to be tested except the first version;
and replacing the soft connection of the installation package of the first version with the soft connection of the installation package of the second version, installing and deploying the second version by using the soft connection of the installation package of the second version in the test basic environment, and testing the second version.
In a specific embodiment of the present application, the establishing a soft connection of an installation package to be used includes:
creating a folder corresponding to a directory where an installation package to be used is located;
and creating the soft connection of the installation packages to be used in the corresponding directory in each folder in a batch mode.
In a specific embodiment of the present application, the creating a snapshot of the system state includes:
if the test basic environment is a virtual machine environment, taking a snapshot of the system state by using a snapshot function of virtual machine software;
and if the test basic environment is the physical machine environment, making a snapshot of the system state by using a snapshot tool.
In a specific embodiment of the present application, the software to be tested is Ambari, and the configuring a test basic environment includes:
modifying configuration information in the configuration file, wherein the configuration information at least comprises host information, network card information and gateway information;
configuring a secure shell protocol (SSH) secret-free;
installing basic software, wherein the basic software at least comprises a development kit JDK, a network time protocol NTP, a hypertext transfer protocol HTTP and a relational database MySQL;
and modifying yum the source address of the Ambari installation source to the address of the soft connection of the Ambari installation package.
In a specific embodiment of the present application, the software to be tested is an component of Ambari, and the configuring a test basic environment includes:
modifying configuration information in the configuration file, wherein the configuration information at least comprises host information, network card information and gateway information;
configuring a secure shell protocol (SSH) secret-free;
installing basic software, wherein the basic software at least comprises a development kit JDK, a network time protocol NTP, a hypertext transfer protocol HTTP and a relational database MySQL;
modifying yum the installation source address of Ambari in the source to the address of the soft connection of the Ambari installation package;
installing and configuring Ambari and starting;
and establishing a cluster, and setting a URL (uniform resource locator) of a software library as the address of the soft connection of the component.
In a specific embodiment of the present application, the creating a cluster includes:
setting cluster attribute information;
and installing basic necessary components.
In a particular embodiment of the present application, the installation configuration Ambari comprises:
installing Ambari service;
configuring information of tools required to be used by Ambari;
the database is initialized.
A software testing apparatus comprising:
the software connection establishing module is used for establishing the soft connection of an installation package to be used, wherein the installation package to be used at least comprises an installation package of a first version of software to be detected;
the test basic environment configuration module is used for configuring a test basic environment;
the snapshot creating module is used for creating a snapshot of the system state based on the soft connection and the test basic environment;
a system state recovery module, configured to recover the system state based on the snapshot when there is a test request for a second version of the software to be tested, where the second version is any version of the software to be tested except for the first version;
and the new version testing module is used for replacing the soft connection of the installation package of the first version with the soft connection of the installation package of the second version, installing and deploying the second version by using the soft connection of the installation package of the second version in the testing basic environment, and testing the second version.
A software testing device comprising:
a memory for storing a computer program;
a processor for implementing the steps of any of the above software testing methods when executing the computer program.
A computer readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the software testing method of any one of the preceding claims.
By applying the technical scheme provided by the embodiment of the application, the soft connection of the installation package to be used at least comprising the installation package of the first version of the software to be tested is established, the test basic environment is configured, then the snapshot of the system state is created based on the soft connection and the test basic environment, when the test request for the second version of the software to be tested exists, the system state can be recovered based on the snapshot, the test basic environment is obtained again, the soft connection of the installation package of the first version is replaced by the soft connection of the installation package of the second version, the soft connection of the installation package of the second version is used for installation and deployment of the second version in the test basic environment, and the second version is tested. When a new version of the software to be tested is tested, the system state is restored through the snapshot, and the test basic environment can be quickly obtained, so that the new version can be installed and deployed in the test basic environment to test the new version without reconfiguring the test basic environment. By the incremental testing mode, time consumed by a large amount of repeated work can be reduced, the environment deployment process is simplified when the new software version is tested, the testing efficiency is improved, and the overall development progress is accelerated.
Detailed Description
In order that those skilled in the art will better understand the disclosure, the following detailed description will be given with reference to the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, a flowchart of an implementation of a software testing method provided in an embodiment of the present application is shown, where the method may include the following steps:
s110: and establishing soft connection of the installation package to be used.
The installation package to be used at least comprises the installation package of the first version of the software to be tested.
In the embodiment of the application, the software to be tested may be any software, and is the software which needs to be tested currently. The software to be tested may have different versions. The installation package to be used can be obtained by downloading, copying and the like. The installation package to be used at least comprises the installation package of the first version of the software to be tested. Of course, an installation package of components associated with the software under test may also be included.
In practical application, a developer develops software to be tested or components thereof, and can automatically package the software to be tested and each component after submitting codes. And then packaging the software package of the software to be tested and the software packages of all components into an ISO file (optical disc image file), namely an installation package, through a set timing packaging task.
After the installation package to be used is obtained, the soft connection of the installation package to be used can be established. By soft-connect is meant a file that is connected to another file system.
S120: and configuring a testing basic environment.
For testing any software, certain environment support is required. In the embodiment of the application, the test basic environment can be configured based on the attribute of the software to be tested and the like. Such as configuration host information, network card information, gateway information, installation base software, etc.
On the basis of a test foundation environment, software to be tested can be installed and deployed so as to test the software to be tested.
S130: based on the soft connection and the test base environment, a snapshot of the system state is created.
After the soft connection of the installation package to be used is established and the test basic environment is configured, a snapshot of the current system state can be created based on the soft connection and the test basic environment. Namely, various data at a certain time of the recording system can be restored to the system state during recording through the snapshot.
Specifically, if the test base environment is a virtual machine environment, a snapshot of the system state may be taken using a snapshot function of the virtual machine software. For example, a snapshot may be taken using a snapshot function of virtual machine software such as VMware work or VMware ESXi to preserve the state of the virtual machine for later restoration to the same state.
If the test base environment is a physical machine environment, a snapshot of the system state may be made using a snapshot tool. For example, snapshot tools such as Snapper may be used to make a snapshot of the current system state.
The snapshot is used to quickly clear and restore the test basic environment, which is especially suitable for the software to be tested which does not support the uninstallation or has residual uninstallation.
S140: and when a test request for the second version of the software to be tested exists, restoring the system state based on the snapshot.
The second version is any version of the software to be tested except the first version.
In practical applications, after creating the snapshot of the system state, the first version of the software to be tested may be installed and deployed, and the first version may be tested. In this case, the system state will change. With the continuous updating of the software, there may be a testing requirement for the second version of the software to be tested. For testing the second version of the software to be tested, if the system state is changed, the testing accuracy is difficult to guarantee.
Therefore, in the embodiment of the present application, when there is a test request for the second version of the software to be tested, the system state may be restored based on the snapshot. I.e. restore the system state to the state at the time the snapshot was created in order to retrieve the test base environment.
The second version is any version of the software to be tested except the first version. That is, after the snapshot of the system state is created, as long as there is a test request for any other version of the software to be tested except for the first version, the system state can be restored based on the snapshot, and the test basic environment is obtained again, so as to perform a test on the test basic environment.
S150: and replacing the soft connection of the installation package of the first version with the soft connection of the installation package of the second version, installing and deploying the second version by using the soft connection of the installation package of the second version in a test basic environment, and testing the second version.
In the embodiment of the application, when there is a test request for the second version of the software to be tested, the installation package of the second version of the software to be tested can be obtained, and the soft connection of the installation package of the second version is established.
Based on the snapshot, after the system state is restored, the soft connection of the installation package of the first version can be replaced by the soft connection of the installation package of the second version. I.e., replace the original soft connection with the new one, the source is updated yum. And then in a test basic environment, deploying the second version by using the soft connection installation of the installation package of the second version, and testing the second version.
The installation package usually has a read-only characteristic, and the installation package required to be tested is modified and replaced in a soft connection mode, so that the redeployment of the test basic environment can be avoided.
The method provided by the embodiment of the application comprises the steps of firstly establishing soft connection of an installation package to be used, at least comprising an installation package of a first version of software to be tested, configuring a test basic environment, then creating a snapshot of a system state based on the soft connection and the test basic environment, recovering the system state based on the snapshot when a test request for a second version of the software to be tested exists, reacquiring the test basic environment, replacing the soft connection of the installation package of the first version with the soft connection of the installation package of the second version, installing and deploying the second version by using the soft connection of the installation package of the second version in the test basic environment, and testing the second version. When a new version of the software to be tested is tested, the system state is restored through the snapshot, and the test basic environment can be quickly obtained, so that the new version can be installed and deployed in the test basic environment to test the new version without reconfiguring the test basic environment. By the incremental testing mode, time consumed by a large amount of repeated work can be reduced, the environment deployment process is simplified when the new software version is tested, the testing efficiency is improved, and the overall development progress is accelerated.
In an embodiment of the present application, the step S110 of establishing a soft connection of an installation package to be used may include the following steps:
the method comprises the following steps: creating a folder corresponding to a directory where an installation package to be used is located;
step two: and creating the soft connection of the installation packages to be used in the corresponding directories in each folder in batches.
In this embodiment, there may be a plurality of installation packages to be used, such as an installation package of the first version of the software to be tested, an installation package of a component of the software to be tested, and the like. Different types of installation packages may be placed in different directories. In practical application, folders corresponding to directories where the installation packages to be used are located can be created, and the soft connections of the installation packages to be used in the corresponding directories are created in batches in each folder. The efficiency of soft connection creation is improved.
For example, when the software to be tested is Ambari or an Ambari component, establishing the soft connection of the installation package to be used mainly includes establishing the soft connection of all installation packages in manager, hdp and hdp _ utils software libraries. Components refer to various application software suitable for use in a big data platform. Wherein, manager is a folder containing Ambari and related configuration files thereof, hdp is a folder containing all big data component installation packages, and hdp _ utils is a folder containing big data tool component installation packages. Namely, the Ambari installation package is in the manager directory, the big data component installation package is in the hdp directory, and the installation package of the required tool software is in the hdp _ utils directory. A soft connection for the installation package in each directory needs to be created separately.
Based on the directories, a folder a, a folder b and a folder c can be respectively created, then the soft connections of all Ambari installation packages in the manager directory are created in a batch mode in the folder a, the soft connections of all component installation packages in the hdp directory are created in a batch mode in the folder b, and the soft connections of all tool class software installation packages in the hdp _ utils directory are created in a batch mode in the folder c.
In an embodiment of the present application, the software to be tested is Ambari, and the step S120 configures a test basic environment, which may include the following steps:
the first step is as follows: modifying configuration information in the configuration file, wherein the configuration information at least comprises host information, network card information and gateway information;
the second step is that: configuring a secure shell protocol (SSH) secret-free;
the third step: installing basic software, wherein the basic software at least comprises a development kit JDK, a network time protocol NTP, a hypertext transfer protocol HTTP and a relational database MySQL;
the fourth step: and modifying yum the installation source address of Ambari in the source to be the address of the soft connection of the installation package of Ambari.
For ease of understanding, the above four steps are described in combination.
In the embodiment of the application, under the condition that the software to be tested is Ambari, the configuration of the testing basic environment mainly configures an environment capable of carrying out Ambari installation deployment and testing.
First, the configuration information in the configuration file may be modified. Specifically, the modification of the configuration information may be performed according to the device to be used. The configuration information may be host information, network card information, gateway information, and the like. The host information may be a host IP (Internet Protocol) address, a host name, and the like.
Second, SSH (Secure Shell) privacy-exempt may be configured.
Third, some basic software, such as JDK (java development kit), NTP (Network Time Protocol), HTTP (HyperText Transfer Protocol), MySQL (relational database), etc., may be installed.
Finally, the source yum can be updated by modifying yum the address of the soft connection of the installation package of which the installation source address of Ambari is Ambari in the source. Here Ambari's installation package is Ambari's first version installation package.
In an embodiment of the present application, the software to be tested is a component of Ambari, and the step S120 of configuring the testing basic environment may include the following steps:
the method comprises the following steps: modifying configuration information in the configuration file, wherein the configuration information at least comprises host information, network card information and gateway information;
step two: configuring a secure shell protocol (SSH) secret-free;
step three: installing basic software, wherein the basic software at least comprises a development kit JDK, a network time protocol NTP, a hypertext transfer protocol HTTP and a relational database MySQL;
step four: modifying yum the installation source address of Ambari in the source to the address of the soft connection of the Ambari installation package;
step five: installing and configuring Ambari and starting;
step six: and establishing a cluster, and setting the URL of the software library as the address of the soft connection of the component.
For ease of understanding, the above six steps are described in combination.
In this embodiment of the present application, in a case where the software to be tested is an Ambari component, configuring the test base environment mainly configures an environment capable of performing installation, deployment, and testing of the Ambari component, and the installation, deployment, and deployment of the Ambari component need to be established on the basis of completion of the installation, deployment of the Ambari component, so that the operations in steps one to four in this embodiment of the present application are intended to perform the installation and deployment of Ambari, and specific implementations of these four steps are consistent with those of the four steps in the previous embodiment, and are not described herein again.
After modifying the configuration information in the configuration file, configuring SSH secret-free, installing basic software, modifying yum the address of the soft connection of the installation package of which the installation source address of Ambari is Ambari in the source, the installation configuration of Ambari can be carried out.
Specifically, Ambari service, that is, Ambari-server, may be installed first, then information of tools that Ambari needs to use, such as information of a database, JDK, HTTP protocol, etc., may be configured, and finally the database may be initialized. The installation configuration of Ambari is completed.
After installing the configuration Ambari, Ambari may be started. And then a cluster can be created, and the URL of the software library is set as the address of the soft connection of the component, namely the address of the soft connection of the installation package of the first version of the component of Ambari.
Specifically, the process of creating the cluster may specifically be to set cluster attribute information and install basic necessary components. Such as setting cluster name and other necessary information, such as host list, SSH private key, SSH user name, port, etc.
In one embodiment of the application, Ambari and component rapid deployment and incremental testing are achieved in the form of taking snapshots and creating soft connections. The initial base environment is first configured and a soft connection is created, and then snapshot a is taken. And then, installing and deploying Ambari, creating a cluster after deployment is completed, setting the URL of a software library of the cluster as the address of the component soft connection, and shooting a snapshot B after the cluster is created. And when the Ambari needs to be tested, based on the snapshot A, recovering the system state, replacing the soft connection of the original Ambari installation package with the soft connection of the new Ambari installation package, and installing and testing the Ambari. And when the component needs to be tested, based on the snapshot B, recovering the system state, replacing the soft connection of the original installation package of the component with the soft connection of the new installation package of the component, and installing and testing the component. It should be noted that, for Ambari testing, the initial basic environment is the testing basic environment, and for component testing, the environment after Ambari installation and configuration on the basis of the initial basic environment is the testing basic environment.
The embodiment of the application can realize the repeated use of the Ambari environment, reduce the time cost and accelerate the development progress.
Corresponding to the above method embodiments, the present application further provides a software testing apparatus, and the software testing apparatus described below and the software testing method described above may be referred to correspondingly.
Referring to fig. 2, the apparatus may include the following modules:
a soft connection establishing module 210, configured to establish a soft connection of an installation package to be used, where the installation package to be used at least includes an installation package of a first version of software to be tested;
a test base environment configuration module 220, configured to configure a test base environment;
a snapshot creation module 230, configured to create a snapshot of a system state based on the soft connection and the test base environment;
a system state recovery module 240, configured to recover the system state based on the snapshot when there is a test request for a second version of the software to be tested, where the second version is any version of the software to be tested except for the first version;
and a new version testing module 250, configured to replace the soft connection of the installation package of the first version with the soft connection of the installation package of the second version, and in the testing basic environment, deploy the second version by using the soft connection installation of the installation package of the second version, and test the second version.
By applying the device provided by the embodiment of the application, the soft connection of the installation package to be used at least comprising the installation package of the first version of the software to be tested is established, the test basic environment is configured, then the snapshot of the system state is created based on the soft connection and the test basic environment, when the test request for the second version of the software to be tested exists, the system state can be recovered based on the snapshot, the test basic environment is obtained again, the soft connection of the installation package of the first version is replaced by the soft connection of the installation package of the second version, the soft connection of the installation package of the second version is used for installation and deployment of the second version in the test basic environment, and the second version is tested. When a new version of the software to be tested is tested, the system state is restored through the snapshot, and the test basic environment can be quickly obtained, so that the new version can be installed and deployed in the test basic environment to test the new version without reconfiguring the test basic environment. By the incremental testing mode, time consumed by a large amount of repeated work can be reduced, the environment deployment process is simplified when the new software version is tested, the testing efficiency is improved, and the overall development progress is accelerated.
In an embodiment of the present application, the soft connection establishing module 210 is configured to:
creating a folder corresponding to a directory where an installation package to be used is located;
and creating the soft connection of the installation packages to be used in the corresponding directory in each folder in a batch mode.
In a specific embodiment of the present application, the snapshot creating module 230 is configured to:
if the test basic environment is a virtual machine environment, taking a snapshot of the system state by using a snapshot function of virtual machine software;
and if the test basic environment is the physical machine environment, making a snapshot of the system state by using a snapshot tool.
In a specific embodiment of the present application, the software to be tested is Ambari, and the test basic environment configuration module 220 is configured to:
modifying configuration information in the configuration file, wherein the configuration information at least comprises host information, network card information and gateway information;
configuring a secure shell protocol (SSH) secret-free;
installing basic software, wherein the basic software at least comprises a development toolkit JDK, a network time protocol NTP, a hypertext transfer protocol HTTP and a relational database MySQL;
and modifying yum the installation source address of Ambari in the source to be the address of the soft connection of the installation package of Ambari.
In a specific embodiment of the present application, the software to be tested is an Ambari component, and the test basic environment configuration module 220 is configured to:
modifying configuration information in the configuration file, wherein the configuration information at least comprises host information, network card information and gateway information;
configuring a secure shell protocol (SSH) secret-free;
installing basic software, wherein the basic software at least comprises a development kit JDK, a network time protocol NTP, a hypertext transfer protocol HTTP and a relational database MySQL;
modifying yum the source Ambari installation source address as the address of the soft connection of the Ambari installation package;
installing and configuring Ambari and starting;
and establishing a cluster, and setting the URL of the software library as the address of the soft connection of the component.
In one embodiment of the present application, the testing infrastructure configuration module 220 is configured to:
setting cluster attribute information;
and installing basic necessary components.
In one embodiment of the present application, the testing infrastructure configuration module 220 is configured to:
installing Ambari service;
configuring information of tools required to be used by Ambari;
the database is initialized.
Corresponding to the above method embodiment, an embodiment of the present application further provides a software testing device, including:
a memory for storing a computer program;
and the processor is used for realizing the steps of the software testing method when executing the computer program.
As shown in fig. 3, which is a schematic diagram of a component structure of a software testing device, the software testing device may include: a processor 10, a memory 11, a communication interface 12 and a communication bus 13. The processor 10, the memory 11 and the communication interface 12 all communicate with each other through a communication bus 13.
In the embodiment of the present application, the processor 10 may be a Central Processing Unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic device, etc.
The processor 10 may call a program stored in the memory 11, and in particular, the processor 10 may perform operations in an embodiment of the software testing method.
The memory 11 is used for storing one or more programs, the program may include program codes, the program codes include computer operation instructions, in this embodiment, the memory 11 stores at least the program for implementing the following functions:
establishing soft connection of an installation package to be used, wherein the installation package to be used at least comprises an installation package of a first version of software to be detected;
configuring a testing basic environment;
creating a snapshot of the system state based on the soft connection and the test base environment;
when a test request for a second version of the software to be tested exists, the system state is restored based on the snapshot, and the second version is any version of the software to be tested except the first version;
and replacing the soft connection of the installation package of the first version with the soft connection of the installation package of the second version, installing and deploying the second version by using the soft connection of the installation package of the second version in a test basic environment, and testing the second version.
In one possible implementation, the memory 11 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function (such as a test function, a snapshot creation function), and the like; the storage data area may store data created during use, such as snapshot data, environmental data, and the like.
Further, the memory 11 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device or other volatile solid state storage device.
The communication interface 13 may be an interface of a communication module for connecting with other devices or systems.
Of course, it should be noted that the structure shown in fig. 3 does not constitute a limitation of the software testing apparatus in the embodiment of the present application, and in practical applications, the software testing apparatus may include more or less components than those shown in fig. 3, or some components in combination.
Corresponding to the above method embodiments, the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the software testing method.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The principle and the implementation of the present application are explained in the present application by using specific examples, and the above description of the embodiments is only used to help understanding the technical solution and the core idea of the present application. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.