Background technology
Along with the quickening of social informatization speed, the application of network has been penetrated into social every aspect, becomes indispensable instrument in the work life.Switch be network with communicate by letter in nucleus equipment, the data forwarding in the network with transmit the participation that all be unable to do without switch.Switch is realized encapsulation and forwarding to packet based on two layers of mac Address Recognition.Its hardware has mainly comprised central processing unit (CPU), exchange chip (MAC), internal memory, register, control desk port, interface and auxiliary port, and wherein internal memory comprises read-only memory (ROM), flash memory (Flash), nonvolatile random access memory (NVRAM) and random access holder (RAM) etc.Store user configuration information on the nonvolatile random access memory wherein.
After the basic hardware system of switch realizes, will be according to the software function of user's request configuration switch.The configuration file of switch can be divided into default configuration file and user profile, and after user or equipment manager were finished the configuration of switch, switch will move according to user profile.User or equipment manager generally can write current configuration power down and keep in the medium after configuring according to use habit and the demand that the management equipment of being easy to is arranged.Switch is in the process that restarts, RAM is preferential loading user profile from NVRAM, if do not have user profile then load the default configuration file and in RAM, generate the copy of a configuration file, utilize the content in this copy to carry out initialization then.
Whether whether for the user, whether a switch meets demand, have to realize and move stablizing according to software function greatly to weigh, and switch carries out work according to user's configuration, and various services are provided.If configuration loss in running, occurs, can influence the efficient and the quality of the network operation, may cause equipment normally to use, make network to move, thereby cause unnecessary economic loss, and bring a large amount of loaded down with trivial details detection maintenance works.Especially very during bulky complex, the problem of generation can be more obvious for network.Therefore, need be configured the test of losing,, guarantee the stability of switch work with the startup configuration loss phenomenon that prevents that switch from may exist to switch.
The method of testing that existing switch configuration is lost mainly is after individual feature is configured, and verifies whether this function is effective, after preserving current configuration, carry out power-off restarting, check whether the configuration of this function loses after startup is finished, verify once more whether this function operation is effective.There is following shortcoming in this method of testing:
1. test function is comprehensive inadequately: present switch function has thousands of, and present test has repetition and omission unavoidably just at the individual feature test in the test process, and configuration loss problem when considering that test switch full configuration is put.
2. switch is constantly restarted and recovery is dispatched from the factory: testing all needs power-off restarting in each function course, need switch is carried out factory reset after testing a function, more than 1000 function items, just need to carry out and preserve power-off restarting and the recovery operation of dispatching from the factory more than 1000 times, just can draw final result.
3. test period is long: present switch function is many, tests according to existing method, will inevitably prolong test period, supposes that switch had 1000 with last function items, generally needs 1 people to test the test that just can finish all functions about 200 hours.Cause the research staff can't in time repair bug.
4. increase the R﹠D costs of product: the testing time is grown, takies more test resource and directly causes product cost to improve.
5. reliability is not high: because the defective of method of testing may cause test leakage, influenced result's reliability.
Summary of the invention
At above-described technical problem, the invention provides a kind of method of testing to switch configuration, restart stand-by period and test period to realize complete detection, to reduce switch, thus the reliability of raising switch.
Concrete technical scheme is as follows:
A kind of method of testing to switch configuration, wherein, described switch is connected with a Switch Console; Described switch comprises checks module, writing module, reservoir part; The described module of checking is used to enter switch first environment or switch second environment; Described Switch Console comprises reservoir part, file contrast module;
Described method of testing specifically comprises the steps:
The described Switch Console of step 1. is preset switch command set file;
The described switch of step 2. reads the command set file that is sent by described Switch Console, and carries out each the bar order in the described command set file, carries out the switch function configuration;
The described Switch Console of step 3. checks that by described switch module is in the user configuration information of checking under the switch first environment under the current switch configuration, and described active user's configuration information is stored in described Switch Console reservoir part, be designated as first user profile;
The described Switch Console of step 4. checks that by described switch module checks the running state information of switch under the switch second environment, and described running state information is stored in described Switch Console reservoir part, be recorded as first running state information;
The described Switch Console of step 5. is saved in active user's configuration information in the switch reservoir part by described switch writing module;
The described switch of step 6. carries out repeatedly the power-off restarting operation;
The described Switch Console of step 7. checks that by described switch module is in the user configuration information of checking under the switch first environment under the current switch configuration, and described active user's configuration information is stored in described Switch Console reservoir part, be designated as second user profile;
The described Switch Console of step 8. checks that by described switch module checks the running state information of switch under the switch second environment, and described running state information is stored in described Switch Console reservoir part, be designated as second running state information;
The described Switch Console of step 9. is by described file contrast more described respectively first user profile of module and described second user profile and described first running state information and described second running state information; It is default value or for empty that switch after restarting has corresponding parameters, then for there being user's configuration loss, otherwise for not existing.
Preferably, described first environment is a switch global schema.
Preferably, described second environment is the shell environment user interface of Linux.
Preferably, described first running state information comprises the first process operation information, the first user profile operation information and the first register operation information;
Specifically comprise in the described step 4:
The described Switch Console of step 41. is checked the process operation information and the user profile operation information of switch under the switch second environment, and is designated as the first process operation information and the first user profile operation information;
The described Switch Console of step 42. checks that by register instruction checks the register operation information under the switch second environment, and be recorded as the first register operation information;
Described second running state information comprises the second process operation information, the second user profile operation information and the second register operation information;
Specifically comprise in the described step 8:
The described Switch Console of step 81. is checked the process operation information and the user profile operation information of switch under the switch second environment, and is designated as the second process operation information and the second user profile operation information
The described Switch Console of step 82. checks that by register instruction checks the register operation information under the switch second environment, and be recorded as the second register operation information;
More described first running state information and described second running state information specifically comprise in the described step 9: more described respectively first process operation information and the described second process operation information, the described first user profile operation information and the described second user profile operation information and the described first register operation information and the described second register operation information.
Preferably, described switch reservoir part is the NVRAM reservoir part.
Preferably, described command set file comprises every function of described switch.
Preferably, there is the order of covering relation to be arranged on the different port of switch in the described command set file each other.
Preferably, also comprise step 21 in the described step 2: described Switch Console recovers to dispatch from the factory configuration with described switch.
Preferably, the power-off restarting number of times in the described step 6 is at least 30 times.
Preferably, described switch is connected in series by control desk port and Switch Console.
The invention has the beneficial effects as follows:
A kind of method of testing of the present invention to switch configuration, disposable configure configuration order collection file after, can test all functions of switch, reduced and restarted number of times, shortened test period, simultaneously, owing to cover all functions of switch, test is comprehensive, so test result is more accurate, and testing reliability is higher.In addition, the resource that method of testing provided by the invention takies is few, and because the testing time weak point, thereby reduced product cost.
Embodiment
The invention will be further described below in conjunction with the drawings and specific embodiments, but not as qualification of the present invention.
Fig. 1 is the schematic diagram of user profile operation.Wherein, after the control desk port of Test Engineer by switch was configured switch, the switch configuration information of this moment can be temporarily stored in the current configuration file in the RAM.Operation is preserved in configuration to switch, preserve in the layoutprocedure switch inside and can set up a process automatically, this process is responsible for current switch configuration information is saved in the startup configuration file (startup-config) in the switch reservoir part.Like this, behind the switch system power-off restarting, can load the startup configuration file of being preserved in the switch reservoir part, and this document called among the RAM one by one carry out, the system configuration of being correlated with, otherwise system enters the Setup pattern, start default configuration, default configuration leaves in the switch file system.
What deposit in the switch reservoir part is some user's configuration parameters, and the user is when carrying out viewing command, and switch is resolved the information that views that becomes with the parameter in the switch reservoir part.Switch configuration information dropout mainly comprises two aspects: 1. configuration store or read failure; 2. restart the abnormal startup of back function.Its possible reason has: 1. the wrong 3. preservation processes of the register set of wrong 2. certain function of the analytical function of certain function are wrong etc.The analysis of causes at above-described switch configuration information dropout, we can be by checking that switch configuration and switch reservoir part information are to confirm whether configuration loses, and, so just guaranteed reliability of testing result from configuration and two aspects of function by checking pbx process information and register information to confirm whether certain function is moved normally.
In a kind of specific embodiment, the switch reservoir part of above-mentioned storage user configuration information is a switch NVRAM holder.
Fig. 2 is the schematic flow sheet of the embodiment of a kind of method of testing to switch configuration of the present invention.
A kind of method of testing to switch configuration, switch is connected with a Switch Console; Switch comprises checks module, writing module, reservoir part; Check that module is used to enter switch first environment or switch second environment; Switch Console comprises reservoir part, file contrast module; Wherein, method of testing specifically comprises the steps:
Step 1. Switch Console is preset switch command set file.Command set file wherein is the command set file that uses when switch pastes configuration.When the configuration file whether foundation test switch configuration loses, choosing of ordering in the command set file is whether the test switch configuration exists a key of losing.
A kind of preferred embodiment in, covered every function of switch in this command set file, can all functions of switch can both being tested when the test, thereby reach the purpose of the reliability that has improved switch.
In another preferred embodiment, there is the order of covering relation to be arranged on the different port position of switch in the command set file each other.For the configuration that covering relation is arranged, by being arranged on the different switch ports themselves, can prevent in layoutprocedure switch, because front and back covering relation, cause the order of back (for example to cover order before, port is set to semiduplex mode earlier, and then same again port is set to full-duplex mode), thus can not all carry out complete test to all functions of switch.
After having set up the command set file, just be equivalent to set up the standard configuration file of a switch test configuration loss.When test next time just can directly be utilized or make an amendment slightly according to actual conditions and get final product, for the later stage tests switch configuration and loses the time saved.
Step 2. switch reads the command set file that is sent by Switch Console, and each the bar order in the fill order collection file, carries out the switch function configuration.The command set file that control desk port by switch will need to test writes switch by the mode of pasting configuration.After the command set file write switch, switch CPU can be carried out every configuration order, and this process need is through one period processing time, and the command set file is write in the current configuration file, if restart switch at this time point, switch configuration can return to default setting.
The mode of operation of switch is divided into user model, privileged mode, global configuration mode, interface configuration mode, shows as the relation that layer advances between these patterns.Global configuration mode is the topmost pattern of switch, therefore the configuration change that carries out CLI in global configuration mode can influence the overall work situation of equipment, by under the global schema of switch the command set file of step 1 being write switch by switch console port.When relating to need under interface modes, carry out the configuration of switch function the time, by the corresponding command in the command set file is set, can make switch enter interface modes by global configuration mode, carry out the configuration under the interface modes.
Therefore be chosen in the configuration information that global configuration mode gets off to obtain switch in the time of can the command set file being write switch by switch console port, finish and revise configuration renewal afterwards in the CPU.It comprises parameters such as quantity, speed with physical memory, the CPU register of initialization control reflection, and it will detect configuration file, and resolve these configuration orders by OS.Before can importing the command set file for switch, guarantee that switch console port has been connected on PC or the terminal, and got well PC or terminal-emulation software for the Switch Console interface configuration and connect speed and character format, the command set file that will need to test of the control desk port by switch writes switch then.After the command set file write switch, CPU need carry out every configuration order, and this process need is through one period processing time, and configuration file is write in the current configuration file.If restart switch at this time point, switch configuration can return to default setting.
In a kind of preferred implementation of the present invention, also comprise step 21 in the step 2: Switch Console is with the switch reduction configuration of dispatching from the factory.By before the subsides of command set file are configured to switch, all configurations of switch should be removed, i.e. factory reset impacts the result of this test to avoid original configuration.
In a kind of preferred implementation of the present invention, switch is connected in series by control desk port and Switch Console, and user or equipment manager communicate by utilizing control desk port and switch, and command set is write in the switch.Because what adopt is that the direct physical of control terminal and switch console port is connected, rather than take as network-based remote login connection, the connected mode of telnet for example, just can not be used in and carry out any configuration relevant on the former switch with logining connection, all of assurance switch are configured to empty, and prevent to exert an influence because of the result of original configuration to this test.
The described Switch Console of step 3. checks that by described switch module is in the user configuration information of checking under the switch first environment under the current switch configuration, and described active user's configuration information is stored in described Switch Console reservoir part, be designated as first user profile.In a kind of specific embodiment, the first environment of switch is the global schema of switch.Configuration information in the operating system parsing operation configuration file of switch, can be by under the global schema, view the current configuration information of switch by the viewing command of order line, need duplicate the user profile that shows this moment, be designated as first user profile, for last contrast is prepared.
Step 4. Switch Console checks that by switch module checks the running state information of switch under the switch second environment, and running state information is stored in described Switch Console reservoir part, is recorded as first running state information.In a kind of embodiment, second environment is the shell environment user interface of Linux.Switch function can be divided into by the CPU realization with by two kinds of exchange chip (ASIC) realizations, the function difference that these two kinds of chips are realized.The CPU of switch mainly is responsible for the configuration management and the protocol processes of switch, the exchange chip of switch then mainly is responsible for is quick forwarding to Layer 2 data, as MAC address learning and aging, ingress filters, according to basic functions such as MAC+VLAN forwarding, broadcast domain inundation, spanning-tree port states.Therefore it is also different to confirm whether these two kinds of functions move normal method, by the function that CPU realizes, need check progress information, and by the function that exchange chip is realized, need check register information.Therefore, on the basis of technique scheme, the first above-mentioned running state information comprises the first process operation information, a NVRAM operation information and the first register operation information.
Concrete, comprise in the above-mentioned step 4:
The described Switch Console of step 41. is checked the process operation information and the user profile operation information of switch under the switch second environment, and is designated as the first process operation information and the first user profile operation information;
The described Switch Console of step 42. checks that by register instruction checks the register operation information under the switch second environment, and be recorded as the first register operation information.
By checking that these information can directly understand whether operate as normal of function that switch realizes by CPU, can also check that in addition the interface message of corresponding process confirms whether the state machine of this function moves normally.In case certain function goes wrong, can promptly and accurately locate, for the fault recovery of switch provides important information.Duplicate the process and the user profile operation information of switch this moment, be designated as the first process operation information and the first user profile operation information.
Therefore process under the shell environment of switch linux does not comprise the function of being finished by exchange chip, need confirm whether operate as normal of this function according to the register information of these functions.The physical address that each function is distributed in register is determined by exchanger chip, the register of checking each function correspondence need be understood the physical address of the corresponding register of this function, the physical address of register can be searched by this exchanger chip databook, under the shell environment of Linux, use the register viewing command that the register information of this function is checked then, for example the register address of the last vlan correspondence of BCM53242 is 05, can may there are differences by the order of order regscan-p0X05(different vendor) just can see the register information of vlan function correspondence, certainly also have than the mode of checking register faster, can check the information of the whole page or leaf of register by spi – r+ parameter.Be recorded as the first register operation information.
The described Switch Console of step 5. is saved in active user's configuration information in the switch reservoir part by described switch writing module.In a kind of specific embodiment, the switch reservoir part that stores user profile is the NVRAM reservoir part.General switch configuration file can be stored in two places, and the content that is respectively after the RAM(outage here can be lost), the NVRAM(nonvolatile random access memory).After the running configuration file among the RAM is changed, need up-to-date running configuration file is backed up.This is because can lose after the content outage in the memory ram.Can be by using the write order, the implication of this order is exactly that running configuration file is saved in the startup configuration file of NVRAM.After switch was carried out and preserved action, exchange opportunity was set up a process automatically, and current configuration is left among the NVRAM, and configuration just can not lost after power failure or premeditated restarting like this.After above step is finished, just can carry out the test of power-off restarting to switch.
Step 6. switch is power-off restarting repeatedly.In a kind of specific embodiment, the power-off restarting number of times is at least 30 times, as the foundation of judgement of stability.Restart the general sequence that starts according to switch and carry out, pass through the system hardware Power-On Self-Test successively, software initialization is sought and the loading system file, search subscriber configuration file and execution etc. in NVRAM.
Step 7. Switch Console checks that by switch module is under the switch first environment, it is the switch global schema in the foregoing description, check the user configuration information under the current switch configuration, and active user's configuration information is stored in the Switch Console reservoir part, be designated as second user profile.
Step 8. Switch Console checks that by switch module is under the switch second environment, it is the shell environment user interface of the Linux in the foregoing description, check the running state information of switch, and running state information is stored in the Switch Console reservoir part, be designated as second running state information.
On the basis of technique scheme, step 8 specifically comprises: step 81. Switch Console is checked the process operation information and the user profile operation information of switch under the shell environment of switch Linux, and is designated as the second process operation information and the second user profile operation information;
Step 82. Switch Console checks that by register instruction checks the register operation information under the shell environment of switch Linux, and be recorded as the second register operation information.
After the switch power-off restarting is finished, carry out above-mentioned step 7 and step 8, step 7 and step 8 are repeating step 3 and step 4 substantially.Step 7 is checked current configuration by the order line under the global schema of switch, and duplicates and be designated as second user profile.Step 8 item is checked progress information, NVRAM information and the register information of the function that switch under the shell environment of switch linux is finished by CPU, and duplicate, respective record is the second process operation information, the 2nd NVRAM operation information, the second register operation information.It should be noted, can not carry out step operation in addition to switch in this process.
Step 9. Switch Console compares first user profile and second user profile and first running state information and second running state information respectively by described file contrast module; It is default value or for empty that switch after restarting has corresponding parameters, then for there being user's configuration loss, otherwise for not existing.On the basis of technique scheme, comparison first running state information and second running state information specifically comprise in the step 9: a NVRAM operation information and the 2nd NVRAM operation information in the step 8 and the first register operation information in the step 4 and the second register operation information in the step 8 of first process operation information in the difference comparison step 4 and the second process operation information in the step 8, step 4.Compare by first user profile and second user profile, check whether the configuration of switch before and after restarting is consistent.Compare by the first process operation information and the second process operation information, check whether the process before restarting loses after restarting.Compare by a NVRAM operation information and the 2nd NVRAM operation information, check whether the configuration file among the NVRAM is consistent before and after restarting.Compare by the first register operation information and the second register operation information, check whether the configuration of register before and after restarting is consistent.It is default value or for empty that switch after restarting has corresponding parameters, then for user's configuration loss takes place, otherwise for there not being generation user configuration loss.
A kind of method of testing of the present invention to switch configuration, according to structure, workflow, the function implementation of switch, at the configuration loss behind switch power-off restarting test, proposed a kind of comprehensively, method of testing efficiently.Set command set file is at the switch all functions in this method, coverage rate to the total interface all functions has reached 100% basically, and have flexible and changeable characteristics, can make an amendment slightly according to the port variation promptly can be used for the test of other model switch.Simultaneously, the shell environment of the linux that provides in the switch development process has been provided, in this environment, check pbx process, NVRAM information and register information, be to judge from the angle of exploitation, clear accurate, can guarantee the accuracy of file, also can help to locate configuration loss reason that produces and the link that makes a mistake, increase the coverage rate of test and goed deep into degree.Method of testing of the present invention is used comparison software, to user profile, pbx process, NVRAM information and the register information of record, improves the accuracy of judgement and the time of reduction contrast, increases work efficiency.
Compare with the existing method of testing that switch configuration is lost, command set file of the present invention comprises all functions of switch, and full configuration is put test, has covered all functions of switch.And existing test can only be tested at individual feature, configuration loss problem when consideration test switch full configuration is put.Because present switch function has thousands of, so has repetition and omission in the test process unavoidably.Secondly, the present invention can reduce the number of times of restarting of when the configuration loss test of carrying out switch switch significantly, has improved testing efficiency.And all need power-off restarting in existing each function course of method of testing, and need switch is carried out factory reset after testing a function, repeatedly carry out and preserve power-off restarting and recovery is dispatched from the factory, just can draw final result.Once more, the present invention has shortened test period, according to present method switch is tested, and will inevitably prolong test period, generally needs 1 people to test the test that just can finish all functions about 200 hours.Cause the research staff can't time update Bug.And method provided by the invention is disposable configure after, can all functions of switch be tested, general 1 people just can finish in two hours, had reduced the time significantly.In addition, the present invention has also significantly reduced R﹠D costs: how existing method test period long, take manpower directly causes the research and development of products cost to improve if being.The manpower that method of testing provided by the invention takies is few, and the testing time is short, therefore must reduce the research and development of products cost.Simultaneously, method of testing of the present invention has improved reliability of products, and the existing existing defective of method of testing may cause test leakage, and therefore often taking time and effort resulting test result can't obtain gratifying reliability.Method of testing provided by the invention.Method provided by the invention covers all functions of switch, and test result is more accurate, for the stability of judging switch provides a foundation.
The above only is preferred embodiment of the present invention; be not so restriction embodiments of the present invention and protection range; to those skilled in the art; should recognize that being equal to that all utilizations specification of the present invention and diagramatic content done replace and the resulting scheme of conspicuous variation, all should be included in protection scope of the present invention.