Automatic test method and system of micro-service system and electronic equipment
By recording the test environment information and binding names of microservices and message middleware, using the encapsulation class of the public method layer to conduct message accumulation tests, and automatically identify microservice bottlenecks, solving the problem of manual configuration and testing of microservice systems. Improves testing efficiency and reduces costs.
Patent Information
- Application Number
- CN202310589842.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-23
- Publication Date
- 2024-11-26
AI Technical Summary
Before the microservice system was launched, manual configuration of the test environment was cumbersome and time-consuming, making it difficult to implement microservice system testing. Especially due to the wide variety of microservices and different test methods of message middleware testing, a large number of test case scripts are required, which increases the time and labor costs.
By recording the test environment information of the message middleware cluster and the binding name of the microservice, the encapsulation class of the public method layer is called for the message stacking test, and the microservices with bottlenecks are determined based on the changing trend of the message stacking, and automated testing is realized and simplified Test environment configuration and use case writing.
It realizes automated testing of microservice systems, improves testing efficiency and reduces costs, and can quickly locate performance bottlenecks, which are suitable for the testing needs of a variety of smart park systems.
Smart Images

Figure CN119025401A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to an automated testing method for a microservice system, an automated testing system for a microservice system, and an electronic device. Background Art
[0002] The smart park system may include equipment that implements various business functions of the park, such as data collection equipment, data processing equipment and display equipment, etc. The collection equipment can obtain data at various locations in the smart park. The location data may include sensor data, access control card swiping record data, security camera data, power / electrical terminal data, billing data, etc. The data processing equipment may be a server cluster and can be used for real-time value processing of location data, recording historical values, triggering alarm rules, etc. The display device may be a display screen and a mobile phone that obtains interface data, etc., and can present the specified data. The smart park system can be a microservice system, which can be deployed with multiple microservices with different data collection, processing, display and other functions under the microservice architecture. Any microservice can be a program instance (including executable components) that acts as a message producer and / or message consumer, and data can flow between microservices through a message middleware cluster.
[0003] At present, before a microservice system goes online, it is usually necessary to test the microservice system. To complete the test, it is necessary to manually configure the corresponding test environment for the production environment of each microservice in the microservice system. Manual configuration one by one is very cumbersome. At the same time, due to the wide variety of microservices and different testing methods for microservices and message middleware, it is necessary to write a large number of test case scripts to test each microservice and message middleware, which will consume a lot of time and manpower costs. It is very difficult to implement the testing of the microservice system. Summary of the invention
[0004] The purpose of the present invention is to provide an automated testing method, system and electronic device for a microservice system, so as to avoid configuring the test environments of different microservices separately and avoid using different test cases between microservices, realize automated testing of the microservice system, locate microservices with bottlenecks, and improve testing efficiency and cost.
[0005] In order to achieve the above object, an embodiment of the present invention provides an automated testing method for a microservice system, the automated testing method comprising:
[0006] Record the test environment information of the message middleware cluster and the binding name consisting of the microservice name to be tested and the subject identification name. The message middleware cluster and each microservice are deployed in the server cluster;
[0007] Read the recorded test environment information and connect with the message middleware cluster and the server cluster;
[0008] Calling the encapsulation class in the public method layer, performing a message accumulation test on the message middleware cluster and the server cluster, and recording the message accumulation corresponding to a topic, the topic identification name of which is the topic identification name in the binding name;
[0009] Based on the changing trend of the message accumulation amount of each topic, the microservice with consumption bottleneck is determined, and the name of the microservice is the name of the microservice to be tested in the binding name.
[0010] Specifically, the test environment information includes:
[0011] Access information of message middleware cluster, access information of relational database, access information of server cluster, and monitoring and collection parameters;
[0012] The relational database is used to record the message accumulation amount corresponding to each binding name;
[0013] The monitoring and collection parameters are used to configure the total monitoring duration and collection interval of the message accumulation amount.
[0014] Specifically, the microservice with the name of the microservice to be tested serves as a consumer of messages in the topic with the topic identifier or a consumer group belonging to the topic.
[0015] Specifically, the message accumulation test includes:
[0016] Feed the test data into the microservice that acts as a producer;
[0017] By means of the message middleware cluster and each microservice under test, the resource occupancy metric value of the server cluster is increased to a specified threshold;
[0018] Determine the offset data in the current message middleware and count the message accumulation amount of the topic in the message middleware.
[0019] Specifically, determining the offset data in the current message middleware and counting the message accumulation amount of the topic in the message middleware includes:
[0020] By using the encapsulation class, the first offset bit data of each topic is counted;
[0021] By using the encapsulation class, the second offset data of the consumed records of the consumer group of each topic is counted;
[0022] The amount of message accumulation of the topic having the topic identification name is determined through the encapsulation class based on the difference between the first offset bit data and the second offset bit data.
[0023] Specifically, the public method layer includes: an encapsulation class for reading configuration files, an encapsulation class for counting message accumulation, an encapsulation class for counting server occupied resources, and an encapsulation class for executing multiple threads.
[0024] Specifically, the microservices with consumption bottlenecks are determined based on the changing trend of the message accumulation amount of each topic, including:
[0025] Importing the binding name and the message accumulation amount corresponding to the binding name into a visual analysis system to determine a change trend graph;
[0026] Through the statistical tool and the change trend graph, the microservice with the microservice name in the binding name that has a consumption bottleneck is determined.
[0027] Specifically, the microservices with consumption bottlenecks are determined based on the changing trend of the message accumulation amount of each topic, including:
[0028] Determine the ratio of the duration of the message accumulation of each topic exceeding the specified accumulation threshold to the total monitoring duration;
[0029] The topic identifiers and corresponding binding names whose proportion is higher than a specified proportion threshold are determined, and the microservices having the microservice names in the binding names are regarded as microservices with consumption bottlenecks.
[0030] An embodiment of the present invention provides an automated testing system for a microservice system, the automated testing system comprising:
[0031] A configuration file module is used to record the test environment information of the message middleware cluster and the binding name composed of the microservice name to be tested and the subject identification name. The message middleware cluster and each microservice are deployed in the server cluster;
[0032] A public method module, used for reading the recorded test environment information and connecting with the message middleware cluster and the server cluster;
[0033] A monitoring execution module, used for calling the encapsulation class in the public method layer, performing a message accumulation test on the message middleware cluster and the server cluster, and recording the message accumulation corresponding to a topic, the topic identification name of which is the topic identification name in the binding name;
[0034] The data analysis module is used to determine the microservice with consumption bottleneck based on the changing trend of the message accumulation amount of each topic, and the name of the microservice is the name of the microservice to be tested in the binding name.
[0035] In another aspect, an embodiment of the present invention provides an electronic device, the electronic device comprising:
[0036] at least one processor;
[0037] a memory connected to the at least one processor;
[0038] The memory stores instructions that can be executed by the at least one processor, and the at least one processor implements the aforementioned method by executing the instructions stored in the memory.
[0039] The present invention determines the message consumption of the microservice to its theme through the encapsulation class by binding the name, realizes the real-time monitoring of the message accumulation of the theme in the message middleware cluster, the test can be automatically executed, the test data can be automatically stored and the data presentation can be completed, and reliable data can be provided for the performance analysis of each microservice. At the same time, the microservice with performance (message consumption capacity) bottleneck can be determined and located. The present invention decouples the testing and monitoring functions of the microservice and theme corresponding to the binding name from the test environment through the encapsulation class in the public method layer. When the access information of the message middleware cluster and the server cluster to be monitored changes, only the recorded information needs to be modified, and the test personnel do not need to understand and master the code of the program script. The test personnel can also quickly apply it to the testing of various smart park systems.
[0040] Other features and advantages of the embodiments of the present invention will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present invention, but do not constitute a limitation on the embodiments of the present invention. In the accompanying drawings:
[0042] Figure 1 A schematic diagram of the steps of the main method of an embodiment of the present invention;
[0043] Figure 2 A schematic diagram of a hierarchical architecture of an exemplary test software according to an embodiment of the present invention;
[0044] Figure 3 A schematic diagram of a configuration file of an exemplary test environment according to an embodiment of the present invention;
[0045] Figure 4 A schematic diagram of associated data and a statistical window of an exemplary encapsulation class according to an embodiment of the present invention;
[0046] Figure 5 This is a schematic diagram of an exemplary database multi-thread synchronization operation according to an embodiment of the present invention;
[0047] Figure 6 A schematic diagram of a curve showing an exemplary message accumulation amount according to an embodiment of the present invention;
[0048] Figure 7 A schematic diagram of an exemplary electronic device architecture according to an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The specific implementation of the embodiment of the present invention is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described here is only used to illustrate and explain the embodiment of the present invention, and is not used to limit the embodiment of the present invention.
[0050] Example 1
[0051] The present invention provides an automated testing method for a microservice system. Figure 1 , the automated testing method may include:
[0052] S1) recording the test environment information of the message middleware cluster and recording the binding name consisting of the microservice name to be tested and the subject identification name, wherein the message middleware cluster and each microservice are deployed in the server cluster;
[0053] S2) reading the recorded test environment information and connecting with the message middleware cluster and the server cluster;
[0054] S3) calling the encapsulation class in the public method layer, performing a message accumulation test on the message middleware cluster and the server cluster, and recording the message accumulation corresponding to the topic, the topic identification name of which is the topic identification name in the binding name;
[0055] S4) Based on the changing trend of the message accumulation amount of each topic, determine the microservice with consumption bottleneck, the name of the microservice is the name of the microservice to be tested in the binding name.
[0056] In an embodiment of the present invention, the aforementioned automated testing method can be executed by a designated server or server cluster or other device with computing and instruction processing capabilities. For example, the device can be configured with one or more executable test scripts or compiled executable test programs and other testing software. When the testing software is executed by the device, it can implement the functions corresponding to the aforementioned method.
[0057] The device executing the microservice may also be a virtual or physical server or a device with computing and instruction processing capabilities. In an embodiment of the present invention, the consumption bottleneck may refer to the fact that within a specified time range, the amount of unconsumed messages in the subject of the microservice is higher than the message accumulation threshold; in some application scenarios, the consumption bottleneck may also require that the proportion of the duration in the time range is higher than the specified proportion threshold. Among them, the duration refers to the duration of the resource utilization of the device executing the microservice higher than the specified resource utilization threshold; resources refer to thread resources, processing resources, etc., and processing resources are processor resources, memory resources, and network bandwidth resources, etc.; the message accumulation threshold may be configured, for example, the message accumulation of each subject in the microservice is determined, and the message accumulation threshold is configured based on the statistics of the message accumulation of each subject in the microservice. The statistics may include: the median, the average, the peak value multiplied by the specified percentage, etc.; the change trend may be the numerical characteristics of the message accumulation of the subject in time change, for example, within a specified time range (composed of unit time), each unit time corresponding to the message accumulation of a subject higher than the message accumulation threshold is marked 1, and the rest The unit time corresponds to the mark 0, and a numerical feature is obtained. If all the marks in the numerical feature are 1 (or 70% or 90% are 1 marks), it is determined that a certain topic has a consumption bottleneck, and the microservice bound to the name of the certain topic can be regarded as also having a consumption bottleneck; when one or more topics have consumption bottlenecks, it can also be regarded that the microservice that has a binding name relationship with the names of one or more topics also has a consumption bottleneck. At this time, the microservice with a binding name relationship can bind the names of at least two topics; the message accumulation amount and time change trend chart of the topic can also be used for intuitive presentation, so as to observe the message accumulation amount of the topics bound to each microservice name, and use statistical indicators that meet the product requirements and scenario characteristics of the microservice system to determine whether the topic and / or microservice has a consumption bottleneck.
[0058] In some application scenarios, the aforementioned microservice system may include multiple microservices and message middleware clusters. The producer microservice generates a message and writes the generated message into the topic corresponding to the microservice in the specified message middleware. The message middleware (through the broker) pushes the message in the topic to the consumer microservice to complete the message consumption. At the same time, in the microservice system, the microservice and the message middleware cluster can be configured in the same or specified server clusters with different addresses. Each message middleware in the message middleware cluster can be configured in the same or specified server clusters with different addresses. The microservice can be configured in the same or specified server clusters with different addresses. The microservice as a producer can transmit data through the specified message middleware, and is also a consumer of other producer microservices. The microservice as a consumer can transmit data through the specified message middleware, and is also a producer of other consumer microservices. The message middleware in the aforementioned message middleware cluster can provide real-time middleware services between a large number of microservices with diverse functions. Understandably, due to the complex and intertwined data flow relationships in a microservice system, it is very difficult to identify microservices with performance bottlenecks by manually configuring and testing them one by one.
[0059] In an exemplary test software example disclosed in the present invention, in terms of implementation, Figure 2 The aforementioned test software may include a config configuration file layer 100, a common method layer 101 and a monitor execution layer 102. In the embodiment of the present invention, a software layer is a collection of components with specified functions, for example, it may be a collection of library files and a collection of executable files. Method calls can be made between different software layers and between files with defined calling relationships.
[0060] In the configuration file layer, the test environment information of the message middleware cluster and the binding name consisting of the microservice name to be tested and the subject identification name can be recorded in a specified configuration file (such as config.ini file). The binding names are paired, and multiple pairs of binding names can be recorded. The test environment information includes:
[0061] The access information of the message middleware cluster, the access information of the relational database, the access information of the server cluster, and the monitoring and collection parameters; the relational database is used to record the message accumulation corresponding to the microservice name to be tested and the subject identification name in each binding name; the monitoring and collection parameters are used to configure the total monitoring time and collection interval (or interval time, interval time point) of the message accumulation. For example, the message middleware cluster can be a Kafka cluster, and the relational database can be a MySQL database, such as Figure 3 , the test environment information can include:
[0062] Kafka cluster access address (recorded under the configuration item kafka): cluster cluster and record ip_1, ip_2 and port ip_1 port_1, ip_2 port_2, and colon can be used as a separator;
[0063] MySQL database information (recorded under the configuration item mysql): username username and the corresponding root user root, password password and record example_1, access address host and record ip_3, port port and record port_3;
[0064] Server cluster address and login information (recorded under the configuration item host_node): server node information node_info and triple records. The first triple record includes server address ip_1, root user root, and password record example_2. The second triple record includes server address ip_2, root user root, and password record example_3. The third triple record includes server address ip_4, root user root, and password record example_4. The fourth triple record includes server address ip_5, root user root, and password record example_5.
[0065] Binding name (recorded under the configuration item test_info): the name of the microservice to be monitored and the topic identifier of Kafka. Record the microservice name on the left side of the separator " / " and the topic identifier on the right side. The first microservice name is device-shadow and the bound topic identifier is ddc_structuredDevice. The second microservice name is alarm-monitor and the bound topic identifier is ddc_AppPoint_data. The third microservice name is data-parser-nHaystack and the bound topic identifier is ddc_collectTask_HayStack. Other microservice names S and bound topic identifiers T are also recorded.
[0066] And (not shown) monitoring duration and sampling interval (collection interval) etc.
[0067] When the test environment changes, you only need to modify the relevant configuration parameters to monitor Kafka topics at different addresses.
[0068] In the aforementioned public method layer, encapsulation classes with designed functions can be implemented by constructing classes. In some application scenarios, the public method layer may include:
[0069] The configuration file reading (encapsulation) class can be represented as the ConfigRead class, which can be used to read various configuration data in the config.ini configuration file;
[0070] The message acquisition class of the message middleware can be represented as the KafkaClient class: it can be used to connect to the Kafka cluster, read the offset data of each Kafka topic (to determine the total amount of messages) and the offset data in the consumer group (to determine the number of consumed messages), and calculate the message accumulation amount;
[0071] Server resource acquisition class, which can be represented as LinuxClient class: it can be used to establish connection relationship with each (remote) server cluster and obtain server resource occupancy measurement value, such as processor occupancy ratio, memory occupancy ratio, disk read and write utilization ratio, network bandwidth utilization ratio, etc.
[0072] The database writing class can be represented as the MySQLClient class: it can be used to connect to the MySQL database to realize the automatic storage function of the message accumulation data corresponding to each binding name;
[0073] The thread management class, which can be represented as the ThreadTest class, can enable the monitoring strategy of multi-threaded execution configuration and collect the message accumulation corresponding to each binding name through multiple threads.
[0074] The aforementioned monitoring execution layer may include a TestMonitor class, which can be used to call multiple encapsulation classes in the public method layer to implement the final monitoring strategy. In the monitoring strategy, the data to be monitored can be selected based on the test requirements and product features. For example, Figure 4, in the TestMonitor class 300 (file), specify the number of points (self.point_num), equipment number (self.equip_num), deployment environment description (self.deployment), cache data processor name (self.collector, which can be used to collect data of multi-thread ids, and each thread is used to execute monitoring strategies for microservices and message middleware), message accumulation data corresponding to the binding name (first offset data t_result[0], second offset data t_result[1]), cache data processor haystack link to microservice (self.link), timestamp data (time_stamp), interval mark data (self.mark) where the message accumulation exceeds the threshold, and other data. In some application scenarios, the monitoring strategy can be configured to use the difference between the end time end_time and the start time start_time as the total monitoring duration, and the configured interval point interval as the message accumulation amount of the topic and the cycle period for writing the binding name into the database, so as to realize the real-time monitoring and automatic storage of the Kafka message accumulation amount. In a window 301 of script execution information feedback, the total offset describes the current interval 0, 1, 2 cycle time points, and different binding names correspond to offset data in sequence. For example, the binding name device-shadow / ddc_structuredDevice corresponds to the total offset: [(0,44714501), (1,254985), (2,2346802)]. Multiple statistics can be performed to determine the first offset data and the second offset data respectively.
[0075] It should be noted that in the aforementioned automated testing method, for the microservice name and the subject identification name in the binding name, the microservice with the microservice name to be tested can be used as a consumer of messages in the subject with the subject identification name or a consumer group belonging to the subject. The message middleware can record the consumed records of the messages of the consumer microservice in the consumer group (realized by the offset data), which can be used to calculate the number of messages consumed. At the same time, the offset data of each subject can be used to calculate the total amount of messages, so that the message accumulation amount in each subject can be determined, which is the difference between the total amount of messages and the number of consumed messages. Use the binding name and encapsulation class for testing to reflect the performance (message consumption capability) of the consumer microservice through the message accumulation amount in the subject.
[0076] When the server cluster enters a pressurized environment and the amount of collected data is large, you can monitor the message accumulation in the Kafka cluster to determine whether the processing performance of the microservices in the consumer group has reached a bottleneck. To this end, it is necessary to monitor the message accumulation of the Kafka topic in real time, and analyze the message accumulation trend to find the service pressure bottleneck in order to optimize the microservice system. The message accumulation test may include:
[0077] Feed the test data into the microservice that acts as a producer;
[0078] By using the message middleware cluster and each microservice under test, the resource occupancy metric of the server cluster is increased to a specified threshold, so that the server cluster can enter a pressurized environment;
[0079] Determine the offset data in the current message middleware and count the message accumulation amount of the topic in the message middleware.
[0080] Determining the offset data in the current message middleware and counting the message accumulation amount of the topic in the message middleware may include:
[0081] By using the encapsulation class, the first offset bit data of each topic is counted;
[0082] By using the encapsulation class, the second offset data of the consumed records of the consumer group of each topic is counted;
[0083] The message accumulation amount of the topic having the topic identification name is determined based on the difference between the first offset bit data and the second offset bit data through the encapsulation class.
[0084] In the embodiment of the present invention, in terms of use, in the aforementioned step S1), in the configuration file layer, the monitoring execution layer can first detect whether there are unfilled configuration items in the current configuration file. In some application scenarios, enter the config.ini configuration file or pop-up window, and modify the various configuration items of the test environment information in the configuration file according to the information list of the current test environment. In the aforementioned step S2), in the monitoring execution layer, a script (which can be called a TestMonitor script) containing a TestMonitor class can be started, and the ConfigRead class is called by the TestMonitor script to read the configuration file. The read configuration items can be used to connect to each server and obtain a binding name, etc. In the aforementioned step S3), the TestMonitor script can be executed in the monitoring execution layer (multi-threaded), calling the LinuxClient class, the KafkaClient class, and the MySQLClient class to connect to each server, and the server cluster is determined to enter a pressurized environment through the LinuxClient class, and the message accumulation amount of the subject in the binding name is determined according to the binding name through the KafkaClient class, and the message accumulation amount corresponding to the binding name is imported into the specified database through the MySQLClient class.
[0085] In an exemplary database scenario disclosed in the present invention, Figure 5The message accumulation amount can be written into the database 402 through SQL instructions (such as INSERT insertion instruction 400), and multiple threads Thread_id (1, 2, 3, etc.) can also be started to synchronize the data 401 of the microservice and topic corresponding to the binding name to the database through multiple threads by the MySQLClient class, wherein, through SQL instructions, the (monitoring indicator) point quantity data (self.point_num), equipment quantity data (self.equip_num), deployment environment description data (self.deployment), cache data processor name (self.collector, available The data of multi-thread ids is collected, and each thread is used to execute monitoring strategies for microservices and message middleware), the message accumulation data corresponding to the binding name (the first offset data t_result[0], the second offset data t_result[1]), the cache data processor's link to the microservice (self.link), the timestamp data (time_stamp), the mark data (self.mark), and the corresponding monitoring data v1~v10 are synchronously written into the MySQL database. The written test data TestData includes both the specified monitoring indicators and the corresponding monitoring data. The data written into the MySQL database can then be imported into the visual analysis (GVP) system. In one example, in the aforementioned step S4), in the monitoring execution layer, it can include:
[0086] S401a) importing the binding name and the message accumulation amount corresponding to the binding name into the visual analysis system, and determining a change trend graph, such as Figure 6 ;
[0087] S402a) Determine, by using statistical tools and the change trend graph, a microservice having a consumption bottleneck and having a microservice name in the binding name.
[0088] The statistical tool can determine the maximum value point of the curve of the message accumulation corresponding to the binding name (for example, at time t1, the curve corresponding to the binding name device-shadow / ddc_structuredDevice has a maximum value point), extreme points, duration of continuously exceeding the specified accumulation threshold and other parameter values, as well as according to the configured indicators and weights, etc., to look up the table to determine whether each microservice is a microservice with a message consumption bottleneck, where different microservices can have different message accumulation thresholds and indicators. It can be understood that public quantities such as parameters and indicators are not the only implementation methods of the embodiments of the present invention, and can be designed and selected according to the application environment and product characteristics of the smart park system.
[0089] In another example, the aforementioned test software may further include a data analysis layer, in which an encapsulated Dataanalysis class may be constructed, and the Dataanalysis class may be used to evaluate and determine whether a microservice is a microservice with a message consumption bottleneck in the microservice system. In the aforementioned step S4), a script including the Dataanalysis class may be executed to determine a microservice with a consumption bottleneck based on a trend in the amount of message accumulation of each topic, which may include:
[0090] S401b) determining the ratio of the duration of the message accumulation amount of each topic being higher than the specified accumulation amount threshold (configured message accumulation amount threshold) to the total monitoring duration (a specified period of time);
[0091] S402b) determining the topic identification name and the corresponding binding name of the ratio higher than the specified ratio threshold, and treating the microservice with the microservice name in the binding name as the microservice with consumption bottleneck.
[0092] The embodiment of the present invention can collect the message accumulation in the Kafka topic in real time by running the above-mentioned automated script, automatically write it into the MySQL database, and import the data collected in MySQL into GVP for chart display, analyze the message accumulation trend of the Kafka topic, and provide a reliable test basis for the stress test of microservices, find out the stress bottleneck of microservices, and optimize the software system; the embodiment of the present invention uses automated scripts to adapt to different test environments. When a new test environment is deployed, it only needs to modify the relevant configuration parameters in the config.ini configuration file to execute the monitoring strategy normally.
[0093] Example 2
[0094] The embodiment of the present invention and embodiment 1 belong to the same inventive concept. The embodiment of the present invention provides an automated testing system for a microservice system. The automated testing system may include:
[0095] A configuration file module is used to record the test environment information of the message middleware cluster and the binding name composed of the microservice name to be tested and the subject identification name. The message middleware cluster and each microservice are deployed in the server cluster;
[0096] A public method module, used for reading the recorded test environment information and connecting with the message middleware cluster and the server cluster;
[0097] A monitoring execution module, used for calling the encapsulation class in the public method layer, performing a message accumulation test on the message middleware cluster and the server cluster, and recording the message accumulation corresponding to a topic, the topic identification name of which is the topic identification name in the binding name;
[0098] The data analysis module is used to determine the microservice with consumption bottleneck based on the changing trend of the message accumulation amount of each topic, and the name of the microservice is the name of the microservice to be tested in the binding name.
[0099] Specifically, the test environment information includes:
[0100] Access information of message middleware cluster, access information of relational database, access information of server cluster, and monitoring and collection parameters;
[0101] The relational database is used to record the message accumulation amount corresponding to each binding name;
[0102] The monitoring and collection parameters are used to configure the total monitoring duration and collection interval of the message accumulation amount.
[0103] Specifically, the microservice with the name of the microservice to be tested serves as a consumer of messages in the topic with the topic identifier or a consumer group belonging to the topic.
[0104] Specifically, the message accumulation test includes:
[0105] Feed the test data into the microservice that acts as a producer;
[0106] By means of the message middleware cluster and each microservice under test, the resource occupancy metric value of the server cluster is increased to a specified threshold;
[0107] Determine the offset data in the current message middleware and count the message accumulation amount of the topic in the message middleware.
[0108] Specifically, determining the offset data in the current message middleware and counting the message accumulation amount of the topic in the message middleware includes:
[0109] By using the encapsulation class, the first offset bit data of each topic is counted;
[0110] By using the encapsulation class, the second offset data of the consumed records of the consumer group of each topic is counted;
[0111] The amount of message accumulation of the topic having the topic identification name is determined through the encapsulation class based on the difference between the first offset bit data and the second offset bit data.
[0112] Specifically, the public method layer includes: an encapsulation class for reading configuration files, an encapsulation class for counting message accumulation, an encapsulation class for counting server occupied resources, and an encapsulation class for executing multiple threads.
[0113] Specifically, the microservices with consumption bottlenecks are determined based on the changing trend of the message accumulation amount of each topic, including:
[0114] Importing the binding name and the message accumulation amount corresponding to the binding name into a visual analysis system to determine a change trend graph;
[0115] Through the statistical tool and the change trend graph, the microservice with the microservice name in the binding name that has a consumption bottleneck is determined.
[0116] Specifically, the microservices with consumption bottlenecks are determined based on the changing trend of the message accumulation amount of each topic, including:
[0117] Determine the ratio of the duration of the message accumulation of each topic exceeding the specified accumulation threshold to the total monitoring duration;
[0118] The topic identifiers and corresponding binding names whose proportion is higher than a specified proportion threshold are determined, and the microservices having the microservice names in the binding names are regarded as microservices with consumption bottlenecks.
[0119] Example 3
[0120] The embodiment of the present invention and embodiments 1 and 2 all belong to the same inventive concept. The embodiment of the present invention provides an electronic device, such as Figure 7 The electronic device A0 may include: at least one processor A01; a memory A02, connected to the at least one processor A01, for example, the memory A02 may be communicatively connected to the at least one processor A01 via a bus A03; wherein the memory A02 stores instructions that can be executed by the at least one processor A01, and the at least one processor A01 implements the method in Example 1 by executing the instructions stored in the memory A02.
[0121] The optional implementation modes of the embodiments of the present invention are described in detail above in conjunction with the accompanying drawings. However, the embodiments of the present invention are not limited to the specific details in the above implementation modes. Within the technical concept of the embodiments of the present invention, various simple modifications can be made to the technical scheme of the embodiments of the present invention, and these simple modifications all belong to the protection scope of the embodiments of the present invention.
[0122] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, the embodiments of the present invention will not further describe various possible combinations.
[0123] Those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including several instructions to enable a single-chip microcomputer, a chip or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium can be non-transient, and the storage medium can include: U disk, hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), flash memory (Flash memory), disk or optical disk and other media that can store program codes.
[0124] In addition, various implementation modes of the embodiments of the present invention may be arbitrarily combined, and as long as they do not violate the concept of the embodiments of the present invention, they should also be regarded as the contents disclosed by the embodiments of the present invention.
Claims
1. An automated testing method for a microservice system, characterized in that: The automated testing method includes: Record the test environment information of the message middleware cluster and the binding name consisting of the microservice name to be tested and the subject identifier. The message middleware cluster and each microservice are deployed in the server cluster. Read the recorded test environment information and connect with the message middleware cluster and the server cluster; Calling the encapsulation class in the public method layer, performing a message accumulation test on the message middleware cluster and the server cluster, and recording the message accumulation corresponding to a topic, the topic identification name of which is the topic identification name in the binding name; Based on the changing trend of the message accumulation amount of each topic, the microservice with consumption bottleneck is determined, and the name of the microservice is the name of the microservice to be tested in the binding name.
2. The automated testing method for a microservice system according to claim 1, characterized in that: The test environment information includes: Access information of message middleware cluster, access information of relational database, access information of server cluster, and monitoring and collection parameters; The relational database is used to record the message accumulation amount corresponding to each binding name; The monitoring and collection parameters are used to configure the total monitoring duration and collection interval of the message accumulation amount.
3. The automated testing method for a microservice system according to claim 1, characterized in that: The microservice with the name of the microservice to be tested serves as a consumer of messages in the topic with the topic identifier or a consumer group belonging to the topic.
4. The automated testing method for a microservice system according to claim 3, characterized in that: in, The message accumulation test includes: Feed the test data into the microservice that acts as a producer; By means of the message middleware cluster and each microservice under test, the resource occupancy metric value of the server cluster is increased to a specified threshold; Determine the offset data in the current message middleware and count the message accumulation amount of the topic in the message middleware.
5. The automated testing method for a microservice system according to claim 4, characterized in that: The step of determining the offset data in the current message middleware and counting the message accumulation amount of the topic in the message middleware includes: By using the encapsulation class, the first offset bit data of each topic is counted; By using the encapsulation class, the second offset data of the consumed records of the consumer group of each topic is counted; The amount of message accumulation of the topic having the topic identification name is determined through the encapsulation class based on the difference between the first offset bit data and the second offset bit data.
6. The automated testing method for a microservice system according to any one of claims 1 to 5, characterized in that: in, The public method layer includes: encapsulation class for reading configuration files, encapsulation class for counting message accumulation, encapsulation class for counting server occupied resources and encapsulation class for executing multithreading.
7. The automated testing method for a microservice system according to claim 1, characterized in that: The microservices with consumption bottlenecks are determined based on the changing trend of the message accumulation amount of each topic, including: Importing the binding name and the message accumulation amount corresponding to the binding name into a visual analysis system to determine a change trend graph; Through the statistical tool and the change trend graph, the microservice with the microservice name in the binding name that has a consumption bottleneck is determined.
8. The automated testing method for a microservice system according to claim 1, characterized in that: The microservices with consumption bottlenecks are determined based on the changing trend of the message accumulation amount of each topic, including: Determine the ratio of the duration of the message accumulation of each topic exceeding the specified accumulation threshold to the total monitoring duration; The topic identifiers and corresponding binding names whose proportion is higher than a specified proportion threshold are determined, and the microservices having the microservice names in the binding names are regarded as microservices with consumption bottlenecks.
9. An automated testing system for a microservice system, characterized in that: The automated testing system includes: A configuration file module is used to record the test environment information of the message middleware cluster and the binding name composed of the microservice name to be tested and the subject identification name. The message middleware cluster and each microservice are deployed in the server cluster; A public method module, used for reading the recorded test environment information and connecting with the message middleware cluster and the server cluster; A monitoring execution module, used for calling the encapsulation class in the public method layer, performing a message accumulation test on the message middleware cluster and the server cluster, and recording the message accumulation corresponding to a topic, the topic identification name of which is the topic identification name in the binding name; The data analysis module is used to determine the microservice with consumption bottleneck based on the changing trend of the message accumulation amount of each topic, and the name of the microservice is the name of the microservice to be tested in the binding name.
10. An electronic device, characterized in that: The electronic device includes: at least one processor; a memory connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the at least one processor implements the method of any one of claims 1 to 8 by executing the instructions stored in the memory.
