The content of the invention
It is an object of the invention to provide a kind of method and device of the data syn-chronization of environment and test environment on line, for realityThe synchronization of the data of environment on existing test environment and line, so as to avoid because data are asynchronous and the problem of produce.
In order to solve the above technical problems, the method that the present invention provides the data syn-chronization of environment and test environment on a kind of line,Including:
Establish the connection of environment and test environment on line;
Obtain the data of environment and the data of the test environment on the line;
Contrast the data of environment and the data of the test environment on the line;
When contrast obtains the data of the test environment with the difference of the data of environment on the line, according to the differenceThe data of the test environment are modified.
Preferably, it is described establish environment and test environment on line connection be specially:
Start the test environment, and pass through environment on line described in the account and cryptographic acess of environment on the line.
Preferably, it is described establish environment and test environment on line connection be specially:
Start the test environment, and environment on the line is accessed by data-interface.
Preferably, the data of environment and the data of the test environment are specially on the contrast line:
By database structure from big to small in the way of, contrast the number of the data of environment and the test environment on the lineAccording to.
Preferably, described modified according to the difference to the data of the test environment specifically includes:
Difference generation is included into position to be modified and the modification file for changing content according to mode set in advance;
After the location lookup to be modified to the relevant position of the test environment, carried out according to the modification contentModification.
Preferably, the sentence of the modification file application is structured query sentence SQL.
Preferably, after contrast obtains the difference, in addition to:
By the differential disply on a display screen.
In order to solve the above technical problems, the present invention also provides a kind of dress of the data syn-chronization of environment and test environment on linePut, including:
Connection unit, for establishing the connection of environment and test environment on line;
Comparison unit, for contrasting the data of environment and the data of the test environment on the line;
Synchronization unit, for contrasting to obtain the data of environment and the test environment on the line in the comparison unitDuring the difference of data, the data of the test environment are modified according to the difference.
Preferably, in addition to:
Display unit, for showing the difference.
The method and device of the data syn-chronization of environment and test environment on line provided by the present invention, by establishing ring on lineBorder and the connection of test environment, on line is got after the data of environment and the data of test environment, the number of environment on reference lineAccording to the difference between the data of test environment, test environment is modified further according to difference.By according to environment on lineDifference between data and the data of test environment is modified to test environment, it is possible to completes environment and test environment on lineData syn-chronization so that in test environment by the project of test can trouble-free operation in environment on line, avoid factorAccording to asynchronous and caused other problemses.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, completeSite preparation describes, it is clear that described embodiment is only part of the embodiment of the present invention, rather than whole embodiments.It is based onEmbodiment in the present invention, those of ordinary skill in the art are obtained every other under the premise of creative work is not madeEmbodiment, belong to the scope of protection of the invention.
The core of the present invention is to provide a kind of method and device of the data syn-chronization of environment and test environment on line, for realityThe data syn-chronization of environment and test environment on existing line, so that can environment on line by the project of test in test environmentMiddle trouble-free operation, avoid the asynchronous and caused other problemses of factor data.
In order that those skilled in the art more fully understand the present invention program, with reference to the accompanying drawings and detailed descriptionThe present invention is described in further detail.
Fig. 1 is the method for the data syn-chronization of environment and test environment on the first line provided in an embodiment of the present invention.Such as Fig. 1Shown, the method for the data syn-chronization of environment and test environment includes on line:
S10:Establish the connection of environment and test environment on line.
S11:Obtain the data of environment and the data of test environment on line.
S12:The data of environment and the data of test environment on reference line.
S13:Judge whether the data of environment in the data and line of test environment are variant, if it is, into stepS14;If it is not, then terminate.
S14:The data of test environment are modified according to difference.
Project development is generally required by three phases:Exploitation, tests and reaches the standard grade.These stages are needed in different environmentMiddle progress.Test environment refers to for computer hardware, software, the network equipment, history necessary to completing Experience of Software Testing WorkThe general name of data, usually clone environment on a line.After the completion of test environment deployment, operation maintenance personnel may be according to projectThe problem of producing in the process of running is modified to environment on line, so that occurring difference on line between environment and test environmentIt is different.
In specific implementation, for step S10, for the data of environment on reference line and the data of test environment,Firstly the need of the connection for establishing environment and test environment on line, facilitate the interaction of data.Because test environment is typically in local, instituteTest environment can be operated with need to only start.And often by operation maintenance personnel management, tester needs to obtain environment on lineObtain authority and just may have access to environment on line.On access line is obtained after the authority of environment, it can be read out or copy.ObtainingOn access line after the authority of environment, the exploitation of contrast business function can be realized by Python or Php language.
For step S11, the data of test environment can be obtained by starting test environment, and the environment on line is obtainedThe data of environment on line can be just obtained during access rights.Can by read or copy obtain line on environment data.
For step S12, in general, test environment is cloned according to environment on line, so without mustBy replacement test environment after environment copy on line.A kind of mode that is preferably carried out is to travel through the data and test wrapper of environment on lineThe data in border, by the data of environment on rank (database, tables of data, record, field, index etc.), address and title reference lineWith the data of test environment, i.e., by the data of environment on the line of same levels, identical address and same names and test environmentData are contrasted.In addition, if by program setting make comparison process carry out automatically if, it is necessary in advance in program settingThe data type (as index has compared with polymorphic type) for needing to contrast is recorded, for the data type of no record, program can not be automaticContrasted.
For step S13 and step S14, when contrasting the difference to the data of environment on line and the data of test environmentWhen, then stop step S12, perform step S14, otherwise continue executing with the contrast in step S12.The difference contrasted such as first time" table 3 " in test environment missing data storehouse 1, then to copy the table 3 of the database 1 of environment on line, being placed on the number of test environmentAccording in storehouse 1, and it is identical with the position of table in environment on line 3.When having changed the difference currently contrasted, then step is performedContrast in S12, similarly, contrast is to step S14 is then continued executing with again during difference, until having contrasted all numbers for needing to contrastAccording to (in order to which speed can not have to contrast all data, such as determine the data of environment on unmodified line, can skip).
The method of the data syn-chronization of environment and test environment on line provided in an embodiment of the present invention, by establishing environment on lineWith the connection of test environment, the difference on reference line between environment and test environment, test environment is repaiied further according to differenceChange.By being modified according to the difference on line between environment and test environment to test environment, it is possible to complete environment on lineWith the data syn-chronization of test environment so that can smoothly be transported in environment on line by the project of test in test environmentOK, the asynchronous and caused other problemses of factor data are avoided.
As preferred embodiment, the data of environment and test environment on the first line provided in an embodiment of the present inventionOn the basis of synchronous method, step S10 is specially:
Start test environment, and environment in the account and cryptographic acess line for passing through environment on line.
Tester wants to obtain the data of environment on line, it is necessary to first obtain access rights.By to operation maintenance personnel applicationThe account and password of environment on one line, because without being modified to environment on line, as long as the account opens readingWeighting limits.Obtain on line after the account of environment and password, tester's can passes through the account and cryptographic acess lineUpper environment, restart test environment, select data interface channel, it is possible to establish the connection of environment on test environment and line.
The method of the data syn-chronization of environment and test environment on line provided in an embodiment of the present invention, by starting test wrapperBorder, and environment in the account and cryptographic acess line for passing through environment on line, so as to establish the connection of environment and test environment on line.It is logicalEnvironment in the account of environment and cryptographic acess line is crossed on line, environment and test environment on connecting line only need to be selected in operation pages, connected without hardware, it is simple and convenient.
As preferred embodiment, the data of environment and test environment on the first line provided in an embodiment of the present inventionOn the basis of synchronous method, step S10 is specially:
Start test environment, and pass through environment on data-interface access line.
It is understood that except environment in the account by environment on line and cryptographic acess line, data can also be passed throughEnvironment and test environment on interface connecting line.The account of environment and the situation of password or network is not connected on no lineIn the case of, environment on data-interface access line can be passed through.
The method of the data syn-chronization of environment and test environment on line provided in an embodiment of the present invention, by starting test wrapperBorder, and by environment on data-interface access line, so as to establish the connection of environment and test environment on line.Connected by data-interfaceEnvironment and test environment in wiring, compared to by environment in account and cryptographic acess line, connection is resettled, is more stablized, noIt can be influenceed by suspension.
As preferred embodiment, the data of environment and test environment on the first line provided in an embodiment of the present inventionOn the basis of synchronous method, step S12 is specially:
By database structure from big to small in the way of, the data of environment and the data of test environment on reference line.
Database structure has database, tables of data, record, field, index etc..Wherein, a database is by one or oneGroup tables of data composition.Each database is stored on disk in the form of a file, i.e., corresponding to a physical file.Tables of dataAbbreviation table, it is made up of one group of data record, the data in database are that tissue is carried out in units of table, and a table is one group of phaseThe data by rows closed;Information containing same type in each table, table is actually a two-dimensional table, for example,The total marks of the examination of one all student of class, it can be stored in a table, the corresponding student of every a line in table, this line bagInclude the student number of student, name and various courses achievement.Every a line in tables of data is referred to as a record, and it is by several field groupsInto.Field is also referred to as domain, and each row in table are referred to as a field.Each field has corresponding description information, as data type,Data width etc..Index is a kind of tables of data of specific type, wherein the value (being defined by the user) containing critical field and sensingThe pointer of physical record position, these values and pointer in particular order (being also defined by the user) store, so as to compared withFast speed finds required data record.
It should be noted that by database structure from big to small in the way of, i.e., first comparison database, check in databaseWhether missing or unnecessary tables of data are had;Contrast the tables of data under the database successively again, check in every a line (record) whetherThere are missing or unnecessary field;Because index is a kind of tables of data of specific type, therefore also contrasted using aforesaid way.
Certainly, except being contrasted by database structure in the way of from big to small, can also according to database structure fromIt is small to be contrasted to big mode, but so contrast, when certain tables of data missing in certain database in test environment, needAll fields of the tables of data in environment on line are traveled through, reduce the speed of contrast.
The method of the data syn-chronization of environment and test environment on line provided in an embodiment of the present invention, by database structure from bigTo small mode, the data of environment and the data of test environment on reference line, there is provided a kind of way of contrast of specification, and phaseThan in by database structure from small to large in the way of, versus speed is faster.
Fig. 2 is the method for the data syn-chronization of environment and test environment on second of line provided in an embodiment of the present invention.Such as Fig. 2It is shown, on the first line provided in an embodiment of the present invention on the basis of the method for the data syn-chronization of environment and test environment, stepRapid S14 is specifically included:
S20:Difference generation is included into position to be modified and the modification file for changing content according to mode set in advance.
S21:Behind the relevant position of location lookup to be modified to test environment, modified according to modification content.
In specific implementation, for step S20, it can set and automatically generate modification file, can also be by testerMember establishes modification file and write manually.Modification file content can be " in database 1 increase newly table 3, table 3 table 2 itAfterwards, the content of table 3 is as follows:……”.If being automatically generated modification file, need to only be carried in file is changed " in database 1Table 2 after " as position to be modified, and " content of supplementary table 3 " such the two key messages of modification content,The generation content such as time, version number can also be carried, depending on the program statement used and form set in advance.
For step S21, if being automatically generated modification file, it can also be automatically sent to test by program settingPosition to be modified in environment.If the modification file write manually by tester, can be set in file is changed certainlyIt is dynamic to send.
It is of course also possible to modified manually in test environment by tester, but so modification speed is relativelySlowly.
The method of the data syn-chronization of environment and test environment, defines step according to difference on line provided in an embodiment of the present inventionThe different data to test environment, which modify to specifically include, to be included change of address to be repaired according to difference generation and changes the modification of contentFile, the relevant position in test environment is found by change of address to be repaired, modified according to modification content.Compared to testerAccording to difference in test environment manual modification, run more specification, modification speed faster.
As preferred embodiment, the data of environment and test environment on second of line provided in an embodiment of the present inventionOn the basis of synchronous method, the sentence of modification file application is structured query sentence SQL.
SQL (Structured Query Language) abbreviation SQL, is a kind of data base querying and journeySequence design language, for accessing data and inquiry, renewal and administrative relationships Database Systems;Simultaneously and database script is literaryThe extension name of part.On the basis of modification file is automatically generated in above-mentioned embodiment, it can set and automatically generate SQL textsPart.
The method of the data syn-chronization of environment and test environment on line provided in an embodiment of the present invention, application structureization inquiry languageSentence SQL writes modification file.SQL is most important relational database operation language, powerful, is widely used, is compiled using SQLWrite modification file, it is easier to operate, more specification, facilitate tester to look back modification record.
Fig. 3 is the method for the data syn-chronization of environment and test environment on the third line provided in an embodiment of the present invention.Such as Fig. 3It is shown, on the first line provided in an embodiment of the present invention on the basis of the method for the data syn-chronization of environment and test environment,After being judged as YES in step S13, in addition to:
S30:By differential disply on a display screen.
It should be noted that because step S12, S13 and S14 are that circulation is carried out, existed in step s 13 every timeThe judgement of difference, you can perform the display difference in step S30, and step S30 and step S14 out-of-order relations.
In specific implementation, the difference of the data of environment in the data and line of test environment is checked in order to facilitate testerPlace, a window can be set to be used to show difference, display content be able to can also lead to shaped like " table 3 of database 1 lacks "Cross auditory tone cues and difference occur.Tester can also make further operation to the difference shown, such as preserve, or beatPrint off and, difference Producing reason, convenient record and research learning can be derived by the content of difference.
The method of the data syn-chronization of environment and test environment on line provided in an embodiment of the present invention, after difference is contrasted,By differential disply on a display screen, obtain while tester's simple, intuitive can be allowed difference content, convenient record to difference andResearch learning.
The each specific embodiment of the method for the data syn-chronization of environment and test environment on above-detailed line, hereinOn the basis of, the invention also discloses the device of the data syn-chronization of environment and test environment on line corresponding with the above method.Fig. 4 isThe schematic diagram of the device of the data syn-chronization of environment and test environment on a kind of line provided in an embodiment of the present invention.As shown in figure 4, lineThe device 400 of the data syn-chronization of upper environment and test environment includes:
Connection unit 401, for establishing the connection of environment 404 and test environment 405 on line.
Comparison unit 402, for obtaining the data of environment 404 and test environment 405 on line, and environment 404 on reference lineData and test environment 405 data.
Synchronization unit 403, the data of environment 404 and test environment 405 on line are obtained for being contrasted in comparison unit 402During the difference of data, the data of test environment 405 are modified according to difference.
Because the embodiment of device part and the embodiment of method part are mutually corresponding, therefore the embodiment of device part pleaseReferring to the description of the embodiment of method part, wouldn't repeat here.
The device of the data syn-chronization of environment and test environment on line provided in an embodiment of the present invention, by establishing environment on lineWith the connection of test environment, the difference on reference line between environment and test environment, test environment is repaiied further according to differenceChange.By being modified according to the difference on line between environment and test environment to test environment, it is possible to complete environment on lineWith the data syn-chronization of test environment so that can smoothly be transported in environment on line by the project of test in test environmentOK, the asynchronous and caused other problemses of factor data are avoided.
Fig. 5 is the signal of the device of the data syn-chronization of environment and test environment on another line provided in an embodiment of the present inventionFigure.As shown in figure 5, as preferred embodiment, on the basis of said apparatus 400, the number of environment and test environment on lineDevice according to synchronization also includes:
Display unit 501, for showing difference.
Due to the data of environment and test environment in the preferred embodiment of the present apparatus and the third line of method partSynchronous method is mutually corresponding, thus the description of specific embodiment refer on the third line provided by the invention environment andThe method of the data syn-chronization of test environment, it wouldn't repeat here.
The device of the data syn-chronization of environment and test environment on line provided in an embodiment of the present invention, after difference is contrasted,By differential disply on a display screen, obtain while tester's simple, intuitive can be allowed difference content, convenient record to difference andResearch learning.
The method and device of the data syn-chronization of environment and test environment on line provided by the present invention has been carried out in detail aboveIt is thin to introduce.Each embodiment is described by the way of progressive in specification, and what each embodiment stressed is and other realitiesApply the difference of example, between each embodiment identical similar portion mutually referring to.For device disclosed in embodimentSpeech, because it is corresponded to the method disclosed in Example, so description is fairly simple, related part is referring to method part illustration.It should be pointed out that for those skilled in the art, under the premise without departing from the principles of the invention, alsoSome improvement and modification can be carried out to the present invention, these are improved and modification also falls into the protection domain of the claims in the present inventionIt is interior.
It should also be noted that, in this manual, such as first and second or the like relational terms be used merely to byOne entity or operation make a distinction with another entity or operation, and not necessarily require or imply these entities or operationBetween any this actual relation or order be present.Moreover, term " comprising ", "comprising" or its any other variant meaningCovering including for nonexcludability, so that process, method, article or equipment including a series of elements not only include thatA little key elements, but also the other element including being not expressly set out, or also include for this process, method, article orThe intrinsic key element of equipment.