Automatic script testing method for linux system server

Through the automated script testing method, the problem of low efficiency of restarting and power-on-off switch testing under Linux system servers is solved, and effective detection and log comparison of hardware device status is realized, testing efficiency is improved and hardware problems is discovered, and cost savings are saved.

CN118939485APending Publication Date: 2024-11-12SHENZHEN GOOXI INFORMATION SECURITY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410201950.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-02-23
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

Under Linux system servers, there are few stability tests for restarting and power-on-down switches, and the existing methods are inefficient and time-consuming, making it difficult to effectively detect the status and performance problems of hardware devices.

Method used

Provides an automated script testing method, including Reboot scripts and PowerOnOff scripts, which automatically detects the status of hardware devices, records logs, compares test results, sends restart or shutdown instructions, and judges whether the test passes through the difference log file, improving testing efficiency.

Benefits of technology

The stability test of Linux system server hardware devices has been realized, the testing efficiency has been improved, the time and labor cost of viewing logs has been saved, and the problems of hardware loss and speed loss can be discovered in a timely manner.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939485A_ABST
    Figure CN118939485A_ABST
Patent Text Reader

Abstract

The invention provides an automatic script testing method for a linux system server. The automatic script testing method comprises the following steps: S1, starting up, selecting a main script testing program and automatically running the main script testing program; s2, skipping according to the selected script type; s3, adding 1 to the number of times of testing, recording the current number of times of testing, and comparing whether the current number of times of testing reaches a preset value or not; s4, calling the sub-script file, obtaining the state of the current hardware equipment, and recording the state information of the current hardware equipment into a log file; s5, comparing the test results of the current test and the first test; and S6, finishing the test, and judging whether the test is qualified or not. According to the automatic script testing method for stability testing of restarting and power-on and power-off of the linux system server, whether the problems of hardware equipment dropping and rate dropping occur or not can be known through the testing method, the testing efficiency is improved, and the time cost and the labor cost are saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a Linux system server testing method, and in particular to an automated script testing method for Linux system server stability testing. Background Art

[0002] In the information age, the performance and stability of servers have become increasingly important. The stability and reliability of servers will have a great impact on the user experience. Therefore, stability testing is extremely important. Through the analysis of the load and application scenarios of actual user usage scenarios, the real user usage scenarios are simulated, and long-term stable operation is carried out to ensure the timely discovery and effective resolution of potential problems that may exist in the long-term operation of the product. Stability includes operations such as load, restart, and continuous power on and off. At present, most server reboot tests (reboot tests) and AC onff tests (power on and off tests) are mostly tested using Dos disks under Windows, while Linux systems have a wider range of usage scenarios, but the reboot test and AC onoff test are rarely run on Linux system servers. In addition, when running the reboot test and AC onoff test under Linux, the subsequent queries on logs, hardware device drops, and hardware drop rates require a lot of work on the generated log files, which is very inefficient and time-consuming. Summary of the invention

[0003] The technical problem to be solved by the present invention is to provide an automated test script method for stability testing of restarting and powering on and off a Linux system server.

[0004] To this end, the present invention provides an automated script testing method for a Linux system server, comprising the following steps: Step S1, boot up and select the main script test program and run it automatically, the script types of the main script test program include Reboot script and PowerOnOff script; Step S2, jump according to the script type of the selected main script test program, when the script type is selected as a Reboot script, jump to step S3; when the script type is selected as a PowerOnOff script, jump to step S4; Step S3, add 1 to the test number, record the current test number, and compare whether the current test number reaches the preset value. If so, jump to step S6; if not, go to step S4; Step S4, calling the sub-script file, obtaining the status of the current hardware device, and recording the status information of the current hardware device into a log file; Step S5, comparing the test results of the current test with those of the first test, includes the following sub-steps: Step S501, comparing the hardware device status information obtained in this test with the hardware device status information recorded in the log file generated by the first test to see if they are consistent, if not, jumping to step S502, if consistent, jumping to step S504; Step S502, recording the status information of the hardware device under test into a difference log file; Step S503, select whether to end the test, if yes, jump to step S6; if no, jump to step S504; Step S504: If the currently selected script type is a Reboot script, send a command to restart the server and jump to step S1; if the currently selected script type is a PowerOnOff script, send a shutdown command to power off, and then power on again and jump to step S1; Step S6, the test is finished and whether the test is qualified is determined.

[0005] A further improvement of the present invention is that the hardware device includes any one or more of a CPU, a memory, a hard disk, an NVME hard disk, a network port, a graphics card, a raid card, a BMC and a backplane.

[0006] A further improvement of the present invention is that, during the first test, in step S4: Get the device information and quantity information of NVME hard disks, and record them in the two log files nvme-time1.log and nvme-all.log; get the speed information of NVME hard disks, and record them in the two log files nvme-speed-time1.log and nvme-speed-all.log; get the device information and quantity information of network ports, and record them in the two log files lan-time1.log and lan-all.log; get the device information and quantity information of graphics cards, and record them in the two log files vga-time1.log and vga-all.log; get the speed information of graphics cards, and record them in the two log files vga-speed-time1.log and vga-speed-all.log.

[0007] A further improvement of the present invention is that step S2 also includes: after selecting the Reboot script or the PowerOnOff script, first wait for a fixed time and detect whether to stop the test command. If a stop test command is detected, stop the test; if no stop test command is detected within the fixed time, continue running according to the selected script type.

[0008] A further improvement of the present invention is that after the first test is completed, the second test is run in a loop, and when entering step S2, while waiting for the fixed time, a stop test command is sent to check the log file generated by the first test to confirm whether the hardware device status is correct.

[0009] A further improvement of the present invention is that, in each test including the first test, in step S4: Get CPU information and record it in the cpu.log file; get memory information and record it in the mem.log file; get all types of hard disk quantity information and record it in the hdd.log log file; get NVME hard disk device information and NVME hard disk quantity information, and record them in the nvme-all.log log file; get NVME hard disk speed information and record it in the nvme-speed-all.log log file; get network port device information and network port quantity information, and record them in the lan-all.log log file; get graphics card device information and graphics card quantity information, and record them in the vga-all.log log file; get graphics card speed information and record it in the vga-speed-all.log log file; get raid card device information and raid card quantity information, and record them in the raid-all.log log file; get BMC information and BMC sensor information, and record them in the BMC-all.log log file; get backplane temperature and voltage information, fan speed information, and record them in the backplane_sensor-all.log log file.

[0010] A further improvement of the present invention is that in the step S5, the device information of the NVME hard disk obtained this time and the quantity information of the NVME hard disk are compared with the nvme-time1.log log file information recorded in the first test. If the information is inconsistent, the test time and the information of this test are recorded in the nvme-diff.log difference log file. If the information is consistent, no processing is performed; the speed information of the NVME hard disk obtained this time is compared with the nvme-speed-time1.log log file information recorded in the first test. If the information is inconsistent, the test time and the information of this test are recorded in the nvme-speed-fail.log difference log file. If the information is consistent, no processing is performed; the device information and the quantity information of the network port obtained this time are compared with the lan- The time1.log log file information is compared. If the information is inconsistent, the test time and the information of this test are recorded in the difference log file lan-diff.log. If the information is consistent, no processing is performed; the device information and the number of graphics cards obtained this time are compared with the vga-time1.log log file recorded in the first test. If the information is inconsistent, the test time and the information of this test are recorded in the vga-diff.log difference log file. If the information is consistent, no processing is performed; the speed information of the graphics card obtained this time is compared with the vga-speed-time1.log log file recorded in the first test. If the information is inconsistent, the test time and the information of this test are recorded in the vga-speed-fail.log difference log file. If the information is consistent, no processing is performed.

[0011] A further improvement of the present invention is that in step S4, a sub-script file is called, the status of the current hardware device is obtained through instructions, keywords are filtered to find the status information of the hardware device, and finally the status information of the current hardware device is recorded in a log file.

[0012] A further improvement of the present invention is that in step S6, after the test is completed, the following sub-steps are performed to determine whether the test is qualified: Step S601, checking whether the number of tests reaches a preset value; Step S602, checking the log file of the hardware device to determine whether the device is lost, if so, the test fails; if not, the test passes; Step S603, whether a difference log file is generated, and whether the NVME hard disk, network port and graphics card have dropped devices or dropped speeds in the difference log file. If so, the test fails; if not, the test passes.

[0013] A further improvement of the present invention is that in step S602, an instruction is used to check whether the number of hardware operations in the hardware device log file is equal to the preset value of the number of tests. If they are equal, it is determined that there is no device loss; if they are not equal, it is determined that there is a device loss.

[0014] Compared with the prior art, the beneficial effects of the present invention are: providing an automated script testing method for stability testing of Linux system server restarts and power on and off, realizing detection of server hardware devices at each restart and power on and off, and checking the logs generated in the test by the method provided by the present invention to know whether the stability test has hardware device failure and speed drop problems, thereby improving test efficiency and saving time and labor costs for checking logs. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Figure 1 It is a schematic diagram of the working process of an embodiment of the present invention. DETAILED DESCRIPTION

[0016] The preferred embodiments of the present invention will be further described in detail below in conjunction with the accompanying drawings.

[0017] like Figure 1 As shown, this embodiment provides an automated script testing method for a Linux system server, characterized by comprising steps S1 to S6. Among them: Step S1, select the main script test program at startup and run it automatically, the script types of the main script test program include Reboot script and PowerOnOff script; more specifically, in step S1, set the server password-free login at startup, and set the startup self-start terminal to add and run the main script instruction according to the different versions of the Linux system. The version of the Linux system used in this embodiment is CentOS, wherein the startup self-start terminal adds and runs the Reboot main script instruction: add cd / home / reboot-Ebp-v1;gnome-terminal -e . / reboot in the / root / .bashrc file; wherein the startup self-start terminal adds and runs the PowerOnOff main script instruction: add cd / home / reboot-Ebp-v1;gnome-terminal -e . / poweronoff in the / root / .bashrc file.

[0018] Step S2, jump according to the script type of the selected main script test program. When the script type is selected as a Reboot script, jump to step S3; when the script type is selected as a PowerOnOff script, jump to step S4.

[0019] Step S3, add 1 to the test number, record the current test number, and compare whether the current test number reaches the preset value. If so, jump to step S6; if not, enter step S4.

[0020] Step S4, call the sub-script file, obtain the status of the current hardware device, and record the status information of the hardware device in the log file; in more detail, the Reboot script is used for the Reboot test (i.e., restart test), and the PowerOnOff script is used for the AC onff test (i.e., power on and off test), and different scripts are selected to correspond to different test requirements. Compared with the PowerOnOff script, the Reboot script adds the condition of the number of tests. Therefore, the Reboot script is used for server restart tests that require setting the number of tests, while the PowerOnOff script is used for power on and off test that does not limit the number of tests. At the end of each test, the Reboot script restarts the server and the PowerOnOff script sends a shutdown command to power off and then power on again. In this embodiment, the preset value of the Reboot script test times is 1005 times. In step S3, the current test times are recorded and compared to see whether the current test times reaches the preset value. The specific instructions and methods are: input 1 into the count.txt file, check the running times and assign them to the times variable through the command cat count.txt | grep -i -c 1, and determine whether the variable times is less than or equal to 1005. If the variable times is greater than 1005, a pop-up box displays "1006 times, Test End!!" and jumps to step S6; if the variable times is less than or equal to 1005, go to step S4.

[0021] Step S5, comparing the test results of the current test with those of the first test, includes the following sub-steps: Step S501, comparing the hardware device status information obtained in this test with the hardware device status information recorded in the log file generated by the first test to see if they are consistent, if not, jumping to step S502, if consistent, jumping to step S504; Step S502, recording the status information of the hardware device under test into a difference log file; Step S503, select whether to end the test, if yes, jump to step S6; if no, jump to step S504; Step S504, if the currently selected script type is a Reboot script, send an instruction to restart the server and jump to step S1; if the currently selected script type is a PowerOnOff script, send a shutdown instruction to power off, and then power on again, and jump to step S1.

[0022] Step S6, the test is finished and whether the test is qualified is determined.

[0023] In step S4 described in this embodiment, the hardware devices include a CPU, a memory, a hard disk, an NVME hard disk, a network port, a graphics card, a raid card, a BMC and a backplane.

[0024] In more detail, BMC refers to the abbreviation of Baseboard Management Controller; NVME hard disk refers to the hard disk with non-volatile memory host controller interface specification, and NVME is the abbreviation of Non-Volatile Memory Express; raid card refers to the abbreviation of Redundant Array of Independent Disks Controller Card.

[0025] In this embodiment, during the first test, in step S4: Get the device information and quantity information of NVME hard disks, and record them in the two log files nvme-time1.log and nvme-all.log; get the speed information of NVME hard disks, and record them in the two log files nvme-speed-time1.log and nvme-speed-all.log; get the device information and quantity information of network ports, and record them in the two log files lan-time1.log and lan-all.log; get the device information and quantity information of graphics cards, and record them in the two log files vga-time1.log and vga-all.log; get the speed information of graphics cards, and record them in the two log files vga-speed-time1.log and vga-speed-all.log.

[0026] Step S2 described in this embodiment also includes: after selecting the Reboot script or the PowerOnOff script, wait for a fixed time and detect whether to stop the test command. If a stop test command is detected, stop the test; if no stop test command is detected within the fixed time, continue running according to the selected script type.

[0027] In this example, after the first test is completed, the second test is executed in a loop, and when entering step S2, a stop test command is sent while waiting for the fixed time, and the log file generated by the first test is checked to confirm whether the hardware device status is correct.

[0028] More specifically, in the present embodiment, after selecting the Reboot script or the PowerOnOff script, first wait for a fixed time of 10 seconds, and detect whether to stop the test command. In the present embodiment, the specific stop test command is to press the ctrl+c keys at the same time. If the stop test command is detected, the test is stopped. If the stop test command is not detected within 10 seconds, the operation continues according to the selected script type. After the first test is completed, the cycle enters the second test, and when entering step S2, while waiting for 10 seconds, press the ctrl+c keys at the same time to send the stop test command, check the log file generated by the first test, and confirm whether the hardware device status is correct. It should be noted that the purpose of doing so is to confirm whether the hardware status of the first test is correct by checking the log file generated for the first time. Each test of the subsequent cycle is compared with the log file information generated by the first test. It is only necessary to check the log file after the first test without checking all log files for each test, thereby improving the test efficiency and saving the time cost and labor cost of checking the log.

[0029] In this embodiment, in each test including the first test, in step S4: Get CPU information and record it in the cpu.log file; get memory information and record it in the mem.log file; get all types of hard disk quantity information and record it in the hdd.log log file; get NVME hard disk device information and NVME hard disk quantity information, and record them in the nvme-all.log log file; get NVME hard disk speed information and record it in the nvme-speed-all.log log file; get network port device information and network port quantity information, and record them in the lan-all.log log file; get graphics card device information and graphics card quantity information, and record them in the vga-all.log log file; get graphics card speed information and record it in the vga-speed-all.log log file; get raid card device information and raid card quantity information, and record them in the raid-all.log log file; get BMC information and BMC sensor information, and record them in the BMC-all.log log file; get backplane temperature and voltage information, fan speed information, and record them in the backplane_sensor-all.log log file.

[0030] In step S5 of the present embodiment, the device information and quantity information of the NVME hard disk obtained this time are compared with the nvme-time1.log log file information recorded in the first test. If the information is inconsistent, the test time and the information of this test are recorded in the nvme-diff.log difference log file. If the information is consistent, no processing is performed; the speed information of the NVME hard disk obtained this time is compared with the nvme-speed-time1.log log file information recorded in the first test. If the information is inconsistent, the test time and the information of this test are recorded in the nvme-speed-fail.log difference log file. If the information is consistent, no processing is performed; the device information and quantity information of the network port obtained this time are compared with the lan-time recorded in the first test. 1. Compare the information in the log file. If the information is inconsistent, record the test time and information of this test in the lan-diff.log difference log file. If the information is consistent, do not process it. Compare the device information and quantity information of the graphics card obtained this time with the vga-time1.log log file recorded in the first test. If the information is inconsistent, record the test time and information of this test in the vga-diff.log difference log file. If the information is consistent, do not process it. Compare the speed information of the graphics card obtained this time with the vga-speed-time1.log log file recorded in the first test. If the information is inconsistent, record the test time and information of this test in the vga-speed-fail.log difference log file. If the information is consistent, do not process it.

[0031] In step S4 of this embodiment, the sub-script file is called, the status of the current hardware device is obtained through instructions, and the status information of the hardware device is searched by filtering keywords, and finally the status information of the hardware device is recorded in the log file.

[0032] In more detail, the complete process from step S4 to step S5 is: 1. Use the command echo $times to input the current running times into the time.txt file, and use the command date to input the current time into time.txt; 2. Call the sub-script lspcu.sh to obtain CPU information. The sub-script lspcu.sh passes the parameter times into the cpu.log log file through the command bash lscpu.sh$times, and records the current time and the CPU information (model, quantity, number of cores) obtained by the command lscpu and dmidecode filtering keywords into the cpu.log log file. The script needs to modify options according to Intel, AMD, and domestic CPUs; 3. Call the sub-script getmem.sh to obtain memory information. The sub-script getmem.sh passes the parameter times into the mem.log log file through the command bashgetmem.sh $times, and records the current time and the current total memory capacity (GB) obtained through the command dmidecode filter keyword and all memory information (manufacturer, model, frequency, quantity, slot) into the mem.log log file; 4. Call the sub-script hdd_chk.sh to obtain information about all types of hard disks. The sub-script hdd_chk.sh passes the parameter times through the command bash hdd_chk.sh $times and inputs it into the hdd.log log file. It also inputs the current time, the hard disk information obtained through the commands lsblk and lsscsi -s, and the current hard disk quantity information obtained through the command lsblk | grep -i -c disk filtering the disk keyword and inputs them into the hdd.log log file.

[0033] 5. Call the sub-script nvme_sn_chk.sh to obtain the number of NVME hard disks. The sub-script nvme_sn_chk.sh passes the parameter times assignment variable through the command bash nvme_sn_chk.sh $times, and records the current time and the NVMe number, BusID, Speed ​​and other information obtained in the first test into two log files, nvme-time1.log and nvme-all.log. Each subsequent test automatically obtains information when the power is turned on and compares it with the first test result nvme-time1.log log file: If the NVME hard disk is lost or added, resulting in inconsistent information, the output is recorded in the nvme-diff.log difference log file and the nvme-all.log log file at the same time; otherwise, if the information is consistent, it is only recorded in the nvme-all.log log file.

[0034] 6. Call the sub-script nvme_speed_chk.sh to obtain the NVME hard disk information and speed, and compare whether there is a disk drop or speed reduction; the sub-script nvme_speed_chk.sh uses the command bash nvme_speed_chk.sh $times passes in the parameter times to assign a variable and records the current time in the log file: the NVMe quantity and BusID, Speed, LnkCap, LnkSta and other specific information obtained in the first test are recorded in the nvme-speed-time1.log and nvme-speed-all.log log files, and the BusID, LnkCta, LnkSta dictionary is recorded in the nvme-speed-time1.log log file; each subsequent test automatically obtains information when the power is turned on and compares it with the result of the first test, the nvme-speed-time1.log log file: if the NVME hard disk is lost, added, or the speed drops, resulting in inconsistent information, the output is recorded in the nvme-speed-fail.log difference log file, and at the same time in the nvme-speed-all.log log file; on the contrary, if the information is consistent, it is only recorded in the nvme-speed-all.log log file.

[0035] 7. Call the sub-script lan_chk.sh to obtain the number of network ports. The sub-script lan_chk.sh passes the parameter times assignment variable through the command bashlan_chk.sh $times and records the current time in the log: the specific information such as the number of network ports, BusID, Speed, etc. obtained in the first test is recorded in the two log files lan-time1.log and lan-all.log, and the BusID list is recorded in the lan-time1.log log file; each subsequent test automatically obtains information when the power is turned on and compares it with the first test result lan-time1.log log file: if the network port is lost or added, resulting in inconsistent information, the output is recorded in the lan-diff.log difference log file and the lan-all.log log file at the same time; otherwise, if the information is consistent, it is only recorded in the lan-all.log log file.

[0036] 8. Call the sub-script vga.sh to obtain the number of graphics cards. The sub-script vga.sh passes the parameter times assignment variable through the command bash vga.sh $times and records the current time in the log file: the number of graphics cards and specific information such as BusID, Speed, etc. obtained in the first test are recorded in the two log files vga-time1.log and vga-all.log, and the BusID list is recorded in the vga-time1.log log file; each subsequent test automatically obtains information when the power is turned on and compares it with the first test result vga-time1.log log file: if a graphics card is lost or added, the output is recorded in the vga-diff.log difference log file and the vga-all.log log file at the same time; otherwise, if the information is consistent, it is only recorded in the vga-all.log log file.

[0037] 9. Call the sub-script vga_speed_chk.sh to obtain the graphics card information and speed. The sub-script vga_speed_chk.sh passes the parameter times assignment variable through the command bash vga_speed_chk.sh $times and records the current time in the log file: In the first test, the NVMe quantity and BusID, Speed, LnkCap, LnkSta and other specific information are recorded in the two log files vga-speed-time1.log and vga-speed-all.log, and the BusID, LnkCta, LnkSta form a dictionary and record it in the vga-speed-time1.log log file; For each subsequent test, the information is automatically obtained when the power is turned on and compared with the first detection result vga-speed-time1.log log file: If the graphics card is lost, added, or the speed drops, resulting in inconsistent information, the output is recorded in the vga-speed-fail.log difference log file, and at the same time in the vga-speed-all.log log file; on the contrary, if the information is consistent, it is only recorded in the vga-speed-all.log log file.

[0038] 10. Call the sub-script raid.sh to obtain the number of raid card information. The sub-script raid.sh passes the parameter times assignment variable through the command bashraid.sh $times and records the current time in the raid.log log file; use the command lspci to view the keywords to obtain RAID information (model, quantity, BusID) and record it in the raid.log log file.

[0039] 11. Call the sub-script bmc_chk.sh to obtain BMC information and sensor information. The sub-script bmc_chk.sh passes the parameter times assignment variable through the command bash bmc_chk.sh $times and records the current time in the bmc-all.log log file; use the ipmitool command to obtain the current BMC time, BMC Sensor value, and BMC log and record them in bmc.log.

[0040] 12. Call the sub-script backplane_sensor_chk.sh to obtain the backplane temperature, voltage and fan speed information. The sub-script backplane_sensor_chk.sh passes in the parameter times assignment variable through the command bash backplane_sensor_chk.sh $times and records the current time in the backplane-sensor.log log file; use the command sg_map to obtain the current backplane serial number / dev / sg0, and then use the command sg_ses -p 0x2 / dev / sg0 to view the backplane fan speed, temperature and voltage value; obtain the characters through sed and awk segmentation and output the assigned variables to the backplane-sensor.log log file. The script backplane_sensor_chk.sh requires the backplane to support monitoring temperature, voltage and fan functions. It can be seen that the test method provided by the present embodiment through the automated script realizes the stability test for the restart and power-on and power-off of the Linux system server, improves the test efficiency, and saves time and labor costs.

[0041] In the step S6 of this embodiment, the test is finished, and whether the test is qualified is determined by the following sub-steps: Step S601, checking whether the number of tests reaches a preset value; Step S602, checking the log file of the hardware device to determine whether the device is lost, if so, the test fails; if not, the test passes; Step S603, checks whether a difference log file is generated, and whether the NVME hard disk, network port and graphics card have dropped devices or dropped speeds in the difference file. If so, the test fails; if not, the test passes.

[0042] In the present embodiment, in the step S602, an instruction is used to check whether the operation times of the hardware device in the log file is equal to the preset value of the test times. If they are equal, it is determined that the device is not lost; if they are not equal, it is determined that the device is lost.

[0043] More specifically, in step S601, the command #cat times.txt is used to check whether the number of times reaches the preset value 1005 of this embodiment. 1005 may be displayed at the end of the time.txt file, indicating that the test has been performed 1005 times.

[0044] In step S602, the number of hardware operation times under the log file is checked by instructions to see if it is equal to the preset value of the number of tests. For example, by the instruction #cat raid.log | grep -i "raid=1" | wc -l, the total number of raid cards in the raid.log log file that is 1 can be checked, and the number of lines displayed by wc -1 represents the number of raid card operations. If the number of operations is equal to 1005 times, it means that there is no raid card drop, and the test is qualified; by the instruction #cat hdd.log | grep -i "disk=25" | wc -l, the total number of hard disks in the hdd.log log file that is equal to 25 can be checked, and the number of lines displayed by wc -1 represents the number of hard disk operations. If the number of operations is equal to 1005 times, it means that there is no hard disk drop, and the test is qualified. The viewing method for other hardware devices is consistent with the above method, and only needs to be viewed by replacing the name of the log file of the corresponding hardware device in the instruction. It can be seen from this that the above method for judging whether the test is qualified does not require viewing and checking all log files generated during the test process. It only needs to determine whether a difference log file is generated by obtaining the number of hardware runs and judging whether the preset number of test times is equal. This method greatly improves the test efficiency and saves time and labor costs.

[0045] In summary, this embodiment provides an automated test script method for stability testing of Linux system server restarts and power on and off, which realizes the detection of server hardware devices at each restart and power on and off. The method provided by the present invention checks the logs generated in the test, and compares the hardware status information generated by each current test with the log file generated by the first test. It can be determined whether hardware device failure and speed drop problems occur in the test, and the test efficiency is improved, saving the time and labor costs of checking the logs.

[0046] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as falling within the protection scope of the present invention.

Claims

1. An automated script testing method for a Linux system server, characterized in that: The following steps are involved: Step S1, boot up and select the main script test program and run it automatically, the script types of the main script test program include Reboot script and PowerOnOff script; Step S2, jump according to the script type of the selected main script test program, when the script type is selected as a Reboot script, jump to step S3; when the script type is selected as a PowerOnOff script, jump to step S4; Step S3, add 1 to the test number, record the current test number, and compare whether the current test number reaches the preset value. If so, jump to step S6; if not, go to step S4; Step S4, calling the sub-script file, obtaining the status of the current hardware device, and recording the status information of the current hardware device into a log file; Step S5, comparing the test results of the current test with those of the first test, includes the following sub-steps: Step S501, comparing the hardware device status information obtained in this test with the hardware device status information recorded in the log file generated by the first test to see if they are consistent, if not, jumping to step S502, if consistent, jumping to step S504; Step S502, recording the status information of the hardware device under test into a difference log file; Step S503, select whether to end the test, if yes, jump to step S6; if no, jump to step S504; Step S504: If the currently selected script type is a Reboot script, send a command to restart the server and jump to step S1; if the currently selected script type is a PowerOnOff script, send a shutdown command to power off, and then power on again and jump to step S1; Step S6, the test ends and whether the test is qualified is determined.

2. The automated script testing method for a Linux system server according to claim 1, characterized in that: The hardware device includes any one or more of a CPU, memory, hard disk, NVME hard disk, network port, graphics card, raid card, BMC and backplane.

3. The automated script testing method for a Linux system server according to claim 2, characterized in that: During the first test, in step S4: Get the device information and quantity information of NVME hard disks, and record them in the two log files nvme-time1.log and nvme-all.log; get the speed information of NVME hard disks, and record them in the two log files nvme-speed-time1.log and nvme-speed-all.log; get the device information and quantity information of network ports, and record them in the two log files lan-time1.log and lan-all.log; get the device information and quantity information of graphics cards, and record them in the two log files vga-time1.log and vga-all.log; get the speed information of graphics cards, and record them in the two log files vga-speed-time1.log and vga-speed-all.log.

4. The automated script testing method for a Linux system server according to claim 3, characterized in that: The step S2 also includes: after selecting the Reboot script or the PowerOnOff script, first wait for a fixed time and detect whether to stop the test command. If a stop test command is detected, stop the test; if no stop test command is detected within the fixed time, continue to run according to the selected script type.

5. The automated script testing method for a Linux system server according to claim 4, characterized in that: After the first test is completed, the second test is executed in a loop, and when entering step S2, a stop test command is sent while waiting for the fixed time, and the log file generated by the first test is checked to confirm whether the hardware device status is correct.

6. The automated script testing method for a Linux system server according to claim 3, characterized in that: In each test including the first test, in step S4: Get CPU information and record it in the cpu.log file; get memory information and record it in the mem.log file; get all types of hard disk quantity information and record it in the hdd.log log file; get NVME hard disk device information and NVME hard disk quantity information, and record them in the nvme-all.log log file; get NVME hard disk speed information and record it in the nvme-speed-all.log log file; get network port device information and network port quantity information, and record them in the lan-all.log log file; get graphics card device information and graphics card quantity information, and record them in the vga-all.log log file; get graphics card speed information and record it in the vga-speed-all.log log file; get raid card device information and raid card quantity information, and record them in the raid-all.log log file; get BMC information and BMC sensor information, and record them in the BMC-all.log log file; get backplane temperature and voltage information, fan speed information, and record them in the backplane_sensor-all.log log file.

7. The automated script testing method for a Linux system server according to claim 6, characterized in that: In the step S5, the device information and quantity information of the NVME hard disk obtained this time are compared with the nvme-time1.log log file information recorded in the first test. If the information is inconsistent, the test time and the information of this test are recorded in the nvme-diff.log difference log file. If the information is consistent, no processing is performed; the speed information of the NVME hard disk obtained this time is compared with the nvme-speed-time1.log log file information recorded in the first test. If the information is inconsistent, the test time and the information of this test are recorded in the nvme-speed-fail.log difference log file. If the information is consistent, no processing is performed; the device information and quantity information of the network port obtained this time are compared with the lan-time1.log log file information recorded in the first test. log file information. If the information is inconsistent, the test time and information of this test are recorded in the difference log file lan-diff.log. If the information is consistent, no processing is performed; the device information and quantity information of the graphics card obtained this time are compared with the vga-time1.log log file recorded in the first test. If the information is inconsistent, the test time and information of this test are recorded in the vga-diff.log difference log file. If the information is consistent, no processing is performed; the speed information of the graphics card obtained this time is compared with the vga-speed-time1.log log file recorded in the first test. If the information is inconsistent, the test time and information of this test are recorded in the vga-speed-fail.log difference log file. If the information is consistent, no processing is performed.

8. The automated script testing method for a Linux system server according to claim 6, characterized in that: In step S4, the sub-script file is called, the status of the current hardware device is obtained through instructions, and the status information of the hardware device is searched by filtering keywords, and finally the status information of the hardware device is recorded in the log file.

9. The automated script testing method for a Linux system server according to claim 7, characterized in that: In step S6, the test is completed, and whether the test is qualified is determined by the following sub-steps: Step S601, checking whether the number of tests reaches a preset value; Step S602, checking the log file of the hardware device to determine whether the device is lost, if so, the test fails; if not, the test passes; Step S603, checks whether a difference log file is generated, and whether the NVME hard disk, network port and graphics card have dropped devices or dropped speeds in the difference log file. If so, the test fails; if not, the test passes.

10. The automated script testing method for a Linux system server according to claim 9, characterized in that: In step S602, the instruction is used to check whether the number of hardware operations in the hardware device log file is equal to the preset value of the number of tests. If they are equal, it is determined that there is no device loss; if they are not equal, it is determined that there is a device loss.