Configuration file generation method and framework construction method for middleware testing
By acquiring and processing the characteristic parameters of middleware test scenarios, generating configuration files and integrating them with test case templates, the problem of low efficiency in middleware test case generation is solved, achieving efficient and accurate test case generation and framework construction.
Patent Information
- Application Number
- CN202111245839.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-26
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2041-10-26
AI Technical Summary
In existing technologies, middleware test case generation is inefficient and error-prone, relying on cumbersome manual operations and parameter integration.
By acquiring multiple characteristic parameters that indicate a specified test scenario, processing these parameters using preset rules to generate a configuration file, and integrating it with a preset test case template, a target test framework is constructed, reducing the technical threshold for user participation.
It improves the efficiency and accuracy of test case generation, reduces the error rate of manual operation, and simplifies the configuration file generation process.
Smart Images

Figure CN116028331B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet communication technology, and in particular to a method for generating configuration files and constructing frameworks for middleware testing. Background Technology
[0002] Middleware is a standalone system software or service program that sits between the operating system (OS) and regular applications (Apps) in the system architecture. Its role is to provide a runtime and development environment for applications running at higher layers. Middleware falls under the category of reusable software; during application development, directly calling the functions implemented by middleware can effectively improve development efficiency. Therefore, to ensure the effective implementation of middleware functions, it is necessary to test it.
[0003] Test cases are used when testing middleware. In related technologies, test case generation often relies on tedious manual operations by staff. Staff need to enter parameters on multiple pages; correspondingly, test case generation depends on integrating relevant parameters distributed across different pages. This tedious manual operation increases the likelihood of errors by staff, and simply integrating parameters to obtain test cases is inefficient. Summary of the Invention
[0004] To address the low efficiency issues in generating test cases for middleware testing in existing technologies, this application provides a method for generating configuration files and a framework construction method for middleware testing:
[0005] According to a first aspect of this application, a method for generating configuration files for middleware testing is provided, the method comprising:
[0006] Obtain multiple feature parameters that indicate a specified test scenario; wherein, the multiple feature parameters describe the content of message passing implemented using the specified middleware, the multiple feature parameters and the preset test case template respectively indicate different components of the test cases for the specified middleware, and the specified middleware is the test object under the specified test scenario;
[0007] The multiple feature parameters are processed using preset rules to obtain a configuration file indicating the specified test scenario; wherein, the configuration file is used to merge with the preset test case template to generate test cases for the specified test scenario, the configuration file records the relationship between a specified message and a specified message consumer, and the specified message will be sent to the specified message consumer by the specified middleware.
[0008] According to a second aspect of this application, a framework construction method for middleware testing is provided, the method comprising:
[0009] Obtain the preset test framework;
[0010] Obtain business code; wherein the business code indicates the configuration file generation method for middleware testing as described in the first aspect;
[0011] The preset test framework and the business code are combined to construct a target test framework for middleware testing.
[0012] According to a third aspect of this application, a configuration file generation apparatus for middleware testing is provided, the apparatus comprising:
[0013] Acquisition Module: Used to acquire multiple feature parameters indicating a specified test scenario; wherein, the multiple feature parameters describe the content of message passing using the specified middleware, the multiple feature parameters and the preset test case template respectively indicate the different components of the test cases for the specified middleware, and the specified middleware is the test object under the specified test scenario;
[0014] Processing module: used to process the multiple feature parameters using preset rules to obtain a configuration file indicating the specified test scenario; wherein, the configuration file is used to merge with the preset test case template to generate test cases for the specified test scenario, the configuration file records the relationship between a specified message and a specified message consumer, and the specified message will be sent to the specified message consumer by the specified middleware.
[0015] According to a fourth aspect of this application, a framework building apparatus for middleware testing is provided, characterized in that the apparatus comprises:
[0016] Framework acquisition module: Used to acquire preset test frameworks;
[0017] Code acquisition module: used to acquire business code; wherein, the business code indicates the configuration file generation method for middleware testing as described in the first aspect;
[0018] Fusion Module: Used to fuse the preset test framework and the business code to build a target test framework for middleware testing.
[0019] According to a fifth 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 configuration file generation method for middleware testing as described in the first aspect or the framework construction method for middleware testing as described in the second aspect.
[0020] According to a sixth aspect of this application, a computer-readable storage medium is provided, the storage medium 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 a processor to implement the configuration file generation method for middleware testing as described in the first aspect or the framework construction method for middleware testing as described in the second aspect.
[0021] According to a seventh 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 a configuration file generation method for middleware testing as described in the first aspect or a framework construction method for middleware testing as described in the second aspect.
[0022] This application provides a configuration file generation method and a framework construction method for middleware testing, which have the following technical effects:
[0023] This application obtains multiple feature parameters indicating a specified test scenario, and then processes these parameters using preset rules to obtain a configuration file indicating the specified test scenario. This configuration file can then be integrated with a preset test case template to generate test cases for the specified test scenario. This application standardizes the processing of relevant feature parameters, making the generation of configuration files more standardized and improving the efficiency of integrating them with test case templates to generate test cases. Simultaneously, by integrating the test framework and related business code to construct a target test framework for generating configuration files for middleware testing, the technical barrier for users to participate in configuration file generation can be lowered, improving convenience. Attached Figure Description
[0024] 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.
[0025] Figure 1 This is a schematic diagram of an application environment provided in an embodiment of this application;
[0026] Figure 2 This is a flowchart illustrating a method for generating configuration files for middleware testing, provided in an embodiment of this application.
[0027] Figure 3This is a flowchart illustrating a method for processing multiple feature parameters using preset rules to obtain a configuration file indicating a specified test scenario, as provided in an embodiment of this application.
[0028] Figure 4 This is also a flowchart illustrating a method for generating configuration files for middleware testing provided in an embodiment of this application;
[0029] Figure 5 This is a schematic diagram of the architecture of an automated testing framework provided in an embodiment of this application;
[0030] Figure 6 This is a block diagram of a configuration file generation device for middleware testing provided in an embodiment of this application;
[0031] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0032] 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.
[0033] 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.
[0034] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.
[0035] Configuration Center: A component used for unified management of various configurations.
[0036] Service discovery: A component that provides call addresses for calls between different services based on a registration mechanism.
[0037] IP (Internet Protocol): Internet Protocol.
[0038] LocalIP: Refers to local IP mode, which is a routing mode (method).
[0039] locall5: refers to local L5 mode, which is a routing mode (method).
[0040] CPIP: Refers to Configuration Center IP mode, which is a routing mode (method).
[0041] ccl5: refers to Configuration Center L5 mode, which is a routing mode (method).
[0042] sd: refers to service discovery mode, which is a routing mode (method).
[0043] HTTP (Hypertext Transfer Protocol): Hypertext Transfer Protocol.
[0044] Middle protocol: A protocol based on the middle framework;
[0045] JavaScript: A lightweight, interpreted or just-in-time (JIT) programming language with a function-first approach.
[0046] Relay framework: A JavaScript framework.
[0047] relay protocol: A protocol based on the relay framework.
[0048] FBP protocol: A protocol based on the Fable framework, a pure FBP protocol.
[0049] fbpurl protocol: a protocol based on the fable framework, fable-middle-url protocol.
[0050] fbpmf protocol: a protocol based on the fable framework, fable-middle-pb protocol.
[0051] UDP (User Datagram Protocol).
[0052] TCP (Transmission Control Protocol).
[0053] Risk Agreement: Risk Control Agreement.
[0054] Python: A cross-platform computer programming language. It is a high-level scripting language that combines interpreted, compiled, interactive, and object-oriented features.
[0055] Pytest: A testing framework developed using Python.
[0056] BVT (Build Verification Test): Smoke test.
[0057] Please see Figure 1 , Figure 1 This 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. Workers can send a preset test case template and multiple characteristic parameters indicating a specified test scenario to the server 20 through the client 10. The server 20 processes the multiple characteristic parameters using preset rules to obtain a configuration file indicating the specified test scenario, and merges the preset test case template and the configuration file to generate test cases for the specified test scenario. These test cases can be used to test a specified middleware under the specified test scenario. It should be noted that... Figure 1 This is just one example.
[0058] 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.
[0059] 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.
[0060] In practical applications, the aforementioned middleware can provide support for the use of relevant internet products. These relevant internet products can be payment products, cloud technology products, artificial intelligence products, smart transportation products, assisted driving products, etc.
[0061] The following describes a specific embodiment of a configuration file generation method for middleware testing according to this application. Figure 2 This is a flowchart illustrating a method for generating configuration files for middleware testing, provided in an embodiment of this application. This application provides the operational steps described in the embodiments 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 embodiments is merely one possible execution order among many and does not represent the only possible execution order. In actual system or product execution, the methods shown in the embodiments or drawings can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment). Specifically, as shown... Figure 2 As shown, the method may include:
[0062] S201: Obtain multiple feature parameters indicating a specified test scenario; wherein, the multiple feature parameters describe the content of message passing using the specified middleware, the multiple feature parameters and the preset test case template respectively indicate different components of test cases for the specified middleware, and the specified middleware is the test object under the specified test scenario;
[0063] In this embodiment, the server obtains multiple feature parameters indicating a specified test scenario. A relevant object (such as a user or simulator) can send a configuration file generation request to the server via a client. The server receives the configuration file generation request and extracts the multiple feature parameters indicating the specified test scenario from it. Similarly, a relevant object can send a test case generation request to the server via a client. The server receives the test case generation request and extracts a preset test case template and the multiple feature parameters indicating the specified test scenario from it.
[0064] Test scenarios can be determined based on test requirements, and correspondingly, the characteristic parameters indicating the test scenario can change according to changes in test requirements. Test requirements clarify information such as the test scenario and the object to be tested, which needs to be tested within a specific test scenario. Therefore, the test cases used in the test need to be adapted to the corresponding test scenario. This application provides a configuration file generation scheme for middleware testing, where the object to be tested is a specified middleware, and the specified middleware needs to be tested within a specific test scenario. The type of specified middleware can be a message queue type, a configuration center type, or a service discovery type. Taking a message queue component as an example, the message queue component can provide asynchronous message queue services, the producer (the service that produces messages) provides messages to the message queue component, and the message queue component forwards messages to consumers. Taking a configuration center component as an example, the producer provides configuration information as messages to the configuration center component, and the configuration center component forwards the configuration information as messages to consumers. Taking a service discovery component as an example, the producer provides the service discovery component with a call address as a message, and the service discovery component forwards the call address as messages to consumers.
[0065] Compared to related technologies where staff need to fill in parameters on multiple pages to generate test cases, this application introduces the concepts of test scenarios and test case templates. By deconstructing the structure of test cases, it improves the efficiency and scalability of test case generation. For example, two test cases can use the same test case template, but the difference lies in adapting to different test scenarios. For middleware testing, multiple characteristic parameters indicating the test scenario and the preset test case template respectively indicate different components of the test cases for the specified middleware. The multiple characteristic parameters describe the message transmission content implemented using the specified middleware, which may include at least one of the following: information about the message to be sent, information about the consumer receiving the message, and how to send the message to the consumer. The preset test case template can record content related to message verification, and of course, it can also record content related to message transmission. Message verification can be performed from dimensions such as message quantity and message content. The former verifies whether the number of messages sent by the producer to the middleware is consistent with the number of messages obtained by the consumer from the middleware, in order to determine whether there is any message loss; the latter verifies whether the message content sent by the producer to the middleware is consistent with the message content obtained by the consumer from the middleware, and the message content can be characterized by encryption results.
[0066] In practical applications, the content described in the use case template can be used to supplement any aspects not covered in the above section on "implementing message passing using specified middleware". For example, if the above section on "implementing message passing using specified middleware" does not cover "the information of the message to be sent", the default message can be selected for sending based on the use case template; if the above section on "implementing message passing using specified middleware" does not cover "how to send the message to the consumer", the default sending method can be selected based on the use case template.
[0067] S202: The multiple feature parameters are processed using preset rules to obtain a configuration file indicating the specified test scenario; wherein, the configuration file is used to merge with the preset test case template to generate test cases for the specified test scenario, the configuration file records the relationship between a specified message and a specified message consumer, and the specified message will be sent to the specified message consumer by the specified middleware.
[0068] In this embodiment, the server uses preset rules to process multiple feature parameters to obtain a configuration file indicating a specified test scenario. The configuration file originates from the unified processing result of the relevant feature parameters. The configuration file records the relationship between a specified message and a specified message consumer, and the specified message will be sent to the specified message consumer by a specified middleware. Combining the descriptions of "information of the message to be sent," "information of the consumer receiving the message," and "how to send the message to the consumer" in the aforementioned step S201, it can be understood that the information described by multiple feature parameters can be used to determine the specified message to be sent, determine the specified message consumer that will receive the specified message, and establish the relationship between the specified message and the specified message consumer.
[0069] Compared to related technologies that simply integrate relevant parameters distributed across different pages to generate test cases, this application's embodiment introduces the concepts of test scenarios and test case templates. It employs preset rules to process multiple feature parameters to obtain a configuration file indicating a specified test scenario. The use of preset rules ensures that the configuration file provides relatively unified and standardized test scenario identification information, avoiding the identification difficulties caused by the arbitrariness of simple integration. Simultaneously, the use of preset rules ensures constraints between relevant feature parameters in the configuration file, improving the effectiveness of test case management at the test scenario level.
[0070] In one exemplary implementation, such as Figure 3 As shown, the step of processing the multiple feature parameters using preset rules to obtain the configuration file indicating the specified test scenario includes:
[0071] S301: Based on preset naming rules and the multiple feature parameters, a standard description field indicating the specified test scenario is obtained;
[0072] S302: Use a preset script to read the standard description field and generate a configuration file that indicates the specified test scenario; wherein, the preset naming rule and the preset script belong to the preset rule, and the structure of the preset script is set based on the preset test framework.
[0073] The preset naming rules and preset scripts originate from preset rules. The steps here refine the process of using preset rules to process multiple feature parameters to obtain a configuration file. Preset naming rules provide instructions on how to combine and concatenate feature parameters to obtain the content of standard description fields. For example, key parameters that meet the parameter requirements in the preset naming rules can be selected from multiple feature parameters. Then, these key parameters are concatenated according to the concatenation requirements in the preset naming rules to obtain the standard description fields. Parameter requirements are set for standard description fields. Since there can be at least one standard description field, each standard description field has corresponding parameter requirements. Compared to feature parameters, which focus on the global aspects of test scenarios, standard description fields focus on key local aspects. Different standard description fields can represent key local aspects of test scenarios from different dimensions. This improves the accuracy and effectiveness of identifying test scenarios based on standard description fields.
[0074] The structure of the preset scripts is based on a preset test framework. The preset scripts read standard description fields to generate configuration files that specify test scenarios, thus ensuring the applicability of the configuration files within the preset test framework. Subsequently, test cases can be generated by integrating the configuration files and test case objectives within the preset test framework. The preset test framework can use Pytest.
[0075] Furthermore, the plurality of feature parameters may include a specified mode parameter, a specified environment parameter, a specified protocol parameter, and a specified routing parameter. The specified mode parameter is used to indicate the delivery mode for the specified message, the specified environment parameter is used to indicate the applicable business environment of the generated use case, the specified protocol parameter is used to indicate the communication protocol involved in message delivery, and the specified routing parameter is used to indicate the routing method involved in message delivery.
[0076] Accordingly, based on the preset naming rules, the specified mode parameters, the specified environment parameters, the specified protocol parameters, and the specified routing parameters, the topic field, service field, and address field can be obtained, and the topic field, service field, and address field can be used as standard description fields to indicate the specified test scenario.
[0077] Based on the foregoing, the subject field, service field, and address field are each a standard description field, while the specified mode parameter, specified environment parameter, specified protocol parameter, and specified routing parameter serve as candidate parameters for constructing these three standard description fields. By combining and concatenating the specified mode parameter, specified environment parameter, specified protocol parameter, and specified routing parameter, these parameters can be fully utilized to obtain standard identification fields with more representative meaning. For feature parameters indicating different test scenarios, if corresponding standard description fields are generated according to the same naming rule to construct a set, the test scenarios indicated by each standard description field in the set can be easily identified based on the unified standard description fields. Of course, multiple feature parameters can also include parameters indicating extended descriptions, which can also be included in the category of candidate parameters. Among them, extended descriptions can indicate whether to send the specified message immediately, or if to delay sending the specified message, for how long.
[0078] The obtained topic field can be used to represent a specified message, the obtained service field can be used to indicate the message delivery path, and the obtained address field can be used to indicate the node addresses involved in the message delivery path. The topic field determines which messages need to be forwarded by the middleware in the corresponding test scenario, or which messages the middleware needs to receive before sending. In practical applications, the service and address fields determine the message recipient in the corresponding test scenario, and how the middleware needs to forward the message to the consumer in that scenario. Taking a specified middleware as a message queue component as an example, a subscription relationship can be uniquely determined by the representation of the specified message by the topic field and the representation of the specified message consumer by the service and address fields.
[0079] Furthermore, when the specified middleware is a message queue component, the specified mode parameter indicates any one of point-to-point mode and publish-subscribe mode; the specified environment parameter indicates any one of development environment, first type of test environment (e.g., self-test environment), and second type of test environment (e.g., BVT environment); the specified protocol parameter indicates any one of Hypertext Transfer Protocol, Middle Protocol, Relay Protocol, pure FBP Protocol, first type of FBP extended protocol (e.g., FBPURL Protocol), second type of FBP extended protocol (e.g., FBPMF Protocol), User Datagram Protocol, Transmission Control Protocol, and risk control protocol; the specified routing parameter indicates any one of local IP mode, local L5 mode, configuration center IP mode, configuration center L5 mode, and service discovery mode. This application provides a wide range of parameter candidates, thereby indicating a richer range of test scenarios and improving the adaptability of the generated standard description fields, configuration files, and test cases to a wider range of test scenarios.
[0080] The configuration file specifying the test scenario can be used to integrate with preset test case templates to generate test cases for the specified test scenario. The following will introduce the generation and application of test cases:
[0081] 1) Machine A generates configuration files, test cases, and executes the test cases:
[0082] If the server is treated as machine device A, then the server integrates preset test case templates and configuration files to generate test cases for the specified test scenario, and the server executes the test cases.
[0083] When the specified middleware is a message queue component and the specified mode parameter indicates a publish-subscribe mode, the server side includes a module that provides background services for message delivery. During the execution of test cases on the server side, the configuration file can be loaded into memory to start the module, and the module can be used to deliver specified messages from the specified middleware to the specified message consumer.
[0084] 2) Machine A generates configuration files and test cases, and machine B executes the test cases:
[0085] If the server is designated as machine A and the first machine is designated as machine B, then the server can generate test cases (the first test case) for the specified test scenario by integrating the preset test case template and configuration file.
[0086] After determining that the first test case will be executed by the first machine device, the server can send the first test case to the first machine device so that the first machine device can execute the first test case.
[0087] When the specified middleware is a message queue component and the specified mode parameter indicates a publish-subscribe mode, the first machine device includes a module that provides background services for message delivery. During the execution of the first test case on the first machine device, the configuration file can be loaded into memory to enable the module to start, and the module can be used to deliver specified messages from the specified middleware to the specified message consumer.
[0088] 3) Configuration files are generated by machine A, and test cases are generated and executed by machine B:
[0089] If the server is designated as machine A and the second machine is designated as machine B, then after determining that the relevant test cases will be executed by the second machine (for example, determining that the second machine is associated with a specified middleware), the server can send a configuration file to the second machine. This allows the second machine to combine the preset test case template and the configuration file to generate test cases (second test cases) for the specified test scenario, and then execute the second test cases.
[0090] When the specified middleware is a message queue component and the specified mode parameter indicates a publish-subscribe mode, the second machine device includes a module that provides background services for message delivery. During the execution of the second test case on the second machine device, the configuration file can be loaded into memory to enable module startup, and the module can be used to deliver specified messages from the specified middleware to the specified message consumer.
[0091] Based on the introduction of the concepts of test scenarios and test case templates, the embodiments of this application provide detailed scenarios for test case generation and application.
[0092] In practical applications, see Figure 4 The naming rules are shown in Table 1 below:
[0093]
[0094] Table 1
[0095] MQ1 indicates point-to-point mode, and MQ2 indicates publish-subscribe mode.
[0096] When generating the aforementioned standard description fields, a name generation tool (such as an Excel editor) can be used to automatically generate the topic name (corresponding to the aforementioned topic field), service name (corresponding to the aforementioned service field), and address alias (corresponding to the aforementioned address field) based on the input environment, mode, protocol, routing, and extended description. The specific formula is as follows:
[0097] topic:
[0098] =IF(E173<>"","t_"&B173&"_"&A173&"_"&C173&"_"&D173&"_"&E173,"t_"&B173&"_"&A173&"_"&C173&"_"&D173&"_001");
[0099] Service Name:
[0100] =IF(C173<>"middle","test_"&A173&"_"&C173&"_"&D173&"_consumer_sys",IF(E173="processor","test_"& A173&"_"&C173&"_"&D173&"_processor_middle","test_"&A173&"_"&C173&"_"&D173&"_consumer_middle"));
[0101] Address alias:
[0102] =IF(OR(D173="ccip",D173="ccl5"),IF(C173="middle",IF(E173="processor",IF(G173<>"","test_"&A173&"_"&C173&"_"&D173&"_"&G173&"_processor_middle","test_" &A173&"_"&C173&"_"&D173&"_processor_middle"),"test_"&A173&"_"&C173&"_"&D17 3&"_consumer_middle"),"test_"&A173&"_"&C173&"_"&D173&"_consumer_sys")," / ").
[0103] The default script used can be the configuration script `modify_fmq_conf.py`, which reads the topic, service name, and address alias from the Excel file to generate the configuration files `mqagent_topic.xml` and `mqserver_sub.xml`. These configuration files can be used to start the relevant service modules. Furthermore, the automatic update tool `Mini_deploy` can be used to synchronize the configuration files to relevant machines (such as the aforementioned second machine) for testing.
[0104] Combination Figure 5 The test cases generated using the embodiments of this application for a specified test scenario can be implemented based on Pytest. The test cases can consist of four parts, with a common library configuring logs, tools, and the environment. Any message can be defined in three parts: message definition, message sending, and message verification. Message definition first determines the message type and process; then the message is sent to middleware, which forwards it to the consumer, where message verification is finally completed. Correspondingly, the message writing format is uniformly divided into three steps: message production – message sending – message verification. All test cases can be generated following this process, encapsulating similar operations into the same function, such as function A for "message production," function B for "message sending," and function C for "message verification." This approach offers the advantage of a clear structure, facilitating code maintenance and saving workload.
[0105] The generated test cases can include the following parameters: queue_list indicating the pattern, env_list indicating the environment, protocol_list indicating the protocol, and route_list indicating the route. Combining the candidate patterns, environments, protocols, and routes from the previous examples, a single test case template can cover 2*3*9*5 = 270 test scenarios. The advantage of parameterized test case writing is that staff only need to write one test case template to cover multiple test scenarios, greatly improving the efficiency of test case writing and simplifying test cases. Otherwise, for test scenarios with multiple protocols, routes, component patterns, and environments, there would be a large amount of duplicate code, severely impacting the efficiency of test case writing and increasing the difficulty and time consumption of test case maintenance. This is because a test case needs to define the protocol, routing method, component pattern, environment type, and then define the message, message sending, and message validation.
[0106] As can be seen from the technical solutions provided in the embodiments of this application above, the embodiments of this application obtain multiple feature parameters indicating a specified test scenario, and then process the multiple feature parameters using preset rules to obtain a configuration file indicating the specified test scenario. This allows for the fusion of the configuration file with a preset test case template to generate test cases for the specified test scenario. This application performs unified processing on the relevant feature parameters, making the generation of the configuration file more standardized and improving the efficiency of fusion with the test case template to generate test cases.
[0107] This application also provides a framework construction method for middleware testing, the method comprising:
[0108] Obtain the preset test framework;
[0109] Obtain the business code; wherein the business code indicates the configuration file generation method for middleware testing as described in steps S201-S202 above;
[0110] The preset test framework and the business code are combined to construct a target test framework for middleware testing.
[0111] It is possible to obtain a preset test framework (such as Pytest) and the business code in the above embodiments that instructs the generation of configuration files, and then merge the preset test framework and the business code to construct a target test framework for middleware testing. Figure 4 , 5This target testing framework is an automated testing framework developed based on Pytest. It automates the generation of configuration files indicating subscription relationships within the asynchronous message queue component. A single test case can cover 270 test scenarios across multiple protocols, routes, component modes, and environments. The topic, service name, and address alias in the configuration file are not arbitrary but generated according to naming rules. The names clearly indicate the component mode, environment type, protocol, and routing method of the test scenario, greatly improving the speed of problem location and troubleshooting while facilitating management. The generated configuration files indicating subscription relationships can be automatically synchronized to relevant machines and devices, eliminating the need for manual file downloads and updates. This automated testing framework lowers the technical barrier to generating configuration files and is easy to use.
[0112] As can be seen from the technical solutions provided in the above embodiments of this application, the embodiments of this application integrate the testing framework and related business code to build a target testing framework for generating configuration files for middleware testing, which can reduce the technical threshold for users to participate in configuration file generation and improve convenience.
[0113] This application also provides a configuration file generation device for middleware testing, such as... Figure 6 As shown, the configuration file generation device 60 for middleware testing includes:
[0114] Acquisition module 601: used to acquire multiple feature parameters indicating a specified test scenario; wherein, the multiple feature parameters describe the content of message passing using the specified middleware, the multiple feature parameters and the preset test case template respectively indicate different components of test cases for the specified middleware, and the specified middleware is the test object under the specified test scenario;
[0115] Processing module 602: used to process the multiple feature parameters using preset rules to obtain a configuration file indicating the specified test scenario; wherein, the configuration file is used to merge with the preset test case template to generate test cases for the specified test scenario, the configuration file records the relationship between a specified message and a specified message consumer, and the specified message will be sent to the specified message consumer by the specified middleware.
[0116] It should be noted that the apparatus and method embodiments described in the device embodiments are based on the same inventive concept.
[0117] This application also provides a framework building apparatus for middleware testing, the apparatus comprising:
[0118] Framework acquisition module: Used to acquire preset test frameworks;
[0119] Code acquisition module: used to acquire business code; wherein, the business code indicates the configuration file generation method for middleware testing as described in steps S201-S202 above;
[0120] Fusion Module: Used to fuse the preset test framework and the business code to build a target test framework for middleware testing.
[0121] It should be noted that the apparatus and method embodiments described in the device embodiments are based on the same inventive concept.
[0122] 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 configuration file generation method for middleware testing or the framework construction method for middleware testing provided in the above method embodiments.
[0123] Furthermore, Figure 7 A schematic diagram of the hardware structure of an electronic device for implementing the configuration file generation method or the framework construction method for middleware testing provided in the embodiments of this application is shown. The electronic device may participate in or include the configuration file generation device or the framework construction device for middleware testing provided in the embodiments of this application. Figure 7 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 7 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 7 The more or fewer components shown, or having the same Figure 7 The different configurations shown.
[0124] 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).
[0125] 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 configuration file generation method for middleware testing described in the embodiments of this application, or the program instructions / data storage device corresponding to the framework construction method for middleware testing. The processor 1002 executes various functional applications and data processing by running the software programs and modules stored in the memory 1004, that is, implementing the above-mentioned configuration file generation method for middleware testing or framework construction method for middleware testing. 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 the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0126] 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.
[0127] 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).
[0128] 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 configuration file generation method for middleware testing or a framework construction method for middleware testing in the method embodiments. The at least one instruction or the at least one program is loaded and executed by the processor to implement the configuration file generation method for middleware testing or the framework construction method for middleware testing provided in the above method embodiments.
[0129] 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.
[0130] 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.
[0131] 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.
[0132] 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.
[0133] 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 configuration file generation method for middleware testing, characterized by, The method includes: Obtain multiple characteristic parameters indicating a specified test scenario; these multiple characteristic parameters describe the message passing content implemented using a specified middleware, including specified mode parameters, specified environment parameters, specified protocol parameters, and specified routing parameters. The specified mode parameters indicate the passing mode for a specified message, the specified environment parameters indicate the applicable business environment for the generated test cases, the specified protocol parameters indicate the communication protocol involved in message passing, and the specified routing parameters indicate the routing method involved in message passing. The multiple characteristic parameters and the preset test case template respectively indicate different components of the test cases for the specified middleware, where the specified middleware is the test object under the specified test scenario. Based on the parameter requirements of the standard description field dimension in the preset naming rules, at least one key parameter that meets the parameter requirements is selected from the multiple feature parameters, and the at least one key parameter is concatenated to obtain a standard description field indicating the specified test scenario, so as to obtain at least one standard description field; the at least one standard description field includes a topic field, a service field, and an address field, wherein the topic field is used to characterize the specified message, the service field is used to indicate the message delivery path, and the address field is used to indicate the node address involved in the message delivery path; A preset script is used to read at least one standard description field to generate a configuration file indicating the specified test scenario. The structure of the preset script is based on a preset test framework. The configuration file is used to integrate with the preset test case template to generate test cases for the specified test scenario. The configuration file records the relationship between the specified message and the specified message consumer. The specified message will be sent to the specified message consumer by the specified middleware. The preset test case template records the content to be verified from the dimensions of message quantity and / or message content. The content to be verified from the dimension of message quantity refers to checking whether the number of messages sent by the producer to the middleware is consistent with the number of messages obtained by the consumer from the middleware. The content to be verified from the dimension of message content refers to checking whether the message content sent by the producer to the middleware is consistent with the message content obtained by the consumer from the middleware.
2. The method of claim 1, wherein, When the specified middleware is a message queue component, the specified mode parameter indicates any one of point-to-point mode and publish-subscribe mode; the specified environment parameter indicates any one of development environment, first type test environment, and second type test environment; the specified protocol parameter indicates any one of Hypertext Transfer Protocol, Middle Protocol, Relay Protocol, pure FBP Protocol, first type FBP extended protocol, second type FBP extended protocol, User Datagram Protocol, Transmission Control Protocol, and risk control protocol; the specified routing parameter indicates any one of local IP mode, local L5 mode, configuration center IP mode, configuration center L5 mode, and service discovery mode.
3. The method of claim 1, wherein, The method further includes: The preset test case template and the configuration file are combined to generate a first test case for the specified test scenario.
4. The method of claim 3, wherein, The specified middleware is a message queue component and the specified mode parameter is a publish-subscribe mode. After generating the first test case for the specified test scenario by integrating the preset test case template and the configuration file, the method further includes: A first machine device is determined for executing the first test case; wherein the first machine device includes a module that provides background services for message passing; The first test case is sent to the first machine device so that the first machine loads the configuration file into memory to start the module, and uses the module to pass the specified message from the specified middleware to the specified message consumer.
5. The method of claim 1, wherein, The method further includes: Identify a second machine or device that is associated with the specified middleware; The configuration file is sent to the second machine device, so that the second machine device integrates the preset test case template and the configuration file to generate a second test case for the specified test scenario, and executes the second test case.
6. A framework construction method for middleware testing, characterized in that, The method includes: Obtain the preset test framework; Obtain the business code; wherein the business code indicates the configuration file generation method for middleware testing as described in any one of claims 1-5; The preset test framework and the business code are combined to construct a target test framework for middleware testing.
7. A configuration file generation apparatus for middleware testing, characterized in that, The device includes: Acquisition Module: Used to acquire multiple feature parameters indicating a specified test scenario; the multiple feature parameters describe the content of message passing using the specified middleware, and the multiple feature parameters include specified mode parameters, specified environment parameters, specified protocol parameters, and specified routing parameters. The specified mode parameters are used to indicate the transmission mode for the specified message, the specified environment parameters are used to indicate the applicable business environment of the generated test cases, the specified protocol parameters are used to indicate the communication protocol involved in message passing, and the specified routing parameters are used to indicate the routing method involved in message passing. The multiple feature parameters and the preset test case template respectively indicate the different components of the test cases for the specified middleware, and the specified middleware is the test object under the specified test scenario; Processing module: Based on the parameter requirements of the standard description field dimension in the preset naming rules, it selects at least one key parameter from the plurality of feature parameters that meets the parameter requirements, and concatenates the at least one key parameter to obtain a standard description field indicating the specified test scenario, thus obtaining at least one standard description field. The at least one standard description field includes a topic field, a service field, and an address field. The topic field is used to characterize the specified message, the service field is used to indicate the message delivery path, and the address field is used to indicate the node addresses involved in the message delivery path. It also uses a preset script to read the at least one standard description field to generate a configuration file indicating the specified test scenario. The structure of this test is based on a preset test framework. The configuration file is used to integrate with the preset test case template to generate test cases for the specified test scenario. The configuration file records the relationship between the specified message and the specified message consumer. The specified message will be sent to the specified message consumer by the specified middleware. The preset test case template records the content to be verified from the dimensions of message quantity and / or message content. The content to be verified from the dimension of message quantity refers to checking whether the number of messages sent by the producer to the middleware is consistent with the number of messages obtained by the consumer from the middleware. The content to be verified from the dimension of message content refers to checking whether the message content sent by the producer to the middleware is consistent with the message content obtained by the consumer from the middleware.
8. The apparatus according to claim 7, characterized in that, When the specified middleware is a message queue component, the specified mode parameter indicates any one of point-to-point mode and publish-subscribe mode; the specified environment parameter indicates any one of development environment, first type test environment, and second type test environment; the specified protocol parameter indicates any one of Hypertext Transfer Protocol, Middle Protocol, Relay Protocol, pure FBP Protocol, first type FBP extended protocol, second type FBP extended protocol, User Datagram Protocol, Transmission Control Protocol, and risk control protocol; the specified routing parameter indicates any one of local IP mode, local L5 mode, configuration center IP mode, configuration center L5 mode, and service discovery mode.
9. The apparatus according to claim 7, characterized in that, The device is also used for: The preset test case template and the configuration file are combined to generate a first test case for the specified test scenario.
10. The apparatus according to claim 9, characterized in that, The specified middleware is a message queue component and the specified mode parameter is a publish-subscribe mode. The device is further configured to: After generating a first test case for the specified test scenario by integrating the preset test case template and the configuration file, a first machine device for executing the first test case is determined; wherein, the first machine device includes a module that provides background services for message passing; The first test case is sent to the first machine device so that the first machine loads the configuration file into memory to start the module, and uses the module to pass the specified message from the specified middleware to the specified message consumer.
11. The apparatus according to claim 7, characterized in that, The device is also used for: Identify a second machine or device that is associated with the specified middleware; The configuration file is sent to the second machine device, so that the second machine device integrates the preset test case template and the configuration file to generate a second test case for the specified test scenario, and executes the second test case.
12. A framework construction apparatus for middleware testing, characterized in that, The device includes: Framework acquisition module: Used to acquire preset test frameworks; Code acquisition module: used to acquire business code; wherein, the business code indicates the configuration file generation method for middleware testing as described in any one of claims 1-5; Fusion Module: Used to fuse the preset test framework and the business code to build a target test framework for middleware testing.
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 configuration file generation method for middleware testing as described in any one of claims 1-5 or the framework construction method for middleware testing as described in claim 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 configuration file generation method for middleware testing as described in any one of claims 1-5 or the framework construction method for middleware testing as described in claim 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 configuration file generation method for middleware testing as described in any one of claims 1-5 or the framework construction method for middleware testing as described in claim 6.
Citation Information
Patent Citations
Message-oriented middleware tuning method and system, electronic equipment and storage medium
CN111488271A
Test case generation method, device and system, equipment and medium
CN112214390A
