Software deployment method, software deployment system and electronic equipment
Technical Field
The present invention relates to the field of information technology, and in particular, to a software deployment method, a software deployment system, an electronic device, and a computer-readable storage medium.
Background
In the existing Information Technology (IT) enterprise, tools are usually introduced to assist a human to complete a specific task during the delivery process of a software product, for example, when a tester needs to test software, a maintenance worker needs to manually test and deploy the software with the aid of a software deployment tool and a customized script in advance; after the test deployment is completed, the tester can test the software.
Disclosure of Invention
The invention provides a software deployment method, a software deployment system, electronic equipment and a computer readable storage medium, aiming at improving the efficiency of testing and deploying software.
A first aspect of the present invention provides a software deployment method, including:
acquiring a construction product and a handover description file related to the software tested at this time;
calling a preset first script to detect whether the constructed product and the handover description file meet a preset test condition;
if the construction product and the transfer description file both meet preset test conditions, calling a preset second script, and carrying out test deployment on the software in a target test host on the basis of the construction product and the transfer description file.
A second aspect of the present invention provides a software deployment system, including:
the first acquisition module is used for acquiring a construction product, a test input parameter and a handover description file related to the software to be tested;
the first calling module is used for calling a preset first script to detect whether the constructed product and the handover description file meet preset test conditions or not;
and the second calling module is used for calling a preset second script when the construction product and the handover description file both meet preset test conditions, and carrying out test deployment on the software in a target test host based on the construction product and the handover description file.
A third aspect of the present invention provides an electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to the first aspect when executing the computer program.
A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, performs the steps of the method according to the first aspect.
As can be seen from the above, according to the scheme of the present invention, a build product and a handover description file related to a software to be tested at this time are first obtained, then a preset first script is called to detect whether the build product and the handover description file meet preset test conditions, when both the build product and the handover description file meet the preset test conditions, a preset second script is called, and based on the build product and the handover description file, test deployment is performed on the software in a target test host. According to the scheme of the invention, the software is tested and deployed by calling the script, so that automatic test deployment can be realized, and the efficiency of test deployment is greatly improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a flowchart of an implementation of a software deployment method according to an embodiment of the present invention;
FIG. 2 is a flowchart of another implementation of a software deployment method according to an embodiment of the present invention;
FIG. 3 is a flowchart of an implementation of a third software deployment method according to an embodiment of the present invention;
FIG. 4 is a block diagram of a software deployment system provided by an embodiment of the invention;
fig. 5 is a schematic diagram of an electronic device provided in an embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
Example one
Fig. 1 shows an implementation flow of a software deployment method provided in an embodiment of the present invention, which is detailed as follows:
in step S101, a construction product and a handover description file related to the software under test are acquired;
in the embodiment of the invention, firstly, a construction product and a handover description file related to the software tested at this time are obtained. The build product is specifically a product obtained after the build construction operation is performed by the software, and includes an executable program, a configuration file and output data obtained after the build construction operation is performed by the software. The handover description file is a JSON-formatted file, which is specifically a transmission standard file applied to Java, and a standard design of a software deployment method is embedded in the file, which is the basis for the operation of the software deployment method. The content of the handover description file includes, but is not limited to, the following data: file (files) data, configuration (configs) data and database (sqls) data; specifically, the file data includes: the file system comprises component types (component), operations (action), a source file (file) and a target file (destfile), wherein the operations specifically comprise addition (add), update (update) and deletion (delete); the configuration data includes: the method comprises the steps of selecting a component type (component), an operation (action), a target file (destfilename), a configuration item key value (key) and an environment value list, wherein the operation specifically comprises addition (add), update (update) and deletion (delete); the database data includes: the database type comprises mysql and oracle. It is noted that some data in the handover description file, such as component type, operation and object files, belong to both the content of the file data and the content of the configuration data.
In step S102, a preset first script is called to detect whether the constructed product and the handover description file satisfy a preset test condition;
in the embodiment of the present invention, after the building product and the handover description file are obtained in step S101, a preset first script may be called to parse the handover description file, and then the first script is called to detect whether the building product and the handover description file satisfy a preset test condition. The test conditions may be preset by a developer, and are not limited herein. Specifically, the first script is a Shell script.
In step S103, if the built product and the handover description file both satisfy a predetermined test condition, a predetermined second script is called, and based on the built product and the handover description file, a test deployment is performed for the software in the target test host.
In the embodiment of the present invention, after the target test host is determined in step S103, a preset second script is called, and based on the building product and the handover description file, test deployment is performed for the software in the target test host. Specifically, the second script is a Shell script.
Optionally, the software deployment method further includes:
acquiring test input parameters related to the software tested at this time;
determining a target test host based on the test input parameters;
the test input parameters can be obtained by calling a preset Shell script. Specifically, the test input parameters include: system coding and environment coding; based on the test input parameters, determining a target test host, comprising: calling a designated Shell script, inquiring and determining a target test host from a preset deployment platform according to the obtained system code and environment code, and obtaining host information of the target test host, wherein the host information comprises but is not limited to an Internet Protocol (IP) address of the target test host. Optionally, after the target test host is determined, the target test host may be verified, including verifying a public key, a private key, a state, and the like of the target test host.
Optionally, the step S103 includes:
calling a preset second script, and sequentially executing service stopping operation, cache cleaning operation, handover description file copying operation, constructed product copying operation and service starting operation in the target test host;
after step S103, the software deploying method further includes:
and calling a test platform, and testing the constructed product in the target test host based on the test platform and the test input parameters.
The test input parameters comprise a system code and an environment code, and also comprise a test type of the test. When test deployment is performed, firstly, the service of the target test host needs to be stopped, the cache of the target test host needs to be cleaned, then the handover description file and the constructed product obtained in the step S101 are respectively copied into the target test host to construct the test environment of the target test host, and finally, the service of the target test host is started to complete the test deployment. The process takes the traditional operations of manually stopping service, copying files and starting service by developers, and saves the waiting time of a compiling link and a testing deployment link. After the test deployment is completed, the test platform can be called, the system code, the environment code and the test type which are firstly related to the software tested at this time are used as the input of the test platform, the software is automatically tested, and the test result is returned after the test is completed. The types of the tests include, but are not limited to, smoke test, regression test, and the like, and are not limited herein.
Therefore, through the embodiment of the invention, when the software needs to be tested, the script can be called to determine the target test host, and the deployment of the test environment of the software is realized in the target test host, so that the waiting time of compiling and test deployment is saved, and the efficiency of test deployment is improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
Example two
On the basis of the first embodiment, fig. 2 shows an implementation flow of another software deployment method provided by the second embodiment of the present invention, which is detailed as follows:
in step S201, a construction description file of the software is obtained and analyzed to obtain a construction product related to the software;
in the embodiment of the invention, whether a code set in a code base is changed or not is periodically detected, wherein the code base is a collection of all software developed by an enterprise and is stored in a management tool such as svn or git. Each software possesses different address in the code base, and each software possesses its corresponding hand-over number; when a developer changes the code of a certain software in the code base, the handover number of the software is changed. Therefore, the handover number corresponding to each piece of software can be used as a basis for judging whether the code set in the code base is changed, when the handover number of a piece of software in the code base is detected to be changed, the code set in the code base is determined to be changed, and the build description file build. Specifically, the above construction description file includes: the method comprises the steps of constructing a tool, constructing a version of the tool, compiling a version of the language, constructing a code, constructing a knowner list, constructing an execution file and constructing a product directory. After the construction description file is executed, a software environment corresponding to the software is selected to complete the work of compiling, unit testing, code quality checking and construction packaging, so that a construction product related to the software is obtained.
In step S202, a preset third script is called, and the above-mentioned build product and a preset handover description file are copied to a specified location in a preset file server;
in the embodiment of the present invention, a preset third script may be called to perform a handover operation on the above-mentioned build product and a preset handover description file. Specifically, the third script is a Python script. Optionally, the third script may be invoked to parse the handover description file to obtain configuration data included in the handover description file, and transmit and copy the build product and the handover description file to a predetermined location of a file server, where the predetermined location is determined based on the configuration data and a system code. By calling the preset third script, the operation that the constructed product needs to be manually copied after the traditional construction is finished is omitted, and the efficiency is further improved.
In step S203, the build product and the handover description file are obtained from a designated location in the file server;
in the embodiment of the present invention, the construction product and the handover description file related to the software tested this time are acquired from the designated location of the file server in step S202. After the construction is completed, relevant parameters in the construction process are reserved and are applied in the test deployment process.
In step S204, a preset first script is called to detect whether the constructed product and the handover description file satisfy a preset test condition;
in step S205, if the built product and the handover description file both satisfy the predetermined test condition, a predetermined second script is called, and based on the built product and the handover description file, the software is tested and deployed in the target test host.
In the embodiment of the present invention, the implementation manners of the steps S204 and S205 are the same as or similar to the implementation manners of the steps S102 and S103, and reference may be specifically made to the related descriptions of the steps S102 and S103, which are not described herein again.
Therefore, through the embodiment of the invention, the script can be called to carry out the transfer operation after the construction is finished, so that the construction and transfer efficiency of the software is greatly saved; when the software needs to be tested, the script can be called to determine the target test host, the deployment of the test environment of the software is realized in the target test host, the waiting time of compiling and test deployment is saved, and the efficiency of test deployment is improved.
EXAMPLE III
On the basis of the first embodiment, fig. 3 shows an implementation flow of a third software deployment method provided by the third embodiment of the present invention, which is detailed as follows:
in step S301, a construction product and a handover description file related to the software to be tested are acquired;
in step S302, a preset first script is called to detect whether the constructed product and the handover description file satisfy a preset test condition;
in step S303, if the built product and the handover description file both satisfy a preset test condition, a preset second script is called, and based on the built product and the handover description file, test deployment is performed for the software in a target test host;
in the embodiment of the present invention, the implementation manners of the steps S301, S302, and S303 are the same as or similar to the implementation manners of the steps S101, S102, and S103, and reference may be specifically made to the related descriptions of the steps S101, S102, and S103, which are not described herein again.
In step S304, detecting whether the software is in a production release state;
in step S305, if the software is already in the production release state, a production deployment is performed on the target production host for the software.
In the embodiment of the invention, after the test deployment is finished and the software is tested, the relevant parameters during the test deployment are reserved, and a preset fourth script is called to detect whether the software is in a production release state. If the software is in a production release state, determining a target production host and executing production transfer and production deployment, wherein the specific process of executing the production transfer and the production deployment is similar to the steps S301 to S303, but the test input parameters are not adopted, but the production input parameters are adopted; and the production environment obtained after the production deployment is synchronized into the test environment, so that the test environment is the same as the production environment.
Optionally, before the step S305, the software deploying method further includes:
a target production host is determined among the hosts currently in an idle state.
Wherein the target production host can be determined in a randomly specified manner among all hosts in idle state to ensure that the target production host can be called for production deployment.
Optionally, after the step S305, the software deploying method further includes:
calling a preset fourth script to verify whether the production deployment is successful;
and if the production deployment is successful, backing up all scripts in the target production host.
The fourth script may be continuously called, and whether the production deployment operation is successful is verified based on a production deployment rule preset by the software deployment system, for example, the target production host subjected to production deployment is verified in a manner of simulating login, a simulation request, and the like, so as to replace a conventional manual verification manner. Specifically, the fourth script is a Shell script. And when the production deployment is determined to be successful, backing up all scripts in the target production host and backing up information related to the production deployment of the target production host, so that if an abnormal condition occurs in the target production host subsequently, the target production host can return to a normal state by rolling back the backed-up scripts and the backed-up information related to the production deployment.
Therefore, by the embodiment of the invention, when software needs to be tested, the script can be called to determine the target test host, and the deployment of the test environment of the software is automatically realized in the target test host, so that the waiting time of compiling and test deployment is saved, and the efficiency of test deployment is improved; and moreover, after the test deployment is finished, the production deployment can be automatically executed through the script, so that the software publishing efficiency is further improved.
Example four
Fig. 4 shows a specific structural block diagram of the software deployment system provided by the embodiment of the present invention, and for convenience of explanation, only the parts related to the embodiment of the present invention are shown. The software deployment system 4 includes: a first obtaining module 41, a first calling module 42, and a second calling module 43.
The first obtaining module 41 is configured to obtain a construction product, a test input parameter, and a handover description file related to the software to be tested, where the handover description file is a JSON-formatted file;
a first calling module 42, configured to call a preset first script to detect whether the constructed product and the handover description file meet a preset test condition;
and the second calling module is used for calling a preset second script when the constructed product and the handover description file both meet preset test conditions, and carrying out test deployment on the software in the target test host based on the constructed product and the handover description file.
Optionally, the software deployment system 4 further includes:
the second acquisition module is used for acquiring the construction description file of the software;
the analysis module is used for analyzing the construction description file of the software to obtain a construction product related to the software;
the third calling module is used for calling a preset third script and copying the constructed product and a preset handover description file to a specified position in a preset file server;
the first obtaining module 41 is specifically configured to obtain the build product and the handover description file from a specified location in the file server.
Optionally, the software deployment system 4 further includes:
the third acquisition module is used for acquiring test input parameters related to the software tested at this time;
and the target test host determination module is used for determining the target test host based on the test input parameters.
Optionally, the second invoking module 43 is specifically configured to invoke a preset second script, and sequentially execute a service stopping operation, a cache cleaning operation, a handover description file copying operation, a build result copying operation, and a service starting operation in the target test host;
the software deployment system 4 further includes:
and the test calling module is used for calling a test platform and testing the constructed product in the target test host based on the test platform and the test input parameters.
Optionally, the software deployment system 4 further includes:
the state detection module is used for detecting whether the software is in a production release state;
and the production deployment module is used for carrying out production deployment on the software in the target production host, wherein the production environment obtained after the production deployment is the same as the test environment obtained after the test deployment.
Optionally, the software deployment system 4 further includes:
and the target production host determination module is used for determining the target production host in the hosts which are in the idle state currently.
Optionally, the software deployment system 4 further includes:
the fourth calling module is used for calling a preset fourth script and verifying whether the production deployment is successful or not;
and the backup module is used for backing up all scripts in the target production host when the production deployment is successful.
Therefore, through the embodiment of the invention, the software deployment system can call the script to perform the constructed handover operation, so that the construction and handover efficiency of the software is greatly saved; when the software needs to be tested, the script can be called to determine the target test host, and the deployment of the test environment of the software is automatically realized in the target test host, so that the waiting time of compiling and test deployment is saved, and the efficiency of test deployment is improved; and moreover, after the test deployment is finished, the production deployment can be automatically executed through the script, so that the software publishing efficiency is further improved.
EXAMPLE five
Fig. 5 is a schematic diagram of an electronic device provided in an embodiment of the present invention. As shown in fig. 5, the electronic apparatus 5 of this embodiment includes: a processor 50, a memory 51 and a computer program 52, such as a software deployment program, stored in the memory 51 and executable on the processor 50. The processor 50 implements the steps of the various method embodiments described above, such as steps S101 to S103 shown in fig. 1, when executing the computer program 52. Alternatively, the processor 50 executes the computer program 52 to implement the functions of the modules in the system embodiments, such as the modules 41 to 43 shown in fig. 4.
Illustratively, the computer program 52 may be divided into one or more modules, which are stored in the memory 51 and executed by the processor 50 to implement the present invention. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 52 in the electronic device 5. For example, the computer program 52 may be divided into a first obtaining module, a first calling module, and a second calling module. The specific functions of each module are as follows:
the first acquisition module is used for acquiring a construction product, test input parameters and a handover description file related to the software to be tested, wherein the handover description file is a JSON (Java Server object notation) file;
the first calling module is used for calling a preset first script to detect whether the constructed product and the handover description file meet preset test conditions or not;
and the second calling module is used for calling a preset second script when the constructed product and the handover description file both meet preset test conditions, and carrying out test deployment on the software in the target test host on the basis of the constructed product and the handover description file.
The electronic device 5 may be a desktop computer, a notebook, a palm computer, a smart phone, a smart watch, or other computing devices. The electronic device may include, but is not limited to, a processor 50 and a memory 51. Those skilled in the art will appreciate that fig. 5 is merely an example of the electronic device 5, and does not constitute a limitation of the electronic device 5, and may include more or less components than those shown, or combine certain components, or different components, for example, the electronic device 5 may further include an input-output device, a network access device, a bus, etc.
The Processor 50 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 51 may be an internal storage module of the electronic device 5, such as a hard disk or a memory of the electronic device 5. The memory 51 may be an external storage device of the electronic device 5, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device 5. Further, the memory 51 may include both an internal storage module and an external storage device of the electronic device 5. The memory 51 is used for storing the computer program and other programs and data required by the electronic device 5. The above-mentioned memory 51 may also be used to temporarily store data that has been output or is to be output.
Therefore, through the embodiment of the invention, the electronic equipment can call the script to perform the constructed handover operation, so that the software construction and handover efficiency is greatly saved; when the software needs to be tested, the script can be called to determine the target test host, and the deployment of the test environment of the software is automatically realized in the target test host, so that the waiting time of compiling and test deployment is saved, and the efficiency of test deployment is improved; and moreover, after the test deployment is finished, the production deployment can be automatically executed through the script, so that the software publishing efficiency is further improved.
It will be clear to those skilled in the art that, for convenience and simplicity of description, the foregoing functional modules and division of modules are merely illustrated, and in practical applications, the above functions may be distributed by different functional modules and modules as needed, that is, the internal structure of the system is divided into different functional modules to complete all or part of the above described functions. Each functional module in the embodiments may be integrated into one processing module, or each module may exist alone physically, or two or more modules are integrated into one module, and the integrated module may be implemented in a form of hardware, or in a form of software functional module. In addition, specific names of the functional modules are only used for distinguishing one functional module from another, and are not used for limiting the protection scope of the application. The specific working process of the modules in the system may refer to the corresponding process in the foregoing method embodiment, and is not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative modules and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. 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 invention.
In the embodiments provided in the present invention, it should be understood that the disclosed system/electronic device and method can be implemented in other ways. For example, the above-described system/electronic device embodiments are merely illustrative, and for example, the division of the above-described modules is merely a logical division, and in actual implementation, there may be another division, for example, multiple modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, and the system module indirect coupling or communication connection may be in an electrical, mechanical or other form.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
The integrated module may be stored in a computer-readable storage medium if it is implemented in the form of a software functional module and sold or used as a separate product. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium and can implement the steps of the embodiments of the method when the computer program is executed by a processor. . The computer program includes computer program code, and the computer program code may be in a source code form, an object code form, an executable file or some intermediate form. The computer readable medium may include: any entity or device capable of carrying the above-mentioned computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signal, telecommunication signal, software distribution medium, etc. It should be noted that the computer readable medium described above may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media excludes electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.