Request processing method and device, equipment, storage medium and program product
By obtaining service configuration information and matching the entry parameters, the response data is automatically constructed, which solves the problem of flexibility in response data construction in tests, and realizes efficient service calls and automated service orchestration.
Patent Information
- Application Number
- CN202411399811.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-08
- Publication Date
- 2025-03-25
AI Technical Summary
During the testing process, it is difficult to flexibly construct the response data of the service being tested to meet diverse testing needs.
By obtaining the configuration information of the service, the construction strategy of the response data under multiple incoming conditions is determined, and the corresponding strategy is matched according to the input data, and the response data is automatically constructed.
It realizes flexible structure of response data, improves service call efficiency, supports convenient and automated service orchestration, and is suitable for various business scenarios and diversified business needs.
Smart Images

Figure CN119690755A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a request processing method, apparatus, device, storage medium and program product. Background Art
[0002] During the test process, for some services under test whose real response data is not easy to obtain, it is usually necessary to construct virtual response data to simulate the real response data of the service under test, so as to achieve the purpose of auxiliary verification of the service under test. How to flexibly construct the response data of the service under test to better meet the testing requirements has become a hot research direction. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a request processing method, apparatus, device, storage medium and program product for realizing flexible construction of response data to better meet testing requirements.
[0004] In order to achieve the above objectives, the present application embodiment adopts the following technical solutions: In a first aspect, an embodiment of the present application provides a request processing method, including: In response to a call request for a first service, first configuration information of the first service is obtained, where the first configuration information includes a strategy used to determine response data under multiple input parameter conditions, and the call request carries first input data; Determining whether there is a first policy matching the first input data in the first configuration information; If the first policy exists in the first configuration information, the response data of the call request is determined based on the first policy.
[0005] In a second aspect, an embodiment of the present application provides a request processing device, including: an acquisition module, configured to respond to a call request for a first service and acquire first configuration information of the first service, wherein the first configuration information includes a strategy used to determine response data under multiple input parameter conditions, and the call request carries first input data; A query module, used to determine whether there is a first policy matching the first input data in the first configuration information; A return module is used to determine response data of the call request based on the first policy if the first configuration information exists.
[0006] In a third aspect, an embodiment of the present application provides an electronic device, including: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the request processing method provided in the first aspect.
[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the request processing method provided in the first aspect.
[0008] In a fifth aspect, an embodiment of the present application provides a computer program product, characterized in that the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to enable a computer to execute part or all of the steps in the request processing method provided in the first aspect.
[0009] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: In the process of calling the first service, you only need to carry the corresponding first input data in the call request, and you can automatically obtain the response data that meets the call request according to the first configuration information of the first service, without manual participation in writing or modifying the existing response data. This not only helps to improve the efficiency of service calls, but also facilitates the realization of convenient and automated service orchestration. In addition, since the response data of the call request varies according to the different input conditions, the structure of the response data is more flexible and can be applied to various business scenarios to meet diverse business needs. For example, for test scenarios that require different response data to be returned when calling the same service multiple times in the same process, it can be achieved by providing different first input data each time the same service is called. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 A flowchart of a request processing method provided for an embodiment of the present application; Figure 2 A flowchart of a request processing method provided for another embodiment of the present application; Figure 3 A schematic diagram of the structure of a request processing device provided for one embodiment of the present application; Figure 4 A schematic diagram of the structure of an electronic device provided for one embodiment of the present application. DETAILED DESCRIPTION
[0011] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0012] The terms "first", "second", etc. in this specification and claims are used to distinguish similar objects, and are not used to describe a particular order or precedence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein. In addition, "and / or" in this specification and claims means at least one of the connected objects, and the character " / " generally means that the objects associated with each other are in an "or" relationship.
[0013] Mock data: a type of data that simulates the actual return of an interface, used to assist in verifying whether the interface has been called and to simulate various return situations in order to verify the interface or business logic branch.
[0014] Interface testing: Interface testing is a test of the interface of system components. Interface testing is mainly used to detect the interaction points between external systems and internal subsystems. The focus of the test is to check the data exchange, transmission and control management process, as well as the mutual logical dependencies between systems.
[0015] Automated testing: Edit and simulate various test scenarios through programs, scripts, and applications to achieve automatic verification of normal and abnormal scenarios for software testing.
[0016] In order to achieve flexible construction of response data to better meet testing requirements, the embodiment of the present application proposes a request processing method. In the process of calling the first service, only the corresponding first input data needs to be carried in the call request, and the response data that meets the call request can be automatically obtained according to the first configuration information of the first service. There is no need for manual participation in writing or modification based on the existing response data, which not only helps to improve the efficiency of service calls, but also facilitates the realization of convenient and automated service orchestration. In addition, since the response data of the call request varies according to different input conditions, the construction of the response data is more flexible and can be applied to various business scenarios to meet diverse business needs. For example, for a test scenario that requires returning different response data when calling the same service multiple times in the same process, it can be achieved by providing different first input data each time the same service is called.
[0017] It should be understood that the request processing method provided in the embodiment of the present application can be executed by an electronic device. The electronic device referred to here may include a terminal device, such as a smart phone, a tablet computer, a laptop computer, a desktop computer, an intelligent voice interaction device, a smart home appliance, a smart watch, a vehicle terminal, an aircraft, etc.; or, the electronic device may also include a server, such as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The electronic device is independent of the backend server.
[0018] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0019] Please refer to Figure 1 , is a flowchart of a request processing method provided by an embodiment of the present application, the method comprising the following steps: S102: Respond to a call request for a first service and obtain first configuration information of the first service.
[0020] The first service refers to a service to be tested, which may include, but is not limited to, the following types of services: an interface, a functional module of an application program, a business component of a business system, and the like.
[0021] The call request is used to request the call of the first service. The call request carries the first input data. The first input data may include the name and value of the first input parameter. In practical applications, the call request may have various appropriate forms. In practical applications, after receiving the call request, the request address of the call request may be parsed to obtain the first service requested by the call request and the first data carried in the call request.
[0022] The first configuration information of the first service is used to describe the strategy used to determine the response data under multiple input conditions. In this way, the response data of the service varies according to the different input conditions, so the structure of the response data is more flexible and can be applied to various business scenarios to meet diverse business needs. For example, for a test scenario that requires returning different response data when calling the same service multiple times in the same process, it can be achieved by providing different first input data each time the same service is called.
[0023] Specifically, as an example, the first configuration information may include at least one output parameter and a strategy of the output parameter under multiple input parameter conditions. The output parameter represents a field to be included in the response data, and the strategy is used to determine the value of the output parameter.
[0024] In practical applications, as an example, the first configuration information includes multiple input parameter conditions and a strategy used to determine the response data under each input parameter condition. Each input parameter condition includes: an input parameter name and a value range of the input parameter.
[0025] As another example, the first configuration information may be set according to the development language format of the first service. For example, if the development language format of the first service is json, the first configuration information may be configured based on the jsonPath format.
[0026] For example, the first configuration information includes keywords $.XXX, req.YYY, and return. $.XXX represents the output parameter, that is, the field contained in the response data, and XXX is the name of the output parameter. req.YYY represents the input parameter, YYY represents the name of the input parameter, and the keyword return represents the value of the element.
[0027] In the setting of req.YYY, you can set special characters such as greater, less, between, notIn, etc. Greater means greater than, less means greater than, between means within a certain range, and notIn means not within a certain range. The character after return indicates the value of the parameter, which can be a preset value or a value expression to determine the value of the parameter. As an example, return can be followed by random_int_13, which means generating a random number of type int and length 13 as the value of the parameter.
[0028] An example of part of the first configuration information is shown below: {"$.code":{ [{"req.phone":"123","return":"201"},{"phone":"234","return":"10700"}] }, which means that when the input parameter phone is 123, the strategy used to determine the response data is: the response data includes the output parameter code, and the value of code is 201; when the input parameter phone is 234, the strategy used to determine the response data is: the response data includes the output parameter code, and the value of code is 10700.
[0029] {"$.message":{ [{"idCard":"123","return":"AAAA"},{"idCard":"234","return":"BBBB"}] }, which means that when the value of the input parameter idCard is 123, the strategy used to determine the response data is: the response data includes the output parameter message, and the value of message is AAAA; when the value of the input parameter idCard is 234, the strategy used to determine the response data is: the response data includes the output parameter message, and the value of message is BBBB.
[0030] {"$.phone":{ [{"req.AA":"A","return":"random_int_13"},{"AA":"B","return":"13888888888"}] }, which means that when the value of the input parameter AA is A, the strategy used to determine the response data is: the response data includes the output parameter phone, and the value of phone is a random number of type int and length 13; when the value of the input parameter AA is B, the strategy used to determine the response data is: the response data includes the output parameter phone, and the value of phone is 13888888888.
[0031] {"$.idCard":{ [{"BB":"A","return":"request_idCard"}] }, which means that when the value of the input parameter BB is A, the strategy used to determine the response data is: the response data includes the output parameter idCard, and the value of idCard is the value of the input parameter idCard carried in the request.
[0032] {"$.result.score1":{ [{"req.CC":"greater_12","return":"100"},{"CC":"less_1","return":"-100"}] }, which means that when the value of the input parameter CC is greater than 12, the strategy used to determine the response data is: the response data includes the output parameter result.score1, and the value of result.score1 is 100; when the value of the input parameter CC is less than 1, the strategy used to determine the response data is: the response data includes the output parameter result.score1, and the value of result.score1 is -100.
[0033] In order to make the response data obtained based on the first configuration information better meet the test requirements, before the above S102, the first configuration information of the first service can be configured in the following manner: based on the test requirement information of the first service, determine the output parameter of the first service, the fourth input parameter condition corresponding to the output parameter, and the value-taking method of the output parameter; based on the value-taking method, generate a first expression for the output parameter, and the first expression is used to calculate the value of the output parameter; based on the format of the development language used to develop the first service, splice the output parameter of the first service, the fourth input parameter condition corresponding to the output parameter, and the first expression to obtain the first configuration information of the first service.
[0034] As an example, if the test requirement information is to test whether the cache of the first service is effective, the value of the output parameter includes: generating a random number of the first type and the first length. For example, if the output parameter is idCard, the value of the output parameter includes: generating a random number of the integer type (int) and the length of 13, and the first expression is: random_int_13.
[0035] In the actual business processing process, if you want to query the user's basic information by calling the first service (such as an interface), when the cache of the first service is effective, the first query obtains the user's basic information from the data source and stores the query result in the cache for the next query; in subsequent queries, the query is all from the cache, and the query result obtained is the same as the first query result. When the cache of the first service is not effective, each query obtains the user's basic information from the data source. Since the user's basic information is constantly updated, the result of each query is different.
[0036] Based on this, if the test requirement is to test whether the cache of the first service is effective, by determining the value of the output parameter to generate a random number, the randomness of the value can be used to accurately verify whether the cache of the first service is effective by judging whether the results of the two queries are the same.
[0037] As another example, if the test requirement information is to test whether the first service is successfully called, the value of the output parameter includes: selecting a preset value as the value of the output parameter. For example, the user's ID number is fixed and unchanged. If you want to test whether the ID query interface is successfully called, the value of the output parameter includes: returning a fixed 13-digit number.
[0038] In the above S102, the first configuration information of the first service can be queried in various ways, which can be selected according to actual needs, and the embodiment of the present application does not limit this. In one embodiment, querying the first configuration information of the first service includes the following steps: S121, obtaining a first data table, the first data table is used to describe the correspondence between the service identifier and the first configuration information; S122, based on the service identifier of the first service, querying the first configuration information of the first service from the first data table.
[0039] Specifically, based on the correspondence described in the first data table, the configuration information corresponding to the service identifier of the first service can be determined, and the configuration information is the first configuration information of the first service. In practical applications, the first data table can be pre-configured by relevant personnel according to actual needs and continuously updated as test requirements change.
[0040] The first data table may have various appropriate forms, which are not limited in the embodiments of the present application.
[0041] In one embodiment, each row of data in the first data table includes a first service identifier and configuration information. In this case, the above S102 includes the following steps: obtaining the first data table; obtaining the first target row of data from the first data table based on the service identifier of the service, wherein the first service identifier included in the first target row of data is the same as the service identifier of the first service; and determining the configuration information in the first target row of data as the first configuration information of the first service.
[0042] Of course, each row of data in the first data table may also contain more content, such as a primary key value that is auto-incremented, fixed response data, field values of the extended field AAA, field values of the extended field BBB, etc. These contents can be set according to actual needs, and the embodiments of the present application are not limited to this.
[0043] For example, the following Table 1 is an example of a first data table, in which each row of data in the first data table includes a primary key value, a first service identifier, fixed response data, and configuration information.
[0044] Table 1
[0045] In the above Table 1, the configuration information in the row data of the second row is a null value, indicating that the configuration information of the service with the service identifier service_code2 is a null value.
[0046] If the service identifier of the first service is service_code1, the row data of the first row is determined as the first target row data, and the configuration information is extracted therefrom as the first configuration information of the first service.
[0047] In the above implementation, by storing the service identifier and configuration information in the same data table, the correspondence between the service identifier and the configuration information can be more intuitively reflected, and then by performing a query operation on the first data table based on the service identifier of the first service, the first configuration information of the first service can be quickly obtained, which is conducive to the subsequent rapid acquisition of response data of the call request.
[0048] In another embodiment, the above S102 includes the following steps: obtaining a second data table and a third data table, wherein each row of data in the second data table includes a primary key value, a second service identifier and a status value, and each row of data in the third data table includes a third service identifier and configuration information. Obtaining a second target row of data from the second data table, wherein the second service identifier contained in the second target row of data is the same as the service identifier of the first service; if the status value in the second target row of data is the first status value, obtaining a third target row of data from the third data table, wherein the third service identifier contained in the third target row of data is the same as the primary key value; obtaining configuration information in the third target row of data, and determining it as the first configuration information of the first service.
[0049] Of course, each row of data in the second data table may also contain more content, such as fixed response data, field values of the extended field AAA, field values of the extended field BBB, etc. These contents can be set according to actual needs, and the embodiments of the present application do not limit this. Each row of data in the third data table may also contain more content, such as a primary key value that is taken in an auto-incremental manner, a status value indicating whether it is effective, etc. These contents can be set according to actual needs, and the embodiments of the present application do not limit this. Among them, the primary key value is used to distinguish each row of data in the third data table, and the status value is used to indicate whether the corresponding configuration information is effective.
[0050] For example, Table 2 below is an example of a second data table, and each row of data in the second data table includes a primary key value, a second service identifier, fixed response data, and a status value. Table 3 below is an example of a third data table, and each row of data in the third data table includes a primary key value, a third service identifier, configuration information, and a status value.
[0051] Table 2
[0052] Table 3
[0053] If the service identifier of the first service is service_code1, the row data of the first row in the second data table is determined as the second target row data. Since the state value in the second target row data is 1, it means that the corresponding configuration information is configured for the first service, that is, the state value meets the preset state value condition, and thus the third target row data whose third service identifier matches the primary key value 112233 is searched from the third data table, that is, the row data of the first to fifth rows in the third data table, and then the configuration information in these row data is used as the first configuration information of the first service.
[0054] In the above implementation, by storing the corresponding service identifier and configuration information in the second data table and the third data table respectively, and using the primary key value of the second data table and the third service identifier of the third data table to associate the two data tables, the query of the configuration information of the first service can also be realized. In addition, this method of storing in separate tables can disperse the data pressure of a data table and improve the query speed, which is particularly suitable for situations where the amount of data of the configuration information corresponding to the service identifier is large.
[0055] S104: Determine whether there is a first strategy matching the first input data in the first configuration information.
[0056] Specifically, the above S104 includes the following steps: S141, matching the first input parameter data with the input parameter condition in the first configuration information to obtain the first input parameter condition satisfied by the first input parameter data; S142, determining the strategy used to determine the response data under the first input parameter condition as the first strategy matching the first input data. In this way, the response data constructed based on the first strategy better meets the requirements of the call request.
[0057] In order to more intuitively describe the strategy used to determine the response data under multiple input parameter conditions, in one embodiment, the first configuration information includes multiple input parameter conditions and the strategy used to determine the response data under each input parameter condition. Each input parameter condition includes: the name of the input parameter and the value range of the input parameter. The first input data includes the name and value of the first input parameter.
[0058] In this case, the above S104 may include the following steps: Step A1, determining a second input parameter condition from multiple input parameter conditions, where the name of the input parameter included in the second input parameter condition is the same as the name of the first input parameter.
[0059] For example, taking the first configuration information shown in Table 1 above as an example, if the name of the first input parameter is phone, the second input parameter condition determined and the strategy used to determine the response data under the second input parameter condition are as follows: Input condition 1: "req.phone": "123"; Strategy 1: "return": "201"; Input condition 2: "phone": "234"; Strategy 2: "return": "10700"}.
[0060] Step A2: based on the value range of the input parameter included in the second input parameter condition and the value of the first input parameter, determine the first input parameter condition satisfied by the first input data from the second input parameter condition.
[0061] Step A3: determining the strategy used to determine the response data under the first input parameter condition as a first strategy that matches the first input data.
[0062] As an example, in the above step A2, the value of the first input parameter is compared with each second input parameter condition, and then the second input parameter condition that is successfully compared is determined as the first input parameter condition. For example, taking the above two second input parameter conditions as an example, if the value of the first input parameter phone is 123, input parameter condition 1 is determined as the first input parameter condition.
[0063] Considering that there are a large number of second input parameter conditions, comparing the value of the first input parameter with each second input parameter condition will not only consume a lot of computing resources, but also affect the efficiency of obtaining response data. In view of this, as another example, in the above step A2, multiple second input parameter conditions are traversed; each time a second input parameter condition is traversed, the second input parameter condition is compared with the value of the first input parameter; if the value range of the input parameter in the second input parameter condition includes the value of the first input parameter, the second input parameter condition is determined as the first input parameter condition, and the traversal is stopped.
[0064] For example, continuing with the above-mentioned input parameter conditions 1 and 2 as an example, if the value of the traversed input parameter phone is 123, input parameter condition 1 is determined as the second input parameter condition. When traversing to input parameter condition 1, input parameter condition 1 can be determined as the first input parameter condition, and there is no need to traverse input parameter condition 2 again.
[0065] Considering that there is an intersection between at least one of the above-mentioned second input parameter conditions, it will not only increase the consumption of computing resources, but also increase the computational complexity, which will have a greater impact on the business involved in the traversal service. For example, the strategy used to determine the response data under the first second input parameter condition is to set the value of output parameter 1 to AAA, but the strategy used to determine the response data under the second second input parameter condition is to set the value of output parameter 1 to BBB, which will cause the value of output parameter 1 to be modified repeatedly. However, for simulation testing, only one setting of output parameter 1 is required to meet the test requirements, without the need for multiple settings. In this case, repeated modifications to output parameter 1 will increase the consumption of computing resources, increase computational complexity, and have a greater impact on the business involved in output parameter 1.
[0066] In view of this, as another example, the first configuration information also includes: the state of each input parameter condition, which is used to indicate whether the input parameter condition is effective. In the above step A2, the third input parameter condition is determined from the second input parameter condition, and the state of the third input parameter condition is an effective state; if the value of the first input parameter is within the value range of the input parameter included in the third input parameter condition, the third input parameter condition is determined as the first input parameter condition satisfied by the first input data.
[0067] For example, there are two second input parameter conditions. Each second input parameter condition and its corresponding output parameter, output parameter status, and strategy are as follows: Entry condition 3: "req.phone": "123"; Status: 1 (effective); Strategy 3: "return": "201"; Input condition 4: "req.phone": "123"; Status: 0 (not effective); Strategy 4: "return": "200".
[0068] Since the status of the output parameter code is effective, the input parameter 3 is determined as the third input parameter. If the value of the first input parameter phone is 123, the third input parameter is determined as the first input parameter.
[0069] In the above method, it is only necessary to set some of the input parameter conditions to be effective, and then determine the first input parameter condition from the effective input parameter conditions, so as to ensure that there is no overlap between the first input parameter conditions, thereby effectively solving the above technical problem.
[0070] The embodiment of the present application shows some implementation methods of the above S104. Of course, it should be understood that the above S104 can also be implemented in other ways, which are not limited in the embodiment of the present application.
[0071] S106: If the first policy exists in the first configuration information, determine response data of the call request based on the first policy.
[0072] Since the first strategy describes the strategy used to determine the response data, based on the first strategy, response data that meets the requirements can be generated.
[0073] In one embodiment, the above S106 includes the following steps: determining the first output parameter corresponding to the first strategy from the output parameters corresponding to the input parameter conditions contained in the first configuration information; determining the value of the first output parameter based on the first strategy; and encapsulating the value of the first output parameter based on the response format of the call request to obtain response data of the call request.
[0074] For example, the first output parameter of the first strategy is code, and the first strategy is to return a fixed value of 100, so the value of the first output parameter is determined to be 100; further, based on the response format of the call request, code and its value 100 are encapsulated to obtain the response data of the call request.
[0075] In another embodiment, the above-mentioned request processing method may also include: if obtaining the first configuration information of the first service fails, using the preset response data as the response data of the call request; and / or, if the first policy does not exist in the first configuration information, outputting prompt information, and the prompt information is used to prompt to modify the first input data.
[0076] For example, taking the service identifier and its corresponding configuration information shown in Table 1 above as an example, if the service identifier of the first service is service_code2, since its corresponding configuration information is an empty value, it is determined that the first configuration information of the first service is not queried, and then the fixed response data {"code":200, "message":"OK"} corresponding to the service identifier is read as the response data of the call request, that is, the response data including the parameters code and message, and the value of code is 200, and the value of message is OK.
[0077] For another example, still taking the configuration information corresponding to the service identification machine shown in Table 1 above as an example, if the name of the first input parameter is user and the value is 345, the first policy does not exist in the first configuration information of the first service, and then a prompt message is output to prompt the name of the first input parameter to be modified.
[0078] Through the above embodiments, the problem of no response data affecting the accuracy of the test results can be effectively avoided.
[0079] To facilitate a more intuitive understanding of the above request processing method, the following Figure 2 Provide explanation.
[0080] In S21, a request address of a call request is received, and a first service requested to be called and first input data of the first service are obtained by parsing the request address.
[0081] In S22, it is queried whether the configuration information of the first service exists in the first data table.
[0082] If it does not exist, execute S23; if it does exist, execute S24; In S23, fixed response data corresponding to the first service is obtained from the first data table as response data of the call request.
[0083] In S24, at least one second input parameter condition whose input parameter name is the same as the name of the first input parameter is obtained from the first configuration information of the first service.
[0084] In S25, a first input parameter condition including an input parameter value range that matches the input parameter value is selected from the second input parameter conditions.
[0085] If there is no matching third input parameter condition, execute S26; if there is a matching first input parameter condition, execute S27.
[0086] In S26, prompt information is output.
[0087] The prompt information is used to prompt to modify the first input data carried in the call request.
[0088] In S27, the strategy used to determine the response data under the first input parameter condition is determined as the first strategy.
[0089] In S28, based on the first strategy, response data of the call request is determined.
[0090] The request processing method provided by one or more embodiments of the present application, in the process of calling the first service, only needs to carry the corresponding first input data in the call request, and the response data that satisfies the call request can be automatically obtained according to the first configuration information of the first service, without the need for manual participation in writing or modification based on the existing response data, which not only helps to improve the efficiency of service calls, but also facilitates the realization of convenient and automated service orchestration. In addition, since the response data of the call request varies according to different input conditions, the structure of the response data is more flexible and can be applied to various business scenarios to meet diverse business needs. For example, for a test scenario that requires returning different response data when calling the same service multiple times in the same process, it can be achieved by providing different first input data each time the same service is called.
[0091] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0092] Based on the same inventive concept, the present application embodiment also provides a request processing device. Figure 3 , is a schematic diagram of a structure of a request processing device 300 provided in one embodiment of the present application. Figure 3 As shown, in a software implementation, the request processing device 300 includes: The acquisition module 310 is used to respond to a call request for a first service and obtain first configuration information of the first service, wherein the first configuration information includes a strategy used to determine response data under multiple input conditions, and the call request carries first input data.
[0093] The query module 320 is used to determine whether there is a first policy matching the first input data in the first configuration information.
[0094] The return module 330 is used to determine the response data of the call request based on the first policy if the first configuration information exists.
[0095] In another embodiment, the acquisition module is used to: Acquire a first data table, wherein each row of data in the first data table includes a first service identifier and configuration information; Acquire first target row data from the first data table, where a first service identifier included in the first target row data is the same as a service identifier of the first service; The configuration information in the first target row data is determined as the first configuration information of the first service.
[0096] In another embodiment, the acquisition module performs the following steps when acquiring the first configuration information of the first service: Acquire a second data table and a third data table, wherein each row of data in the second data table includes a primary key value, a second service identifier, and a status value, and each row of data in the third data table includes a third service identifier and configuration information; Acquire second target row data from the second data table, where a second service identifier included in the second target row data is the same as a service identifier of the first service; If the state value in the second target row data is the first state value, obtaining the third target row data from the third data table, wherein the third service identifier included in the third target row data is the same as the primary key value; The configuration information in the third target row data is determined as the first configuration information of the first service.
[0097] In another embodiment, the first configuration information includes a plurality of input parameter conditions and a strategy used to determine the response data under each of the input parameter conditions, each of the input parameter conditions including: a name of an input parameter and a value range of the input parameter; the first input data includes a name and a value of a first input parameter; The query module is used to: Determine a second input parameter condition from the multiple input parameter conditions, where the name of the input parameter included in the second input parameter condition is the same as the name of the first input parameter; Based on the value range of the input parameter included in the second input parameter condition and the value of the first input parameter, determining the first input parameter condition satisfied by the first input data from the second input parameter condition; The strategy used to determine the response data under the first input parameter condition is determined as a first strategy that matches the first input data.
[0098] In another embodiment, the first configuration information further includes: a state of each of the input parameter conditions; When the query module determines the first input parameter condition satisfied by the first input data from the second input parameter condition based on the value range of the input parameter included in the second input parameter condition and the value of the first input parameter, the query module performs the following steps: Determine a third input parameter condition from the second input parameter condition, where the third input parameter condition is in an effective state; If the value of the first input parameter is within the value range of the input parameter included in the third input parameter condition, the third input parameter condition is determined as the first input parameter condition satisfied by the first input data.
[0099] In another embodiment, the apparatus further comprises: A determination module, configured to determine an output parameter of the first service, a fourth input parameter condition corresponding to the output parameter, and a value taking method of the output parameter based on test requirement information of the first service; A generating module, used for generating a first expression of the output parameter based on the value obtaining method, wherein the first expression is used for calculating the value of the output parameter; A splicing module is used to splice the output parameter of the first service, the fourth input parameter condition corresponding to the output parameter and the first expression based on the format of the development language used to develop the first service to obtain the first configuration information of the first service.
[0100] Obviously, the request processing device 300 provided in the embodiment of the present application can be used as the above Figure 1 The execution subject of the request processing method shown in FIG. Figure 1 The functions realized are as follows. Since the principles are the same, they will not be described in detail.
[0101] Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 4 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0102] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0103] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0104] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a request processing device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations: In response to a call request for a first service, first configuration information of the first service is obtained, where the first configuration information includes a strategy used to determine response data under multiple input parameter conditions, and the call request carries first input data; Determining whether there is a first policy matching the first input data in the first configuration information; If the first policy exists in the first configuration information, the response data of the call request is determined based on the first policy.
[0105] The above application Figure 1 The method executed by the request processing device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0106] The electronic device may also perform Figure 1 method, and implement the request processing device in Figure 1 , Figure 2 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.
[0107] Of course, in addition to software implementation methods, the electronic device of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0108] The embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including a plurality of application programs, enable the portable electronic device to execute Figure 1 The method of the embodiment shown is specifically used to perform the following operations: In response to a call request for a first service, first configuration information of the first service is obtained, where the first configuration information includes a strategy used to determine response data under multiple input parameter conditions, and the call request carries first input data; Determining whether there is a first policy matching the first input data in the first configuration information; If the first policy exists in the first configuration information, the response data of the call request is determined based on the first policy.
[0109] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps in the request processing method provided in the embodiment of the present application.
[0110] In short, the above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0111] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0112] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0113] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0114] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
Claims
1. A request processing method, characterized in that: include: In response to a call request for a first service, first configuration information of the first service is obtained, where the first configuration information includes a strategy used to determine response data under multiple input parameter conditions, and the call request carries first input data; Determining whether there is a first policy matching the first input data in the first configuration information; If the first policy exists in the first configuration information, response data of the call request is determined based on the first policy.
2. The method according to claim 1, characterized in that: The obtaining the first configuration information of the first service includes: Acquire a first data table, wherein each row of data in the first data table includes a first service identifier and configuration information; Acquire first target row data from the first data table, where a first service identifier included in the first target row data is the same as a service identifier of the first service; The configuration information in the first target row data is determined as the first configuration information of the first service.
3. The method according to claim 1, characterized in that: The obtaining the first configuration information of the first service includes: Acquire a second data table and a third data table, wherein each row of data in the second data table includes a primary key value, a second service identifier, and a status value, and each row of data in the third data table includes a third service identifier and configuration information; Acquire second target row data from the second data table, where a second service identifier included in the second target row data is the same as a service identifier of the first service; If the state value in the second target row data is the first state value, obtaining the third target row data from the third data table, wherein the third service identifier included in the third target row data is the same as the primary key value; The configuration information in the third target row data is determined as the first configuration information of the first service.
4. The method according to claim 1, characterized in that The first configuration information includes a plurality of input parameter conditions and a strategy used to determine the response data under each of the input parameter conditions, each of the input parameter conditions including: a name of the input parameter and a value range of the input parameter; the first input data includes a name and a value of the first input parameter; The determining whether there is a first policy matching the first input data in the first configuration information includes: Determine a second input parameter condition from the multiple input parameter conditions, where the name of the input parameter included in the second input parameter condition is the same as the name of the first input parameter; Based on the value range of the input parameter included in the second input parameter condition and the value of the first input parameter, determining the first input parameter condition satisfied by the first input data from the second input parameter condition; The strategy used to determine the response data under the first input parameter condition is determined as a first strategy that matches the first input data.
5. The method according to claim 4, characterized in that The first configuration information also includes: the status of each of the input conditions; The determining, based on the value range of the input parameter included in the second input parameter condition and the value of the first input parameter, the first input parameter condition satisfied by the first input data from the second input parameter condition includes: Determine a third input parameter condition from the second input parameter condition, where the third input parameter condition is in an effective state; If the value of the first input parameter is within the value range of the input parameter included in the third input parameter condition, the third input parameter condition is determined as the first input parameter condition satisfied by the first input data.
6. The method according to claim 1, characterized in that Before the step of responding to the call request for the first service and acquiring the first configuration information of the first service, the step further includes: Based on the test requirement information for the first service, determine an output parameter of the first service, a fourth input parameter condition corresponding to the output parameter, and a value taking method of the output parameter; Based on the value-taking method, generate a first expression of the output parameter, where the first expression is used to calculate the value of the output parameter; Based on the format of the development language used to develop the first service, the output parameter of the first service, the fourth input parameter condition corresponding to the output parameter, and the first expression are concatenated to obtain first configuration information of the first service.
7. A request processing device, characterized in that: include: an acquisition module, configured to respond to a call request for a first service and acquire first configuration information of the first service, wherein the first configuration information includes a strategy used to determine response data under multiple input parameter conditions, and the call request carries first input data; A query module, used to determine whether there is a first policy matching the first input data in the first configuration information; A return module is used to determine response data of the call request based on the first policy if the first policy exists in the first configuration information.
8. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the request processing method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the request processing method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that The computer program product comprises a non-transitory computer-readable storage medium storing a computer program, wherein the computer program is operable to cause a computer to execute part or all of the steps in the request processing method according to any one of claims 1 to 6.