K8S-based database middleware high-availability automatic testing method

By automatically building a test environment and injecting multiple abnormal scenarios in the K8S environment, the problems of low manual testing efficiency and lack of automation in high availability testing are solved, and efficient testing processes and accurate test reports are achieved, providing strong technical support for the high availability guarantee of database middleware.

CN119938510APending Publication Date: 2025-05-06UNICLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411742796.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

In high availability testing, there is a complex and time-consuming process for setting up the test environment and exception injection, lack of standardized operations, low manual testing efficiency, difficulty in covering multi-dimensional scenarios, and existing testing methods lack automation capabilities, making it impossible to quickly discover problems and provide accurate evaluation results.

Method used

A highly available automated testing method for database middleware based on K8S is proposed, including initializing the test environment, planning resources, injection logic of containers and network exceptions, injection of CPU overload, memory exhaustion and network delay, and automatically collecting middleware running data.

Benefits of technology

It realizes efficient construction of the test environment, automatic execution of exception injection, and automatic collection and analysis of result data, comprehensively simulates multi-dimensional abnormal scenarios, improves testing efficiency, shortens the test cycle, and generates test reports to accurately evaluate the high availability performance of middleware.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119938510A_ABST
    Figure CN119938510A_ABST
Patent Text Reader

Abstract

The invention provides a K8S-based database middleware high-availability automatic test method, which comprises the following steps of: initializing a test environment, and deploying database middleware and a monitoring system; based on the test environment established in the previous step, planning injection logic of resources, containers and network anomalies; aiming at a designed resource exception strategy, injecting a CPU overload and memory depletion scene; in combination with stability verification in the previous step, triggering restarting and collapse abnormity of the container in a test environment, and further investigating the fault-tolerant capability of the middleware under Kubernetes scheduling; after the resource and container exception test is completed, injecting network delay and packet loss scenes, and simulating a complex network environment to verify a high-availability mechanism of middleware; and comprehensively executing various types of abnormal injection tests, and automatically collecting middleware operation data. The method has the beneficial effects that firstly, efficient construction of a test environment, automatic execution of abnormal injection and automatic acquisition and analysis of result data are realized;
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology, and in particular to a high-availability automated testing method for database middleware based on K8S. Background Art

[0002] With the development of cloud-native technologies, database middleware deployed based on Kubernetes (K8S) is increasingly used in high availability scenarios.

[0003] However, there are the following pain points in high availability testing: first, the process of setting up the test environment and injecting exceptions is complex and time-consuming, and lacks standardized operations; second, manual testing is inefficient and it is difficult to fully cover multi-dimensional scenarios such as resources, containers, and network anomalies within a limited time; third, existing testing methods lack automation capabilities and cannot quickly detect problems and provide accurate evaluation results.

[0004] These issues directly affect the efficiency and effectiveness of reliability verification of middleware in high availability scenarios. Summary of the invention

[0005] In view of this, the present invention aims to propose a high-availability automated testing method for database middleware based on K8S to at least solve one of the problems in the background technology.

[0006] To achieve the above object, the technical solution of the present invention is achieved as follows: A high-availability automated testing method for database middleware based on K8S, including: Initialize the test environment, deploy database middleware and monitoring system; Based on the test environment built in the previous step, plan the injection logic for resources, containers, and network anomalies; Inject CPU overload and memory exhaustion scenarios based on the designed resource exception strategy; Combined with the stability verification in the previous step, trigger container restart and crash exceptions in the test environment to further examine the fault tolerance of the middleware under Kubernetes scheduling; After completing the resource and container anomaly tests, inject network delay and packet loss scenarios to simulate complex network environments to verify the high availability mechanism of the middleware; Comprehensively perform the aforementioned types of exception injection tests and automatically collect middleware operation data.

[0007] Furthermore, the initialization of the test environment and the deployment of the database middleware and monitoring system include: Use Kubernetes official tools to initialize the cluster, set up the master node, and configure the worker nodes to join the master node to form a complete Kubernetes cluster; Prepare the configuration file of the middleware, define the number of replicas, container specifications, and storage volume mount locations, deploy the database middleware to the K8S cluster using the Kubernetes deployment tool, and ensure the normal operation of the middleware; Configure container-level monitoring tools to collect middleware performance indicators, deploy log collection systems, and centrally record container operation logs.

[0008] Furthermore, the test environment built in the previous step is used to plan the injection logic of resources, containers and network anomalies, including: Define the types of exceptions that may affect the high availability of middleware, including resource exceptions, container exceptions, and network exceptions; Define injection parameters in the exception injection script; Integrate logging functionality into the script to record in detail the exception type, injection parameters, and execution time of each injection.

[0009] Furthermore, the resource anomaly strategy designed for the injection of CPU overload and memory exhaustion scenarios includes: Run high-computational-intensity tasks in the target container to increase CPU usage; Allocate a memory block of a specified size in the container and maintain the memory occupancy for a period of time; Create large files to occupy container storage space, observe the impact of insufficient disk space on middleware operation, and verify the fault tolerance and recovery capabilities of the middleware.

[0010] Furthermore, the stability verification in the previous step is combined with triggering container restart and crash exceptions in the test environment to further examine the fault tolerance of the middleware under Kubernetes scheduling, including: Stop the target container or delete the target Pod manually to simulate the scenario where the middleware instance exits unexpectedly, and test the disaster recovery capability and restart time of the middleware. When starting the container, set a health check delay or manually block some key startup steps to test whether the middleware can correctly handle the startup delay.

[0011] Furthermore, after completing the resource and container anomaly tests, network delay and packet loss scenarios are injected to simulate a complex network environment to verify the high availability mechanism of the middleware, including: Artificially set delays in the container network communication path to simulate a high-latency network environment and test the middleware's tolerance to delays and performance changes; Configure network communication rules, randomly discard a certain percentage of packets, and observe the behavior and recovery capabilities of the middleware in the event of packet loss; Prevent the target container from communicating with other containers or external services, and verify the middleware's isolation response mechanism and external dependency processing capabilities.

[0012] Furthermore, the aforementioned comprehensive execution of various types of abnormal injection tests and automatic collection of middleware operation data include: Regularly check the running status of the database middleware and containers, and obtain container status information through the K8S API interface, including whether the Pod is running, the number of restarts, and resource usage; Collect container resource usage data and performance indicators through monitoring tools; Save key data during the test as structured files, recording exception injection time, impact scope, and middleware recovery time.

[0013] Furthermore, the present solution discloses an electronic device, comprising a processor and a memory that is communicatively connected to the processor and is used to store executable instructions of the processor, wherein the processor is used to execute a high-availability automated testing method for database middleware based on K8S.

[0014] Furthermore, the present solution discloses a server comprising at least one processor and a memory communicatively connected to the processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor so that the at least one processor executes a high-availability automated testing method for database middleware based on K8S.

[0015] Furthermore, the present solution discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, implements a high-availability automated testing method for database middleware based on K8S.

[0016] Compared with the prior art, the high-availability automated testing method for database middleware based on K8S described in the present invention has the following beneficial effects: (1) The high-availability automated testing method for database middleware based on K8S described in the present invention realizes efficient construction of the test environment, automated execution of exception injection, and automatic collection and analysis of result data; (2) The present invention describes a K8S-based database middleware high-availability automated testing method, which achieves multi-dimensional injection of resource, container and network anomalies through unified planning and scripting, and comprehensively simulates abnormal scenarios that may occur in a real environment; by combining monitoring and log analysis systems, it effectively improves testing efficiency and shortens testing cycles; the test report finally generated accurately evaluates the high availability performance of the middleware, providing a reliable basis for its optimization and application, which not only solves the inefficiency problem of traditional manual testing, but also enhances the degree of automation and coverage of the test, providing strong technical support for the high availability of the middleware. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:

[0018] Figure 1 is a flow chart of an embodiment of the present invention. DETAILED DESCRIPTION

[0019] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.

[0020] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.

[0021] A high-availability automated testing method for database middleware based on K8S, including: Initialize the test environment, deploy database middleware and monitoring system; Based on the test environment built in the previous step, plan the injection logic for resources, containers, and network anomalies; Inject CPU overload and memory exhaustion scenarios based on the designed resource exception strategy; Combined with the stability verification in the previous step, trigger container restart and crash exceptions in the test environment to further examine the fault tolerance of the middleware under Kubernetes scheduling; After completing the resource and container anomaly tests, inject network delay and packet loss scenarios to simulate complex network environments to verify the high availability mechanism of the middleware; Comprehensively perform the aforementioned types of exception injection tests and automatically collect middleware operation data.

[0022] The initialization of the test environment, deployment of database middleware and monitoring system, includes: Use Kubernetes official tools to initialize the cluster, set up the master node, and configure the worker nodes to join the master node to form a complete Kubernetes cluster; Prepare the configuration file of the middleware, define the number of replicas, container specifications, and storage volume mount locations, deploy the database middleware to the K8S cluster using the Kubernetes deployment tool, and ensure the normal operation of the middleware; Configure container-level monitoring tools to collect middleware performance indicators, deploy log collection systems, and centrally record container operation logs.

[0023] Based on the test environment built in the previous step, the injection logic of resources, containers and network anomalies is planned, including: Define the types of exceptions that may affect the high availability of middleware, including resource exceptions, container exceptions, and network exceptions; Define injection parameters in the exception injection script; Integrate logging functionality into the script to record in detail the exception type, injection parameters, and execution time of each injection.

[0024] The resource anomaly strategy designed for this purpose injects CPU overload and memory exhaustion scenarios, including: Run high-computational-intensity tasks in the target container to increase CPU usage; Allocate a memory block of a specified size in the container and maintain the memory occupancy for a period of time; Create large files to occupy container storage space, observe the impact of insufficient disk space on middleware operation, and verify the fault tolerance and recovery capabilities of the middleware.

[0025] Combined with the stability verification in the previous step, the container restart and crash exceptions are triggered in the test environment to further examine the fault tolerance of the middleware under Kubernetes scheduling, including: Stop the target container or delete the target Pod manually to simulate the scenario where the middleware instance exits unexpectedly, and test the disaster recovery capability and restart time of the middleware. When starting the container, set a health check delay or manually block some key startup steps to test whether the middleware can correctly handle the startup delay.

[0026] After completing the resource and container anomaly tests, network delay and packet loss scenarios are injected to simulate a complex network environment to verify the high availability mechanism of the middleware, including: Artificially set delays in the container network communication path to simulate a high-latency network environment and test the middleware's tolerance to delays and performance changes; Configure network communication rules, randomly discard a certain percentage of packets, and observe the behavior and recovery capabilities of the middleware in the event of packet loss; Prevent the target container from communicating with other containers or external services, and verify the middleware's isolation response mechanism and external dependency processing capabilities.

[0027] The aforementioned comprehensive execution of various types of abnormal injection tests and automatic collection of middleware operation data include: Regularly check the running status of the database middleware and containers, and obtain container status information through the K8S API interface, including whether the Pod is running, the number of restarts, and resource usage; Collect container resource usage data and performance indicators through monitoring tools; Save key data during the test as structured files, recording exception injection time, impact scope, and middleware recovery time.

[0028] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0029] In the several embodiments provided in the present application, it should be understood that the disclosed methods and systems can be implemented in other ways. For example, the division of the units described above is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The above-mentioned units may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.

[0030] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and specification of the present invention.

[0031] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A high-availability automated testing method for database middleware based on K8S, characterized in that: include: Initialize the test environment, deploy database middleware and monitoring system; Based on the test environment built in the previous step, plan the injection logic for resources, containers, and network anomalies; Inject CPU overload and memory exhaustion scenarios based on the designed resource exception strategy; Combined with the stability verification in the previous step, trigger container restart and crash exceptions in the test environment to further examine the fault tolerance of the middleware under Kubernetes scheduling; After completing the resource and container anomaly tests, inject network delay and packet loss scenarios to simulate complex network environments to verify the high availability mechanism of the middleware; Comprehensively perform the aforementioned types of exception injection tests and automatically collect middleware operation data.

2. According to a K8S-based database middleware high-availability automated testing method according to claim 1, it is characterized in that: The initialization of the test environment, deployment of database middleware and monitoring system, includes: Use Kubernetes official tools to initialize the cluster, set up the master node, and configure the worker nodes to join the master node to form a complete Kubernetes cluster; Prepare the configuration file of the middleware, define the number of replicas, container specifications, and storage volume mount locations, deploy the database middleware to the K8S cluster using the Kubernetes deployment tool, and ensure the normal operation of the middleware; Configure container-level monitoring tools to collect middleware performance indicators, deploy log collection systems, and centrally record container operation logs.

3. According to a K8S-based database middleware high-availability automated testing method according to claim 1, it is characterized in that: Based on the test environment built in the previous step, the injection logic of resources, containers and network anomalies is planned, including: Define the types of exceptions that may affect the high availability of middleware, including resource exceptions, container exceptions, and network exceptions; Define injection parameters in the exception injection script; Integrate logging functionality into the script to record in detail the exception type, injection parameters, and execution time of each injection.

4. According to a K8S-based database middleware high-availability automated testing method according to claim 1, it is characterized in that: The resource anomaly strategy designed for this purpose injects CPU overload and memory exhaustion scenarios, including: Run high-computational-intensity tasks in the target container to increase CPU usage; Allocate a memory block of a specified size in the container and maintain the memory occupancy for a period of time; Create large files to occupy container storage space, observe the impact of insufficient disk space on middleware operation, and verify the fault tolerance and recovery capabilities of the middleware.

5. According to a K8S-based database middleware high-availability automated testing method according to claim 1, it is characterized in that: Combined with the stability verification in the previous step, the container restart and crash exceptions are triggered in the test environment to further examine the fault tolerance of the middleware under Kubernetes scheduling, including: Stop the target container or delete the target Pod manually to simulate the scenario where the middleware instance exits unexpectedly, and test the disaster recovery capability and restart time of the middleware. When starting the container, set a health check delay or manually block some key startup steps to test whether the middleware can correctly handle the startup delay.

6. According to a K8S-based database middleware high-availability automated testing method according to claim 1, it is characterized in that: After completing the resource and container anomaly tests, network delay and packet loss scenarios are injected to simulate a complex network environment to verify the high availability mechanism of the middleware, including: Artificially set delays in the container network communication path to simulate a high-latency network environment and test the middleware's tolerance to delays and performance changes; Configure network communication rules, randomly discard a certain percentage of packets, and observe the behavior and recovery capabilities of the middleware in the event of packet loss; Prevent the target container from communicating with other containers or external services, and verify the middleware's isolation response mechanism and external dependency processing capabilities.

7. According to a K8S-based database middleware high-availability automated testing method according to claim 1, it is characterized in that: The aforementioned comprehensive execution of various types of abnormal injection tests and automatic collection of middleware operation data include: Regularly check the running status of the database middleware and containers, and obtain container status information through the K8S API interface, including whether the Pod is running, the number of restarts, and resource usage; Collect container resource usage data and performance indicators through monitoring tools; Save key data during the test as structured files, recording exception injection time, impact scope, and middleware recovery time.

8. An electronic device, comprising a processor and a memory connected to the processor for storing instructions executable by the processor, characterized in that: The processor is used to execute a K8S-based database middleware high-availability automated testing method as described in any one of claims 1-7 above.

9. A server, characterized in that: It includes at least one processor and a memory communicatively connected to the processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor so that the at least one processor executes a K8S-based database middleware high-availability automated testing method as described in any one of claims 1-7.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by the processor, it implements the high-availability automated testing method for database middleware based on K8S as described in any one of claims 1-7.