CN113645095A - Automatic switch testing method, equipment and medium based on snmp alarm information - Google Patents
Automatic switch testing method, equipment and medium based on snmp alarm information Download PDFInfo
- Publication number
- CN113645095A CN113645095A CN202110914233.2A CN202110914233A CN113645095A CN 113645095 A CN113645095 A CN 113645095A CN 202110914233 A CN202110914233 A CN 202110914233A CN 113645095 A CN113645095 A CN 113645095A
- Authority
- CN
- China
- Prior art keywords
- preset
- virtual machine
- trap
- switch
- test cases
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 207
- 238000012544 monitoring process Methods 0.000 claims abstract description 58
- 238000000034 method Methods 0.000 claims abstract description 31
- 238000001514 detection method Methods 0.000 claims abstract description 13
- 230000006870 function Effects 0.000 claims description 66
- 238000003860 storage Methods 0.000 claims description 7
- 238000004891 communication Methods 0.000 claims description 5
- 239000000126 substance Substances 0.000 claims description 3
- 230000008569 process Effects 0.000 abstract description 10
- 230000002159 abnormal effect Effects 0.000 description 5
- 239000000243 solution Substances 0.000 description 5
- 239000003795 chemical substances by application Substances 0.000 description 4
- 238000009826 distribution Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 238000002347 injection Methods 0.000 description 3
- 239000007924 injection Substances 0.000 description 3
- 238000012423 maintenance Methods 0.000 description 3
- 238000011161 development Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000006872 improvement Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 238000012827 research and development Methods 0.000 description 2
- 230000005856 abnormality Effects 0.000 description 1
- 230000004075 alteration Effects 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004883 computer application Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 238000010998 test method Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/50—Testing arrangements
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The embodiment of the specification provides an automatic switch testing method based on snmptrap alarm information, and aims to solve the problems that manual testing costs and testing processes are complex in the prior art. The method comprises the following steps: executing a plurality of test cases of a preset queue in a plurality of virtual machines in parallel through a preset control program; respectively inputting a plurality of test cases of a preset queue into the switch corresponding to the virtual machine, so that the snmp function modules of the switch respectively execute the test cases; monitoring a port of the snmp function module for sending a fault message through a monitoring thread of the virtual machine so as to obtain the fault message returned by the snmp function module to the virtual machine; analyzing a preset message segment in the fault message, acquiring a trap identifier in the fault message according to the preset message segment, and monitoring the matching condition of the trap identifier and a test case, wherein the trap identifier corresponds to a trap alarm message in a key-value pair mode; and adopting a corresponding mode according to the matching condition to complete the switch detection of the test case.
Description
Technical Field
The present disclosure relates to the field of computer application technologies, and in particular, to a method and an apparatus for automatically testing a switch based on snmp trap alarm information.
Background
With the rapid development of computer technology and communication technology, ethernet switches capable of realizing high-speed data exchange are widely used. Reliability of the switch and product cost are therefore increasingly valued. Product costs include development costs as well as maintenance costs. In the product design, how to reduce the research and development cost and the maintenance cost needs to be considered. The first point of reduction of research and development cost is the improvement of efficiency; the maintenance cost is reduced mainly by reliably manufacturing the product, and meanwhile, the fault phenomenon and specific fault points which have problems can be stripped off at the first time when the problems occur. Therefore, it is necessary to ensure that the failure information can be accurately printed when a failure occurs while performing a test. The Trap is mainly used for sending a message of device abnormity to the management server when the switch device is abnormal.
In the existing use case test of the switch snmp trap, manual test is generally adopted, and a large amount of manpower and time are consumed.
Based on this, there is a need for an automatic testing method for switch snmp trap, so as to shorten the time of automatic testing and save human resources.
Disclosure of Invention
One or more embodiments of the present specification provide an automated testing method, apparatus, device and medium for a switch snmp trap, which are used to solve the following technical problems: automated testing of switch snmp trap consumes a lot of manpower and time.
One or more embodiments of the present disclosure adopt the following technical solutions:
one or more embodiments of the present specification provide a switch automation test method based on snmp trap alarm information, including:
executing a plurality of test cases of a preset queue in a plurality of virtual machines in parallel through a preset control program;
respectively inputting the plurality of test cases of the preset queue into the switch corresponding to the virtual machine, so that the snmp function modules of the switch respectively execute the test cases;
monitoring a port of the snmp function module, which sends a fault message, through a monitoring thread of the virtual machine so as to obtain the fault message returned by the snmp function module to the virtual machine;
analyzing a preset message segment in the fault message, acquiring a trap identifier in the fault message according to the preset message segment, and detecting the matching condition of the trap identifier and the test case; wherein the trap identifier corresponds to the test case in the form of a key-value pair;
and adopting a corresponding mode according to the matching condition to complete the switch detection of the test case.
Optionally, in one or more embodiments of the present specification, before the executing, by the control program, the test cases in the preset queue in parallel in the virtual machine, the method further includes:
acquiring the version number of the snmp function module;
collecting test cases of different versions of the snmp function module according to the version number;
and storing the test cases into a queue in a preset sequence to obtain a preset queue.
Optionally, in one or more embodiments of the present specification, before the executing, by the control program, the test cases in the preset queue to the virtual machine in parallel, the method further includes:
acquiring an IP address of the virtual machine;
and if the virtual machine is determined to be in a normal network state according to the IP address of the virtual machine and a communication instruction sent by a switch corresponding to the virtual machine, so that the test cases in a preset queue are executed to the virtual machine in parallel through a control program.
Optionally, in one or more embodiments of the present specification, the executing, by the control program, the test case in the preset queue in parallel in the virtual machine specifically includes:
if the test case does not exist in the current preset queue, finishing executing the test case of the preset queue;
if the test cases exist in the current preset queue, distributing the test cases in the preset queue to the multiple virtual machines in sequence through a control program according to the preset storage sequence, and controlling the multiple virtual machines to execute the distributed test cases.
Optionally, in one or more embodiments of the present specification, the respectively inputting the multiple test cases in the preset queue into the switch corresponding to the virtual machine specifically includes:
connecting the virtual machine to a corresponding switch through an automatic script, and configuring a snmp function module for the switch to obtain the switch with the snmp function module;
and sequentially inputting the test cases of the preset queue to the switch with the snmp function module through the automation script of the virtual machine.
Optionally, in one or more embodiments of the present specification, the monitoring, by the monitoring thread of the virtual machine, a port at which the snmp function module sends a fault packet specifically includes:
responding to the test cases of the preset queue through the snmp function module to obtain a fault message containing trap alarm information;
monitoring the port of the switch, which sends the fault message, for preset time according to the monitoring thread of the virtual machine;
if the virtual machine monitors a fault message which is sent by the port and contains trap alarm information within the preset time, continuously executing the test cases in the preset queue;
and if the virtual machine cannot monitor the fault message containing trap information sent by the port within the preset time, ending the monitoring thread.
Optionally, in one or more embodiments of the present specification, the analyzing a preset segment in the failure message, obtaining a trap identifier in the failure message according to the preset segment, and detecting a matching condition between the trap identifier and the test case specifically includes:
receiving a fault message through a monitoring thread of the virtual machine, and analyzing a preset message segment in the fault message; the preset message segment is a message segment used as a protocol data unit;
and if the trap identifier exists in the fault message is determined according to the preset message segment, detecting the matching condition of the trap identifier and the test case.
Optionally, in one or more embodiments of the present specification, the taking a corresponding manner according to the matching condition specifically includes:
if the trap identifier in the fault message is matched with the test case, stopping the monitoring process of the virtual machine;
and if the trap identifier in the fault message does not match with the test case, determining that the snmp function module fails the test of the test case.
One or more embodiments of the present specification provide a switch automation test apparatus based on snmp trap alarm information, the apparatus including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
executing a plurality of test cases of a preset queue in a plurality of virtual machines in parallel through a preset control program;
respectively inputting the plurality of test cases of the preset queue into the switch corresponding to the virtual machine, so that the snmp function modules of the switch respectively execute the test cases;
monitoring a port of the snmp function module, which sends a fault message, through a monitoring thread of the virtual machine so as to obtain the fault message returned by the snmp function module to the virtual machine;
analyzing a preset message segment in the fault message, acquiring a trap identifier in the fault message according to the preset message segment, and detecting the matching condition of the trap identifier and the test case; wherein the trap identifier corresponds to a trap alert message in the form of a key-value pair;
and adopting a corresponding mode according to the matching condition to complete the switch detection of the test case.
One or more embodiments of the present specification provide a non-transitory computer storage medium storing computer-executable instructions configured to:
executing a plurality of test cases of a preset queue in a plurality of virtual machines in parallel through a preset control program;
respectively inputting the plurality of test cases of the preset queue into the switch corresponding to the virtual machine, so that the snmp function modules of the switch respectively execute the test cases;
monitoring a port of the snmp function module, which sends a fault message, through a monitoring thread of the virtual machine so as to obtain the fault message returned by the snmp function module to the virtual machine;
analyzing a preset message segment in the fault message, acquiring a trap identifier in the fault message according to the preset message segment, and detecting the matching condition of the trap identifier and the test case; wherein the trap identifier corresponds to a trap alert message in the form of a key-value pair;
and adopting a corresponding mode according to the matching condition to complete the switch detection of the test case.
The embodiment of the specification adopts at least one technical scheme which can achieve the following beneficial effects:
all test cases of the snmptrap are executed in the virtual machine in a parallel mode, so that steps and time for case testing are saved. The snmp alarm information is analyzed in an automatic mode, the complex process of manually decrypting the snmp multi-version is avoided, and errors caused by manual negligence are avoided.
Drawings
In order to more clearly illustrate the embodiments of the present specification or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the present specification, and for those skilled in the art, other drawings can be obtained according to the drawings without any creative effort. In the drawings:
fig. 1 is a schematic flowchart of a method for automatically testing a switch based on snmp trap alarm information according to one or more embodiments of the present disclosure;
fig. 2 is a schematic flowchart of test case distribution in an application scenario according to one or more embodiments of the present disclosure;
fig. 3 is a schematic flowchart of a monitoring thread of a virtual machine in an application scenario according to one or more embodiments of the present disclosure;
fig. 4 is a schematic internal structural diagram of a switch automation test equipment based on snmp trap alarm information according to one or more embodiments of the present specification;
FIG. 5 provides a non-volatile storage medium for one or more embodiments of the present description.
Detailed Description
The embodiment of the specification provides a method, equipment and medium for automatically testing a switch based on snmp trap alarm information.
In order to make those skilled in the art better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only a part of the embodiments of the present specification, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present specification without any creative effort shall fall within the protection scope of the present specification.
The Simple Network Management Protocol (snmp) belongs to the application layer Protocol in TCP/IP five-layer Protocol, and is used for Network Management. The snmp is mainly composed of two major parts: a snmp management station and a snmp agent. The snmp management station is a central node and is responsible for collecting and maintaining information of each snmp element, processing the information and finally feeding back the information to a network administrator; the snmp agent runs on each managed network node, is responsible for counting various information of the node, and is responsible for interacting with the snmp management station, receiving and executing commands of the management station, and uploading various local network information. the trap is that an agent actively notifies a management station of an important event, and the function of the trap is that under the premise that the network management system does not have explicit requirements, the management agent notifies the network management system that some special situations or problems occur, and the management station can correspondingly process the situations.
When the equipment of the existing switch is abnormal, the trap mainly sends an equipment abnormal message to the administrator server when the switch equipment is abnormal, and in the test of the switch snmp, the trap mainly captures a packet to acquire a message to perform a matching test when the equipment fails. The current steps when performing the snmp trap test include: and the server starts packet capturing software and starts packet capturing, and after the packet capturing is finished, faults are manually injected into the switch. After the fault is injected, packet capturing of the server is stopped after waiting for a certain time, and then the captured message is checked and the snmp message is filtered out. Finding out a trap message in the snmp message, then checking whether the message has trap information consistent with the injected fault, and finishing the snmp test of a fault at the moment. And modifying the behavior of fault injection, and completing fault test of all the switches in sequence.
The current process of manually testing the snmptrap alarm information is very complicated, and consumes manpower and resources. And because the snmp has different versions corresponding to each other, including snmp v1, snmp v2 and snmpv3, each version needs to be executed with the test case in sequence in a serial manner when the test is performed each time. After each packet capture, the snmp 3 trap related to message encryption needs information such as a user name, an encryption mode, an encryption password, an authentication mode, an authentication password and the like to analyze trap information carried by a fault message in the snmp and judge whether the trap information meets expectations or not, and the test mode consumes time and energy. In addition, three versions of trap test cases are executed in series in a manual test mode, and the consumed time cost is large.
In order to solve the above problem, an automated method is used in this specification to inject a fault into the switch, and the virtual machine is used as a server monitoring port of the switch to monitor a fault message sent. And analyzing the snmptrap alarm information in an automatic mode, and matching the snmptrap alarm information with the injection fault value to see whether the snmptrap alarm information meets the expectation or not. And all cases of the snmp are executed in a parallel mode, so that the time cost of fault testing is saved, technical personnel are liberated, and the technical cost is reduced.
The technical solution provided in the present specification is described in detail below with reference to the accompanying drawings.
One or more embodiments of the present specification provide a method flow diagram of a switch automation testing method based on snmp trap alarm information, as shown in fig. 1.
The method comprises the following steps:
s101: and executing a plurality of test cases of a preset queue in a plurality of virtual machines in parallel through a preset control program.
In one or more embodiments of the present specification, before the executing, by the control program, the test cases in the preset queue in parallel in the virtual machine, the method further includes:
acquiring the version number of the snmp function module;
collecting test cases of different versions of the snmp function module according to the version number;
and storing the test cases into a queue in a preset sequence to obtain a preset queue.
In one or more embodiments of the present specification, before the executing, by the control program, the test cases in the preset queue to the virtual machine in parallel, the method further includes:
acquiring an IP address of the virtual machine;
and if the virtual machine is determined to be in a normal network state according to the IP address of the virtual machine and a communication instruction sent by a switch corresponding to the virtual machine, so that the test cases in a preset queue are executed to the virtual machine in parallel through a control program.
In one or more embodiments of the present specification, the executing, by a control program, a test case in a preset queue in parallel in a virtual machine specifically includes:
if the test case does not exist in the current preset queue, finishing executing the test case of the preset queue;
if the test cases exist in the current preset queue, distributing the test cases in the preset queue to the multiple virtual machines in sequence through a control program according to the preset storage sequence, and controlling the multiple virtual machines to execute the distributed test cases.
snmp corresponds to different versions, snmp v1, snmp v2 and snmp v 3. Therefore, when the switch automation test of the snmp is carried out, all test cases of the three versions of the snmp trap are collected firstly. And then the test cases are stored in the queue in a random sequence or a fixed sequence according to the requirements. And after the test cases are stored in the preset queue, the preset queue behind the fixed test case sequence is obtained.
Wherein, it is to be noted that snmp currently has three versions of v1, v2 and v 3. The snmp v1 is the initial version of the snmp protocol, provides minimum network management functions, and is the basic way for many manufacturers to implement snmp. The snmp v2 is generally referred to as colony-based, and is compatible with the snmp v1 and expands the functions of the snmp v 1. snmpv2 provides more operation types, and supporting more data types provides richer error codes to distinguish errors more finely. snmpv3 is the latest version of snmp, and its greatest contribution to network management is security, which increases support for authentication and ciphertext transmission. The message formats of the messages composed of the alarm information of the three versions of the snmp trap are different, so that the test cases of all the versions need to be collected when the test cases are detected for subsequent detection.
In order to reduce errors in test results when test conditions permit, it is necessary to use as many virtual machines as possible. Assuming that there are M virtual machines, the M virtual machines can be used as the servers corresponding to the M switches to perform an automated test of the switch snmptrap. Before test case detection of the snmp, the network state of the virtual machine needs to be checked, so that the virtual machine can be in a normal network state, normal distribution of the test case by the virtual machine is guaranteed, and inaccurate test results caused by virtual machine faults are avoided. First, the IP address of the virtual machine needs to be acquired, so as to determine the network state of the virtual machine according to the IP address of the virtual machine and the connectivity command. In one or more embodiments of the present description, the connectivity command may be a ping command. If the switch can ping the corresponding virtual machine IP address, the virtual machine is in a normal network state, and a fault message sent by the switch can be received. If the switch cannot ping the corresponding IP address of the virtual machine, the network state of the virtual machine is in an abnormal state, subsequent test case detection processes cannot be carried out, and the virtual machine needs to be maintained or replaced, so that the reliability of a test result is ensured.
After determining that the virtual machine is in a normal network state, as shown in fig. 2, one or more embodiments of the present specification provide a flowchart of test case distribution in an application scenario.
If the control program determines that no test case exists in the current queue, the test cases in the preset queue are all tested, and the test process can be finished after the test cases are executed. And if the test cases still exist in the current queue, distributing the test cases at the front end in the current queue to the multiple virtual machines in parallel. It should be noted that the test cases in the preset queue are distributed to all the virtual machines in parallel each time. And the test cases are removed from the preset queue after being distributed each time, and after the execution of one test case is finished, the control program continues to distribute the test cases in the preset queue until all the test cases in the preset queue are executed, and the preset queue becomes an empty queue. The time cost in the process of testing the case is saved by testing all versions of the snmp trap in parallel.
S102: and respectively inputting the plurality of test cases of the preset queue into the switch corresponding to the virtual machine, so that the snmp function modules of the switch respectively execute the test cases.
In one or more embodiments of the present specification, the respectively inputting the multiple test cases in the preset queue to the switch corresponding to the virtual machine specifically includes:
connecting the virtual machine to a corresponding switch through an automatic script, and configuring a snmp function module for the switch to obtain the switch with the snmp function module;
and sequentially inputting the test cases of the preset queue to the switch with the snmp function module through the automation script of the virtual machine.
As shown in fig. 3, the virtual machine serves as a server to distribute test cases to the corresponding switch, so as to inject fault information into the corresponding switch. The virtual machine is used as a server of the test switch snmptrap, and a monitoring thread needs to be started on the virtual machine. It should be noted that the monitoring thread is mainly a fault message sent by the default communication port 162 of the snmp function module of the monitoring switch.
In the monitoring process of the monitoring thread, the corresponding switch equipment is simultaneously connected through the automation script to perform the relevant configuration of the snmp function module, so that the corresponding switch equipment has the trap function of the snmp function module. And inputting test cases of a preset queue to a switch with a snmp function module in sequence through an automation script of the virtual machine so as to complete automatic injection of the fault. When the fault type test of one snmp trap is completed, the control program detects the next test case from the preset queue to test other fault alarms until all test cases are executed, and the complete coverage rate of the snmp trap test is ensured. The test case may include: port closing, equipment shutdown, user login failure, over-temperature alarm and the like.
S103: and monitoring a port of the snmp function module, which sends a fault message, through a monitoring thread of the virtual machine so as to obtain the fault message returned by the snmp function module to the virtual machine.
In one or more embodiments of the present specification, the monitoring, by the monitoring thread of the virtual machine, a port at which the snmp function module sends a failure packet specifically includes:
responding to the test cases of the preset queue through the snmp function module to obtain a fault message containing trap alarm information;
monitoring the port of the switch, which sends the fault message, for preset time according to the monitoring thread of the virtual machine;
if the virtual machine monitors a fault message which is sent by the port and contains trap alarm information within the preset time, continuously executing the test cases in the preset queue;
and if the virtual machine cannot monitor the fault message containing trap information sent by the port within the preset time, ending the monitoring thread.
As shown in fig. 3, the snmp function module of the switch responds to the test case in the preset queue injected by the virtual machine, and obtains a fault message containing trap alarm information. And the virtual machine is used as a server to monitor the fault message of the switch, and if the monitoring thread of the virtual machine receives the fault message within the preset time, the subsequent fault message analysis and other test cases are detected. If the monitoring thread of the virtual machine cannot receive the fault message returned by the snmp trap all the time after the test case is injected into the switch, the monitoring thread stops after the preset time is exceeded, and the overtime information is returned to the virtual machine. For example: if the monitoring thread does not obtain the fault message sent by the switch snmp function module within the waiting time of 10s after the fault of the test case is injected into the switch, the monitoring thread does not continuously monitor the port, but stops the monitoring thread after 10s is exceeded, and returns the overtime information to the virtual machine serving as the server.
S104: analyzing a preset message segment in the fault message, acquiring a trap identifier in the fault message according to the preset message segment, and detecting the matching condition of the trap identifier and the test case; wherein the trap identifier corresponds to the test case in the form of a key-value pair.
In one or more embodiments of the present specification, the analyzing a preset segment in the failure message, obtaining a trap identifier in the failure message according to the preset segment, and detecting a matching condition between the trap identifier and the test case specifically includes:
receiving a fault message through a monitoring thread of the virtual machine, and analyzing a preset message segment in the fault message; the preset message segment is a message segment used as a protocol data unit;
and if the trap identifier exists in the fault message is determined according to the preset message segment, detecting the matching condition of the trap identifier and the test case.
As shown in fig. 3, after a monitoring thread of a virtual machine serving as a server receives a fault message of a switch snmp function module, a preset message segment in the fault message is analyzed, and because a pdu in the fault message carries trap alarm information, it is only necessary to analyze whether the pdu in the fault message has trap alarm information, and it is possible to obtain whether a port returns the trap alarm information. If the trap identifier exists in the pdu of the preset segment, that is, if the trap identifier exists in the pdu of the preset segment, whether the fault value corresponding to the trap identifier matches with the test case can be detected according to the key value relationship between the trap identifier and the test case. And taking corresponding measures according to the matching condition to obtain a test result.
S105: and adopting a corresponding mode according to the matching condition to complete the switch detection of the test case.
In one or more embodiments of the present specification, the taking a corresponding manner according to the matching condition specifically includes:
if the trap identifier in the fault message is matched with the test case, stopping the monitoring process of the virtual machine;
and if the trap identifier in the fault message does not match with the test case, determining that the snmp function module fails the test of the test case.
According to the matching condition obtained in step S104, if it is determined that the trap alarm information sent by the snmp function module matches the test case injected into the switch by the virtual machine, it indicates that the trap alarm of the snmp function module to the test case is normal, and the virtual machine may stop monitoring the thread of the test case and perform the next test case in the preset queue until the test case in the preset queue is executed. If the trap alarm information sent by the snmp function module is determined not to be matched with the test case injected into the switch by the virtual machine, the abnormality of the trap alarm of the test case by the snmp function module of the switch is shown, and the trap alarm information cannot be sent to the virtual machine if the same fault as the test case occurs in the actual application process. The ports of the thread monitoring switch are started to capture packets, the messages are analyzed to match the trap identifiers with the corresponding fault values of the test cases, redundant message information can be filtered, unnecessary errors caused by manual negligence in the matching process are reduced, and the reliability and the efficiency of the test are improved.
As shown in fig. 4, one or more embodiments of the present specification provide a switch automation test equipment based on snmptrap alarm information, which is characterized in that the equipment comprises:
at least one processor 401; and the number of the first and second groups,
a memory 402 communicatively coupled to the at least one processor 401; wherein the content of the first and second substances,
the memory 402 stores instructions executable by the at least one processor 401 to enable the at least one processor 401 to: executing a plurality of test cases of a preset queue in a plurality of virtual machines in parallel through a preset control program;
respectively inputting the plurality of test cases of the preset queue into the switch corresponding to the virtual machine, so that the snmp function modules of the switch respectively execute the test cases;
monitoring a port of the snmp function module, which sends a fault message, through a monitoring thread of the virtual machine so as to obtain the fault message returned by the snmp function module to the virtual machine;
analyzing a preset message segment in the fault message, acquiring a trap identifier in the fault message according to the preset message segment, and detecting the matching condition of the trap identifier and the test case; wherein the trap identifier corresponds to a trap alert message in the form of a key-value pair;
and adopting a corresponding mode according to the matching condition to complete the switch detection of the test case.
As shown in fig. 5, one or more embodiments of the present specification provide a non-volatile storage medium storing executable instructions 501 of a computer, where the executable instructions 501 are configured to:
executing a plurality of test cases of a preset queue in a plurality of virtual machines in parallel through a preset control program;
respectively inputting the plurality of test cases of the preset queue into the switch corresponding to the virtual machine, so that the snmp function modules of the switch respectively execute the test cases;
monitoring a port of the snmp function module, which sends a fault message, through a monitoring thread of the virtual machine so as to obtain the fault message returned by the snmp function module to the virtual machine;
analyzing a preset message segment in the fault message, acquiring a trap identifier in the fault message according to the preset message segment, and detecting the matching condition of the trap identifier and the test case; wherein the trap identifier corresponds to a trap alert message in the form of a key-value pair;
and adopting a corresponding mode according to the matching condition to complete the switch detection of the test case.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The above description is merely one or more embodiments of the present disclosure and is not intended to limit the present disclosure. Various modifications and alterations to one or more embodiments of the present description will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement or the like made within the spirit and principle of one or more embodiments of the present specification should be included in the scope of the claims of the present specification.
Claims (10)
1. An automatic switch testing method based on snmp trap alarm information, which is characterized in that the method comprises the following steps:
executing a plurality of test cases of a preset queue in a plurality of virtual machines in parallel through a preset control program;
respectively inputting the plurality of test cases of the preset queue into the switch corresponding to the virtual machine, so that the snmp function modules of the switch respectively execute the test cases;
monitoring a port of the snmp function module, which sends a fault message, through a monitoring thread of the virtual machine so as to obtain the fault message returned by the snmp function module to the virtual machine;
analyzing a preset message segment in the fault message, acquiring a trap identifier in the fault message according to the preset message segment, and detecting the matching condition of the trap identifier and the test case; wherein the trap identifier corresponds to the test case in the form of a key-value pair;
and adopting a corresponding mode according to the matching condition to complete the switch detection of the test case.
2. The method according to claim 1, wherein before the test cases of the preset queue are executed in parallel in the virtual machine by the control program, the method further comprises:
acquiring the version number of the snmp function module;
collecting test cases of different versions of the snmp function module according to the version number;
and storing the test cases into a queue in a preset sequence to obtain a preset queue.
3. The method according to claim 1, wherein before the test cases in the preset queue are executed in parallel to the virtual machine by the control program, the method further comprises:
acquiring an IP address of the virtual machine;
and if the virtual machine is determined to be in a normal network state according to the IP address of the virtual machine and a communication instruction sent by a switch corresponding to the virtual machine, so that the test cases in a preset queue are executed to the virtual machine in parallel through a control program.
4. The method according to claim 2, wherein the executing test cases of the preset queue in the virtual machine in parallel by the control program specifically includes:
if the test case does not exist in the current preset queue, finishing executing the test case of the preset queue;
if the test cases exist in the current preset queue, distributing the test cases in the preset queue to the multiple virtual machines in sequence through a control program according to the preset storage sequence, and controlling the multiple virtual machines to execute the distributed test cases.
5. The method according to claim 1, wherein the step of inputting the plurality of test cases in the preset queue into the switch corresponding to the virtual machine includes:
connecting the virtual machine to a corresponding switch through an automatic script, and configuring a snmp function module for the switch to obtain the switch with the snmp function module;
and sequentially inputting the test cases of the preset queue to the switch with the snmp function module through the automation script of the virtual machine.
6. The method according to claim 1, wherein the monitoring, by the monitoring thread of the virtual machine, a port at which the snmp function module sends a fault message includes:
responding to the test cases of the preset queue through the snmp function module to obtain a fault message containing trap alarm information;
monitoring the port of the switch, which sends the fault message, for preset time according to the monitoring thread of the virtual machine;
if the virtual machine monitors a fault message which is sent by the port and contains trap alarm information within the preset time, continuously executing the test cases in the preset queue;
and if the virtual machine cannot monitor the fault message containing trap information sent by the port within the preset time, ending the monitoring thread.
7. The method according to claim 1, wherein the analyzing a preset segment in the failure message, obtaining a trap identifier in the failure message according to the preset segment, and detecting a matching condition between the trap identifier and the test case specifically includes:
receiving a fault message through a monitoring thread of the virtual machine, and analyzing a preset message segment in the fault message; the preset message segment is a message segment used as a protocol data unit;
and if the trap identifier exists in the fault message is determined according to the preset message segment, detecting the matching condition of the trap identifier and the test case.
8. The method according to claim 1, wherein the taking of a corresponding manner according to the matching condition specifically includes:
if the trap identifier in the fault message is matched with the test case, stopping the monitoring process of the virtual machine;
and if the trap identifier in the fault message does not match with the test case, determining that the snmp function module fails the test of the test case.
9. An automatic switch testing device based on snmp trap alarm information, characterized in that the device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to: executing a plurality of test cases of a preset queue in a plurality of virtual machines in parallel through a preset control program;
respectively inputting the plurality of test cases of the preset queue into the switch corresponding to the virtual machine, so that the snmp function modules of the switch respectively execute the test cases;
monitoring a port of the snmp function module, which sends a fault message, through a monitoring thread of the virtual machine so as to obtain the fault message returned by the snmp function module to the virtual machine;
analyzing a preset message segment in the fault message, acquiring a trap identifier in the fault message according to the preset message segment, and detecting the matching condition of the trap identifier and the test case; wherein the trap identifier corresponds to a trap alert message in the form of a key-value pair;
and adopting a corresponding mode according to the matching condition to complete the switch detection of the test case.
10. A non-volatile storage medium storing computer-executable instructions, the computer-executable instructions configured to:
executing a plurality of test cases of a preset queue in a plurality of virtual machines in parallel through a preset control program;
respectively inputting the plurality of test cases of the preset queue into the switch corresponding to the virtual machine, so that the snmp function modules of the switch respectively execute the test cases;
monitoring a port of the snmp function module, which sends a fault message, through a monitoring thread of the virtual machine so as to obtain the fault message returned by the snmp function module to the virtual machine;
analyzing a preset message segment in the fault message, acquiring a trap identifier in the fault message according to the preset message segment, and detecting the matching condition of the trap identifier and the test case; wherein the trap identifier corresponds to a trap alert message in the form of a key-value pair;
and adopting a corresponding mode according to the matching condition to complete the switch detection of the test case.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110914233.2A CN113645095B (en) | 2021-08-10 | 2021-08-10 | Automatic switch testing method, equipment and medium based on snmp alarm information |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110914233.2A CN113645095B (en) | 2021-08-10 | 2021-08-10 | Automatic switch testing method, equipment and medium based on snmp alarm information |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113645095A true CN113645095A (en) | 2021-11-12 |
CN113645095B CN113645095B (en) | 2022-07-12 |
Family
ID=78420522
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110914233.2A Active CN113645095B (en) | 2021-08-10 | 2021-08-10 | Automatic switch testing method, equipment and medium based on snmp alarm information |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113645095B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116743619A (en) * | 2023-08-15 | 2023-09-12 | 苏州浪潮智能科技有限公司 | Network service testing method, device, equipment and storage medium |
TWI830099B (en) * | 2021-12-09 | 2024-01-21 | 中華電信股份有限公司 | Method, system and computer-readable medium for automatic detection and notification of pbx malfunction |
CN117560276A (en) * | 2024-01-11 | 2024-02-13 | 北京奥普维尔科技有限公司 | Message processing method, device and system |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6269330B1 (en) * | 1997-10-07 | 2001-07-31 | Attune Networks Ltd. | Fault location and performance testing of communication networks |
CN1988482A (en) * | 2006-12-22 | 2007-06-27 | 华为技术有限公司 | Method and system for realizing automatic detection for simple network managing protocol agent |
US20080147833A1 (en) * | 2006-12-13 | 2008-06-19 | International Business Machines Corporation ("Ibm") | System and method for providing snmp data for virtual networking devices |
CN101388808A (en) * | 2008-10-24 | 2009-03-18 | 中兴通讯股份有限公司 | Trap processing method on the basis of simple network management protocol |
CN104394011A (en) * | 2014-11-11 | 2015-03-04 | 浪潮电子信息产业股份有限公司 | Method for supporting server virtualization operation and maintenance through alarm information |
CN108989153A (en) * | 2018-08-15 | 2018-12-11 | 郑州云海信息技术有限公司 | A kind of performance test methods and device |
CN109541495A (en) * | 2017-09-22 | 2019-03-29 | 上海金艺检测技术有限公司 | UPS state integrated monitoring based on UPS monitoring card |
CN110535682A (en) * | 2019-07-19 | 2019-12-03 | 浪潮思科网络科技有限公司 | The analytical equipment and method of equipment alarm information in a kind of SDN network |
-
2021
- 2021-08-10 CN CN202110914233.2A patent/CN113645095B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6269330B1 (en) * | 1997-10-07 | 2001-07-31 | Attune Networks Ltd. | Fault location and performance testing of communication networks |
US20080147833A1 (en) * | 2006-12-13 | 2008-06-19 | International Business Machines Corporation ("Ibm") | System and method for providing snmp data for virtual networking devices |
CN1988482A (en) * | 2006-12-22 | 2007-06-27 | 华为技术有限公司 | Method and system for realizing automatic detection for simple network managing protocol agent |
CN101388808A (en) * | 2008-10-24 | 2009-03-18 | 中兴通讯股份有限公司 | Trap processing method on the basis of simple network management protocol |
CN104394011A (en) * | 2014-11-11 | 2015-03-04 | 浪潮电子信息产业股份有限公司 | Method for supporting server virtualization operation and maintenance through alarm information |
CN109541495A (en) * | 2017-09-22 | 2019-03-29 | 上海金艺检测技术有限公司 | UPS state integrated monitoring based on UPS monitoring card |
CN108989153A (en) * | 2018-08-15 | 2018-12-11 | 郑州云海信息技术有限公司 | A kind of performance test methods and device |
CN110535682A (en) * | 2019-07-19 | 2019-12-03 | 浪潮思科网络科技有限公司 | The analytical equipment and method of equipment alarm information in a kind of SDN network |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI830099B (en) * | 2021-12-09 | 2024-01-21 | 中華電信股份有限公司 | Method, system and computer-readable medium for automatic detection and notification of pbx malfunction |
CN116743619A (en) * | 2023-08-15 | 2023-09-12 | 苏州浪潮智能科技有限公司 | Network service testing method, device, equipment and storage medium |
CN116743619B (en) * | 2023-08-15 | 2023-11-03 | 苏州浪潮智能科技有限公司 | Network service testing method, device, equipment and storage medium |
CN117560276A (en) * | 2024-01-11 | 2024-02-13 | 北京奥普维尔科技有限公司 | Message processing method, device and system |
CN117560276B (en) * | 2024-01-11 | 2024-03-19 | 北京奥普维尔科技有限公司 | Message processing method, device and system |
Also Published As
Publication number | Publication date |
---|---|
CN113645095B (en) | 2022-07-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113645095B (en) | Automatic switch testing method, equipment and medium based on snmp alarm information | |
CN110380907B (en) | Network fault diagnosis method and device, network equipment and storage medium | |
US10592330B2 (en) | Systems and methods for automatic replacement and repair of communications network devices | |
US7213179B2 (en) | Automated and embedded software reliability measurement and classification in network elements | |
CN100536403C (en) | Method and equipment of intelligent patrol detection for communication network | |
CN102571498B (en) | Fault injection control method and device | |
CN108429629A (en) | Equipment fault restoration methods and device | |
CN103414916B (en) | Fault diagnosis system and method | |
CN103812726A (en) | Automated testing method and device for data communication equipment | |
CN103810076B (en) | The monitoring method and device of data duplication | |
CN113708995A (en) | Network fault diagnosis method, system, electronic equipment and storage medium | |
CN111953542B (en) | System for guaranteeing stable operation of gateway | |
WO2016082543A1 (en) | Device testing method and testing device | |
CN111078484B (en) | Power-off test method, device, equipment and storage medium for system upgrade | |
CN110673993A (en) | Fault injection method, platform and system | |
CN108174400B (en) | Data processing method, system and equipment of terminal equipment | |
CN111752741A (en) | System performance detection method and device | |
CN111431749A (en) | FPGA cloud server management platform and use method thereof | |
CN107528705B (en) | Fault processing method and device | |
CN106411643B (en) | BMC detection method and device | |
CN113076210A (en) | Server fault diagnosis result notification method, system, terminal and storage medium | |
JP2016066303A (en) | Server device, redundant configuration server system, information taking-over program and information taking-over method | |
CN100421381C (en) | Method and device for obtaining information of operation and failure state for network equipment | |
CN116775376A (en) | Method, system, device and storage medium for processing NVMe disk link failure | |
CN116133021A (en) | Wireless network card self-management flow based on LINUX board card |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP03 | Change of name, title or address |
Address after: 250101 s01-6 / F, No. 1036, Langchao Road, high tech Zone, Jinan City, Shandong Province Patentee after: Inspur Network Technology (Shandong) Co.,Ltd. Country or region after: China Address before: 250101 s01-6 / F, No. 1036, Langchao Road, high tech Zone, Jinan City, Shandong Province Patentee before: INSPUR CISCO NETWORK TECHNOLOGY Co.,Ltd. Country or region before: China |