[go: up one dir, main page]

CN118779232A - Test case execution method, device and server - Google Patents

Test case execution method, device and server Download PDF

Info

Publication number
CN118779232A
CN118779232A CN202410877559.6A CN202410877559A CN118779232A CN 118779232 A CN118779232 A CN 118779232A CN 202410877559 A CN202410877559 A CN 202410877559A CN 118779232 A CN118779232 A CN 118779232A
Authority
CN
China
Prior art keywords
abnormal
abnormal process
simulated
test case
determined
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.)
Pending
Application number
CN202410877559.6A
Other languages
Chinese (zh)
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.)
XFusion Digital Technologies Co Ltd
Original Assignee
XFusion Digital Technologies 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 XFusion Digital Technologies Co Ltd filed Critical XFusion Digital Technologies Co Ltd
Priority to CN202410877559.6A priority Critical patent/CN118779232A/en
Publication of CN118779232A publication Critical patent/CN118779232A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/079Root cause analysis, i.e. error or fault diagnosis
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0793Remedial or corrective actions

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Computer Hardware Design (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本申请提供了一种测试用例执行方法及服务器。涉及计算机技术领域。包括:可以获取测试用例的进程信息,然后根据进程信息确定测试用例的进程中是否存在异常进程,当确定进程中存在异常进程还可以进一步判断异常进程是否为模拟出来的异常进程,即异常进程是否为模拟异常进程,当确定异常进程不为模拟异常进程,则终止异常进程,这样本申请中就可以终止无法正常执行测试任务且不是模拟出来的异常进程,只保留可以正常执行测试用例的进程,进而可以防止造成测试进程堵塞,在主进程执行完当前执行的测试用例执行后,即可执行下一个测试用例,从而可以提高测试的效率。

The present application provides a test case execution method and server. It relates to the field of computer technology. It includes: the process information of the test case can be obtained, and then whether there is an abnormal process in the process of the test case is determined according to the process information. When it is determined that there is an abnormal process in the process, it can be further determined whether the abnormal process is a simulated abnormal process, that is, whether the abnormal process is a simulated abnormal process. When it is determined that the abnormal process is not a simulated abnormal process, the abnormal process is terminated. In this way, the present application can terminate the abnormal process that cannot execute the test task normally and is not simulated, and only retain the process that can execute the test case normally, thereby preventing the test process from being blocked. After the main process executes the currently executed test case, the next test case can be executed, thereby improving the efficiency of the test.

Description

测试用例执行方法、装置以及服务器Test case execution method, device and server

技术领域Technical Field

本申请涉及计算机技术领域,尤其涉及一种测试用例执行方法、装置以及服务器。The present application relates to the field of computer technology, and in particular to a test case execution method, device and server.

背景技术Background Art

测试工具是用于对计算设备或者虚拟机的接口或者性能等进行测试的软件或平台。A testing tool is software or a platform used to test the interface or performance of a computing device or a virtual machine.

以服务器作为计算设备的示例,目前,服务器可以利用测试工具执行测试用例,进而自动化地测试服务器中的软件以及应用程序的功能是否符合预期,测试服务器中的一些接口是否能够正常工作,以及是否存在安全漏洞和潜在风险等。Taking the server as an example of a computing device, currently, the server can use testing tools to execute test cases, thereby automatically testing whether the functions of the software and applications in the server meet expectations, whether some interfaces in the server can work properly, and whether there are security vulnerabilities and potential risks.

服务器可以调用或者创建主进程执行测试用例进行上述测试,在某些情况下,主进程可以创建多个子进程去执行测试用例,多个子进程之间由于资源竞争、死锁等原因,可能会导致执行进程卡住,从而造成进程堵塞,无法继续执行下一个测试用例。进程的堵塞导致计算设备应用测试工具进行测试的效率较低。The server can call or create a main process to execute the test case to perform the above test. In some cases, the main process can create multiple sub-processes to execute the test case. Due to resource competition, deadlock and other reasons between the multiple sub-processes, the execution process may be stuck, resulting in process congestion and inability to continue to execute the next test case. The process congestion leads to low efficiency of computing device application test tools for testing.

发明内容Summary of the invention

本申请实施例提供了一种测试用例执行方法及服务器,目的是减少测试用例的进程堵塞,提高测试效率。The embodiments of the present application provide a test case execution method and a server, the purpose of which is to reduce process congestion of test cases and improve test efficiency.

第一方面,本申请实施例提供了一种测试用例执行方法,所述方法包括:In a first aspect, an embodiment of the present application provides a test case execution method, the method comprising:

获取测试用例的进程信息,然后根据进程信息确定执行测试用例的进程中是否存在异常进程,其中,异常进程为进程状态满足预设的异常条件的进程,进程状态满足预设的异常条件的进程指的是睡眠进程以及僵尸进程等无法正常执行测试任务的进程。Obtain the process information of the test case, and then determine whether there is an abnormal process in the process of executing the test case based on the process information, where the abnormal process is a process whose process status meets the preset abnormal conditions. The process whose process status meets the preset abnormal conditions refers to sleeping processes and zombie processes and other processes that cannot execute test tasks normally.

当确定进程中存在异常进程,确定异常进程是否存在模拟异常进程,当存在模拟异常进程时,保留模拟异常进程,并处理不是模拟异常进程的异常进程。这样基于进程信息分析异常进程,并结合异常进程的类型在必要时进行终止,可以避免进程长时间、持续的堵塞,后续正常执行测试用例,从而可以提高测试的效率。When it is determined that there is an abnormal process in the process, it is determined whether there is a simulated abnormal process in the abnormal process. When there is a simulated abnormal process, the simulated abnormal process is retained and the abnormal process that is not a simulated abnormal process is processed. In this way, the abnormal process is analyzed based on the process information, and it is terminated when necessary based on the type of the abnormal process, which can avoid long-term and continuous blocking of the process, and the test case is executed normally afterwards, thereby improving the efficiency of the test.

在某些可能实现的方式中,进程信息可以包括进程标识,在确定异常进程是否存在模拟异常进程前还可以:配置模拟异常进程的代码,当代码运行时,将代码对应的进程标识存储在内存中。In some possible implementations, the process information may include a process identifier. Before determining whether the abnormal process has a simulated abnormal process, the following may be done: configure code to simulate the abnormal process, and when the code runs, store the process identifier corresponding to the code in memory.

然后可以通过以下方式确定异常进程是否为模拟异常进程:Then you can determine whether the abnormal process is a simulated abnormal process by:

当异常进程的进程标识与代码对应的进程标识匹配时,确定存在模拟异常进程,当异常进程的进程标识与代码对应的进程标识不匹配时,确定不存在模拟异常进程。When the process identifier of the abnormal process matches the process identifier corresponding to the code, it is determined that a simulated abnormal process exists; when the process identifier of the abnormal process does not match the process identifier corresponding to the code, it is determined that no simulated abnormal process exists.

示例性的,例如代码对应的进程标识,也就是模拟异常进程的PID为2315,则确定异常进程的进程标识(PID)是否为2315,若是则确定该异常进程为模拟异常进程,若否则确定该异常进程不为模拟异常进程。For example, if the process identifier corresponding to the code, that is, the PID of the simulated abnormal process is 2315, then determine whether the process identifier (PID) of the abnormal process is 2315. If so, determine that the abnormal process is a simulated abnormal process. Otherwise, determine that the abnormal process is not a simulated abnormal process.

在某些可能实现的方式中,由于不同类型的异常进程的状态以及行为不同,因此不同类型的异常进程需要通过不同的方式进行处理,进而本申请中可以根据异常进程的类型,确定与异常进程的类型匹配的进程终止方式,然后采用与异常进程的类型匹配的进程终止方式终止异常进程。In some possible implementation methods, since different types of abnormal processes have different states and behaviors, different types of abnormal processes need to be handled in different ways. Therefore, in this application, a process termination method that matches the type of abnormal process can be determined based on the type of the abnormal process, and then the abnormal process can be terminated using the process termination method that matches the type of the abnormal process.

以异常进程包括睡眠进程、僵尸进程以及停止进程为例进行介绍。Abnormal processes including sleeping processes, zombie processes, and stopped processes are introduced as examples.

若异常进程的类型为睡眠进程或停止进程,则可以确定进程终止方式为执行kill命令,其中,停止进程为已被停止或正在被调试器追踪的进程。If the type of the abnormal process is a sleeping process or a stopped process, it can be determined that the process termination method is to execute a kill command, wherein the stopped process is a process that has been stopped or is being tracked by a debugger.

若异常进程的类型为僵尸进程,则可以确定进程终止方式为利用僵尸进程的父进程回收僵尸进程。If the type of the abnormal process is a zombie process, then the process termination method may be determined to be to recycle the zombie process using the parent process of the zombie process.

在某些可能实现的方式中,本申请还可以确定是否成功终止异常进程;In some possible implementations, the present application may also determine whether the abnormal process is successfully terminated;

当确定未成功终止异常进程时,可以根据异常进程的类型,确定与类型匹配的强制终止方式,采用与类型匹配的强制终止方式,强制终止异常进程。When it is determined that the abnormal process is not successfully terminated, a forced termination method matching the type may be determined according to the type of the abnormal process, and the abnormal process may be forcibly terminated using the forced termination method matching the type.

示例性的,若异常进程的类型为睡眠进程或停止进程,则确定强制终止方式为执行kill-9命令,通过执行kill-9命令强制终止异常进程;Exemplarily, if the type of the abnormal process is a sleeping process or a stopped process, determining the forced termination method is to execute a kill-9 command, and forcibly terminating the abnormal process by executing the kill-9 command;

若异常进程的类型为僵尸进程,则确定强制终止方式为执行kill命令或者kill-9命令,通过执行kill命令或者kill-9命令终止僵尸进程的父进程或重启父进程,以强制终止僵尸进程。If the type of the abnormal process is a zombie process, the forced termination method is determined to be executing a kill command or a kill-9 command. The parent process of the zombie process is terminated or the parent process is restarted by executing the kill command or the kill-9 command to forcibly terminate the zombie process.

在某些可能实现的方式中,当判断异常进程不是模拟的异常进程时,可以尝试对异常进程进行修复。In some possible implementations, when it is determined that the abnormal process is not a simulated abnormal process, an attempt may be made to repair the abnormal process.

具体的,可以判断异常进程是否为可修复进程,若异常进程的类型为僵尸进程或异常进程的进程状态为不为可中断睡眠状态,可以确定异常进程为不可修复进程,则终止异常进程。Specifically, it can be determined whether the abnormal process is a repairable process. If the type of the abnormal process is a zombie process or the process state of the abnormal process is not an interruptible sleep state, it can be determined that the abnormal process is an unrepairable process, and the abnormal process is terminated.

若异常进程的类型为睡眠进程且异常进程的进程状态为可中断睡眠状态,可以确定异常进程为可修复进程,进而可以执行对应的修复方式修复异常进程,以唤醒异常进程。If the type of the abnormal process is a sleep process and the process state of the abnormal process is an interruptible sleep state, the abnormal process can be determined to be a repairable process, and then a corresponding repair method can be executed to repair the abnormal process to wake up the abnormal process.

若异常进程的类型为停止进程,可以确定异常进程为可修复进程,执行对应的修复方式修复异常进程,以唤醒异常进程,其中,修复方式例如可以为,执行kill命令向异常进程发送SIGCONT信号,SIGCONT信号可以用来唤醒被停止的进程,即使对于处于可中断睡眠状态的进程,发送SIGCONT通常也是有效的,因为它会唤醒进程并使其继续执行。当然,这里的修复方式只是举例介绍,在此不做限定。If the type of the abnormal process is a stopped process, it can be determined that the abnormal process is a repairable process, and a corresponding repair method is executed to repair the abnormal process to wake up the abnormal process, wherein the repair method can be, for example, executing the kill command to send a SIGCONT signal to the abnormal process, and the SIGCONT signal can be used to wake up the stopped process. Even for a process in an interruptible sleep state, sending SIGCONT is usually effective because it wakes up the process and allows it to continue execution. Of course, the repair method here is only an example and is not limited here.

当异常进程修复失败时,可以终止异常进程。When the abnormal process repair fails, the abnormal process can be terminated.

可以通过以下方式判断异常进程修复是否成功。You can determine whether the abnormal process is repaired successfully in the following ways.

若经过修复,异常进程的STAT列状态码改变为R,可以确定异常进程的进程状态改变为运行状态,进而可以确定该异常进程修复成功,异常进程被成功唤醒,其中,STAT列状态码用于表征进程的进程状态,STAT列状态码为R表征进程的进程状态处于运行状态。If after repair, the STAT column status code of the abnormal process changes to R, it can be determined that the process state of the abnormal process changes to the running state, and further it can be determined that the abnormal process is successfully repaired and the abnormal process is successfully awakened. Among them, the STAT column status code is used to represent the process state of the process, and the STAT column status code is R, which indicates that the process state of the process is in the running state.

若经过修复,异常进程的STAT列状态码未改变或者改变为除了R以外的其他状态码,确定异常进程修复失败,终止异常进程。If, after repair, the status code of the STAT column of the abnormal process does not change or changes to a status code other than R, it is determined that the repair of the abnormal process has failed and the abnormal process is terminated.

在某些可能实现的方式中,还可以对异常进程进行堆栈跟踪,进而可以根据堆栈跟踪信息可以定位问题所在,即可以定位异常进程出现异常的原因,以便相关人员采取相应的措施进行修复。In some possible implementations, the abnormal process can also be stack traced, and the problem can be located based on the stack trace information, that is, the cause of the abnormal process being abnormal can be located so that relevant personnel can take corresponding measures to repair it.

在某些可能实现的方式中,还可以每隔预设时间段对异常进程进行整合,然后对整合的异常进程进行批量处理,这样每隔预设时间整合异常进程,将多个异常进程进行批量处理,可以减少对异常进行处理的次数,从而可以提高系统资源的利用率,其中,预设时间段可以根据实际需求设置,例如可以为0.5s,在此不做限定。In some possible implementation methods, the abnormal processes can be integrated at preset time intervals, and then the integrated abnormal processes can be processed in batches. In this way, the abnormal processes can be integrated at preset time intervals and multiple abnormal processes can be processed in batches, which can reduce the number of times the exceptions are processed, thereby improving the utilization of system resources. The preset time period can be set according to actual needs, for example, it can be 0.5s, which is not limited here.

在某些可能实现的方式中,为了及时回收模拟异常进程,进而避免系统资源(如内存、CPU时间等)的浪费,本申请在当前执行的测试用例执行结束之后,还可以判断是否存在未被回收的模拟异常进程,当确定存在未被回收的模拟异常进程,对未被回收的模拟异常进程进行回收。In some possible implementation methods, in order to timely recycle the simulated exception process and avoid wasting system resources (such as memory, CPU time, etc.), the present application can also determine whether there are any unrecycled simulated exception processes after the execution of the currently executed test case is completed. When it is determined that there are unrecycled simulated exception processes, the unrecycled simulated exception processes are recycled.

第二方面,本申请提供了一种测试用例执行装置,包括:In a second aspect, the present application provides a test case execution device, comprising:

获取单元,用于获取测试用例的进程信息;An acquisition unit is used to obtain the process information of the test case;

第一确定单元,用于根据进程信息确定所述测试用例的进程中是否存在异常进程;A first determining unit, configured to determine whether there is an abnormal process in the process of the test case according to the process information;

第二确定单元,用于当进程中存在异常进程时,确定异常进程是否存在模拟异常进程;A second determining unit is used to determine whether there is a simulated abnormal process in the abnormal process when there is an abnormal process in the process;

处理单元,用于当存在模拟异常进程时,保留模拟异常进程,并处理不是模拟异常进程的异常进程。The processing unit is used for retaining the simulated abnormal process when there is a simulated abnormal process, and processing the abnormal process which is not the simulated abnormal process.

在某些可能实现的方式中,进程信息包括进程标识,装置还可以包括:In some possible implementations, the process information includes a process identifier, and the device may further include:

配置单元,用于配置模拟异常进程的代码;A configuration unit, used to configure the code for simulating abnormal processes;

存储单元,用于当所述代码运行时,将所述代码对应的进程标识存储在内存中;A storage unit, used for storing a process identifier corresponding to the code in a memory when the code is executed;

第二确定单元,具体用于:The second determining unit is specifically configured to:

当异常进程的进程标识与代码对应的进程标识匹配时,确定存在模拟异常进程;When the process identifier of the abnormal process matches the process identifier corresponding to the code, it is determined that a simulated abnormal process exists;

当异常进程的进程标识与代码对应的进程标识不匹配时,确定不存在模拟异常进程。When the process identifier of the abnormal process does not match the process identifier corresponding to the code, it is determined that there is no simulated abnormal process.

在某些可能实现的方式中,装置还可以包括:In some possible implementations, the device may further include:

回收单元,用于当存在模拟异常进程时,回收所述测试用例执行完毕后未被回收的模拟异常进程。The recycling unit is used to recycle the simulated abnormal process that has not been recycled after the test case is executed when there is a simulated abnormal process.

在某些可能实现的方式中,处理单元,可以具体用于:In some possible implementations, the processing unit may be specifically configured to:

根据进程的类型,确定所述进程的进程终止方式;Determining, according to the type of the process, a process termination method of the process;

采用进程终止方式终止所述进程。The process is terminated by using a process termination method.

在某些可能实现的方式中,装置可以还包括:In some possible implementations, the device may further include:

判断单元,用于根据不是模拟异常进程的异常进程的进程状态判断异常进程是否可以修复;a judging unit, configured to judge whether the abnormal process can be repaired according to the process state of the abnormal process which is not a simulated abnormal process;

第三确定单元,用于当确定异常进程为不可修复进程时,确定所述进程的进程终止方式。The third determining unit is used to determine a process termination mode of the process when the abnormal process is determined to be an unrepairable process.

第三方面,本申请实施例提供了一种服务器,所述服务器包括:In a third aspect, an embodiment of the present application provides a server, wherein the server includes:

存储器和处理器;Memory and processor;

存储器与处理器耦合;存储器存储有程序指令,当程序指令由处理器执行时,使得电子设备执行如第一方面的实现方式。The memory is coupled to the processor; the memory stores program instructions, and when the program instructions are executed by the processor, the electronic device executes the implementation method of the first aspect.

由上述技术方案可知,本申请具有如下有益效果:It can be seen from the above technical solution that the present application has the following beneficial effects:

本申请中可以获取测试用例的进程信息,然后根据进程信息确定测试用例的进程中是否存在异常进程,当确定进程中存在异常进程还可以进一步判断异常进程是否为模拟出来的异常进程,即异常进程是否为模拟异常进程,当确定异常进程不为模拟异常进程,则终止异常进程。本申请中,基于进程信息分析异常进程,并结合异常进程的类型在必要时进行终止,可以避免进程长时间、持续的堵塞,后续正常执行测试用例,从而可以提高测试的效率。In this application, the process information of the test case can be obtained, and then whether there is an abnormal process in the process of the test case can be determined based on the process information. When it is determined that there is an abnormal process in the process, it can be further determined whether the abnormal process is a simulated abnormal process, that is, whether the abnormal process is a simulated abnormal process. When it is determined that the abnormal process is not a simulated abnormal process, the abnormal process is terminated. In this application, the abnormal process is analyzed based on the process information, and terminated when necessary in combination with the type of abnormal process, which can avoid long-term and continuous blockage of the process, and the test case is executed normally afterwards, thereby improving the efficiency of the test.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1为本申请实施例提供的一种测试用例执行方法的应用场景示意图;FIG1 is a schematic diagram of an application scenario of a test case execution method provided in an embodiment of the present application;

图2为本申请实施例提供的一种测试用例执行方法流程图;FIG2 is a flow chart of a test case execution method provided in an embodiment of the present application;

图3为本申请实施例提供的另一种测试用例执行方法流程图;FIG3 is a flow chart of another test case execution method provided in an embodiment of the present application;

图4为本申请实施例提供的一种测试用例执行装置的结构框图;FIG4 is a structural block diagram of a test case execution device provided in an embodiment of the present application;

图5为本申请实施例提供的一种计算设备的硬件结构示意图。FIG5 is a schematic diagram of the hardware structure of a computing device provided in an embodiment of the present application.

具体实施方式DETAILED DESCRIPTION

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。The term "and/or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and/or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

本申请实施例的说明书和权利要求书中的术语“第一”和“第二”等是用于区别不同的对象,而不是用于描述对象的特定顺序。例如,第一目标对象和第二目标对象等是用于区别不同的目标对象,而不是用于描述目标对象的特定顺序。The terms "first" and "second" in the description and claims of the embodiments of the present application are used to distinguish different objects rather than to describe a specific order of objects. For example, a first target object and a second target object are used to distinguish different target objects rather than to describe a specific order of target objects.

在本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

在本申请实施例的描述中,除非另有说明,“多个”的含义是指两个或两个以上。例如,多个处理单元是指两个或两个以上的处理单元;多个系统是指两个或两个以上的系统。In the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" refers to two or more than two. For example, multiple processing units refer to two or more processing units; multiple systems refer to two or more systems.

测试工具:指用于帮助测试人员对服务器或者虚拟机进行测试的软件或平台。测试工具可以自动执行测试用例,从而可以实现自动化测试流程,进而减少人工手动操作,提高测试效率。Testing tools: refers to software or platforms used to help testers test servers or virtual machines. Testing tools can automatically execute test cases, thereby automating the testing process, reducing manual operations and improving testing efficiency.

下面示例性介绍几种测试工具。Several testing tools are introduced below as examples.

缺陷管理测试工具:通常提供缺陷管理功能,允许测试人员记录、跟踪和报告在测试过程中发现的缺陷。这有助于确保缺陷得到及时修复,并提供了关于缺陷状态、修复进度和回归测试的详细信息。Defect management testing tools: usually provide defect management capabilities, allowing testers to record, track and report defects found during the testing process. This helps ensure that defects are fixed in a timely manner and provides detailed information about defect status, repair progress and regression testing.

性能测试工具:可以模拟大量用户的并发访问,测试服务器的负载能力和性能表现。这些工具能够收集和分析性能指标,帮助测试人员识别性能瓶颈和优化机会。Performance testing tools: can simulate a large number of users' concurrent access and test the server's load capacity and performance. These tools can collect and analyze performance indicators to help testers identify performance bottlenecks and optimization opportunities.

接口测试工具:可以发送请求并验证响应,以确保应用程序的接口按照预期工作。这些工具支持多种协议和格式,从而能够全面测试API的功能和性能。Interface testing tools: can send requests and verify responses to ensure that the application's interface works as expected. These tools support multiple protocols and formats, enabling comprehensive testing of the functionality and performance of the API.

用户界面(User Interface,UI)测试工具:可以模拟用户与应用程序的交互,验证UI元素的功能和外观是否符合要求。这些工具能够记录用户操作、生成测试脚本,并自动执行UI测试。User Interface (UI) testing tools: can simulate user interactions with applications to verify whether the functions and appearance of UI elements meet the requirements. These tools can record user operations, generate test scripts, and automatically perform UI testing.

安全测试工具:用于检测软件中的安全漏洞和潜在风险。这些工具可以执行漏洞扫描、渗透测试等任务,帮助测试人员评估软件的安全性并采取相应的防护措施。Security testing tools: used to detect security vulnerabilities and potential risks in software. These tools can perform tasks such as vulnerability scanning and penetration testing to help testers assess the security of software and take appropriate protective measures.

目前,服务器可以利用测试工具执行测试用例进而可以自动化测试服务器中的软件以及应用程序的功能是否符合预期、服务器中的一些接口是否能够正常工作以及是否存在安全漏洞和潜在风险等。Currently, the server can use testing tools to execute test cases to automatically test whether the functions of the software and applications in the server meet expectations, whether some interfaces in the server can work properly, and whether there are security vulnerabilities and potential risks.

进一步的,当在测试工具中执行测试用例时,服务器可以调用主进程且主进程可以创建多个子进程执行测试用例进行测试。在某些情况下,测试工具需要按照顺序执行多个测试用例,即,主进程需要执行多个测试用例进行测试。例如,主进程需要执行测试用例A、测试用例B以及测试用例C进行测试,以主进程当前执行测试用例为测试用例A为例,如图1所示,主进程在执行测试用例A时,创建子进程A1、子进程A2以及子进程A3执行测试用例A,不同子进程之间可能会发生资源竞争、死锁等,进而可能导致执行测试用例A的子进程中存在异常进程,从而导致主进程无法结束执行测试用例A,造成主进程发生堵塞,无法继续执行下一个测试用例B。Furthermore, when executing test cases in the test tool, the server can call the main process and the main process can create multiple sub-processes to execute the test cases for testing. In some cases, the test tool needs to execute multiple test cases in sequence, that is, the main process needs to execute multiple test cases for testing. For example, the main process needs to execute test case A, test case B, and test case C for testing. Taking the test case currently executed by the main process as test case A as an example, as shown in Figure 1, when the main process executes test case A, it creates sub-processes A1, A2, and A3 to execute test case A. Resource competition and deadlock may occur between different sub-processes, which may lead to abnormal processes in the sub-processes executing test case A, resulting in the main process being unable to end the execution of test case A, causing the main process to be blocked and unable to continue to execute the next test case B.

有鉴于此,本申请提供一种测试用例执行方法以及服务器,可以获取测试用例的进程信息,然后根据所述进程信息确定测试用例的进程中是否存在异常进程,当确定进程中存在异常进程且异常进程不为模拟异常进程,则终止异常进程,这样本申请中就可以终止无法正常执行测试任务且不是模拟出来的异常进程,只保留可以正常执行测试用例的进程,进而可以防止造成测试进程堵塞,在主进程执行完当前执行的测试用例执行后,即可执行下一个测试用例,从而可以提高测试的效率。In view of this, the present application provides a test case execution method and a server, which can obtain the process information of the test case, and then determine whether there is an abnormal process in the process of the test case based on the process information. When it is determined that there is an abnormal process in the process and the abnormal process is not a simulated abnormal process, the abnormal process is terminated. In this way, the present application can terminate the abnormal process that cannot execute the test task normally and is not simulated, and only retain the process that can execute the test case normally, thereby preventing the test process from being blocked. After the main process completes the execution of the currently executed test case, the next test case can be executed, thereby improving the efficiency of the test.

本申请提供的测试用例执行方法可应用于计算设备中,计算设备例如可以是服务器,服务器可以是独立的物理服务器,也可以由多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、云通信、中间件服务、域名服务、安全服务、内容分发网络(Content Delivery Network,CDN),以及大数据库和人工智能平台等基础云计算服务的云服务器。当上述服务器为由多个物理服务器构成的服务器集群,或者分布式系统时,多个物理服务器可以组成一个区块链,每个物理服务器为该区块链上的节点。服务区的物理类型可以机架服务器、高密服务器、GPU服务器、塔式服务器,还可以为刀片服务器、整机柜服务器等,本申请不具体限定。The test case execution method provided in this application can be applied to a computing device, which can be, for example, a server, which can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and basic cloud computing services such as large databases and artificial intelligence platforms. When the above-mentioned server is a server cluster composed of multiple physical servers, or a distributed system, multiple physical servers can form a blockchain, and each physical server is a node on the blockchain. The physical type of the service area can be a rack server, a high-density server, a GPU server, a tower server, and can also be a blade server, a whole cabinet server, etc., which is not specifically limited in this application.

下面结合图2,对本申请中提供的测试用例执行方法的执行逻辑进行介绍,这里可以称为实施例一,以实施例一中的方法在计算设备中执行且计算设备中的操作系统为linux系统为例,该方法可以包括:In conjunction with FIG. 2 , the execution logic of the test case execution method provided in the present application is introduced, which may be referred to as Embodiment 1. Taking the method in Embodiment 1 as an example in which the method is executed in a computing device and the operating system in the computing device is a Linux system, the method may include:

S201:执行测试。S201: Execute test.

计算设备可以执行测试用例进行测试。The computing device may execute the test case for testing.

在某些可能实现的方式中,计算设备可以利用测试工具执行测试,其中,测试工具可以包括多种。例如接口测试工具、UI测试工具以及性能测试工具等。可以根据用户发布的测试任务确定要执行的测试工具,例如测试任务为测试服务器的性能,则计算设备可以确定需要执行性能测试工具,再比如说。测试任务为测试服务器的接口是否正常工作,则计算设备可以确定需要执行接口测试工具。在确定要执行的测试工具之后,可以为测试工具搭建必要的测试环境。例如包括安装相关软件、配置硬件以及设置网络等,然后将确定的测试工具部署到测试环境中以及将测试框架集成到测试环境中。其中,可能包括配置测试参数以及设置测试执行计划等。最后,计算设备可以执行部署好的测试工具进行测试。In some possible implementations, a computing device may perform tests using a testing tool, wherein the testing tools may include multiple types. For example, an interface testing tool, a UI testing tool, and a performance testing tool. The testing tool to be executed may be determined based on the test task posted by the user. For example, if the test task is to test the performance of the server, the computing device may determine that a performance testing tool needs to be executed. For example, if the test task is to test whether the interface of the server is working properly, the computing device may determine that an interface testing tool needs to be executed. After determining the test tool to be executed, a necessary test environment may be set up for the test tool. For example, this includes installing relevant software, configuring hardware, and setting up a network, and then deploying the determined test tool into the test environment and integrating the test framework into the test environment. This may include configuring test parameters and setting up a test execution plan. Finally, the computing device may execute the deployed test tool for testing.

具体的,计算设备可以利用部署好的测试工具执行测试用例进行测试。Specifically, the computing device can use the deployed test tools to execute test cases for testing.

当在测试工具中执行测试用例时,计算设备可以调用测试工具对应的主进程执行测试用例,在某些可能实现的方式中,为了提高测试效率以及更好地平衡系统负载,主进程还可以创建子进程共同执行测试用例。When executing test cases in a test tool, the computing device can call the main process corresponding to the test tool to execute the test cases. In some possible implementations, in order to improve test efficiency and better balance system load, the main process can also create sub-processes to jointly execute test cases.

在某些可能实现的方式中,在执行部署好的测试工具进行测试之前,还可以配置进程。其中,配置进程可以包括配置主进程命令以及配置主进程的PID,其中,PID指的是每个进程的标识符,用于唯一地标识该进程。进程的名称一般为描述性的字符串,以便用户根据进程名词识别以及理解该进程的含义。进程状态可以包括运行状态、停止状态、睡眠状态以及僵尸状态等。In some possible implementations, before executing the deployed test tool for testing, the process may also be configured. The process configuration may include configuring the main process command and configuring the PID of the main process, wherein the PID refers to an identifier of each process, which is used to uniquely identify the process. The name of the process is generally a descriptive string so that the user can identify and understand the meaning of the process based on the process name. The process status may include running status, stopped status, sleeping status, and zombie status.

例如,可以将执行测试工具的主进程的PID配置为2216,以便后续根据PID确定执行测试工具的主进程。For example, the PID of the main process executing the test tool may be configured as 2216, so that the main process executing the test tool may be subsequently determined according to the PID.

在某些可能实现的方式中,为了测试系统在面对异常情况时的稳定性和可靠性,以及评估系统在面对异常情况时的性能表现等,在配置进程时候,服务器还可以配置模拟异常进程,其中,模拟异常进程为用于模拟出现异常情况的进程。In some possible implementations, in order to test the stability and reliability of the system when facing abnormal situations, and to evaluate the performance of the system when facing abnormal situations, when configuring the process, the server can also configure a simulated abnormal process, where the simulated abnormal process is a process used to simulate the occurrence of abnormal situations.

示例性的,在执行测试之前可以配置模拟异常进程的代码,例如为“simulation”:[“command1”,“command2”],可以代表command1以及command2行的代码为配置模拟异常进程的代码,在测试执行后,运行测试用例时,计算设备会将生成的这段代码对应的进程的PID保存在内存中。Exemplarily, before executing the test, code for simulating an abnormal process can be configured, such as "simulation":["command1", "command2"], which can represent that the code in the command1 and command2 lines is the code for configuring a simulated abnormal process. After the test is executed, when the test case is run, the computing device will save the PID of the process corresponding to the generated code in memory.

例如,测试用例执行后,command1这段代码对应的进程的PID为2315,则计算设备可以将2315保存在内存中,后续可以根据模拟异常进程的PID以及进程的PID是否匹配,确定异常进程是否为模拟异常进程。For example, after the test case is executed, the PID of the process corresponding to the code command1 is 2315, then the computing device can save 2315 in the memory, and subsequently determine whether the abnormal process is a simulated abnormal process based on the PID of the simulated abnormal process and whether the PID of the process matches.

S202:获取测试进程的进程信息。S202: Obtain process information of the test process.

计算设备可以获取测试进程的进程信息。The computing device may obtain process information of the test process.

在一些可能的实现方式中,计算设备可以利用监控工具(例如nmon、htop、glances等)获取测试进程的进程信息。其中,测试进程可以为步骤S201中执行测试用例的进程,获取的测试进程的进程信息可以包括主进程中的各个子进程的信息,子进程的信息可以包括进程的标识(示例性地,可以是PID)以及进程状态。In some possible implementations, the computing device may use a monitoring tool (such as nmon, htop, glances, etc.) to obtain process information of the test process. The test process may be the process that executes the test case in step S201, and the obtained process information of the test process may include information of each sub-process in the main process, and the sub-process information may include a process identifier (exemplarily, PID) and a process status.

在某些可能实现的方式中,子进程的信息还可以包括进程名称。In some possible implementations, the child process information may further include a process name.

进程状态可以包括以下几种状态:The process status can include the following states:

运行状态:进程正在CPU上运行,处于执行状态,可以将进入运行状态的进程称为运行进程。Running state: The process is running on the CPU and is in the execution state. A process that enters the running state can be called a running process.

睡眠状态(也称阻塞状态):指的是进程正在等待某一事件而暂停运行,例如等待某资源为可用或等待I/O完成。即使CPU空闲,该进程也不能运行。当等待的条件得到满足时,进程会由睡眠状态转变为就绪状态。Sleep state (also called blocking state): refers to the process pausing while waiting for an event, such as waiting for a resource to become available or waiting for I/O to complete. Even if the CPU is idle, the process cannot run. When the waiting condition is met, the process changes from the sleep state to the ready state.

睡眠状态通常包括:S(可中断睡眠)或D(不可中断睡眠)状态。可中断睡眠(S状态)状态:指的是进程正在等待某些条件就绪,这些条件例如可能是I/O操作完成、信号到达等。当这些条件满足时,进程可以被唤醒并继续执行。不可中断睡眠(D状态)状态:进程处于不可中断的睡眠状态,通常用于等待磁盘I/O操作完成。在这种状态下,进程不能被唤醒,直到磁盘I/O操作完成。可以将进入睡眠状态的进程称为睡眠进程。Sleep states usually include: S (interruptible sleep) or D (non-interruptible sleep) state. Interruptible sleep (S state) state: refers to the process waiting for certain conditions to be ready, such as the completion of I/O operations, the arrival of signals, etc. When these conditions are met, the process can be awakened and continue to execute. Non-interruptible sleep (D state) state: The process is in an uninterruptible sleep state, usually used to wait for disk I/O operations to complete. In this state, the process cannot be awakened until the disk I/O operation is completed. A process that enters the sleep state can be called a sleeping process.

停止状态:进程已经完成了其需要执行的任务,或者由于某种原因(如出错)而终止,此时操作系统会进行善后处理,并释放该进程所占用的资源。进入终止状态的进程以后不再执行,但依然保留在操作系统中等待善后。一旦其他进程完成了对终止态进程的信息抽取之后,操作系统将释放其占用的空间,可以将进入停止状态的进程称为停止进程。Stopped state: The process has completed the tasks it needs to perform, or terminated for some reason (such as an error). At this time, the operating system will handle the aftermath and release the resources occupied by the process. The process that enters the terminated state will no longer be executed, but will remain in the operating system waiting for the aftermath. Once other processes have completed the information extraction of the terminated process, the operating system will release the space it occupies. The process that enters the stopped state can be called a stopped process.

僵尸状态:指的是当子进程比父进程先结束,而父进程又没有回收子进程,释放子进程占用的资源时,子进程将成为一个僵尸状态的进程,可以将进入僵尸状态的进程称为僵尸进程。僵尸进程不再占用除进程表项外的任何系统资源(如内存、CPU等),但进程表项仍然保留在内存中,以记录僵尸进程的退出状态和其他相关信息。Zombie state: refers to when the child process ends before the parent process, and the parent process does not recycle the child process and release the resources occupied by the child process, the child process will become a zombie process. The process that enters the zombie state can be called a zombie process. The zombie process no longer occupies any system resources (such as memory, CPU, etc.) except the process table entry, but the process table entry is still retained in the memory to record the exit status and other related information of the zombie process.

在某些可能实现的方式中,计算设备可以通过以下方式获取进程的进程状态。In some possible implementations, the computing device may obtain the process status of a process in the following manner.

计算设备可以执行ps命令查看STAT列,进而可以查看当前执行测试任务的所有测试进程的进程状态,其中,ps命令是一个用于报告当前系统的进程状态的命令。The computing device can execute the ps command to view the STAT column, and then view the process status of all test processes currently executing the test task, wherein the ps command is a command for reporting the process status of the current system.

当服务器执行ps命令查看STAT列时,服务器可以确定每个测试进程的STAT列状态码,STAT列状态码可以包括R、S、D、T、Z以及I。When the server executes the ps command to view the STAT column, the server can determine the STAT column status code of each test process. The STAT column status code may include R, S, D, T, Z, and I.

具体的,不同STAT列状态码的含义可以如下:Specifically, the meanings of different STAT column status codes are as follows:

STAT列状态码为R的进程为运行进程,该进程的进程状态处于运行状态,代表该进程正在运行或正在运行队列中等待。The process with the status code R in the STAT column is a running process. The process status of the process is in the running state, which means that the process is running or waiting in the running queue.

STAT列状态码为S的进程为睡眠进程,该进程的进程状态处于可中断睡眠状态,表征该进程正在等待某些条件的发生,例如等待I/O操作完成。The process with the status code S in the STAT column is a sleeping process. The process state of the process is in an interruptible sleeping state, indicating that the process is waiting for certain conditions to occur, such as waiting for an I/O operation to complete.

STAT列状态码为D的进程也为睡眠进程,该进程的进程状态处于不可中断睡眠状态,也可以称为处于磁盘休眠状态,表征该进程正在等待磁盘I/O操作完成。在这种状态下,进程不能被唤醒,直到磁盘I/O操作完成。The process with the status code D in the STAT column is also a sleeping process. The process state of the process is in an uninterruptible sleeping state, which can also be called a disk hibernation state, indicating that the process is waiting for the disk I/O operation to complete. In this state, the process cannot be awakened until the disk I/O operation is completed.

STAT列状态码为T的进程为停止进程,该进程的进程状态处于停止状态,表征该进程已被停止或正在被调试器追踪。The process with the status code T in the STAT column is a stopped process. The process status of the process is in the stopped state, indicating that the process has been stopped or is being tracked by a debugger.

STAT列状态码为Z的进程为僵尸进程,该进程的进程状态处于僵尸状态,意味着该进程已经结束,但其父进程还没有读取它的结束状态信息。The process with the status code Z in the STAT column is a zombie process. The process status of the process is in the zombie state, which means that the process has ended, but its parent process has not read its end status information.

STAT列状态码为I表征该进程的进程状态处于空闲状态。The status code in the STAT column is I, indicating that the process status of the process is in idle state.

这样计算设备就可以通过执行ps命令查看STAT列,进而可以获取当前执行测试任务的所有测试进程的进程状态。In this way, the computing device can view the STAT column by executing the ps command, and then obtain the process status of all test processes currently executing the test task.

S203:根据测试进程的信息判断是否存在异常进程。S203: Determine whether there is an abnormal process based on the information of the test process.

计算设备在获取测试进程的进程信息之后,可以根据测试进程的进程信息判断是否存在异常进程,其中,异常进程可以为进程状态满足预设的异常条件的进程,进程状态满足预设的异常条件的进程指的是睡眠进程以及僵尸进程等无法正常执行测试任务的进程。After obtaining the process information of the test process, the computing device can determine whether there is an abnormal process based on the process information of the test process, where the abnormal process may be a process whose process status meets the preset abnormal conditions. The process whose process status meets the preset abnormal conditions refers to sleeping processes, zombie processes and other processes that cannot execute test tasks normally.

示例性的,下面以异常进程的类型包括睡眠进程以及僵尸进程为例进行介绍。当存在STAT列状态码为S、D以及Z的进程,可以确定测试进程中存在异常进程,即STAT列状态码为S或者D的进程为睡眠进程,STAT列状态码为Z的进程为僵尸进程。Exemplarily, the following is an introduction using the types of abnormal processes including sleep processes and zombie processes as examples. When there are processes with STAT column status codes of S, D, and Z, it can be determined that there are abnormal processes in the test process, that is, the process with STAT column status code of S or D is a sleep process, and the process with STAT column status code of Z is a zombie process.

当然,上述只是以异常进程包括睡眠进程以及异常进程为例进行介绍,需要说明的是异常进程并不限定只包括睡眠进程以及异常进程。Of course, the above description is only based on the example that the abnormal process includes the sleep process and the abnormal process. It should be noted that the abnormal process is not limited to only include the sleep process and the abnormal process.

在一种可能的实现方式中,异常进程还可以包括其他进程,例如停止进程等。In a possible implementation, the abnormal process may also include other processes, such as a stopped process.

在某些可能实现的方式中,当确定测试进程中存在异常进程之后可以执行步骤S205对异常进程处理。In some possible implementations, after it is determined that there is an abnormal process in the test process, step S205 may be executed to process the abnormal process.

当确定测试进程中不存在异常进程可以等待测试结束或者间隔预设时间之后再次执行步骤S202以及步骤S203,进行下一轮的对进程状态的判断,其中,间隔的预设时间可以根据需求设置,例如设置间隔的预设时间为0.3秒,此处对间隔预设时间不做具体的限定。When it is determined that there is no abnormal process in the test process, you can wait for the test to end or execute steps S202 and S203 again after a preset interval to perform the next round of process status judgment, wherein the preset interval time can be set according to demand, for example, setting the preset interval time to 0.3 seconds, and there is no specific limitation on the preset interval time here.

在某些可能实现的方式中,在计算设备预先配置了模拟异常进程的情况下,当确定测试进程中存在异常进程之后,可以执行步骤S204以判断异常进程是否为预先配置的模拟异常进程,需要说明的是测试进程中存在的异常进程的数量可能为一个也可能为多个。In some possible implementations, when a computing device is pre-configured with a simulated abnormal process, after determining that an abnormal process exists in the test process, step S204 can be executed to determine whether the abnormal process is a pre-configured simulated abnormal process. It should be noted that the number of abnormal processes existing in the test process may be one or more.

S204:判断异常进程中是否存在模拟异常进程。S204: Determine whether there is a simulated abnormal process in the abnormal process.

计算设备可以判断异常进程中是否存在模拟异常进程,从而判断异常进程为模拟出来的异常进程还是真实的异常进程。The computing device may determine whether there is a simulated abnormal process in the abnormal process, thereby determining whether the abnormal process is a simulated abnormal process or a real abnormal process.

进一步的,当异常进程的数量为一个时,可以判断该异常进程是否为模拟异常进程,当异常进程的数量为多个时,可以判断多个异常进程中是否存在模拟异常进程。Further, when the number of abnormal processes is one, it can be determined whether the abnormal process is a simulated abnormal process. When the number of abnormal processes is multiple, it can be determined whether there is a simulated abnormal process among the multiple abnormal processes.

下面以异常进程的数量为一个为例进行介绍。The following takes the case where the number of abnormal processes is one as an example.

具体的,可以判断异常进程的PID是否为在步骤201中存储的模拟异常进程的PID,若是,则可以确定异常进程为模拟异常进程,若否,则可以确定异常进程不为模拟异常进程。Specifically, it can be determined whether the PID of the abnormal process is the PID of the simulated abnormal process stored in step 201. If so, it can be determined that the abnormal process is a simulated abnormal process. If not, it can be determined that the abnormal process is not a simulated abnormal process.

当确定异常进程为模拟异常进程时,由于是模拟出来的异常进程而非真实的异常进程因此可以保留该进程。When it is determined that the abnormal process is a simulated abnormal process, the process can be retained because it is a simulated abnormal process rather than a real abnormal process.

当确定异常进程不为模拟异常进程时,可以处理该异常进程。When it is determined that the abnormal process is not a simulated abnormal process, the abnormal process may be processed.

S205:当存在模拟异常进程时,保留模拟异常进程,并对不是模拟异常进程的异常进程进行处理。S205: When there is a simulated abnormal process, the simulated abnormal process is retained, and the abnormal process that is not the simulated abnormal process is processed.

计算设备可以保留是模拟异常进程的异常进程,然后可以等待测试结束或者间隔预设时间之后再次执行步骤S202以及步骤S203进行下一轮的对进程状态的判断。The computing device may retain the abnormal process that simulates the abnormal process, and then wait for the test to end or execute step S202 and step S203 again after a preset time interval to perform the next round of judgment on the process status.

进一步地,计算设备对不是模拟异常进程的异常进程进行处理,可以根据异常进程的类型处理异常进程,即根据异常进程的类型,执行对应的进程终止方式,终止异常进程。这里的异常进程的类型以包括睡眠进程以及僵尸进程为例进行介绍。Furthermore, the computing device processes the abnormal process that is not a simulated abnormal process, and can process the abnormal process according to the type of the abnormal process, that is, according to the type of the abnormal process, execute the corresponding process termination method to terminate the abnormal process. The types of abnormal processes here are introduced by taking sleep processes and zombie processes as examples.

在一种可能的实现方式中当服务器需要对异常进程进行处理时,可以确定与异常进程的类型匹配的进程终止方式然后采用与异常进程的类型匹配的进程终止方式终止异常进程,例如,当确定异常进程的类型为睡眠进程时,对应的进程终止方式可以为执行kill命令,当服务器执行kill命令时,可以向睡眠线程发送SIGTERM信号,其中SIGTERM信号是请求进程终止其操作的信号。睡眠进程在接收到SIGTERM信号后,通常会完成必要的清理工作(如关闭文件、释放资源等),然后终止。In a possible implementation, when the server needs to process an abnormal process, it can determine a process termination method that matches the type of the abnormal process and then terminate the abnormal process using the process termination method that matches the type of the abnormal process. For example, when the type of the abnormal process is determined to be a sleeping process, the corresponding process termination method can be to execute a kill command. When the server executes the kill command, it can send a SIGTERM signal to the sleeping thread, where the SIGTERM signal is a signal requesting the process to terminate its operation. After receiving the SIGTERM signal, the sleeping process usually completes necessary cleanup work (such as closing files, releasing resources, etc.) and then terminates.

由于僵尸进程本身已经终止,不能直接“杀死”或“终止”一个僵尸进程,因此当确定异常进程的类型为僵尸进程时,对应的进程终止方式可以为利用僵尸进程的父进程回收僵尸进程。即,可以确定僵尸进程的父进程,然后利用父进程调用wait()函数或waitpid()函数调用来回收僵尸进程。Since the zombie process itself has terminated, it is not possible to directly "kill" or "terminate" a zombie process. Therefore, when the abnormal process is determined to be a zombie process, the corresponding process termination method can be to recycle the zombie process using the parent process of the zombie process. That is, the parent process of the zombie process can be determined, and then the parent process can be used to call the wait() function or waitpid() function to recycle the zombie process.

在某些可能实现的方式中,异常进程的类型可以包括睡眠进程、僵尸进程以及停止进程,停止进程的进程终止方式可以与睡眠进程的进程终止方式相同为执行kill命令,当服务器执行kill命令时,向停止线程发送SIGTERM信号,停止进程在接收到SIGTERM信号后,通常会完成必要的清理工作(如关闭文件、释放资源等),然后终止。In some possible implementations, the types of abnormal processes may include sleeping processes, zombie processes, and stopped processes. The process termination method of a stopped process may be the same as that of a sleeping process, namely, executing a kill command. When the server executes the kill command, a SIGTERM signal is sent to the stopped thread. After receiving the SIGTERM signal, the stopped process usually completes necessary cleanup work (such as closing files, releasing resources, etc.) and then terminates.

可以理解的是,当不存在模拟异常进程时,计算设备可以直接对不是模拟异常进程的异常进程进行处理。It can be understood that when there is no simulated abnormal process, the computing device can directly process the abnormal process that is not a simulated abnormal process.

在某些可能实现的方式中,为了及时回收模拟异常进程,进而避免系统资源(如内存、CPU时间等)的浪费,本申请在当前执行的测试用例执行结束之后,还可以判断是否存在未被回收的模拟异常进程,当确定存在未被回收的模拟异常进程,对未被回收的模拟异常进程进行回收。In some possible implementation methods, in order to timely recycle the simulated exception process and avoid wasting system resources (such as memory, CPU time, etc.), the present application can also determine whether there are any unrecycled simulated exception processes after the execution of the currently executed test case is completed. When it is determined that there are unrecycled simulated exception processes, the unrecycled simulated exception processes are recycled.

本申请中可以获取测试用例的进程信息,然后根据进程信息确定测试用例的进程中是否存在异常进程,其中,异常进程为进程状态满足预设的异常条件的进程,当确定进程中存在异常进程还可以进一步判断异常进程中是否存在模拟出来的异常进程,即异常进程中是否存在模拟异常进程,进而可以终止不是模拟异常进程的异常进程。这样本申请中就可以终止无法正常执行测试任务且不是模拟出来的异常进程,只保留可以正常执行测试用例的进程,进而可以防止造成测试进程堵塞,在主进程执行完当前执行的测试用例执行后,即可执行下一个测试用例,从而可以提高测试的效率。In this application, the process information of the test case can be obtained, and then whether there is an abnormal process in the process of the test case can be determined based on the process information, wherein the abnormal process is a process whose process status meets the preset abnormal conditions. When it is determined that there is an abnormal process in the process, it can be further determined whether there is a simulated abnormal process in the abnormal process, that is, whether there is a simulated abnormal process in the abnormal process, and then the abnormal process that is not a simulated abnormal process can be terminated. In this way, in this application, the abnormal process that cannot execute the test task normally and is not simulated can be terminated, and only the process that can execute the test case normally can be retained, thereby preventing the test process from being blocked. After the main process executes the currently executed test case, the next test case can be executed, thereby improving the efficiency of the test.

本申请又提供一个实施例,这里称为实施例二,实施例二与实施例一不同之处在于,实施例二中,当判断异常进程不是模拟的异常进程时,可以尝试对异常进程进行修复并且初次处理异常进程之后,还可以进一步判断异常进程是否被成功处理若异常进程未被成功处理,则可以通过预设的强制终止方式再次对异常进程进行处理,这样可以提高本申请处理异常进程的效率大大降低了进程堵塞的概率。实施例二的方法也可以应用于计算设备,具体可以如图3所示,包括:The present application provides another embodiment, which is referred to as Embodiment 2. The difference between Embodiment 2 and Embodiment 1 is that in Embodiment 2, when it is determined that the abnormal process is not a simulated abnormal process, an attempt can be made to repair the abnormal process and after the abnormal process is processed for the first time, it can be further determined whether the abnormal process is successfully processed. If the abnormal process is not successfully processed, the abnormal process can be processed again by a preset forced termination method, which can improve the efficiency of the present application in processing abnormal processes and greatly reduce the probability of process blockage. The method of Embodiment 2 can also be applied to computing devices, as shown in FIG3, including:

S301:执行测试。S301: Execute test.

S302:获取测试进程的进程信息。S302: Obtain process information of the test process.

S303:根据测试进程的进程信息判断是否存在异常进程。S303: Determine whether there is an abnormal process according to the process information of the test process.

S304:判断异常进程中是否存在模拟异常进程。S304: Determine whether there is a simulated abnormal process in the abnormal process.

S305:当存在模拟异常进程时,保留模拟异常进程。S305: When there is a simulated abnormal process, retain the simulated abnormal process.

步骤S301-S305与步骤S201-S205实现方式以及原理类似,可以参照实施例一中的介绍,在此不做多余叙述。可以理解的是,在S305中,对不是模拟异常进程的异常进程进行处理时,又可以包括以下的S306-S310。The implementation and principle of steps S301-S305 are similar to those of steps S201-S205, and can be referred to the introduction in the first embodiment, and no redundant description is given here. It can be understood that in S305, when processing an abnormal process that is not a simulated abnormal process, the following S306-S310 can be included.

在本实施例中,当确定存在不是模拟异常进程的异常进程时,可以执行步骤S306判断该异常进程是否可以修复。In this embodiment, when it is determined that there is an abnormal process that is not a simulated abnormal process, step S306 may be executed to determine whether the abnormal process can be repaired.

S306:根据不是模拟异常进程的异常进程的进程状态判断异常进程是否可以修复。S306: Determine whether the abnormal process can be repaired according to the process status of the abnormal process that is not a simulated abnormal process.

计算设备可以根据异常进程的进程状态判断异常进程是否可以修复(异常进程的类型以包括睡眠进程以及僵尸进程为例进行介绍)。The computing device can determine whether the abnormal process can be repaired according to the process status of the abnormal process (the types of abnormal processes are introduced by taking sleeping processes and zombie processes as examples).

当异常进程为睡眠进程且进程状态为可中断睡眠状态,即STAT列状态码为S时,可以确定异常进程为可修复进程。另外,当异常进程为停止进程,即STAT列状态码为T时,也可以确定异常进程为可修复进程。When the abnormal process is a sleeping process and the process state is an interruptible sleeping state, that is, the STAT column status code is S, the abnormal process can be determined to be a repairable process. In addition, when the abnormal process is a stopped process, that is, the STAT column status code is T, the abnormal process can also be determined to be a repairable process.

当异常进程为僵尸进程,即STAT列状态码为Z时,可以确定异常进程为不可修复进程。另外,当异常进程为睡眠进程且处于不可中断睡眠状态,即STAT列状态码为D时,也可以确定异常进程为不可修复进程。When the abnormal process is a zombie process, that is, the STAT column status code is Z, the abnormal process can be determined to be an unrepairable process. In addition, when the abnormal process is a sleep process and is in an uninterruptible sleep state, that is, the STAT column status code is D, the abnormal process can also be determined to be an unrepairable process.

具体的,处于可中断睡眠状态的进程通常用状态标志位TASK_INTERRUPTIBLE来表示。这种睡眠状态允许进程在等待特定事件时释放CPU资源,以便其他进程可以使用。同时,它也提供了一种灵活的机制,使得进程可以在等待期间被其他事件所唤醒。因此,当异常进程为睡眠进程且进程状态为可中断睡眠状态,即STAT列状态码为S时,可以确定异常进程为可修复进程。Specifically, a process in an interruptible sleep state is usually indicated by the status flag TASK_INTERRUPTIBLE. This sleep state allows a process to release CPU resources while waiting for a specific event so that other processes can use it. At the same time, it also provides a flexible mechanism so that the process can be awakened by other events during the waiting period. Therefore, when the abnormal process is a sleep process and the process state is an interruptible sleep state, that is, the STAT column status code is S, it can be determined that the abnormal process is a repairable process.

停止状态的进程也可以被唤醒,主要是因为处于停止状态的进程一般是通过特定的信号机制进入停止状态的。例如,通常是接收到SIGSTOP信号触发的。当进程处于这种状态时,它会被暂停执行,并等待进一步的信号或操作。可以通过向处于停止状态的进程发送对应的信号,使其退出停止状态,因此,当异常进程为停止进程,即STAT列状态码为T时,可以确定异常进程为可修复进程。A process in the stopped state can also be awakened, mainly because a process in the stopped state generally enters the stopped state through a specific signal mechanism. For example, it is usually triggered by receiving a SIGSTOP signal. When a process is in this state, it is suspended and waits for further signals or operations. The process in the stopped state can be exited by sending a corresponding signal to it. Therefore, when the abnormal process is a stopped process, that is, the STAT column status code is T, it can be determined that the abnormal process is a repairable process.

僵尸进程是当子进程结束运行,父进程尚未回收子进程的资源时,子进程就会变成一个僵尸进程。僵尸进程实际上已经不再运行,它仅仅是一个在进程表中保留的条目,用于记录子进程的退出状态等信息。由于僵尸进程已经不再执行任何代码,因此无法被唤醒,因此,当异常进程为僵尸进程,即STAT列状态码为Z时,可以确定异常进程为不可修复进程或当异常进程为睡眠进程处于不可中断睡眠状态的进程正在等待磁盘I/O操作完成的,此时进程处于阻塞状态,不能进行其他操作,也不能被其他进程或信号所唤醒。只能等待磁盘I/O操作完成,操作系统自动唤醒进程,因此当异常进程为睡眠进程且处于不可中断睡眠状态,即STAT列状态码为D时,可以确定异常进程为不可修复进程。A zombie process is a child process that ends and the parent process has not yet recovered the child process's resources. A zombie process is actually no longer running. It is just an entry reserved in the process table to record the child process's exit status and other information. Since a zombie process no longer executes any code, it cannot be awakened. Therefore, when the abnormal process is a zombie process, that is, the STAT column status code is Z, it can be determined that the abnormal process is an unrepairable process or when the abnormal process is a sleeping process in an uninterruptible sleeping state waiting for the disk I/O operation to complete, the process is in a blocked state and cannot perform other operations or be awakened by other processes or signals. It can only wait for the disk I/O operation to complete and the operating system to automatically wake up the process. Therefore, when the abnormal process is a sleeping process and is in an uninterruptible sleeping state, that is, the STAT column status code is D, it can be determined that the abnormal process is an unrepairable process.

当确定异常进程为可修复进程,可以执行步骤S307对异常进程进行修复。When it is determined that the abnormal process is a repairable process, step S307 may be executed to repair the abnormal process.

当确定异常进程为不可修复进程,可以执行步骤S308对异常进程进行处理。When it is determined that the abnormal process is an unrepairable process, step S308 may be executed to process the abnormal process.

S307:对异常进程进行修复。S307: Repair the abnormal process.

计算设备可以对异常进程进行修复。The computing device can repair the abnormal process.

具体的,计算设备可以使用修复方式对异常进程进行修复。Specifically, the computing device may use a repair method to repair the abnormal process.

示例性的,修复方式例如可以为,执行kill命令向异常进程发送SIGCONT信号,其中,SIGCONT信号可以用来唤醒被停止的进程,即使对于处于可中断睡眠状态的进程,发送SIGCONT通常也是有效的,因为它会唤醒进程并使其继续执行。Exemplary repair methods include, for example, executing a kill command to send a SIGCONT signal to the abnormal process, wherein the SIGCONT signal can be used to wake up the stopped process. Even for a process in an interruptible sleep state, sending SIGCONT is usually effective because it wakes up the process and allows it to continue execution.

在某些可能实现的方式中,当计算设备执行修复方式对异常进程进行修复后,可以判断异常进程是否修复成功,即异常进程是否被成功唤醒。In some possible implementations, after the computing device executes the repair method to repair the abnormal process, it can be determined whether the abnormal process is successfully repaired, that is, whether the abnormal process is successfully awakened.

具体的,可以通过异常进程的状态确定该进程是否修复成功。Specifically, whether the process is repaired successfully can be determined according to the state of the abnormal process.

示例性的,例如,异常进程的类型为停止进程,即STAT列状态码为T的进程,可以利用修复方式对其进行修复,然后判断异常进程的进程状态是否改变为运行状态,即,在利用修复方式对异常进程进行修复之后,可以判断异常进程的STAT列状态码是否由T改变为R,当确定异常进程的STAT列状态码由T改变为R,可以确定异常进程的进程状态改变为运行状态,进而可以确定该异常进程修复成功,异常进程被成功唤醒。Exemplarily, for example, the type of abnormal process is a stopped process, that is, a process with a STAT column status code of T. The repair method can be used to repair the process, and then it can be determined whether the process state of the abnormal process has changed to a running state. That is, after the abnormal process is repaired using the repair method, it can be determined whether the STAT column status code of the abnormal process has changed from T to R. When it is determined that the STAT column status code of the abnormal process has changed from T to R, it can be determined that the process state of the abnormal process has changed to a running state, and then it can be determined that the abnormal process has been repaired successfully and the abnormal process has been successfully awakened.

再比如说,在利用修复方式对异常进程进行修复之后,异常进程的STAT列状态码未改变,或者改变为除了R以外的其他状态码,可以确定该异常进程修复失败,异常进程未被成功唤醒。For another example, after the abnormal process is repaired using the repair method, the STAT column status code of the abnormal process does not change, or changes to a status code other than R, which means that the repair of the abnormal process has failed and the abnormal process has not been successfully awakened.

当修复异常进程失败,可以执行步骤S308对异常进程进行终止。When repairing the abnormal process fails, step S308 may be executed to terminate the abnormal process.

当修复异常进程成功,可以等待测试结束或者间隔预设时间之后再次执行步骤S302以及步骤S303进行下一轮的对进程状态的判断,其中,间隔的预设时间可以根据需求设置,例如设置间隔的预设时间为3s,此处对间隔预设时间不做限定。When the abnormal process is repaired successfully, you can wait for the test to end or execute steps S302 and S303 again after a preset interval to perform the next round of process status judgment, where the preset interval time can be set according to needs, for example, setting the preset interval time to 3s, and there is no limit on the preset interval time here.

S308:对异常进程进行终止。S308: Terminate the abnormal process.

对异常进程进行处理的方式与步骤S205中终止的方法类似,在此不做多余叙述。The method of handling the abnormal process is similar to the method of terminating in step S205, and no redundant description is given here.

在某些可能实现的方式中,还可以对异常进程进行堆栈跟踪,进而可以根据堆栈跟踪信息可以定位问题所在,即可以定位异常进程出现异常的原因,以便相关人员采取相应的措施进行修复。In some possible implementations, the abnormal process can also be stack traced, and the problem can be located based on the stack trace information, that is, the cause of the abnormal process being abnormal can be located so that relevant personnel can take corresponding measures to repair it.

在某些可能实现的方式中,还可以每隔预设时间段对异常进程进行整合,然后对整合的异常进程进行批量处理,这样每隔预设时间整合异常进程,将多个异常进程进行批量处理,可以减少对异常进行处理的次数,从而可以提高系统资源的利用率,其中,预设时间段可以根据实际需求设置,例如可以为0.5s,在此不做限定。In some possible implementation methods, the abnormal processes can be integrated at preset time intervals, and then the integrated abnormal processes can be processed in batches. In this way, the abnormal processes can be integrated at preset time intervals and multiple abnormal processes can be processed in batches, which can reduce the number of times the exceptions are processed, thereby improving the utilization of system resources. The preset time period can be set according to actual needs, for example, it can be 0.5s, which is not limited here.

计算设备在对异常进程进行终止之后,可以执行步骤S309判断异常进程是否终止成功。After terminating the abnormal process, the computing device may execute step S309 to determine whether the abnormal process is terminated successfully.

S309:判断异常进程是否终止成功。S309: Determine whether the abnormal process is terminated successfully.

计算设备可以判断异常进程是否终止成功,即判断异常进程是否还存在。The computing device can determine whether the abnormal process is terminated successfully, that is, determine whether the abnormal process still exists.

当确定异常进程没有处理成功,可以执行步骤S310利用强制终止方式对异常进程进行处理。When it is determined that the abnormal process has not been successfully processed, step S310 may be executed to process the abnormal process by forcibly terminating the process.

S310:利用强制终止方式对异常进程进行终止。S310: Terminate the abnormal process by forced termination.

计算设备可以利用强制终止方式对异常进程进行处理,需要说明的是,为了确保可以将僵尸进程以及睡眠进程强制终止,处理僵尸进程的强制终止手段以及处理睡眠进程的强制终止手段需不相同。因此,可以根据异常进程的类型,确定预先设置的与异常进程类型匹配的强制终止方式,强制终止异常进程,例如,强制终止睡眠进程对应的强制终止方式为执行kill-9命令,强制终止僵尸进程时对应的强制终止方式为执行kill命令或者kill-9命令终止僵尸进程的父进程。The computing device can use the forced termination method to handle abnormal processes. It should be noted that in order to ensure that zombie processes and sleeping processes can be forced to terminate, the forced termination means for handling zombie processes and the forced termination means for handling sleeping processes must be different. Therefore, according to the type of abnormal process, a pre-set forced termination method that matches the abnormal process type can be determined to forcefully terminate the abnormal process. For example, the forced termination method corresponding to the forced termination of the sleeping process is to execute the kill-9 command, and the forced termination method corresponding to the forced termination of the zombie process is to execute the kill command or the kill-9 command to terminate the parent process of the zombie process.

具体的,当异常进程的类型为睡眠进程时,执行对应的强制终止方式可以为执行kill-9命令,当服务器执行kill-9命令时,可以向睡眠进程发送一个SIGKILL信号,其中,SIGKILL信号是一个强制终止信号,它不能被进程捕获、阻塞或忽略。当睡眠进程接收到SIGKILL信号时,它会立即被终止。进而使得睡眠进程被强制终止。Specifically, when the type of abnormal process is a sleeping process, the corresponding forced termination method may be to execute the kill-9 command. When the server executes the kill-9 command, a SIGKILL signal may be sent to the sleeping process. The SIGKILL signal is a forced termination signal that cannot be captured, blocked, or ignored by the process. When the sleeping process receives the SIGKILL signal, it will be terminated immediately, thereby forcibly terminating the sleeping process.

当异常进程为僵尸进程时,执行对应的强制终止方式可以为执行kill命令或者kill-9命令,终止僵尸进程的父进程,在僵尸进程的父进程被终止的情况下,僵尸进程就会变成孤儿进程,并最终被一号进程(也可以叫init进程)接管。当一号进程成为僵尸进程的父进程时,它会负责清理僵尸进程,其中,一号进程指的是第一个被内核启动的用户空间进程。When the abnormal process is a zombie process, the corresponding forced termination method can be to execute the kill command or kill-9 command to terminate the parent process of the zombie process. When the parent process of the zombie process is terminated, the zombie process will become an orphan process and will eventually be taken over by the No. 1 process (also called the init process). When the No. 1 process becomes the parent process of the zombie process, it will be responsible for cleaning up the zombie process. The No. 1 process refers to the first user space process started by the kernel.

在某些可能实现的方式中,也可以通过重启僵尸进程的父进程的方式实现对异常进程进行处理。In some possible implementations, the abnormal process can also be processed by restarting the parent process of the zombie process.

具体的,可以通过上述类似方式对僵尸进程的父进程进行终止,僵尸进程就会变成孤儿进程,并最终被一号进程接管,一号进程就会成为僵尸进程的父进程,从而负责清理僵尸进程。这样就可以通过重启僵尸进程的父进程的方式实现强制终止僵尸进程。Specifically, the parent process of the zombie process can be terminated in a similar manner as described above, and the zombie process will become an orphan process and eventually be taken over by process number one, which will then become the parent process of the zombie process and be responsible for cleaning up the zombie process. In this way, the zombie process can be forcibly terminated by restarting the parent process of the zombie process.

在某些可能实现的方式中,异常进程还可以包括睡眠进程、僵尸进程以及停止进程为例,强制终止停止进程的手段可以与强制终止睡眠进程的手段相同为执行kill-9命令,当服务器执行kill-9命令时,可以向停止进程发送一个SIGKILL信号,当停止进程接收到SIGKILL信号时,使得停止进程会立即被强制终止,这样就可以实现强制终止异常进程。In some possible implementation methods, abnormal processes may also include sleeping processes, zombie processes, and stopped processes. For example, the means for forcibly terminating the stopped process may be the same as the means for forcibly terminating the sleeping process, namely, executing the kill-9 command. When the server executes the kill-9 command, it may send a SIGKILL signal to the stopped process. When the stopped process receives the SIGKILL signal, the stopped process may be immediately terminated, thereby achieving the forced termination of the abnormal process.

本申请提供的这一实施例,当判断异常进程不是模拟的异常进程时,可以尝试对异常进程进行修复,即,可以异常进程是否为可修复进程,当判断异常进程为不可修复进程时,可以终止异常进程,并且当终止异常进程失败,还可以进一步根据异常进程类型,通过预设的强制终止方式再次对异常进程进行处理,也就是说通过预设的强制终止方式对异常进程进行强制终止,这样就可以提高本申请处理异常进程的效率,从而降低了进程堵塞的概率。In this embodiment provided by the present application, when it is determined that the abnormal process is not a simulated abnormal process, an attempt can be made to repair the abnormal process, that is, whether the abnormal process is a repairable process can be determined. When the abnormal process is determined to be an unrepairable process, the abnormal process can be terminated, and when the termination of the abnormal process fails, the abnormal process can be further processed again according to the abnormal process type through a preset forced termination method, that is, the abnormal process is forcibly terminated through a preset forced termination method, thereby improving the efficiency of the present application in processing abnormal processes, thereby reducing the probability of process blockage.

上为本申请实施例提供测试用例执行方法的一些具体实现方式,基于此,本申请还提供了对应的装置。下面将从功能模块化的角度对本申请实施例提供的装置进行介绍,该装置与上文描述的测试用例执行方法可相互对应参照。The above is some specific implementation methods of the test case execution method provided in the embodiment of the present application. Based on this, the present application also provides a corresponding device. The device provided in the embodiment of the present application will be introduced from the perspective of functional modularization. The device and the test case execution method described above can be referenced to each other.

图4为本申请实施例提供的测试用例执行装置的结构框图,参照图4所述装置可以包括:FIG4 is a structural block diagram of a test case execution device provided in an embodiment of the present application. Referring to FIG4 , the device may include:

获取单元400,用于获取测试用例的进程信息;The acquisition unit 400 is used to acquire the process information of the test case;

第一确定单元410,用于根据进程信息确定所述测试用例的进程中是否存在异常进程;A first determining unit 410 is used to determine whether there is an abnormal process in the process of the test case according to the process information;

第二确定单元420,用于当进程中存在异常进程时,确定异常进程是否存在模拟异常进程;The second determining unit 420 is used to determine whether there is a simulated abnormal process in the abnormal process when there is an abnormal process in the process;

处理单元430,用于当存在模拟异常进程时,保留模拟异常进程,并处理不是模拟异常进程的异常进程。The processing unit 430 is used to retain the simulated abnormal process when there is one, and process the abnormal process that is not the simulated abnormal process.

在某些可能实现的方式中,进程信息包括进程标识,装置还可以包括:In some possible implementations, the process information includes a process identifier, and the device may further include:

配置单元,用于配置模拟异常进程的代码;A configuration unit, used to configure the code for simulating abnormal processes;

存储单元,用于当所述代码运行时,将所述代码对应的进程标识存储在内存中;A storage unit, used for storing a process identifier corresponding to the code in a memory when the code is executed;

第二确定单元,具体用于:The second determining unit is specifically configured to:

当异常进程的进程标识与代码对应的进程标识匹配时,确定存在模拟异常进程;When the process identifier of the abnormal process matches the process identifier corresponding to the code, it is determined that a simulated abnormal process exists;

当异常进程的进程标识与代码对应的进程标识不匹配时,确定不存在模拟异常进程。When the process identifier of the abnormal process does not match the process identifier corresponding to the code, it is determined that there is no simulated abnormal process.

在某些可能实现的方式中,装置还可以包括:In some possible implementations, the device may further include:

回收单元,用于当存在模拟异常进程时,回收所述测试用例执行完毕后未被回收的模拟异常进程。The recycling unit is used to recycle the simulated abnormal process that has not been recycled after the test case is executed when there is a simulated abnormal process.

在某些可能实现的方式中,处理单元,可以具体用于:In some possible implementations, the processing unit may be specifically configured to:

根据进程的类型,确定所述进程的进程终止方式;Determining, according to the type of the process, a process termination method of the process;

采用进程终止方式终止所述进程。The process is terminated using a process termination method.

在某些可能实现的方式中,装置可以还包括:In some possible implementations, the device may further include:

判断单元,用于根据不是模拟异常进程的异常进程的进程状态判断异常进程是否可以修复;a judging unit, configured to judge whether the abnormal process can be repaired according to the process state of the abnormal process which is not a simulated abnormal process;

第三确定单元,用于当确定异常进程为不可修复进程时,确定所述进程的进程终止方式。The third determining unit is used to determine a process termination mode of the process when the abnormal process is determined to be an unrepairable process.

下面介绍一下本申请的计算设备的硬件结构,参见图5,图5为本申请实施例提供的一种计算设备的硬件结构示意图。The hardware structure of the computing device of the present application is introduced below, referring to FIG5 , which is a schematic diagram of the hardware structure of a computing device provided in an embodiment of the present application.

如图5所示,计算设备1000包括处理器1010和存储器1020;其中,所述存储器1020存储有计算机指令,所述处理器1010用于执行所述计算机指令,使得计算设备1000执行上文所示的测试用例执行方法。As shown in FIG. 5 , the computing device 1000 includes a processor 1010 and a memory 1020 ; wherein the memory 1020 stores computer instructions, and the processor 1010 is used to execute the computer instructions, so that the computing device 1000 executes the test case execution method shown above.

在一些实施例中,处理器1010可以是中央处理单元(central processing unit,CPU),还可以是其他通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(fieldprogrammable gate array,FPGA)或者其他可编程逻辑器件、晶体管逻辑器件,硬件部件或者其任意组合。通用处理器可以是微处理器,也可以是任何常规的处理器。In some embodiments, the processor 1010 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. A general-purpose processor may be a microprocessor or any conventional processor.

在一些实施例中,存储器1020可以易失性存储器(volatile memory)或非易失性存储器,例如寄存器等。具体地,易失性存储器是指当电源供应中断后,内部存放的数据便会丢失的存储器。其中,易失性存储器主要是随机存取存储器(random access memory,RAM),包括静态随机存取存储器(static RAM,SRAM)和动态随机存取存储器(dynamic RAM,DRAM)。非易失性存储器是指即使电源供应中断,内部存放的数据也不会因此丢失的存储器。常见的非易失性存储器包括只读存储器(read only memory,ROM)、光盘、磁盘、固态硬盘以及基于闪存(flash memory)技术的各种存储卡等。In some embodiments, the memory 1020 may be a volatile memory or a non-volatile memory, such as a register. Specifically, a volatile memory refers to a memory in which the data stored inside will be lost when the power supply is interrupted. Among them, the volatile memory is mainly a random access memory (RAM), including a static random access memory (SRAM) and a dynamic random access memory (DRAM). A non-volatile memory refers to a memory in which the data stored inside will not be lost even if the power supply is interrupted. Common non-volatile memories include read-only memory (ROM), optical disks, magnetic disks, solid-state hard disks, and various memory cards based on flash memory technology.

在一些实施例中,存储器1020具有可执行代码,存储器1010执行该代码,实现测试用例执行方法。In some embodiments, the memory 1020 has executable code, and the memory 1010 executes the code to implement the test case execution method.

通信接口1030用于与外部通信,例如通信接口1030作为第一接口,实现与现实设备的通信。The communication interface 1030 is used for communicating with the outside. For example, the communication interface 1030 is used as a first interface to realize communication with a real device.

总线可以是外设部件互联标准(Peripheral Component Interconnect,PCI)总线,或扩展工业标准结构(extended industry standard architecture,eisa)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于理解,图5仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。本申请实施例还提供了一种包含指令的计算机程序产品。所述计算机程序产品可以是包含指令的,能够运行在计算设备上或被储存在任何可用介质中的软件或程序产品。当所述计算机程序产品在计算设备上运行时,使得计算设备执行上述测试用例执行方法。本申请实施例还提供了一种计算机可读存储介质。所述计算机可读存储介质可以是计算设备能够存储的任何可用介质或者是包含一个或多个可用介质的数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘)等。该计算机可读存储介质包括指令,所述指令指示计算设备执行上述测试用例执行方法。The bus may be a peripheral component interconnect standard (PCI) bus, or an extended industry standard architecture (eisa) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of understanding, FIG. 5 is represented by only one thick line, but it does not mean that there is only one bus or one type of bus. The embodiment of the present application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on a computing device, the computing device executes the above-mentioned test case execution method. The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium may be any available medium that a computing device can store or a data storage device such as a data center containing one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk), etc. The computer-readable storage medium includes instructions that instruct the computing device to execute the above-mentioned test case execution method.

在一些可能实现的方式中,计算设备可以是服务器,当然这里只是举例说明,并不做任何限定。In some possible implementations, the computing device may be a server, which is of course only an example and does not constitute any limitation.

上述各个附图对应的流程或结构的描述各有侧重,某个流程或结构中没有详述的部分,可以参见其他流程或结构的相关描述。The descriptions of the processes or structures corresponding to the above-mentioned figures have different emphases. For parts that are not described in detail in a certain process or structure, please refer to the relevant descriptions of other processes or structures.

以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims (11)

1.一种测试用例执行方法,其特征在于,所述方法包括:1. A test case execution method, characterized in that the method comprises: 获取测试用例的进程信息;Get the process information of the test case; 根据所述进程信息确定所述测试用例的进程中是否存在异常进程;Determine whether there is an abnormal process in the process of the test case according to the process information; 当所述进程中存在异常进程时,确定所述异常进程是否存在模拟异常进程;When there is an abnormal process in the process, determining whether there is a simulated abnormal process in the abnormal process; 当存在所述模拟异常进程时,保留所述模拟异常进程,并处理不是所述模拟异常进程的异常进程。When the simulated abnormal process exists, the simulated abnormal process is retained, and an abnormal process that is not the simulated abnormal process is processed. 2.根据权利要求1所述的方法,其特征在于,所述进程信息包括进程标识,在确定所述异常进程是否存在模拟异常进程前,所述方法还包括:2. The method according to claim 1, wherein the process information includes a process identifier, and before determining whether the abnormal process includes a simulated abnormal process, the method further includes: 配置模拟异常进程的代码;Configure the code to simulate abnormal processes; 当所述代码运行时,将所述代码对应的进程标识存储在内存中;When the code is executed, a process identifier corresponding to the code is stored in a memory; 则所述确定所述异常进程是否存在模拟异常进程,包括:Then the step of determining whether the abnormal process includes a simulated abnormal process includes: 当所述异常进程的进程标识与所述代码对应的进程标识有一个匹配时,确定存在模拟异常进程;When there is a match between the process identifier of the abnormal process and the process identifier corresponding to the code, it is determined that a simulated abnormal process exists; 当所述异常进程的进程标识与所述代码对应的进程标识均不匹配时,确定不存在模拟异常进程。When the process identifier of the abnormal process does not match the process identifier corresponding to the code, it is determined that there is no simulated abnormal process. 3.根据权利要求1-2任一项所述的方法,其特征在于,所述方法还包括:3. The method according to any one of claims 1 to 2, characterized in that the method further comprises: 当存在所述模拟异常进程时,回收所述测试用例执行完毕后未被回收的模拟异常进程。When the simulated abnormal process exists, the simulated abnormal process that is not recovered after the test case is executed is recovered. 4.根据权利要求1-3任一项所述的方法,其特征在于,所述处理不是所述模拟异常进程的异常进程,包括:4. The method according to any one of claims 1 to 3, characterized in that the processing is not an abnormal process of the simulated abnormal process, comprising: 根据所述异常进程的类型,确定所述异常进程的进程终止方式;Determining a process termination method of the abnormal process according to the type of the abnormal process; 采用所述进程终止方式终止所述异常进程。The abnormal process is terminated by using the process termination method. 5.根据权利要求4所述的方法,其特征在于,在所述根据所述进程的类型,确定所述进程的进程终止方式之前,所述方法还包括:5. The method according to claim 4, characterized in that before determining the process termination mode of the process according to the type of the process, the method further comprises: 根据不是模拟异常进程的异常进程的进程状态判断所述异常进程是否可以修复;Determining whether the abnormal process can be repaired according to the process state of the abnormal process that is not a simulated abnormal process; 当确定所述异常进程为不可修复进程时,确定所述异常进程的进程终止方式。When it is determined that the abnormal process is an unrepairable process, a process termination method of the abnormal process is determined. 6.一种测试用例执行装置,其特征在于,所述装置包括:6. A test case execution device, characterized in that the device comprises: 获取单元,用于获取测试用例的进程信息;An acquisition unit is used to obtain the process information of the test case; 第一确定单元,用于根据所述进程信息确定所述测试用例的进程中是否存在异常进程;A first determining unit, configured to determine whether there is an abnormal process in the process of the test case according to the process information; 第二确定单元,用于当所述进程中存在异常进程时,确定所述异常进程是否存在模拟异常进程;a second determining unit, configured to determine, when an abnormal process exists in the process, whether the abnormal process has a simulated abnormal process; 处理单元,用于当存在所述模拟异常进程时,保留所述模拟异常进程,并处理不是所述模拟异常进程的异常进程。The processing unit is used to retain the simulated abnormal process when it exists, and process the abnormal process that is not the simulated abnormal process. 7.根据权利要求6所述的装置,其特征在于,所述进程信息包括进程标识,所述装置还包括:7. The device according to claim 6, wherein the process information includes a process identifier, and the device further comprises: 配置单元,用于配置模拟异常进程的代码;A configuration unit, used to configure the code for simulating abnormal processes; 存储单元,用于当所述代码运行时,将所述代码对应的进程标识存储在内存中;A storage unit, used for storing a process identifier corresponding to the code in a memory when the code is executed; 所述第二确定单元,具体用于:The second determining unit is specifically configured to: 当所述异常进程的进程标识与所述代码对应的进程标识匹配时,确定存在模拟异常进程;When the process identifier of the abnormal process matches the process identifier corresponding to the code, determining that a simulated abnormal process exists; 当所述异常进程的进程标识与所述代码对应的进程标识不匹配时,确定不存在模拟异常进程。When the process identifier of the abnormal process does not match the process identifier corresponding to the code, it is determined that there is no simulated abnormal process. 8.根据权利要求6-7任一项所述的装置,其特征在于,所述装置还包括:8. The device according to any one of claims 6 to 7, characterized in that the device further comprises: 回收单元,用于当存在所述模拟异常进程时,回收所述测试用例执行完毕后未被回收的模拟异常进程。The recycling unit is used to recycle the simulated abnormal process that has not been recycled after the test case is executed when the simulated abnormal process exists. 9.根据权利要求6-8任一项所述的装置,其特征在于,所述处理单元,具体用于:9. The device according to any one of claims 6 to 8, characterized in that the processing unit is specifically used to: 根据所述异常进程的类型,确定所述异常进程的进程终止方式;Determining a process termination method of the abnormal process according to the type of the abnormal process; 采用所述进程终止方式终止所述进异常程。The abnormal process is terminated by using the process termination method. 10.根据权利要求9所述的装置,其特征在于,所述装置还包括:10. The device according to claim 9, characterized in that the device further comprises: 判断单元,用于根据不是模拟异常进程的异常进程的进程状态判断所述异常进程是否可以修复;A judging unit, configured to judge whether the abnormal process can be repaired according to the process state of the abnormal process which is not a simulated abnormal process; 第三确定单元,用于当确定异常进程为不可修复进程时,确定所述异常进程的进程终止方式。The third determining unit is used to determine a process termination mode of the abnormal process when the abnormal process is determined to be an unrepairable process. 11.一种服务器,其特征在于,包括存储器和处理器;11. A server, comprising a memory and a processor; 存储器和处理器,所述存储器与所述处理器耦合;a memory and a processor, the memory being coupled to the processor; 所述存储器存储有程序指令,当所述程序指令由所述处理器执行时,使得所述服务器执行权利要求1-5任一项所述的方法。The memory stores program instructions, and when the program instructions are executed by the processor, the server executes the method according to any one of claims 1 to 5.
CN202410877559.6A 2024-06-28 2024-06-28 Test case execution method, device and server Pending CN118779232A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410877559.6A CN118779232A (en) 2024-06-28 2024-06-28 Test case execution method, device and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410877559.6A CN118779232A (en) 2024-06-28 2024-06-28 Test case execution method, device and server

Publications (1)

Publication Number Publication Date
CN118779232A true CN118779232A (en) 2024-10-15

Family

ID=92996504

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410877559.6A Pending CN118779232A (en) 2024-06-28 2024-06-28 Test case execution method, device and server

Country Status (1)

Country Link
CN (1) CN118779232A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119718592A (en) * 2025-02-27 2025-03-28 苏州元脑智能科技有限公司 Data storage method, electronic device, storage medium and program product

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109634803A (en) * 2018-11-16 2019-04-16 网宿科技股份有限公司 A kind of method and apparatus of reporting equipment exception
CN116166521A (en) * 2021-11-24 2023-05-26 网联清算有限公司 Application testing method and device, electronic equipment and storage medium
CN116401118A (en) * 2023-03-15 2023-07-07 杭州宏杉科技股份有限公司 Method and device for monitoring Samba of file sharing service
CN117032881A (en) * 2023-07-31 2023-11-10 广东保伦电子股份有限公司 Method, device and storage medium for detecting and recovering abnormality of virtual machine
CN118152102A (en) * 2024-05-10 2024-06-07 浪潮云信息技术股份公司 A method and device for realizing rapid cleaning of abnormal processes in a trusted operating system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109634803A (en) * 2018-11-16 2019-04-16 网宿科技股份有限公司 A kind of method and apparatus of reporting equipment exception
CN116166521A (en) * 2021-11-24 2023-05-26 网联清算有限公司 Application testing method and device, electronic equipment and storage medium
CN116401118A (en) * 2023-03-15 2023-07-07 杭州宏杉科技股份有限公司 Method and device for monitoring Samba of file sharing service
CN117032881A (en) * 2023-07-31 2023-11-10 广东保伦电子股份有限公司 Method, device and storage medium for detecting and recovering abnormality of virtual machine
CN118152102A (en) * 2024-05-10 2024-06-07 浪潮云信息技术股份公司 A method and device for realizing rapid cleaning of abnormal processes in a trusted operating system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119718592A (en) * 2025-02-27 2025-03-28 苏州元脑智能科技有限公司 Data storage method, electronic device, storage medium and program product

Similar Documents

Publication Publication Date Title
TWI229796B (en) Method and system to implement a system event log for system manageability
US8412984B2 (en) Debugging in a cluster processing network
US10146653B2 (en) Automated system-level failure and recovery
CN107977308A (en) interface test method and device
CN110413432B (en) Information processing method, electronic equipment and storage medium
CN108923997B (en) A python-based cloud service node automatic testing method and device
CN113127358B (en) A testing method, device, electronic equipment and medium
CN118779232A (en) Test case execution method, device and server
CN102314382A (en) Method and module for emergently probing system information
CN111966599B (en) Virtualization platform reliability testing method, system, terminal and storage medium
CN116827838A (en) Microservice chaos testing method and system based on automatic dependency discovery and proxy
CN113742113B (en) Health management method, equipment and storage medium for embedded system
CN118819936A (en) A detection method, device, equipment and readable storage medium
CN117909160A (en) Firmware crash analysis method and device based on Internet of things
CN116610415A (en) Automated operation and maintenance method, device, equipment and storage medium
WO2024021494A1 (en) Software service processing method, electronic device and storage medium
CN114356660A (en) Android automation fault tolerance method, device, equipment and storage medium
CN109840213B (en) Test data creating method, device, terminal and storage medium for GUI test
CN111966582A (en) Cluster debugging system with multiple debugging objects and management method and debugging method thereof
TWI871638B (en) Method, system and computer program for handling a fault
CN117909907B (en) High-throughput computing platform and its abnormality elimination method, device and storage medium
CN119603299B (en) Method, device, equipment and medium for cross-cloud resource operation based on task orchestration
CN111061597B (en) A method to test the stability of KCS communication
US20240419565A1 (en) Method and system for generating activity report of testbench components in a test environment
CN119003201A (en) Method for unified asynchronous processing of interfaces

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