CN113645095B - 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 PDF

Info

Publication number
CN113645095B
CN113645095B CN202110914233.2A CN202110914233A CN113645095B CN 113645095 B CN113645095 B CN 113645095B CN 202110914233 A CN202110914233 A CN 202110914233A CN 113645095 B CN113645095 B CN 113645095B
Authority
CN
China
Prior art keywords
preset
virtual machine
trap
fault message
test
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.)
Active
Application number
CN202110914233.2A
Other languages
Chinese (zh)
Other versions
CN113645095A (en
Inventor
尹莎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Cisco Networking Technology Co Ltd
Original Assignee
Inspur Cisco Networking Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Inspur Cisco Networking Technology Co Ltd filed Critical Inspur Cisco Networking Technology Co Ltd
Priority to CN202110914233.2A priority Critical patent/CN113645095B/en
Publication of CN113645095A publication Critical patent/CN113645095A/en
Application granted granted Critical
Publication of CN113645095B publication Critical patent/CN113645095B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/50Testing 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

Automatic switch testing method, equipment and medium based on snmp alarm information
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 research and development cost is reduced firstly, namely the efficiency is improved; 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 finish the switch detection of the test case.
Optionally, in one or more embodiments of the present specification, before the test cases in the preset queue are executed in parallel in the virtual machine by the control program, 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 functional module through the automation script of the virtual machine.
Optionally, in one or more embodiments of the present specification, the monitoring, by a monitoring thread of the virtual machine, a port at which the snmp functional 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, continuing to execute 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 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 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 finish 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 a 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 in accordance with one or more embodiments of the present disclosure.
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 the trap message in the snmp message, then checking whether the message has trap information consistent with the injected fault, and completing the snmp trap test of a fault. 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 corresponds to different versions, including snmp v1, snmp v2 and snmpv3, each time the test is performed, the test case needs to be sequentially executed in a serial manner by each version. After each packet capture, the snmp v3 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, the 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. All use cases of the snmp trap are executed in a parallel mode, time cost of fault testing is saved, technical personnel are liberated, and 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 functional 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 storing the test cases into a 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.
It should be noted that the snmp currently has three versions, 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 the functions of the snmp v1 are expanded while the snmp v1 is compatible. 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. If M virtual machines exist, the M virtual machines can be used as the corresponding service ends of the M switches to carry out the automatic test of the switch snmptrap. Before test case detection of the snmp trap is carried out, 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 meanwhile, inaccurate test results caused by virtual machine faults are avoided. First, the IP address of the virtual machine needs to be obtained, so as to determine the network status 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 functional 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 functional 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 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 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 of specific embodiments has been presented for purposes of illustration and description. 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 (9)

1. An automatic switch testing method based on snmp trap alarm information is characterized by comprising 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;
adopting a corresponding mode according to the matching condition to complete the switch detection of the test case; wherein, the corresponding mode is adopted according to the matching condition, which specifically comprises:
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.
2. The method according to claim 1, wherein before the executing the test cases in the preset queue in the virtual machine in parallel by the preset 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 preset 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 the preset 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 preset control program specifically comprises:
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, the test cases of the preset queue are distributed to the virtual machines in sequence through a control program according to a preset storage sequence, and the virtual machines are controlled 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;
if the virtual machine cannot monitor the fault message which is sent by the port and contains trap information within the preset time, the monitoring thread is ended.
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 comprises:
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. An apparatus for automated testing of switches based on snmp trap alert information, the apparatus comprising:
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;
adopting a corresponding mode according to the matching condition to complete the switch detection of the test case; wherein, the corresponding mode is adopted according to the matching condition, which specifically comprises:
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 is not matched with the test case, determining that the snmp functional module fails the test of the test case.
9. 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 a 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;
adopting a corresponding mode according to the matching condition to complete the switch detection of the test case; wherein, the corresponding mode is adopted according to the matching condition, which specifically comprises:
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.
CN202110914233.2A 2021-08-10 2021-08-10 Automatic switch testing method, equipment and medium based on snmp alarm information Active CN113645095B (en)

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 CN113645095A (en) 2021-11-12
CN113645095B true 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)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
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
CN116743619B (en) * 2023-08-15 2023-11-03 苏州浪潮智能科技有限公司 Network service testing method, device, equipment and storage medium
CN117560276B (en) * 2024-01-11 2024-03-19 北京奥普维尔科技有限公司 Message processing method, device and system

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
IL121898A0 (en) * 1997-10-07 1998-03-10 Cidon Israel A method and apparatus for active testing and fault allocation of communication networks
US7925731B2 (en) * 2006-12-13 2011-04-12 International Business Machines Corporation System and method for providing SNMP data for virtual networking devices
CN100461707C (en) * 2006-12-22 2009-02-11 华为技术有限公司 Method and system for realizing automatic detection for simple network managing protocol agent
CN101388808B (en) * 2008-10-24 2011-07-13 中兴通讯股份有限公司 Trap processing method on the basis of simple network management protocol
CN104394011A (en) * 2014-11-11 2015-03-04 浪潮电子信息产业股份有限公司 A method for supporting server virtualization operation and maintenance by a warning message
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

Also Published As

Publication number Publication date
CN113645095A (en) 2021-11-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
CN105630647A (en) Equipment detection method and detection equipment
CN110673993A (en) Fault injection method, platform and system
CN105068763B (en) A kind of virtual machine tolerant system and method for storage failure
CN111431749A (en) FPGA cloud server management platform and use method thereof
CN111953542B (en) System for guaranteeing stable operation of gateway
CN106411643B (en) BMC detection method and device
JP2016066303A (en) Server device, redundant configuration server system, information taking-over program and information taking-over method
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
CN106406963A (en) Initialization method and device for Linux system
CN116137603A (en) Link fault detection method and device, storage medium and electronic device
CN112463494B (en) Large-batch node AC (alternating current) cycle test method based on intelligent PDU (protocol data Unit)
KR100500836B1 (en) Fault management system of metro ethernet network and method thereof
CN115065589A (en) Data traffic acquisition disaster recovery backup processing method, device, equipment, system and medium

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