Firewall test method and device and electronic equipment

By detecting and creating target hosts in container networks and host resource pools, the problem that container clustering technology in firewall tests cannot meet north-south traffic is solved, and the efficiency and accuracy of firewall system integration testing is improved.

CN119071188APending Publication Date: 2024-12-03HILLSTONE NETWORKS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411354094.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

The existing container clustering technology cannot meet the north-south traffic requirements in firewall testing, resulting in insufficient host resources in firewall testing, which cannot meet the testing needs of large quantities of containers and traffic pressures.

Method used

By obtaining the test task set of the firewall to be tested, detect whether the container network exists. If it does not exist, the target host will be determined from the container host resource pool based on the host resource information, network and container creation will be carried out, container number and traffic pressure will be increased, and container resources will be realized. automated management.

Benefits of technology

It realizes the use of container clusters for firewall system integration testing, improves testing efficiency and accuracy, solves the problem of insufficient host resources, and meets the needs of containers and traffic in firewall testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119071188A_ABST
    Figure CN119071188A_ABST
Patent Text Reader

Abstract

The invention discloses a firewall testing method and device and electronic equipment, and relates to the technical field of testing. The method comprises the following steps: acquiring a test task set corresponding to a firewall to be tested, and detecting whether a network of a container corresponding to the test task set exists or not under the condition that a plurality of containers corresponding to the test task set do not exist; if the network of the container corresponding to the test task set does not exist, determining a plurality of target hosts corresponding to the test task set from a container host resource pool according to the host resource information; performing network creation processing and container creation on a plurality of target hosts corresponding to the test task set to obtain a created network and a created container; and testing the firewall to be tested through the created container and the created network. The technical problem that in the prior art, when a large number of containers need to be used for constructing flow in firewall testing, host resources are insufficient is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of testing technology, and in particular to a firewall testing method, device and electronic equipment. Background Art

[0002] Firewall system integration testing is an important stage of firewall testing, usually after the testing of each functional module is completed. During the system integration testing phase, based on user scenarios and behaviors, the various functional modules are combined together, and the firewall is tested as a whole for various functional combinations, stress, and stability tests. During the integration testing process, traffic simulation is crucial. Common methods include using testers and packet sending tools to construct traffic. In order to save testing costs, simulate more simulated traffic, and achieve a certain stress effect, using containers to simulate client / server traffic is also a good choice. However, in traditional automated testing environments, containers are usually built on a single server. Limited by the performance of a single server, the number of containers and the size of traffic are limited, so it is more appropriate to use a container cluster.

[0003] The usage scenarios of existing container cluster technology are usually mutual visits between containers in the same network, that is, east-west traffic interconnection. In the firewall test scenario, the container traffic needs to be directed to the outside, and the traffic between containers is forwarded through the firewall, which is north-south traffic. The current container cluster technology cannot meet the testing requirements.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present invention provide a firewall testing method, device and electronic equipment.

[0006] According to one aspect of an embodiment of the present invention, a firewall testing method is provided, including: obtaining a test task set corresponding to a firewall to be tested, and detecting whether a network of a container corresponding to the test task set exists when multiple containers corresponding to the test task set do not exist; if the network of the container corresponding to the test task set does not exist, determining multiple target hosts corresponding to the test task set from a container host resource pool based on host resource information; performing network creation processing and container creation on the multiple target hosts corresponding to the test task set to obtain a created network and a created container; and testing the firewall to be tested using the created container and the created network.

[0007] Furthermore, the host resource information of each host in the container host resource pool includes at least one of the following: the number of containers, the CPU utilization, and the CPU load, wherein determining the target host corresponding to the test task set from the container host resource pool based on the host resource information includes: screening the hosts in the container host resource pool based on the number of containers and a preset container number threshold to obtain a first host set, wherein the number of containers of the hosts in the first host set is less than the preset container number threshold; screening the hosts in the first host set based on the CPU utilization and the preset CPU utilization threshold to obtain a second host set, wherein the CPU utilization of the hosts in the second host set is less than the preset CPU utilization threshold; if the second host set is empty, determining the target host from the first host set based on the CPU load.

[0008] Furthermore, after screening the hosts in the first host set according to the CPU utilization and the preset CPU utilization threshold to obtain the second host set, the method also includes: if the second host set is not empty, calculating the CPU idle resources of each host in the second host set, and determining the target host from the second host set based on the CPU idle resources.

[0009] Furthermore, network creation processing and container creation are performed on multiple target hosts corresponding to the test task set to obtain a created network and a created container, including: obtaining the interface information of the target host, the network IP information corresponding to the network to be created, and the virtual LAN identifier information, and performing network creation processing based on the interface information of the target host, the network IP information corresponding to the network to be created, and the virtual LAN identifier information to obtain a created network; creating a container based on the container image in the target host, and adding the container to the created network to obtain a created container.

[0010] Furthermore, after detecting whether the network of the container corresponding to the test task set exists, the method further includes: if the network of the container corresponding to the test task set exists, creating a container for the host where the network of the container corresponding to the test task set is located.

[0011] Furthermore, the method also includes: based on a first preset time interval, detecting the hosts in the container host resource pool; if there is a host in the container host resource pool that fails to be detected, identifying the host that fails to be detected as a faulty host, and obtaining the container information of the faulty host and the task instruction information executed in the container; determining the first host from the hosts other than the faulty host in the container host resource pool, and performing network creation processing and container creation processing on the first host based on the container information of the faulty host to obtain the network and container of the first host; and issuing a task execution instruction to the container of the first host based on the task instruction information executed in the container of the faulty host.

[0012] Furthermore, the method also includes: based on a second preset time interval, detecting whether the test task in the database is in a running state, wherein the test task in the database is recorded in the database after the test task of the test task set starts running; if the test task in the database is not in a running state, determining that there is an abnormality in the test task in the database, and based on the identification code of the test task in the database, traversing the hosts in the container host resource pool, and deleting the container and network corresponding to the identification code.

[0013] Furthermore, the number of containers of any host in the container host resource pool is determined in the following manner: for a first container configured with multiple IPs among the existing containers of the host and the containers to be created, a value obtained by multiplying the number of IPs of the first container by a preset coefficient is used as the number of containers corresponding to the first container; for a second container configured with a single IP among the existing containers of the host and the containers to be created, the number of containers of the second container is recorded as a preset value; the number of containers corresponding to all the first containers and the number of containers corresponding to all the second containers are accumulated to obtain the number of containers of the host.

[0014] According to another aspect of an embodiment of the present invention, a firewall testing device is also provided, including: an acquisition module, used to obtain a test task set corresponding to the firewall to be tested, and when multiple containers corresponding to the test task set do not exist, detect whether the network of the container corresponding to the test task set exists; a first determination module, used to determine multiple target hosts corresponding to the test task set from a container host resource pool based on host resource information if the network of the container corresponding to the test task set does not exist; a first processing module, used to perform network creation processing and container creation on the multiple target hosts corresponding to the test task set to obtain a created network and a created container; a testing module, used to test the firewall to be tested through the created container and the created network.

[0015] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and the computer program implements the above-mentioned firewall testing method when executed by a processor.

[0016] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the above-mentioned firewall testing method when running.

[0017] According to another aspect of an embodiment of the present invention, an electronic device is also provided, which includes one or more processors; a memory for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors are implemented to run the programs, wherein the programs are configured to execute the above-mentioned firewall testing method when running.

[0018] In an embodiment of the present invention, a test task set corresponding to the firewall to be tested is first obtained, and when multiple containers corresponding to the test task set do not exist, it is detected whether the network of the container corresponding to the test task set exists. If the network of the container corresponding to the test task set does not exist, multiple target hosts corresponding to the test task set are determined from the container host resource pool based on the host resource information, and then network creation processing and container creation are performed on the multiple target hosts corresponding to the test task set to obtain a created network and a created container, and then the firewall to be tested is tested through the created container and the created network.

[0019] In the above process, the container host resource pool constructed has increased the number of containers and traffic pressure, which can meet the needs of firewall system integration testing. It can distribute containers on different hosts and select hosts based on performance and resource utilization. Through unified scheduling of multi-host resources, automatic management of container resources is achieved.

[0020] It can be seen that through the technical solution of the present invention, the purpose of using a container cluster to perform firewall system integration testing is achieved, thereby achieving the technical effect of improving the efficiency and accuracy of firewall system integration testing, and further solving the technical problem of insufficient host resources when a large number of containers need to be used to construct traffic in firewall testing in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. 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 drawings:

[0022] Figure 1 It is a schematic diagram of a topological environment of a firewall test in the prior art;

[0023] Figure 2 is a flow chart of an optional firewall testing method according to an embodiment of the present invention;

[0024] Figure 3 is a schematic diagram of an optional host election process according to an embodiment of the present invention;

[0025] Figure 4 is a schematic diagram of an optional process of creating a container and a network according to an embodiment of the present invention;

[0026] Figure 5 is a schematic diagram of an optional firewall testing device according to an embodiment of the present invention;

[0027] Figure 6is a schematic diagram of an optional electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in the present invention are all information and data authorized by the user or fully authorized by all parties. For example, an interface is set between the system and the relevant user or organization. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.

[0031] The embodiments or examples of the present disclosure are not exhaustive, but are only illustrative of some embodiments or examples, and are not intended to be specific limitations on the scope of protection of the present disclosure. In the absence of contradiction, each step in a certain embodiment or example can be implemented as an independent example, and the steps can be combined arbitrarily. For example, the scheme after removing some steps in a certain embodiment or example can also be implemented as an independent example, and the order of the steps in a certain embodiment or example can be arbitrarily exchanged. In addition, the optional methods or optional examples in a certain embodiment or example can be combined arbitrarily; in addition, the various embodiments or examples can be combined arbitrarily, for example, some or all steps of different embodiments or examples can be combined arbitrarily, and a certain embodiment or example can be combined arbitrarily with the optional methods or optional examples of other embodiments or examples.

[0032] Example 1

[0033] To conduct system integration testing on firewall devices, multiple containers are needed to simulate the client / server traffic of different applications. The traffic covers different functional modules, such as Flow forwarding, VPN function, threat protection, Quality of Service (QoS), etc. Figure 1 The following is a schematic diagram of a topological environment for firewall testing in the prior art. Figure 1 As shown in the figure, the test environment has: the device to be tested (firewall), Linux host (single, container built on the host), switch. The firewall and host are interconnected through the switch, and the traffic between containers is directed to the firewall and forwarded through the firewall, so as to achieve the purpose of testing the firewall.

[0034] The test set is issued through the automated script. The integrated test requires that each test task be executed in parallel. Each test task corresponds to different traffic (different protocols / applications / attack types, etc.). Different traffic needs to be sent by calling different containers. The same traffic will also be sent by calling different containers to generate a large number of sessions, so as to simulate the test scenario of multiple mixed traffic. The automated script creates the container on the same host, and the container joins the bridge network. The container traffic is directed to the outside through the bridge network and reaches the firewall, and the traffic between containers is forwarded through the firewall. The PC (Personal Computer) running the script is referred to as the script PC. It is the same as the container host. The purpose is that the files on the script PC can be mapped to the container through the Docker volume method, such as transferring files, test result data, etc., which is convenient for the script PC to control and maintain files.

[0035] However, this testing method can only occupy one host resource for a single test, which cannot meet the testing requirements of a large number of containers and traffic pressure. For example, for VPN client testing, each VPN client needs to start a container. When there are hundreds of clients, the server load is very large and other test items cannot be added for integrated testing. In addition, the script PC is bound to the container host, which is not flexible enough.

[0036] Container clusters provide an effective way to manage and run large-scale containerized applications. Clusters are usually composed of multiple physical or virtual machine nodes, each of which can run one or more container instances. Taking the Docker Swarm cluster as an example, Swarm organizes one or more Docker nodes so that users can manage them in a clustered manner.

[0037] However, the usage scenarios of container clusters are very different from firewall test scenarios. Container clusters usually package containers and their replicas into services to provide highly reliable and scalable application resources to the outside world. In terms of network solutions, such as Overlay networks, mutual access between containers in the same network can be achieved, that is, east-west traffic interconnection. Compared with firewall test scenarios, a large number of containers are needed to simulate real client / server traffic and be able to pull traffic to the firewall, which belongs to north-south traffic interconnection. It is very different from the usage scenarios of container clusters, and container cluster technology cannot be directly applied to firewall test scenarios.

[0038] The firewall system integration test needs to create a large number of containers to simulate mixed traffic stress testing. The existing automation solution can only build all containers on one host, and the resources of a single host can no longer meet the needs of system integration testing. However, the container cluster technology that supports unified management of multiple hosts cannot be directly applied to firewall testing due to its different application scenarios. Therefore, under the above technical background, according to an embodiment of the present invention, an embodiment of a firewall testing method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.

[0039] Figure 2 is a flow chart of an optional firewall testing method according to an embodiment of the present invention, such as Figure 2 As shown, the method comprises the following steps:

[0040] Step S201, obtaining a test task set corresponding to the firewall to be tested, and if multiple containers corresponding to the test task set do not exist, detecting whether a network of the container corresponding to the test task set exists.

[0041] In the above steps, the test task set corresponding to the firewall to be tested can be obtained through the application system, processor, electronic device and other devices. Optionally, the test task set corresponding to the firewall to be tested can be obtained through the firewall test system in the script PC, and the script PC and the container host are separated. The script PC serves as a control node and remotely controls the container host through the Docker socket. In order to enable the script PC to still manage and maintain test-related files and map files to the inside of the container, a distributed file system is used to mount the file directories of the script PC and the container host to the distributed file system to achieve file sharing and storage. Among them, the test task set includes multiple test tasks, and the test tasks can be Flow forwarding test tasks, VPN function test tasks, threat protection test tasks, etc. The multiple containers corresponding to the test task set are containers used for system integration testing of firewall devices.

[0042] Optionally, first check whether the container corresponding to the test task set exists. If the container does not exist, check whether the container's network exists. When the container's network exists, obtain the host where the container's network is located and create a container on the host. When the container's network does not exist, select a host from the container host resource pool based on the host resource information, create a network on the selected host, and then create a container.

[0043] In some examples, a network can contain multiple containers. For example, container A and container B both belong to network N. When it is detected that container A does not exist and its network N does not exist, network N and container A are created in sequence. When it is detected that container B does not exist and its network N already exists, container B can be created directly on the host where network N is located.

[0044] Optionally, the container network uses a MACVLAN (MAC Virtual LAN, a network virtualization technology implemented on the Linux operating system) network. Different networks can be isolated using VLANs. This network does not require port mapping or additional bridging and has excellent performance. A network can contain multiple containers. Before a container is created, the network may already exist. Therefore, before creating a container, it is necessary to check whether its network already exists, that is, to check whether the network of the container corresponding to the test task set exists.

[0045] Step S202: If the network of the container corresponding to the test task set does not exist, multiple target hosts corresponding to the test task set are determined from the container host resource pool according to the host resource information.

[0046] In some examples, the host resource information of each host in the container host resource pool includes at least one of the following: the number of containers, CPU utilization, and CPU load.

[0047] In this embodiment, a host that meets a preset condition in the container host resource pool may be determined as a target host.

[0048] In some examples, the host can be determined as the target host when the number of containers of the host is greater than a preset container threshold, or the CPU utilization of the host is less than a preset CPU utilization threshold, or the CPU load of the host is less than the CPU load. In other examples, the host can be determined as the target host when the number of containers of the host is greater than a preset container threshold and the CPU utilization of the host is less than the preset CPU utilization threshold; or when the CPU utilization of the host is less than the preset CPU utilization threshold and the CPU load of the host is less than the CPU load, the host can be determined as the target host; or when the number of containers of the host is greater than the preset container threshold and the CPU load of the host is less than the CPU load, the host can be determined as the target host.

[0049] In some other examples, when the number of containers of the host is greater than a preset container threshold, the CPU utilization of the host is less than a preset CPU utilization threshold, and the CPU load of the host is less than the CPU load, the host can be determined as a target host.

[0050] Optionally, if the network of the container corresponding to the test task set does not exist, a host election is performed, that is, the target host corresponding to the test task set is determined from the container host resource pool based on the host resource information. A cross-host container host resource pool is established based on multiple Linux hosts to support multi-person sharing to meet the needs of firewall system integration testing. Its working form is similar to a container cluster, which enables a large number of containers to be distributed and created on different hosts, and can select the host where the container is located based on the host resource situation. Use MACVLAN network technology to direct traffic between containers to the firewall to achieve north-south cross-host container inter-access.

[0051] In an optional embodiment, after detecting whether the network of the container corresponding to the test task set exists, if the network of the container corresponding to the test task set exists, a container is created for the host where the network of the container corresponding to the test task set is located.

[0052] Optionally, if the network of the container corresponding to the test task set exists, you can directly create a container on the host where the network is located.

[0053] Step S203, performing network creation processing and container creation on multiple target hosts corresponding to the test task set to obtain a created network and a created container.

[0054] Optionally, the premise of container creation and network creation is to select the best host, create the container and network on the relatively better host (i.e., the target host), and when the container is created, the host election will be triggered. Therefore, after the target host is determined, the target host is processed for network creation and container creation to obtain the created network and container, so that instructions can be issued to the container to perform the corresponding test task, and the container and network will be destroyed after the test task is completed. Among them, the container joins at least one network, and a network can contain multiple containers.

[0055] Step S204: Testing the firewall to be tested by using the created container and the created network.

[0056] Optionally, the firewall to be tested can be tested by creating a container and a network. For example, a task execution instruction is sent to the created container so that the created container simulates different devices to send mixed traffic, wherein the mixed traffic is forwarded to the firewall to be tested for processing based on the created network, and then the test result corresponding to the test task set can be determined based on the processing information of the mixed traffic by the firewall to be tested.

[0057] Based on the scheme defined by the above steps S201 to S204, it can be known that in an embodiment of the present invention, the test task set corresponding to the firewall to be tested is first obtained, and when the multiple containers corresponding to the test task set do not exist, it is detected whether the network of the container corresponding to the test task set exists. If the network of the container corresponding to the test task set does not exist, the multiple target hosts corresponding to the test task set are determined from the container host resource pool based on the host resource information, and then the network creation processing and container creation are performed on the multiple target hosts corresponding to the test task set to obtain the created network and the created container, and then the firewall to be tested is tested through the created container and the created network.

[0058] It is easy to notice that in the above process, the number of containers and traffic pressure are increased by constructing a container host resource pool, which can meet the needs of firewall system integration testing, distribute containers on different hosts, and select hosts based on performance and resource utilization. Through unified scheduling of multi-host resources, automatic management of container resources is achieved.

[0059] It can be seen that through the technical solution of the present invention, the purpose of using a container cluster to perform firewall system integration testing is achieved, thereby achieving the technical effect of improving the efficiency and accuracy of firewall system integration testing, and further solving the technical problem of insufficient host resources when a large number of containers need to be used to construct traffic in firewall testing in the prior art.

[0060] In an optional embodiment, the host resource information of each host in the container host resource pool includes at least one of the following: the number of containers, the CPU utilization, and the CPU load, wherein determining the target host corresponding to the test task set from the container host resource pool based on the host resource information includes: screening the hosts in the container host resource pool based on the number of containers and a preset container number threshold to obtain a first host set, wherein the number of containers of the hosts in the first host set is less than the preset container number threshold; screening the hosts in the first host set based on the CPU utilization and the preset CPU utilization threshold to obtain a second host set, wherein the CPU utilization of the hosts in the second host set is less than the preset CPU utilization threshold; if the second host set is empty, determining the target host from the first host set based on the CPU load.

[0061] In an optional embodiment, after the hosts in the first host set are screened according to the CPU utilization and the preset CPU utilization threshold to obtain the second host set, if the second host set is not empty, the CPU idle resources of each host in the second host set are calculated, and based on the CPU idle resources, the target host is determined from the second host set.

[0062] In an optional embodiment, the number of containers of any host in the container host resource pool is determined in the following manner: for a first container configured with multiple IPs among the existing containers of the host and the containers to be created, a value obtained by multiplying the number of IPs of the first container by a preset coefficient is used as the number of containers corresponding to the first container; for a second container configured with a single IP among the existing containers of the host and the containers to be created, the number of containers of the second container is recorded as a preset value; the number of containers corresponding to all the first containers and the number of containers corresponding to all the second containers are accumulated to obtain the number of containers of the host.

[0063] Optionally, host election is to select a host with relatively abundant resources from the container host resource pool, and implement host election based on the obtained host resource information, including the number of containers, CPU utilization, CPU load, number of CPU cores, main frequency, model, etc.

[0064] Optionally, the number of containers of a host is determined based on the existing containers of the host and all containers to be created (the containers to be created will be recorded in the database). For example, for a first container configured with multiple IPs among the existing containers and the containers to be created, the number of IPs of the first container is multiplied by a preset coefficient as the number of containers corresponding to the first container; for a second container configured with a single IP among the existing containers and the containers to be created, the number of containers of the second container is recorded as a preset value (for example, the preset value is 1); the number of containers corresponding to all first containers and the number of containers corresponding to all second containers are accumulated to obtain the number of containers for each host.

[0065] In some examples, the reference indicators for host election are:

[0066] (1) Number of containers and multi_ip: The cumulative number of existing containers and containers to be created on the host. multi_ip refers to the number of multiple IPs configured for the container. Each IP has a corresponding traffic task. The multi_ip can be converted into the number of containers according to a preset coefficient (for example, 0.5). Different models of hosts can set the corresponding upper limit of the number of containers (that is, the preset container number threshold) according to the CPU performance. For example, the upper limit of the number of containers for a certain model of server can be set to 800.

[0067] (2) CPU idle resources, calculated as follows: CPU idle resources = CPU idle rate * main frequency * number of cores * CPU model coefficient.

[0068] (3) CPU load, for example, the average CPU load within 15 minutes.

[0069] Optionally, the hosts in the container host resource pool are screened according to the number of containers and a preset container number threshold to obtain a first host set. For example, the number of containers of each host is compared with the preset container number threshold corresponding to each host, and the hosts whose container numbers are less than the preset container number threshold are taken as hosts in the first host set. Then, the hosts in the first host set can be screened according to the CPU utilization and the preset CPU utilization threshold to obtain a second host set. For example, the preset CPU utilization threshold is 70%, and the hosts in the first host set whose CPU utilization is less than 70% are taken as hosts in the second host set.

[0070] Optionally, if the second host set is empty, that is, the CPU utilization of the hosts is higher than 70%, the target host can be determined from the first host set based on the CPU load. For example, the CPU load of each host in the first host set is obtained, the single-core load of each host is calculated, and the host with the smallest single-core load is selected as the target host.

[0071] Optionally, if the second host set is not empty, the CPU idle resources of each host in the second host set are calculated, and the target host is determined from the second host set based on the CPU idle resources, for example, the host with the most CPU idle resources is selected as the target host.

[0072] In some examples, Figure 3 FIG. 1 is a schematic diagram of an optional host election process according to an embodiment of the present invention. Figure 3As shown, first calculate the total number of existing containers and containers to be created for all hosts, compare the number of containers and the upper limit of host containers, and list the hosts whose number does not exceed the upper limit in a first screening host (for example, the first host set in the aforementioned embodiment). If the number of containers of all hosts exceeds the upper limit, then all hosts are listed in the first screening host, and then traverse the first screening host to obtain CPU utilization, list the hosts with CPU utilization lower than 70% in the second screening host (for example, the second host set in the aforementioned embodiment), and calculate the CPU idle resources. If the second screening host is not empty, select the host with the most CPU idle resources as the target host; if the second screening host is empty, that is, the CPU utilization of all hosts is higher than 70%, traverse the first screening host to obtain CPU load, calculate the single-core load, and select the host with the smallest single-core load as the target host; if the host selection fails, randomly select a host.

[0073] It should be noted that through the unified scheduling of multi-host resources, automatic management of container resources is achieved, and hosts are selected based on performance and resource utilization, which improves the test effect of firewall system integration testing.

[0074] In an optional embodiment, network creation processing and container creation are performed on multiple target hosts corresponding to the test task set to obtain a created network and a created container, including: obtaining interface information of the target host, network IP information corresponding to the network to be created, and virtual LAN identifier information, and performing network creation processing based on the interface information of the target host, network IP information corresponding to the network to be created, and virtual LAN identifier information to obtain a created network; creating a container based on the container image in the target host, and adding the container to the created network to obtain a created container.

[0075] Optionally, firewall system integration testing includes multiple test tasks to be executed in parallel. Different test tasks require the creation of different containers, and the networks and quantities of various containers are different. A test task can include several client / server containers, and the client and server are added to their own networks respectively. Depending on the test requirements, containers of different test tasks can be isolated with different networks or share the same network. Container definitions and the networks they belong to can be defined in the topology file of the automation script.

[0076] The container is created when it is first called. For ease of management, you can set containers in the same network to be created on the same host, that is, select the host when the container is first called, then create the network and container, and join the container to the network. A network can contain multiple containers. Before the container is created, the network may already exist. Therefore, before creating a container, you need to check whether its network already exists. If the container's network already exists, you can directly create the container on the host where the network is located.

[0077] Optionally, the container network uses a MACVLAN network, and different networks can be isolated using VLANs. In order to direct the container traffic to the firewall, specify the parent interface (i.e., the host's physical network card) in the MACVLAN network to direct the container traffic to the physical network. In some examples, in order to save the host's physical network card resources, the parent interface is configured as a network card subinterface, and the subinterface id corresponds to the VLAN id of the physical network. The id of the MACVLAN parent subinterface can be obtained from the topology file.

[0078] Optionally, the interface information of the target host, the network IP information corresponding to the network to be created, and the virtual LAN identifier information are obtained, and network creation processing is performed based on the interface information of the target host, the network IP information corresponding to the network to be created, and the virtual LAN identifier information to obtain the created network. For example, the parent interface information of the target host, the IP network segment corresponding to the network to be created, and the VLAN id information are obtained from the topology file, and the network creation processing is performed based on this information to obtain the created network, and then a container is created in the target host based on the container image, and the container is added to the created network to obtain the created container.

[0079] In some examples, Figure 4 is a schematic diagram of an optional process of creating a container and a network according to an embodiment of the present invention, such as Figure 4 As shown, first check whether the container's network has been assigned a host, that is, whether the container's network already exists. If the container's network does not exist, that is, the host is not assigned and the network is not created, then all the container's networks are set to be created, and the host is selected to create all the container's networks in the selected target host; if the container's network exists, the container's host is set to be the same as the network, that is, the container is created on the host where the network is located. First, when the host has been assigned, traverse all the container's networks to check whether the container's networks are created. If a network has not been created and is not being created, create the network. If the network creation fails, throw an exception and exit; if the network creation is completed, create a container, add the container to the network, configure the IP, maximum transmission unit, etc., so far, the container creation is completed.

[0080] It should be noted that by constructing a container host resource pool to select the target host and create containers and networks, the number of containers and traffic pressure are increased, which can meet the needs of firewall system integration testing and realize the use of container clusters for firewall system integration testing.

[0081] In an optional embodiment, based on a first preset time interval, the hosts in the container host resource pool are detected; if there is a host in the container host resource pool that fails to be detected, the host that fails to be detected is identified as a faulty host, and the container information of the faulty host and the task instruction information executed in the container are obtained; a first host is determined from the hosts in the container host resource pool other than the faulty host, and network creation processing and container creation processing are performed on the first host based on the container information of the faulty host to obtain the network and container of the first host; and a task execution instruction is issued to the container of the first host based on the task instruction information executed in the container of the faulty host.

[0082] Optionally, based on a first preset time interval, the hosts in the container host resource pool are detected, for example, each host node is monitored in real time, and when a host failure is detected, the container and network on the failed host are rescheduled to the remaining normal hosts. Therefore, if there is a host in the container host resource pool that fails to be detected, the host that fails to be detected is identified as a failed host, and the container information of the failed host and the task instruction information executed in the container are obtained, and then the first host (i.e., a normal host) is determined from the hosts in the container host resource pool other than the failed host, and the network creation process and container creation process are performed on the first host based on the container information of the failed host, and the network created on the first host and the container deployed on the first host are obtained, and then the task execution instruction can be issued to the container of the first host based on the task instruction information executed in the container of the failed host.

[0083] In some examples, the firewall test system has an independently running fault scheduling program that can be run on any PC as long as the network with the container host is reachable. The program uses Docker's socket (a mechanism for inter-process communication) to remotely detect hosts in the resource pool in real time. If a host detection fails, the container and network on the faulty host are scheduled to the remaining normal hosts. The main steps include: removing the faulty host from the host election list; obtaining all containers of the faulty host and the task instructions executed in the container from the database; deleting all container information of the faulty host in the database; obtaining the information (image, quantity, etc.) and network information of the faulty container from the topology file; creating the container and network on the normal host through the container and network creation and host election process, executing the task instructions in the container, and entering the new container information into the database.

[0084] In some examples, when the failed host is successfully re-detected, all remaining containers and networks on the host are cleared, and then the host is re-added to the host election list.

[0085] It should be noted that high availability is ensured by monitoring the host nodes for failures and automatically rescheduling containers to other normal hosts.

[0086] In an optional embodiment, based on a second preset time interval, it is detected whether the test task in the database is in a running state, wherein the test task in the database is recorded in the database after the test task of the test task set starts running; if the test task in the database is not in a running state, it is determined that there is an abnormality in the test task in the database, and based on the identification code of the test task in the database, the hosts in the container host resource pool are traversed, and the containers and networks corresponding to the identification codes are deleted.

[0087] In some examples, the firewall test system has a residual environment cleaning function, which is responsible for cleaning the residual containers and networks in the environment, such as the residual containers and networks in the case of abnormal termination of the test task and abnormal script execution. In order to detect whether the test task is in a running state on the script PC, after the test task starts, the identification code (such as Universally Unique Identifier, UUID), process id, IP address of the script PC, etc. of the test task will be entered into the database, and the corresponding information in the database will be deleted after the test task ends.

[0088] Optionally, based on a second preset time interval, it is detected whether the test task in the database is in a running state. For example, a program is used to periodically remotely connect to the script PC to detect whether the test task in the database is in a running state. If the test task in the database is not in a running state, that is, the script PC does not run this task, indicating that the task is abnormally terminated, it is determined that there is an abnormality in the test task in the database, and based on the UUID of the test task in the database, the hosts in the container host resource pool are traversed, and all containers and networks related to the UUID are deleted (the UUID is carried in the container and network names), and the container information related to the UUID is deleted from the database.

[0089] In some examples, in order to ensure the accuracy of container information in the database and avoid the situation where the container has been deleted but still exists in the database, the program will periodically check the containers that have been added to the database for more than a preset period of time (for example, 10 minutes) to check whether the container actually exists on the host. If not, the container will be deleted from the database.

[0090] It should be noted that timely cleaning of the residual environment can avoid occupation of host resources by residual containers, and the target host can be more accurately determined from the container host resource pool through host election.

[0091] In an embodiment of the present invention, a test task set corresponding to the firewall to be tested is first obtained, and when multiple containers corresponding to the test task set do not exist, it is detected whether the network of the container corresponding to the test task set exists. If the network of the container corresponding to the test task set does not exist, multiple target hosts corresponding to the test task set are determined from the container host resource pool based on the host resource information, and then network creation processing and container creation are performed on the multiple target hosts corresponding to the test task set to obtain a created network and a created container, and then the firewall to be tested is tested through the created container and the created network.

[0092] In the above process, the container host resource pool constructed has increased the number of containers and traffic pressure, which can meet the needs of firewall system integration testing. It can distribute containers on different hosts and select hosts based on performance and resource utilization. Through unified scheduling of multi-host resources, automatic management of container resources is achieved.

[0093] It can be seen that through the technical solution of the present invention, the purpose of using a container cluster to perform firewall system integration testing is achieved, thereby achieving the technical effect of improving the efficiency and accuracy of firewall system integration testing, and further solving the technical problem of insufficient host resources when a large number of containers need to be used to construct traffic in firewall testing in the prior art.

[0094] Example 2

[0095] According to an embodiment of the present invention, an embodiment of a firewall testing device is provided, wherein: Figure 5 is a schematic diagram of an optional firewall testing device according to an embodiment of the present invention, such as Figure 5 As shown, the device includes: an acquisition module 501, which is used to acquire a test task set corresponding to the firewall to be tested, and when multiple containers corresponding to the test task set do not exist, detect whether the network of the container corresponding to the test task set exists; a first determination module 502, which is used to determine multiple target hosts corresponding to the test task set from a container host resource pool based on host resource information if the network of the container corresponding to the test task set does not exist; a first processing module 503, which is used to perform network creation processing and container creation on the multiple target hosts corresponding to the test task set to obtain a created network and a created container; a testing module 504, which is used to test the firewall to be tested through the created container and the created network.

[0096] It should be noted that the above-mentioned acquisition module 501, first determination module 502, first processing module 503 and testing module 504 correspond to steps S201 to S204 in the above-mentioned embodiment, and the examples and application scenarios implemented by the four modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above-mentioned embodiment 1.

[0097] Optionally, the first determination module includes: a first processing unit, used to screen the hosts in the container host resource pool according to the number of containers and a preset container number threshold to obtain a first host set, wherein the number of containers of the hosts in the first host set is less than the preset container number threshold; a second processing unit, used to screen the hosts in the first host set according to the CPU utilization and a preset CPU utilization threshold to obtain a second host set, wherein the CPU utilization of the hosts in the second host set is less than the preset CPU utilization threshold; the first determination unit, used to determine the target host from the first host set based on the CPU load if the second host set is empty.

[0098] Optionally, the firewall testing device also includes: a second determination module, which is used to screen the hosts in the first host set based on the CPU utilization and the preset CPU utilization threshold, and after obtaining the second host set, if the second host set is not empty, calculate the CPU idle resources of each host in the second host set, and determine the target host from the second host set based on the CPU idle resources.

[0099] Optionally, the first processing module includes: a third processing unit, used to obtain the interface information of the target host, the network IP information corresponding to the network to be created, and the virtual LAN identifier information, and perform network creation processing based on the interface information of the target host, the network IP information corresponding to the network to be created, and the virtual LAN identifier information to obtain a created network; a fourth processing unit, used to create a container based on the container image in the target host, and add the container to the created network to obtain a created container.

[0100] Optionally, the firewall testing device also includes: a second processing module, which is used to create a container for the host where the network of the container corresponding to the test task set is located after detecting whether the network of the container corresponding to the test task set exists. If the network of the container corresponding to the test task set exists,

[0101] Optionally, the firewall testing device also includes: a third processing module, used to detect the hosts in the container host resource pool based on a first preset time interval; a fourth processing module, used to identify the host that failed to detect as a faulty host if there is a host in the container host resource pool that failed to detect, and obtain the container information of the faulty host and the task instruction information executed in the container; a fifth processing module, used to determine the first host from the hosts in the container host resource pool other than the faulty host, and perform network creation processing and container creation processing on the first host based on the container information of the faulty host to obtain the network and container of the first host; a sixth processing module, used to issue a task execution instruction to the container of the first host based on the task instruction information executed in the container of the faulty host.

[0102] Optionally, the firewall testing device also includes: a seventh processing module, used to detect whether the test task in the database is in a running state based on a second preset time interval, wherein the test task in the database is recorded in the database after the test task of the test task set starts running; an eighth processing module, used to determine that there is an abnormality in the test task in the database if the test task in the database is not in a running state, and traverse the hosts in the container host resource pool according to the identification code of the test task in the database, and delete the container and network corresponding to the identification code.

[0103] Optionally, the firewall testing device also includes: a third determination module, which is used to multiply the number of IP addresses of the first container by a preset coefficient for a first container configured with multiple IP addresses among the existing containers of the host and the containers to be created, and to obtain a value as the number of containers corresponding to the first container; a fourth determination module, which is used to record the number of containers of the second container as a preset value for a second container configured with a single IP address among the existing containers of the host and the containers to be created; and a fifth determination module, which is used to accumulate the number of containers corresponding to all the first containers and the number of containers corresponding to all the second containers to obtain the number of containers of the host.

[0104] Example 3

[0105] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and the computer program implements the above-mentioned firewall testing method when executed by a processor.

[0106] Example 4

[0107] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the above-mentioned firewall testing method when running.

[0108] Example 5

[0109] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, wherein: Figure 6 is a schematic diagram of an optional electronic device according to an embodiment of the present invention, such as Figure 6As shown, the electronic device includes one or more processors; a memory for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors are used to run the programs, wherein the programs are set to execute the above-mentioned firewall testing method when running. When the processor executes the program, the following steps are implemented: obtaining the test task set corresponding to the firewall to be tested, and in the case that the multiple containers corresponding to the test task set do not exist, detecting whether the network of the container corresponding to the test task set exists; if the network of the container corresponding to the test task set does not exist, determining the multiple target hosts corresponding to the test task set from the container host resource pool according to the host resource information; performing network creation processing and container creation on the multiple target hosts corresponding to the test task set to obtain the created network and the created container; testing the firewall to be tested through the created container and the created network.

[0110] Optionally, when the processor executes the program, the following steps are further implemented: the hosts in the container host resource pool are screened according to the number of containers and a preset container number threshold to obtain a first host set, wherein the number of containers of the hosts in the first host set is less than the preset container number threshold; the hosts in the first host set are screened according to the CPU utilization and a preset CPU utilization threshold to obtain a second host set, wherein the CPU utilization of the hosts in the second host set is less than the preset CPU utilization threshold; if the second host set is empty, determining the target host from the first host set according to the CPU load.

[0111] Optionally, the processor also implements the following steps when executing the program: after screening the hosts in the first host set based on the CPU utilization and the preset CPU utilization threshold to obtain the second host set, if the second host set is not empty, calculating the CPU idle resources of each host in the second host set, and determining the target host from the second host set based on the CPU idle resources.

[0112] Optionally, when the processor executes the program, the following steps are also implemented: obtaining the interface information of the target host, the network IP information corresponding to the network to be created, and the virtual LAN identifier information, and performing network creation processing based on the interface information of the target host, the network IP information corresponding to the network to be created, and the virtual LAN identifier information to obtain a created network; creating a container based on the container image in the target host, and adding the container to the created network to obtain a created container.

[0113] Optionally, the processor also implements the following steps when executing the program: after detecting whether the network of the container corresponding to the test task set exists, if the network of the container corresponding to the test task set exists, a container is created for the host where the network of the container corresponding to the test task set is located.

[0114] Optionally, when the processor executes the program, the following steps are also implemented: based on a first preset time interval, the hosts in the container host resource pool are detected; if there is a host in the container host resource pool that fails to be detected, the host that fails to be detected is identified as a faulty host, and the container information of the faulty host and the task instruction information executed in the container are obtained; the first host is determined from the hosts in the container host resource pool other than the faulty host, and network creation processing and container creation processing are performed on the first host based on the container information of the faulty host to obtain the network and container of the first host; and the task execution instruction is issued to the container of the first host based on the task instruction information executed in the container of the faulty host.

[0115] Optionally, the processor also implements the following steps when executing the program: based on a second preset time interval, detecting whether the test task in the database is in a running state, wherein the test task in the database is recorded in the database after the test task of the test task set starts running; if the test task in the database is not in a running state, determining that there is an abnormality in the test task in the database, and based on the identification code of the test task in the database, traversing the hosts in the container host resource pool, and deleting the container and network corresponding to the identification code.

[0116] Optionally, when the processor executes the program, the following steps are further implemented: for a first container configured with multiple IPs among the existing containers of the host and the containers to be created, a value obtained by multiplying the number of IPs of the first container by a preset coefficient is used as the number of containers corresponding to the first container; for a second container configured with a single IP among the existing containers of the host and the containers to be created, the number of containers of the second container is recorded as a preset value; and the number of containers corresponding to all the first containers and the number of containers corresponding to all the second containers are accumulated to obtain the number of containers of the host.

[0117] The devices in this article can be servers, PCs, PADs, mobile phones, etc.

[0118] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0119] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0120] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0121] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0122] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0123] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0124] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A firewall testing method, characterized in that: include: Obtain a test task set corresponding to the firewall to be tested, and if multiple containers corresponding to the test task set do not exist, detect whether a network of the container corresponding to the test task set exists; If the network of the container corresponding to the test task set does not exist, determining multiple target hosts corresponding to the test task set from the container host resource pool according to the host resource information; Performing network creation processing and container creation on multiple target hosts corresponding to the test task set to obtain a created network and a created container; The firewall to be tested is tested through the created container and the created network.

2. The method according to claim 1, characterized in that The host resource information of each host in the container host resource pool includes at least one of the following: the number of containers, CPU utilization, and CPU load, wherein determining multiple target hosts corresponding to the test task set from the container host resource pool according to the host resource information includes: Screening hosts in the container host resource pool according to the number of containers and a preset container number threshold to obtain a first host set, wherein the number of containers of the hosts in the first host set is less than the preset container number threshold; Filtering hosts in the first host set according to the CPU utilization and a preset CPU utilization threshold to obtain a second host set, wherein the CPU utilization of the hosts in the second host set is less than the preset CPU utilization threshold; If the second host set is empty, the target host is determined from the first host set according to the CPU load.

3. The method according to claim 2, characterized in that After the hosts in the first host set are screened according to the CPU utilization and the preset CPU utilization threshold to obtain the second host set, the method further includes: If the second host set is not empty, the CPU idle resources of each host in the second host set are calculated, and the target host is determined from the second host set according to the CPU idle resources.

4. The method according to claim 1, characterized in that: Performing network creation processing and container creation on multiple target hosts corresponding to the test task set to obtain a created network and a created container, including: Acquire the interface information of the target host, the network IP information corresponding to the network to be created, and the virtual local area network identifier information, and perform network creation processing according to the interface information of the target host, the network IP information corresponding to the network to be created, and the virtual local area network identifier information to obtain the created network; A container is created in the target host based on the container image, and the container is added to the created network to obtain the created container.

5. The method according to any one of claims 1 to 3, characterized in that: After detecting whether a network of the container corresponding to the test task set exists, the method further includes: If the network of the container corresponding to the test task set exists, a container is created for the host where the network of the container corresponding to the test task set is located.

6. The method according to any one of claims 1 to 4, characterized in that The method further comprises: Based on a first preset time interval, detecting hosts in the container host resource pool; If there is a host that fails to be detected among the hosts in the container host resource pool, the host that fails to be detected is identified as a faulty host, and container information of the faulty host and task instruction information executed in the container are obtained; Determine a first host from hosts other than the faulty host in the container host resource pool, and perform network creation processing and container creation processing on the first host according to the container information of the faulty host to obtain a network and a container of the first host; A task execution instruction is issued to the container of the first host according to the task instruction information executed in the container of the failed host.

7. The method according to any one of claims 1 to 4, characterized in that The method further comprises: Based on a second preset time interval, detecting whether a test task in the database is in a running state, wherein the test task in the database is recorded in the database after the test task of the test task set starts running; If the test task in the database is not in a running state, it is determined that there is an abnormality in the test task in the database, and based on the identification code of the test task in the database, the hosts in the container host resource pool are traversed to delete the container and network corresponding to the identification code.

8. The method according to any one of claims 1 to 4, characterized in that The number of containers for any host in the container host resource pool is determined in the following manner: For a first container configured with multiple IP addresses among the existing containers of the host and the containers to be created, a value obtained by multiplying the number of IP addresses of the first container by a preset coefficient is used as the number of containers corresponding to the first container; For the existing container of the host and the second container configured with a single IP in the container to be created, the container quantity of the second container is recorded as a preset value; The container quantity corresponding to all the first containers and the container quantity corresponding to all the second containers are accumulated to obtain the container quantity of the host.

9. A firewall testing device, characterized in that: include: An acquisition module is used to acquire a test task set corresponding to the firewall to be tested, and if multiple containers corresponding to the test task set do not exist, detect whether a network of the container corresponding to the test task set exists; A first determination module is used to determine multiple target hosts corresponding to the test task set from a container host resource pool according to host resource information if the network of the container corresponding to the test task set does not exist; A first processing module is used to perform network creation processing and container creation on multiple target hosts corresponding to the test task set to obtain a created network and a created container; A testing module is used to test the firewall to be tested through the created container and the created network.

10. An electronic device, characterized in that: The electronic device includes one or more processors; A memory for storing one or more programs, which, when executed by the one or more processors, enables the one or more processors to run the programs, wherein the programs are configured to execute the firewall testing method described in any one of claims 1 to 8 when run.