Test data packet generation method and apparatus, electronic device, and storage medium

CN116244164BActive Publication Date: 2026-09-25TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111489889.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-08
Publication Date
2026-09-25
Estimated Expiration
2041-12-08

AI Technical Summary

Technical Problem

[0003]为了解决现有技术应用在生成测试数据包时,测试数据形式单一等问题,本申请提供了一种测试数据包生成方法、装置、电子设备及存储介质:

Benefits of technology

[0014]本申请通过响应于测试数据包生成指令,确定对应的预设数据配置信息;然后,根据所述预设数据配置信息生成多个测试数据,以得到目标测试数据包。其中预设数据配置信息描述了待生成的测试数据包中不同数据维度下的待生成数据的构成比例,每个数据维度分别指示不同的数据大小信息,数据大小信息用于限定数据维度下的待生成数据的大小。本申请利用预设数据配置信息来生成构成维度丰富的测试数据包,预设数据配置信息基于数据维度对待生成的测试数据包进行了构成比例、数据大小(长度)的规范,这样生成的测试数据包中的各个测试数据形式多样不单一,可以提高测试数据包的真实性、提高测试效果。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116244164B_ABST
    Figure CN116244164B_ABST
Patent Text Reader

Abstract

The application discloses a test data packet generation method and device, electronic equipment and a storage medium. The method comprises the following steps: in response to a test data packet generation instruction, determining corresponding preset data configuration information; and generating a plurality of test data according to the preset data configuration information to obtain a target test data packet. The application utilizes the preset data configuration information to generate a test data packet with rich dimensions. The preset data configuration information regulates the constituent proportion and data size (length) of the test data packet to be generated based on the data dimension. The various test data in the generated test data packet are diverse and not single, which can improve the authenticity of the test data packet and improve the test effect. The application can be applied to various scenes such as cloud technology, artificial intelligence, intelligent transportation and auxiliary driving.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Internet communication technology, and in particular to a test data packet generation method, apparatus, electronic device and storage medium. Background Technology

[0002] With the development of internet communication technology, internet products are emerging in an endless stream, making testing of these products an important part of the work. In related technologies, test data packets often contain random strings of the same size. Such monotonous test data cannot effectively simulate real-world data to improve the effectiveness of the test. Therefore, there is a need to provide solutions for generating test data with diverse formats. Summary of the Invention

[0003] To address the problem of limited test data formats in existing technologies for generating test data packets, this application provides a test data packet generation method, apparatus, electronic device, and storage medium:

[0004] According to a first aspect of this application, a method for generating test data packets is provided, the method comprising:

[0005] In response to the test data packet generation command, corresponding preset data configuration information is determined; wherein, the preset data configuration information describes the composition ratio of the data to be generated under different data dimensions in the test data packet to be generated, each data dimension indicates different data size information, and the data size information is used to limit the size of the data to be generated under the data dimension;

[0006] Multiple test data are generated based on the preset data configuration information to obtain the target test data package.

[0007] According to a second aspect of this application, a test data packet generation apparatus is provided, the apparatus comprising:

[0008] Response module: used to respond to the test data packet generation command and determine the corresponding preset data configuration information; wherein, the preset data configuration information describes the composition ratio of the data to be generated under different data dimensions in the test data packet to be generated, each data dimension indicates different data size information, and the data size information is used to limit the size of the data to be generated under the data dimension;

[0009] Generation module: used to generate multiple test data according to the preset data configuration information to obtain the target test data package.

[0010] According to a third aspect of this application, an electronic device is provided, the electronic device including a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the test data packet generation method as described in the first aspect.

[0011] According to a fourth aspect of this application, a computer-readable storage medium is provided, the storage medium storing at least one instruction or at least one program segment, the at least one instruction or the at least one program segment being loaded and executed by a processor to implement the test data packet generation method as described in the first aspect.

[0012] According to a fifth aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the test data packet generation method as described in the first aspect.

[0013] This application provides a test data packet generation method, apparatus, electronic device, and storage medium, which have the following technical advantages:

[0014] This application determines corresponding preset data configuration information in response to a test data package generation instruction; then, it generates multiple test data sets based on the preset data configuration information to obtain a target test data package. The preset data configuration information describes the composition ratio of the data to be generated under different data dimensions in the test data package to be generated. Each data dimension indicates different data size information, which is used to limit the size of the data to be generated under each data dimension. This application utilizes preset data configuration information to generate test data packages with rich compositional dimensions. The preset data configuration information standardizes the composition ratio and data size (length) of the test data package to be generated based on the data dimensions. This results in diverse and varied test data formats within the generated test data package, improving the realism of the test data package and enhancing the testing effect. Attached Figure Description

[0015] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 This is a schematic diagram of an application environment provided in an embodiment of this application;

[0017] Figure 2 This is a flowchart illustrating a test data packet generation method provided in an embodiment of this application;

[0018] Figure 3 This is a flowchart illustrating a process for generating multiple test data based on preset data configuration information, as provided in an embodiment of this application.

[0019] Figure 4 This is also a flowchart illustrating a process for generating multiple test data based on preset data configuration information, as provided in this application embodiment.

[0020] Figure 5 This is a schematic diagram of the architecture for generating test data packets provided in an embodiment of this application;

[0021] Figure 6 This is a flowchart illustrating a method for parsing string information provided in an embodiment of this application;

[0022] Figure 7 This is a block diagram of a test data packet generation device provided in an embodiment of this application;

[0023] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0024] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0025] It should be noted that the terms "comprising" and "having" and any variations thereof in the specification, claims and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such processes, methods, products or devices.

[0026] Please see Figure 1 , Figure 1This is a schematic diagram of an application environment provided in an embodiment of this application. This application environment may include a client 10 and a server 20, which can be directly or indirectly connected via wired or wireless communication. Related objects (such as users or simulators) can send test data packet generation instructions to the server 20 through the client 10. The server 20 receives the test data packet generation instructions, determines the corresponding preset data configuration information, and then generates multiple test data according to the preset data configuration information to obtain the target test data packet. It should be noted that... Figure 1 This is just one example.

[0027] Client 10 can be a physical device such as a smartphone, computer (e.g., desktop computer, tablet, laptop), augmented reality (AR) / virtual reality (VR) device, digital assistant, smart voice interaction device (e.g., smart speaker), smart wearable device, smart home appliance, in-vehicle terminal, etc., or it can be software running on the physical device, such as a computer program. The operating system corresponding to the client can be Android, iOS (a mobile operating system developed by Apple), Linux (an operating system), Microsoft Windows, etc.

[0028] The server-side component 20 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The server may include network communication units, processors, and memory, etc. The server-side component can provide backend services to the corresponding clients.

[0029] In practical applications, the target test data package generated using the embodiments of this application can be used to optimize related internet products. Related internet products can include cloud technology products, artificial intelligence products, smart transportation products, assisted driving products, live streaming products, online office products, e-commerce products, game products, local life products, instant messaging products, social products, etc. Taking game products as an example, the game types provided by the game application can be action (ACT), adventure, role-playing game (RPG), narrative, strategy, first-person shooter (FPS), fighting, puzzle, arcade, science fiction, open world, survival, etc. It should be noted that for test data that is associated with user information, when the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.

[0030] The following describes a specific embodiment of a test data packet generation method according to this application. Figure 2 This is a flowchart illustrating a test data packet generation method provided in an embodiment of this application. This application provides the operational steps of the method described in the embodiment or flowchart, but based on conventional or non-inventive methods, more or fewer operational steps may be included. The order of steps listed in the embodiment is merely one possible execution order among many and does not represent the only possible execution order. In actual system or product execution, the method can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment) as shown in the embodiment or drawings. Specifically, as... Figure 2 As shown, the method may include:

[0031] S201: In response to the test data packet generation instruction, determine the corresponding preset data configuration information; wherein, the preset data configuration information describes the composition ratio of the data to be generated under different data dimensions in the test data packet to be generated, each data dimension indicates different data size information, and the data size information is used to limit the size of the data to be generated under the data dimension;

[0032] In this embodiment, in response to a test data packet generation instruction, the client or server determines corresponding preset data configuration information. It can be understood that the client and server are the constituent objects of the test data packet generation system. The client can independently execute steps S201-S202, and the server can also independently execute steps S201-S202. The client and server can also interact to execute steps S201-S205. The test data packet generation instruction can be generated by a related object (such as a user or simulator) triggering a specified interactive control on the interactive interface, which can be provided by the client or server.

[0033] The test data packet generation command can carry business information, allowing the client or server to determine the corresponding preset data configuration information. Business information can indicate a business or a type of business, such as mobile game business, PC game business, or game business; it can indicate an internet product, such as game product A or game product B; or it can indicate a functional module within an internet product, such as the live streaming module in game product A. Multiple associations between business information and multiple preset data configurations can be pre-established, improving the convenience and efficiency of determining the corresponding preset data configuration information based on the business information. The associations between business information and preset data configurations can also be flexibly adjusted as needed. For example, regarding the existing association 1: Business Information 1 - Preset Data Configuration Information 2, it is possible to replace preset data configuration information 2 with the existing preset data configuration information 1; or replace preset data configuration information 2 with newly added preset data configuration information 3; or add an association between business information 1 and preset data configuration information 4, setting the usage priority and scope of preset data configuration information 2 and preset data configuration information 4; or make relevant adjustments to preset data configuration information 2; or delete association 1, etc.

[0034] The preset data configuration information specifies the composition ratio and data size (length) of the test data package to be generated based on data dimensions. It can be understood that a test data package to be generated is composed of data to be generated under different data dimensions, each data dimension corresponding to a certain composition ratio, and each data dimension meeting certain data size requirements. For example, a test data package to be generated consists of data to be generated under four data dimensions. The data size (length) and composition ratio of these four data dimensions are as follows: the first data dimension corresponds to a data size range of 100KB to 300KB and a composition ratio of 1%; the second data dimension corresponds to a data size range of 30KB to 100KB and a composition ratio of 4%; the third data dimension corresponds to a data size range of 10KB to 30KB and a composition ratio of 8%; and the fourth data dimension corresponds to a data size range of 100KB to 1KB and a composition ratio of 87%. It should be noted that: 1) If the boundaries of the data size ranges corresponding to the two data dimensions (e.g., the first data dimension and the second data dimension) indicate the same number (e.g., 100), then the boundary of the specified data size range corresponding to one data dimension (corresponding to that number) is closed, and the boundary of the specified data size range corresponding to the other data dimension (corresponding to that number) is open. 2) Combining with 1) above, it can be seen that the data size ranges corresponding to different data dimensions can be continuous or discrete.

[0035] S202: Generate multiple test data according to the preset data configuration information to obtain the target test data package.

[0036] In this embodiment, the client or server generates multiple test data sets according to preset data configuration information to obtain a target test data packet. When generating the multiple test data sets constituting the target test data packet, the preset data configuration information can be referenced to ensure that the generated target test data packet is a test data packet with a mixture of different data sizes (lengths). The generation of multiple test data sets can be performed in parallel or sequentially.

[0037] In one exemplary implementation, such as Figure 3 As shown, the generation of multiple test data based on the preset data configuration information includes:

[0038] S301: Generate a first random number indicating the proportion information based on a first preset rule; wherein, the first preset rule is used to limit the multiple first random numbers to be generated to match the proportion distribution; wherein, the proportion distribution indicates the proportion of the data to be generated under different data dimensions in the test data packet to be generated;

[0039] S302: Determine the corresponding target data dimension based on the first random number; wherein the composition ratio corresponding to the target data dimension matches the ratio information indicated by the first random number;

[0040] S303: Generate a second random number indicating the data size information based on the data size information corresponding to the target data dimension;

[0041] S304: Extract data that meets the requirements of the second random number from a preset data source to obtain the test data;

[0042] S305: When the generated plurality of first random numbers match the composition ratio distribution, stop repeating the above steps of generating the first random numbers indicating the ratio information to obtain the test data, and obtain the plurality of test data based on the obtained plurality of test data.

[0043] Referring to the example in step S201 above, the first preset rule is used to limit the multiple first random numbers to be generated to match the proportion distribution. The first random numbers indicate proportion information, that is, the multiple first random numbers are composed of 1% of the first type of first random numbers, 4% of the second type of first random numbers, 8% of the third type of first random numbers, and 87% of the fourth type of first random numbers. The proportion information indicated by the first type of first random numbers can be 1% and other numbers within its representation range, the proportion information indicated by the second type of first random numbers can be 4% and other numbers within its representation range, the proportion information indicated by the third type of first random numbers can be 8% and other numbers within its representation range, and the proportion information indicated by the fourth type of first random numbers can be 87% and other numbers within its representation range. [0, 1] can be used as the 1% representation range, (1, 4] as the 4% representation range, (4, 8] as the 8% representation range, and (8, 100] as the 87% representation range; [0, 1] can be used as the 1% representation range, (1, 5] as the 4% representation range, (5, 13] as the 8% representation range, and (13, 100] as the 87% representation range. Of course, the division of the representation range is not limited to these.

[0044] Generating a first random number based on a first preset rule ensures that the specific values ​​of multiple first random numbers fall within a composition ratio range (e.g., [0, 100]), and that the specific values ​​of multiple first random numbers are generated with probabilities according to the indicated composition ratio. The specific value of any one of the first random numbers is either a value that hits a specific composition ratio (corresponding to the composition ratio of the data to be generated under different data dimensions in the test data package to be generated) or another number within the representation range of that composition ratio.

[0045] Taking a first random number of 2 as an example, the corresponding target data dimension, the second data dimension, can be determined based on the first random number. The data size information corresponding to the second data dimension is a data size range of 30KB to 100KB, and a second random number indicating the data size information can be generated accordingly. If the second random number is 50, then data that meets the 50KB requirement is extracted from the preset data source to obtain the test data.

[0046] Steps S301-S304 above describe the process of generating one set of test data. Repeating this process allows the generation of multiple sets of test data to obtain the target test data package. Specifically, when the generated multiple first random numbers match the composition ratio distribution, the process of repeating the steps of generating the first random numbers indicating the ratio information until the test data is obtained is stopped, and the multiple test data are obtained based on the multiple test data already obtained.

[0047] A first preset rule is used to limit the value range of a first random number and the probability of its generation for different composition ratios. Then, the first random number is used to match a specific data dimension, and a second random number indicating the data size is generated based on the corresponding data size. Finally, test data is extracted from a preset data source based on the second random number. With the help of the first preset rule, the generation of the test data package that meets the preset data configuration information can be automated. The introduction of the second random number can enrich the size (length) differences of various test data points locally, thereby improving the realism of the target test data package.

[0048] In practical applications, 1) multiple first random numbers can be generated using a first preset rule so that the generated multiple first random numbers match the proportional distribution. Based on this, steps S301-S304 can be executed in parallel for each first random number.

[0049] 2) The first random number can be used not only to determine the target data dimension, but also, together with the composition ratio, to determine the corresponding deviation degree. This deviation degree can be used to adjust the data size range referenced in generating the second random number. For example, the deviation degree a = 25-14 = 50% between the first random number 2 and the representation number 4 of the composition ratio of the target data dimension can be determined by combining the relevant representation range (e.g., (1,5]). Then, the data size range of 30KB to 100KB can be adjusted using the deviation degree a. The left half of 30KB to 100KB can be taken: 30KB to 65KB. Based on this, a second random number indicating the data size information can be generated. The second random number directly affects the size (length) of the test data. Combining the information of the first random number can further improve the size (length) difference of the test data.

[0050] The preset data source used when generating test data will be introduced from two aspects below:

[0051] A) Preset data size of the data source:

[0052] The client or server can determine the maximum number of the indicated data size based on the preset data configuration information; then, it can generate data that meets the requirement of the maximum number to obtain the preset data source. Referring to the example in step S201 above, the maximum number of the indicated data size, 300, can be determined based on 300K, and then a preset data source with a data size of 300K can be generated. Since the test data is obtained by extracting data that meets the requirements of the second random number from the preset data source, and the second random number originates from the data size information corresponding to the target data dimension, the preset data source that meets the requirement of the maximum number can also meet the requirements of any relevant second random number. The preset data source can be prepared in advance and copied based on the second random number when generating test data, which can ensure the efficiency and stability of test data generation. It avoids the inefficiency and performance loss caused by assigning values ​​based on the second random number to generate test data.

[0053] In practical applications, when initializing the preset data configuration information, the maximum number indicating the data size can be determined, and then a string of the maximum length (corresponding to the maximum number) can be generated as the preset data source. Simultaneously, the storage address (e.g., a pointer) of the preset data source can be saved. The preset data source can be stored in memory, cache, or other locations. When generating test data, a string indicating the length of a second random number can be copied based on the preset data source.

[0054] B) Selection of preset data source:

[0055] Considering the diversity of data formats in real-world business scenarios, which can manifest not only in data size but also in data type and source, each data dimension can be associated with a corresponding data type and source. This improves the granularity of test data simulation. The data types and sources mentioned here, when applied to generating test data, can be represented as follows: determining the preset data source from multiple candidate data sources based on the target data dimension; wherein the multiple candidate data sources correspond to different data types or data sources.

[0056] Data type refers to the format of the data, such as long integer, short integer, single-precision floating-point, or double-precision floating-point. Data source refers to the origin of the data, which can indicate finer-grained business segmentation, such as business version (e.g., V1.0, V2.0) or business platform (e.g., mobile, PC). Different data dimensions can be associated with corresponding data types and / or data sources. Based on a known target data dimension, a matching preset data source can be determined from multiple candidate data sources according to the data type and / or data source associated with the target data dimension. The data type and / or data source indicated by the preset data source matches the data type and / or data source associated with the target data dimension.

[0057] A maximum number can be determined based on the data size information indicated by the data dimensions. Then, data that meets the requirement of the maximum number can be generated using the data type and / or data source associated with the data dimensions to obtain a candidate data source. Thus, multiple candidate data sources corresponding to multiple data dimensions can be obtained.

[0058] In one exemplary implementation, such as Figure 4 As shown, the generation of multiple test data based on the preset data configuration information includes:

[0059] S401: When the preset data configuration information is structure class information, the plurality of test data are generated based on the structure class information; wherein, the structure class information indicates a structure that corresponds one-to-one with the data dimension, and each structure carries corresponding proportion information and data size range;

[0060] S402: When the preset data configuration information is string information, parse the string information to obtain the structure information, and generate the multiple test data based on the structure information.

[0061] The type of preset data configuration information can be a structure type, and correspondingly, the preset data configuration information is structure class information. The type of preset data configuration information can also be a string type, and correspondingly, the preset data configuration information is string class information. Structure class information uses structures to represent information about relevant data dimensions. Leveraging the standardization and readability of structures can improve the efficiency of generating multiple test data based on the preset data configuration information. Therefore, when generating multiple test data based on the preset data configuration information, multiple test data can be generated directly based on the structure class information; alternatively, the string class information can be parsed to obtain the structure class information, and then multiple test data can be generated based on the structure class information.

[0062] Compared to structure-based information, string-based information corresponds to smaller data sets, making it easier to store and maintain, especially for large amounts of pre-defined data configuration information. The strings corresponding to string-based information can be obtained by sorting feature characters based on data dimensions. These feature characters indicate the composition ratio and data size corresponding to each data dimension. For example, the string "rules" consists of feature characters 1-10, where feature character i indicates [min_len(i), max_len(i), weight(i)], where i takes values ​​from 1 to 10, min_len(i) indicates the minimum data size, max_len(i) indicates the maximum data size, and weight(i) indicates the composition ratio. Compared to structure-based information, string-based information is easier to edit and maintain. In practical applications, string-based information can be edited and maintained. When generating test data packages, string-based information can be parsed to obtain structure-based information, and then multiple test data sets can be generated based on this structure-based information.

[0063] Furthermore, the generation of the plurality of test data based on the structure class information may include the following steps: First, generating a first random number indicating proportion information based on a first preset rule; wherein, the first preset rule is used to limit the plurality of first random numbers to be generated to match the proportion distribution; wherein, the proportion distribution is obtained based on the proportion information carried by each structure; then, determining the corresponding target structure according to the first random number; wherein, the proportion information corresponding to the target structure matches the proportion information indicated by the first random number; next, generating a second random number indicating data size information according to the data size range corresponding to the target structure; then, extracting data that meets the requirements of the second random number from a preset data source to obtain the test data; finally, when the plurality of first random numbers generated match the proportion distribution, stopping the above steps of generating the first random number indicating proportion information to obtain the test data, and obtaining the plurality of test data based on the plurality of test data already obtained.

[0064] Due to the correlation between structure information and preset data configuration information, and the correlation between structure and data dimensions, the process of generating multiple test data based on structure information can be referred to the relevant descriptions in steps S301-S305 above, and will not be repeated here. The introduction to preset data sources can be referred to the aforementioned descriptions, and will not be repeated here.

[0065] See Figure 5 , 6The structure class information can include a structure array m_rules[m_rules_size]. The structure array includes multiple structures m_rules[i]. Each structure corresponds to a data dimension. Each structure carries the corresponding proportion information weight(i). Each structure carries the corresponding data size range min_len(i) and max_len(i).

[0066] The first random number w is generated based on the first preset rule, which ensures that the specific values ​​of multiple first random numbers fall within a composition ratio range m_rules_bound, and that the specific values ​​of multiple first random numbers are generated with probabilities according to the indicated composition ratio. The first random number w is generated within the composition ratio range m_rules_bound; the structure array m_rules[m_rules_size] is traversed, and the first random number w is matched with m_rules[i].weight(i) to determine the target structure m_rules[n]; the data size (length) range range is determined according to m_rules[n] = m_rules[n].max_len(n) – m_rules[n].min_len(n); a second random number m is generated within the data size (length) range range; a string of length m is extracted and copied from the longest string m_random_message, which serves as the preset data source. This string is the test data generated this time that meets the requirements of the preset data configuration information. Where m_rules_bound is the sum of the weight(i) carried by all structures, and m_rules_size is the number of structures. If m_rules_size is 10, then i takes the values ​​1-10 mentioned above, and n takes the values ​​1-10 mentioned above.

[0067] The process of parsing string class information to obtain structure class information is described below: a) Read the strings corresponding to the string class information sequentially according to the second preset rule; wherein, the second preset rule is used to limit the characters to be read each time to be corresponding to the data dimension, the string is obtained by sorting the feature characters in units of the data dimension, and the feature characters indicate the composition ratio and data size corresponding to the data dimension; b) Construct the structure based on the currently read characters; c) Repeat the above steps of sequentially reading the strings corresponding to the string class information to constructing the structure until the reading of the string is completed or the current reading number is greater than the preset number of data dimensions, and the structure class information is obtained based on the multiple constructed structures.

[0068] refer to Figure 6The string "rules" is composed of characteristic characters 1-10. The characteristic character i indicates [min_len(i), max_len(i), weight(i)], where i takes values ​​from 1 to 10. min_len(i) indicates the minimum size of the data, max_len(i) indicates the maximum size of the data, and weight(i) indicates the proportion of the data.

[0069] The `Init` method of the `MessageBuilder` class can be used to parse the string `rules` to obtain an array of `MessageRule` structures, `m_rules[m_rules_size]`. Here, `m_rules_size` represents the number of structures, which is also the number of data dimensions.

[0070] Specifically: 1) Initialize the key variables m_rulses_size, m_rules_bound, final_size, min, max, weight, allow_size, and offset. m_rulses_size indicates the total number of structures determined by the currently read characters; m_rules_bound indicates the sum of proportions determined by the currently read characters; final_size indicates the maximum size of the indicated data determined by the currently read characters; min indicates the minimum number of current structures (corresponding to data size) determined by the currently read characters; max indicates the maximum number of current structures (corresponding to data size) determined by the currently read characters; weight indicates the proportion of the current structures determined by the currently read characters; allow_size indicates the preset upper limit of the number of structures (data dimensions) (e.g., 10); and offset indicates the offset of the currently read character relative to the string "rules". 2) When m_rules_size is less than allow_size and offset does not indicate the end character of the string "rules", proceed to the loop in steps 3)-7) below. 3) Perform a validity check on the values ​​of min, max, and weight of the currently read characters. 4) Add the value of weight of the currently read character to the value of m_rules_bound. 5) Assign the values ​​of min, max, and weight of the currently read characters, along with the updated value of m_rules_bound from step 4), to the MessageRule structure array m_rules[m_rules_size], and increment m_rules_size. 6) Compare the value of max of the currently read character with the value of final_size. If it is greater, assign it to final_size to update it. 7) In the string rules, search for the position of the last character (`]`) starting from the position of the currently read character and assign it to offset. Check if offset is the last character; if so, exit the loop; otherwise, continue the loop. 8) After the loop ends, use a character array c to assign values ​​to a random character array m_random_message of length final_size to obtain the preset data source. Among them, m_random_message can point to a private member character pointer of the MessageBuilder class.

[0071] Therefore, the structure class information can include a structure array m_rules[m_rules_size], which contains multiple structures m_rules[i]. Each structure corresponds to a data dimension, and each structure carries corresponding scale information weight(i) and corresponding reference scale information m_rules_bound(i). Figure 5 In the weight_bound array, each structure carries a corresponding data size range min_len(i) and max_len(i). Then, within the proportional range m_rules_bound (the sum of the proportional information weight(i) carried by all structures), a first random number w is generated. The structure array m_rules[m_rules_size] is traversed, and the first random number w is matched with m_rules[i].m_rules_bound(i) to determine the target structure m_rules[n].

[0072] In practical applications, the test data packet generation scheme provided in this application can be used for testing related to service mesh (which can serve as an infrastructure layer for inter-service communication) products in game businesses. For example, it has implemented communication data testing for dozens of service mesh products in game businesses. A specific service mesh product can be a name service communication mesh, which provides easy-to-use, high-performance, and highly reliable communication, service-oriented operation, name communication, and diverse service governance capabilities tailored to the characteristics of game development and operational needs. Correspondingly, the communication data involved in the communication data test can be business data transmitted between the sending and receiving ends of a business client using this specific service mesh product. The communication data involved in the communication data test can originate from a large-scale communication cluster (a cluster consisting of tens of thousands of nodes, where each node can communicate with others).

[0073] The following is an example of a game service mesh communication scenario. It is necessary to test random communication data packets with an average communication data packet size of about 6.7KB. The random communication data packets contain packets of different sizes from four data dimensions.

[0074] The communication data packet rules are configured as follows:

[0075] [100000,300000,1][30000,100000,4][10000,30000,8][100,1000,87] indicates that the random communication data packets in this test process are composed of a mixture of large and small packets in four data dimensions. Among them, random super-large data packets in the range of 100KB to 300KB account for 1%, random large data packets in the range of 30KB to 100KB account for 4%, random ordinary data packets in the range of 10KB to 30KB account for 8%, and random small packets in the range of 100KB to 1KB account for 87%.

[0076] Based on the communication data packet rule configuration above, the test stub program can automatically generate data packets with four data dimensions. These data packets are sent and received in a mixed manner according to the configured ratio, resulting in an average communication data packet size of 6726 bytes, which meets the needs of business testing scenarios. The data in the communication data packet, as the message body, can be combined with a fixed-length message header to form a message for transmission.

[0077] In addition, the communication data packet rules are configured as string-type information. The test stub program can call the MessageBuilder's Init method to parse it to obtain structure-type information. During the parsing process, a random character array m_random_message indicating the maximum number of data sizes can be generated. This avoids having to call the data assignment logic again every time random data is generated. It can reduce the CPU usage from 90% to 30% under the same QPS, thereby greatly improving the effect of generating random data.

[0078] As can be seen from the technical solutions provided in the embodiments of this application above, the embodiments of this application determine the corresponding preset data configuration information in response to the test data packet generation instruction; then, multiple test data are generated according to the preset data configuration information to obtain the target test data packet. The preset data configuration information describes the composition ratio of the data to be generated under different data dimensions in the test data packet to be generated, and each data dimension indicates different data size information, which is used to limit the size of the data to be generated under each data dimension. This application utilizes preset data configuration information to generate test data packets with rich compositional dimensions. The preset data configuration information standardizes the composition ratio and data size (length) of the test data packet to be generated based on the data dimensions. This results in diverse and varied test data formats in the generated test data packet, which can improve the realism of the test data packet and enhance the testing effect.

[0079] This application also provides a test data packet generation device, such as... Figure 7 As shown, the test data packet generation device 70 includes:

[0080] Response module 701: used to respond to the test data packet generation instruction and determine the corresponding preset data configuration information; wherein, the preset data configuration information describes the composition ratio of the data to be generated under different data dimensions in the test data packet to be generated, each data dimension indicates different data size information, and the data size information is used to limit the size of the data to be generated under the data dimension;

[0081] Generation module 702: Used to generate multiple test data according to the preset data configuration information to obtain the target test data package.

[0082] It should be noted that the apparatus and method embodiments described in the device embodiments are based on the same inventive concept.

[0083] This application provides an electronic device including a processor and a memory. The memory stores at least one instruction or at least one program segment, which is loaded and executed by the processor to implement the test data packet generation method provided in the above method embodiments.

[0084] Furthermore, Figure 8 A schematic diagram of the hardware structure of an electronic device for implementing the test data packet generation method provided in the embodiments of this application is shown. The electronic device may participate in or include the test data packet generation apparatus provided in the embodiments of this application. Figure 8 As shown, the electronic device 100 may include one or more processors 1002 (shown as 1002a, 1002b, ..., 1002n in the figure) (processor 1002 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 1004 for storing data, and a transmission device 1006 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 8 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device 100 may also include... Figure 8 The more or fewer components shown, or having the same Figure 8 The different configurations shown.

[0085] It should be noted that the aforementioned one or more processors 1002 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be wholly or partially integrated into any other element within the electronic device 100 (or mobile device). As involved in the embodiments of this application, the data processing circuit serves as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0086] The memory 1004 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the test data packet generation method described in this embodiment. The processor 1002 executes various functional applications and data processing by running the software programs and modules stored in the memory 1004, thereby implementing the aforementioned test data packet generation method. The memory 1004 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1004 may further include memory remotely located relative to the processor 1002, and these remote memories can be connected to the electronic device 100 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0087] The transmission device 1006 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the electronic device 100. In one example, the transmission device 1006 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In one embodiment, the transmission device 1006 may be a radio frequency (RF) module for wireless communication with the Internet.

[0088] The display can be, for example, a touchscreen liquid crystal display (LCD) that allows a user to interact with the user interface of the electronic device 100 (or mobile device).

[0089] Embodiments of this application also provide a computer-readable storage medium, which can be disposed in an electronic device to store at least one instruction or at least one program related to implementing a test data packet generation method in the method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement the test data packet generation method provided in the above method embodiment.

[0090] Optionally, in this embodiment, the storage medium may be located in at least one of the multiple network servers in a computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0091] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, the above description focuses on specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired results. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired results. In some implementations, multitasking and parallel processing are also possible or may be advantageous.

[0092] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and electronic device embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0093] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0094] The above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for generating test data packets, characterized in that, The method includes: In response to the received test data packet generation instruction, the corresponding preset data configuration information is determined; the preset data configuration information describes the composition ratio of the data to be generated under different data dimensions in the test data packet to be generated, and each data dimension indicates different data size information, which is used to limit the size of the data to be generated under the data dimension; Multiple test data are generated according to the preset data configuration information to obtain a target test data package: a first random number indicating proportion information is generated based on a first preset rule; the first preset rule is used to limit the multiple first random numbers to be generated to match the proportion distribution, the proportion distribution indicating the proportion of the data to be generated under different data dimensions in the test data package to be generated; The target data dimension is determined based on the first random number; the composition ratio corresponding to the target data dimension matches the ratio information indicated by the first random number. A second random number indicating the data size information is generated based on the data size information corresponding to the target data dimension; The test data is obtained by extracting data that meets the requirements of the second random number from a preset data source; When the generated plurality of first random numbers match the composition ratio distribution, the process of repeating the above steps of generating first random numbers indicating ratio information to obtain the test data is stopped, and the plurality of test data are obtained based on the obtained plurality of test data.

2. The method according to claim 1, characterized in that, The method further includes: The maximum number of indication data sizes is determined based on the preset data configuration information; Generate data that meets the requirement of the maximum number to obtain the preset data source.

3. The method according to claim 1, characterized in that, Before extracting data that meets the requirements of the second random number from a preset data source to obtain the test data, the method further includes: The preset data source is determined from multiple candidate data sources based on the target data dimension; wherein the multiple candidate data sources correspond to different data types or data sources.

4. The method according to claim 1, characterized in that, The generation of multiple test data based on the preset data configuration information includes: When the preset data configuration information is structure class information, the multiple test data are generated based on the structure class information; wherein, the structure class information indicates a structure that corresponds one-to-one with the data dimension, and each structure carries corresponding proportion information and data size range; When the preset data configuration information is string information, the string information is parsed to obtain the structure information, and the multiple test data are generated based on the structure information.

5. The method according to claim 4, characterized in that, The generation of the multiple test data based on the structure class information includes: A first random number indicating the proportion information is generated based on a first preset rule; wherein, the first preset rule is used to limit the multiple first random numbers to be generated to match the proportion distribution; wherein, the proportion distribution is obtained based on the proportion information carried by each of the structures; The corresponding target structure is determined based on the first random number; wherein the proportion information corresponding to the target structure matches the proportion information indicated by the first random number. A second random number indicating the data size information is generated based on the data size range corresponding to the target structure; The test data is obtained by extracting data that meets the requirements of the second random number from a preset data source; When the generated plurality of first random numbers match the composition ratio distribution, the process of repeating the above steps of generating first random numbers indicating ratio information to obtain the test data is stopped, and the plurality of test data are obtained based on the obtained plurality of test data.

6. The method according to claim 4, characterized in that, The process of parsing the string class information to obtain the structure class information includes: The strings corresponding to the string class information are read sequentially according to the second preset rule; wherein, the second preset rule is used to limit the characters to be read each time to be corresponding to the data dimension, the strings are obtained by sorting the feature characters in units of the data dimension, and the feature characters indicate the composition ratio and data size corresponding to the data dimension; The structure is constructed based on the currently read characters; Repeat the above steps of sequentially reading the strings corresponding to the string class information to construct the structure until the reading of the string is completed or the current number of readings exceeds the preset number of data dimensions, and the structure class information is obtained based on the multiple constructed structures.

7. A test data packet generation apparatus, characterized in that, The device includes: Response module: used to respond to the test data packet generation command and determine the corresponding preset data configuration information; the preset data configuration information describes the composition ratio of the data to be generated under different data dimensions in the test data packet to be generated, each data dimension indicates different data size information, and the data size information is used to limit the size of the data to be generated under the data dimension; Generation module: used to generate multiple test data according to the preset data configuration information to obtain a target test data package: generate a first random number indicating the proportion information based on a first preset rule; the first preset rule is used to limit the multiple first random numbers to be generated to match the proportion distribution, the proportion distribution indicating the proportion of the data to be generated under different data dimensions in the test data package to be generated; The target data dimension is determined based on the first random number; the composition ratio corresponding to the target data dimension matches the ratio information indicated by the first random number. A second random number indicating the data size information is generated based on the data size information corresponding to the target data dimension; The test data is obtained by extracting data that meets the requirements of the second random number from a preset data source; When the generated plurality of first random numbers match the composition ratio distribution, the process of repeating the above steps of generating first random numbers indicating ratio information to obtain the test data is stopped, and the plurality of test data are obtained based on the obtained plurality of test data.

8. The apparatus according to claim 7, characterized in that, The device is also used for: The maximum number of indication data sizes is determined based on the preset data configuration information; Generate data that meets the requirement of the maximum number to obtain the preset data source.

9. The apparatus according to claim 7, characterized in that, The device is also used for: Before extracting data that meets the requirements of the second random number from the preset data source to obtain the test data, the preset data source is determined from multiple candidate data sources according to the target data dimension; wherein, the multiple candidate data sources correspond to different data types or data sources.

10. The apparatus according to claim 7, characterized in that, The generation module is also used for: When the preset data configuration information is structure class information, the multiple test data are generated based on the structure class information; wherein, the structure class information indicates a structure that corresponds one-to-one with the data dimension, and each structure carries corresponding proportion information and data size range; When the preset data configuration information is string information, the string information is parsed to obtain the structure information, and the multiple test data are generated based on the structure information.

11. The apparatus according to claim 10, characterized in that, The generation of the multiple test data based on the structure class information includes: A first random number indicating proportion information is generated based on a first preset rule; wherein, the first preset rule is used to limit the multiple first random numbers to be generated to match the proportion distribution; wherein, the proportion distribution is obtained based on the proportion information carried by each of the structures; The corresponding target structure is determined based on the first random number; wherein the proportion information corresponding to the target structure matches the proportion information indicated by the first random number. A second random number indicating the data size information is generated based on the data size range corresponding to the target structure; The test data is obtained by extracting data that meets the requirements of the second random number from a preset data source; When the generated plurality of first random numbers match the composition ratio distribution, the process of generating the first random numbers indicating the ratio information to obtain the test data is stopped, and the plurality of test data are obtained based on the obtained plurality of test data.

12. The apparatus according to claim 10, characterized in that, The process of parsing the string class information to obtain the structure class information includes: The strings corresponding to the string class information are read sequentially according to the second preset rule; wherein, the second preset rule is used to limit the characters to be read each time to be corresponding to the data dimension, the strings are obtained by sorting the feature characters in units of the data dimension, and the feature characters indicate the composition ratio and data size corresponding to the data dimension; The structure is constructed based on the currently read characters; Repeat the above steps of sequentially reading the strings corresponding to the string class information to construct the structure until the reading of the string is completed or the current number of readings exceeds the preset number of data dimensions, and the structure class information is obtained based on the multiple constructed structures.

13. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the test data packet generation method as described in any one of claims 1-6.

14. A computer-readable storage medium, characterized in that, The storage medium stores at least one instruction or at least one program segment, which is loaded and executed by a processor to implement the test data packet generation method as described in any one of claims 1-6.

15. A computer program product, characterized in that, The computer program product includes at least one instruction or at least one program segment, which is loaded and executed by a processor to implement the test data packet generation method as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Storage reliability test method and server

    CN107562554A

  • Method and device for generating test data, equipment, storage medium and program product

    CN113220593A