Detailed Description
Reference will now be made in detail to embodiments of the present application, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are exemplary and intended to be used for explaining the present application and should not be construed as limiting the present application.
Fig. 1 is a flowchart of a pressure testing method of a business system according to an embodiment of the present application. It should be noted that the pressure testing method for the service system according to the embodiment of the present application may be applied to a pressure testing platform, where the pressure testing platform performs a pressure test on the service system through the pressure testing method for the service system according to the present application, so as to test a maximum load condition of the system, so that relevant personnel (such as testers and developers) can debug the service system according to a test result. In addition, the services in the embodiment of the present application may be understood as various functions in an application or a system, for example, taking a wechat application as an example, the services included in the wechat application include, for example, sending a message, adding a friend, shaking one, red envelope, brushing a friend circle, and the like.
As shown in fig. 1, the method for testing the pressure of the service system includes:
s110, obtaining test account configuration file information, wherein the test account configuration file information comprises account information of a plurality of test accounts.
It can be understood that before the pressure test is performed on the service system, a test script may be prepared in advance for the pressure test on the service system, where the test script at least includes, but is not limited to, test account configuration file information and service information to be tested, and the service information to be tested includes, for example, a type of a service, a test code corresponding to implementing the service function, and the like.
In order to complete login preheating operation of a plurality of test accounts before a pressure test is performed on a service system, a large number of test accounts need to be prepared in advance, and account information of the large number of test accounts can be gathered to a test account configuration file so that a large number of users can be simulated to perform login operation according to the test accounts in a subsequent pressure test process.
In an embodiment of the present application, at the beginning stage of the stress test, a pre-prepared test script may be loaded, and during the process of executing the test script, profile information of a test account may be obtained according to the test script, where the profile information of the test account includes account information of a plurality of test accounts, such as user IDs (identities), user nicknames, and/or passwords of the test accounts.
And S120, generating a plurality of login request information according to the test account configuration file information, and logging in a service system according to the login request information to generate a plurality of login session information.
Specifically, login request information corresponding to each test account included in the configuration file may be generated according to the test account configuration file, where the login request information includes, for example, a user ID, a password, and the like of the account, and then, the login request information may be sent to the service system. When the service system receives the login request information, the service system can complete the login operation of the corresponding test account according to the login request information, generate login Session information Session, and feed back the login Session information Session to the pressure test platform.
S130, storing the account information of the plurality of test accounts and the plurality of login session information into a memory mapping table.
It can be understood that, in order to implement unified management on the login part in the stress test of the service system, after the stress test platform receives the registrable Session information Session fed back by the service system, the account information of each test account and the corresponding login Session information Session may be stored in the memory mapping table. That is, the memory mapping table may store a plurality of test accounts and corresponding login session information.
Specifically, in an embodiment of the present application, a specific implementation process of saving the account information of the plurality of test accounts and the plurality of login session information in the memory mapping table may include the following steps: and determining the corresponding relation between the account information of each test account and each login information, and storing the account information of the plurality of test accounts and the plurality of login session information into a memory mapping table according to the corresponding relation and a preset format, wherein each test account, the login session information and the corresponding relation between the test account and the login session information can be clearly stored according to the preset format.
It is to be understood that, in order to distinguish each login session information, each login session information may be assigned an ID, for example, the login session information is represented by a SessionID. For example, after a login request of a plurality of test accounts is executed to the service system, login session information SessionID corresponding to each test account is obtained, and at this time, each login session information SessionID may be cached and stored in the memory mapping table in a format of < user ID, SessionID >.
S140, when the business system is subjected to stress test, a plurality of business stress test requests are generated according to the account information of a plurality of test accounts.
It can be understood that when the business system is subjected to stress testing, a plurality of business stress testing requests can be generated according to the account information of a plurality of accounts through a testing script prepared in advance, so as to simulate a scene that a plurality of users carry out business requests on the business system.
S150, generating a plurality of service pressure test request data according to the plurality of service pressure test requests and the memory mapping table, and sending the plurality of service pressure test request data to the service system to perform pressure test on the service system.
It can be understood that, at this time, all the test accounts may be considered to be already in the login state, and the test accounts are logged in the service system for the purpose of implementing the test accounts and ensuring that the login state of the test accounts is verified to be passed. Specifically, in the embodiment of the present application, a plurality of login session information corresponding to the account information of the plurality of test accounts may be searched from the memory mapping table according to the account information of the plurality of test accounts, and the login session information corresponding to the account information of the plurality of test accounts is added to cookies of the service pressure test requests corresponding to the login session information of the plurality of test accounts, so as to generate a plurality of pieces of service pressure test request data. And then, sending the data of each service pressure test request to a service system, wherein the service system can complete the verification of the login state of the corresponding test account according to the login session information sessionID in the data of each service pressure test request, and carry out pressure test on the service system according to each service pressure test request.
That is to say, when the service system is subjected to the pressure test, all the test accounts are already in the login state, when the service pressure test request data is constructed, only the corresponding SessionID needs to be found from the memory mapping table according to the user ID of the test account, the SessionID is carried in the uplink request, for example, the SessionID is put into the Cookie in the HTTP request, so that the corresponding service in the service system is subjected to the pressure test according to the service pressure test request in the service pressure test request data while the verification of the login state is passed. Therefore, a login operation is not required to be performed every time when the business system is subjected to the pressure test, and only the corresponding Session ID is required to be found from a memory mapping table (such as a Session pool) and added into the Cookie of the business pressure test request to verify the login state, so that the login operation process is omitted, the pureness of the business pressure test request can be achieved, and the flow control can be more transparent.
In the embodiment of the present application, the service stress test request data is short link request data. Therefore, in order to ensure that the session is effective for a long time and the validity of the link is ensured, a heartbeat request can be sent to the service system at regular time so as to prolong the failure time for the login session information in the memory mapping table at regular time. Further, in an embodiment of the present application, after logging in to the service system according to the multiple login request information to generate multiple login session information, the stress testing method may further include: and periodically generating a plurality of heartbeat requests according to the account information of the plurality of test accounts, and sending the heartbeat requests to the service system so as to carry out failure time prolonging operation on the login session information in the memory mapping table. In the embodiment of the present application, the time interval of the period may be smaller than the expiration time of the login session information (i.e., session). Therefore, the heartbeat request is sent at regular time so as to prolong the failure time for each login session information session in the memory mapping table at regular time.
The method for testing the pressure of the service system includes the steps of generating a plurality of login request information according to account configuration file information including account information of a plurality of test accounts, logging in the service system according to the login request information to generate a plurality of login session information, storing the account information of the test accounts and the login session information into a memory mapping table, generating a plurality of service pressure test requests according to the account information of the test accounts when the service system is subjected to pressure testing, generating a plurality of service pressure test request data according to the service pressure test requests and the memory mapping table, and finally sending the pressure test request data to the service system to perform pressure testing on the service system. Through the implementation mode, the login part for independently executing a plurality of test accounts is realized, namely, the large-batch test accounts are logged in advance and preheated, and the acquired session is stored, so that the session is directly acquired from the session pool to check the login state when the business pressure test is executed, the influence of the login part on the business system pressure test is avoided, the centralization of the business system pressure test is ensured, the business pressure test can be ensured to be pure, the login influence is avoided, and the flow control is transparent.
Fig. 2 is a flowchart of a pressure testing method of a service system according to another embodiment of the present application.
In order to improve the practicability of the pressure test and to omit repeated login operation during the pressure test as much as possible, in the embodiment of the present application, the login session information session may be persisted, that is, after the login session information is generated, the account information of each test account and each login session information may be written into a preset file to generate a login session file, so that the pressure test plan for the business system may be dynamically adjusted according to the login session file.
Specifically, as shown in fig. 2, the method for testing the pressure of the service system includes:
s210, obtaining test account configuration file information, wherein the test account configuration file information comprises account information of a plurality of test accounts.
And S220, generating a plurality of login request information according to the test account configuration file information, and logging in a service system according to the login request information to generate a plurality of login session information.
And S230, writing the account information of the plurality of test accounts and the plurality of login session information into a preset file to generate a login session file.
In order to facilitate dynamic adjustment of a pressure test plan for a business system, repeated login operation during pressure test is omitted as much as possible, and login session information session can be persisted, that is, account information of a plurality of test accounts and a plurality of login session information are written into a preset file to generate a login session file. It will be appreciated that the account information and corresponding login session information are written to a designated file, for example, in a < user ID, sessionID > format to form a login session file.
In an embodiment of the present application, on the premise that the account information of each test account and each login session information are written into a preset file to generate a login session file, after detecting that the stress test on the service system is suspended, the stress test method may further include: detecting whether a recovery instruction input aiming at the pressure test of the service system is received or not, and if the recovery instruction input aiming at the pressure test of the service system is received, judging whether the information of the plurality of login sessions in the memory mapping table is invalid or not; if the login session information in the memory mapping table is not invalid, loading the login session file to reload the login session information in the login session file into the memory mapping table; and if the login session information in the memory mapping table fails, generating a plurality of login request information again according to the test account configuration file information, and logging in the service system according to the login request information to generate a plurality of login session information.
Specifically, in the process of performing a pressure test on the business system, if it is detected that the pressure test on the business system in the midway is suspended, for example, a midway tester wants to replace a business object to be tested, or replace a test script, or suspend the pressure test on the business system due to other reasons, when it is detected that a recovery instruction for the pressure test on the business system is received, and in the case that the session login ID of the login session information is not invalid, the login session file generated by the previous login preheating can be directly loaded, and each login session information in the login session file is reloaded into the memory mapping table in the format of < user ID, sessionID >. Therefore, the login request can be prevented from being generated again to carry out login operation again to the service system to generate login session information, and waste of resources is avoided.
S240, storing the account information of the plurality of test accounts and the plurality of login session information into a memory mapping table.
It should be noted that, in the embodiment of the present application, the execution of the step S230 and the step S240 may not be in a sequential order, for example, the step S230 may be executed first and then the step S240 is executed, the step S240 may be executed first and then the step S230 is executed, or the step S230 and the step S240 may be executed simultaneously.
And S250, when the pressure test is carried out on the service system, generating a plurality of service pressure test requests according to the account information of the plurality of test accounts.
And S260, generating a plurality of service pressure test request data according to the plurality of service pressure test requests and the memory mapping table, and sending the plurality of service pressure test request data to the service system to perform pressure test on the service system.
According to the pressure test request method for the service system, after login session information is generated, the account information of a plurality of test accounts and the login session information are written into a preset file to generate a login session file, so that after the pressure test on the service system is suspended, when a recovery instruction input by the pressure test aiming at the service system is detected and the login session information is not invalid, the login session information in the login session file can be directly loaded into a memory mapping table, the waste of resources is avoided, the practicability of the pressure test method is improved, meanwhile, the pressure test plan of the service system is conveniently and dynamically adjusted, and repeated login operation during the pressure test is omitted as much as possible.
In order to implement the above embodiments, the present application further provides a pressure testing apparatus for a service system. Fig. 3 is a schematic structural diagram of a pressure testing apparatus of a service system according to an embodiment of the present application. As shown in fig. 3, the pressure testing apparatus of the service system includes: an acquisition module 310, a first generation module 320, a saving module 330, a second generation module 340, a third generation module 350, and a sending module 360.
The obtaining module 310 is configured to obtain test account configuration file information, where the test account configuration file information includes account information of multiple test accounts.
It can be understood that before the pressure test is performed on the service system, a test script may be prepared in advance for the pressure test on the service system, where the test script at least includes, but is not limited to, test account configuration file information and service information to be tested, and the service information to be tested includes, for example, a type of a service, a test code corresponding to implementing the service function, and the like.
In order to complete login preheating operation of a plurality of test accounts before a pressure test is performed on a service system, a large number of test accounts need to be prepared in advance, and account information of the large number of test accounts can be gathered to a test account configuration file so that a large number of users can be simulated to perform login operation according to the test accounts in a subsequent pressure test process.
In an embodiment of the present application, at the beginning stage of the stress test, the obtaining module 310 may load a pre-prepared test script, and in the process of executing the test script, may obtain profile information of a test account according to the test script, where the profile information of the test account includes account information of a plurality of test accounts, such as a user ID, a user nickname, and/or a password of the test account.
The first generating module 320 is configured to generate a plurality of login request information according to the test account configuration file information, and log in to the service system according to the plurality of login request information to generate a plurality of login session information.
Specifically, the first generating module 320 may generate login request information corresponding to each test account included in the configuration file according to the test account configuration file, where the login request information includes, for example, a user ID, a password, and the like of the account, and then may send the login request information to the service system. When the service system receives the login request information, the service system can complete the login operation of the corresponding test account according to the login request information, generate login Session information Session, and feed back the login Session information Session to the pressure test platform.
The saving module 330 is configured to save the account information of the multiple test accounts and the multiple login session information in a memory mapping table.
It can be understood that, in order to implement unified management on the login portion in the stress test of the service system, after the stress test platform receives the registrable Session information Session fed back by the service system, the storage module 330 may be used to store the account information of each test account and the corresponding login Session information Session into the memory mapping table. That is, the memory mapping table may store a plurality of test accounts and corresponding login session information.
Specifically, fig. 4 is a schematic structural diagram of a pressure testing apparatus of a business system according to an embodiment of the present application. As shown in fig. 4, the storage module 330 in the pressure testing apparatus of the service system specifically includes: a determination unit 331 and a saving unit 332. In an embodiment of the application, the determining unit 331 determines a correspondence between the account information of each test account and each login information, and the storing unit 332 stores the account information of the plurality of test accounts and the plurality of login session information into a memory mapping table according to the correspondence and a preset format, where each test account and the login session information and the correspondence between the test account and the login session information can be clearly stored according to the preset format.
The second generating module 340 is configured to generate a plurality of service stress test requests according to the account information of the plurality of test accounts when the service system is subjected to stress test.
It can be understood that, when the business system is subjected to the stress test, the second generating module 340 may generate a plurality of business stress test requests according to the account information of the plurality of accounts through a pre-prepared test script, so as to simulate a scenario in which a plurality of users perform business requests on the business system.
The third generating module 350 is configured to generate a plurality of traffic pressure test request data according to the plurality of traffic pressure test requests and the memory mapping table.
It can be understood that, at this time, all the test accounts may be considered to be already in the login state, and the test accounts are logged in the service system for the purpose of implementing the test accounts and ensuring that the login state of the test accounts is verified to be passed.
Fig. 5 is a schematic structural diagram of a pressure testing device of a business system according to another embodiment of the present application. As shown in fig. 5, the third generating module 350 in the pressure testing apparatus of the service system specifically includes: a lookup unit 351 and a generation unit 352.
Specifically, in the embodiment of the present application, the searching unit 351 may search, according to the account information of the multiple test accounts, multiple pieces of login session information corresponding to the account information of the multiple test accounts from the memory mapping table, and the generating unit 352 adds the multiple pieces of login session information corresponding to the account information of the multiple test accounts to cookies of the service pressure test requests corresponding to the multiple pieces of login session information to generate multiple pieces of service pressure test request data.
That is to say, when the service system is subjected to the pressure test, all the test accounts are already in the login state, when the service pressure test request data is constructed, only the corresponding SessionID needs to be found from the memory mapping table according to the user ID of the test account, the SessionID is carried in the uplink request, for example, the SessionID is put into the Cookie in the HTTP request, so that the corresponding service in the service system is subjected to the pressure test according to the service pressure test request in the service pressure test request data while the verification of the login state is passed. Therefore, a login operation is not required to be performed every time when the business system is subjected to the pressure test, and only the corresponding Session ID is required to be found from a memory mapping table (such as a Session pool) and added into the Cookie of the business pressure test request to verify the login state, so that the login operation process is omitted, the pureness of the business pressure test request can be achieved, and the flow control can be more transparent.
The sending module 360 is configured to send the multiple service stress test request data to the service system to perform a stress test on the service system.
In the embodiment of the present application, the sending module 360 sends each service pressure test request data to the service system, and the service system can complete the verification of the login state of the corresponding test account according to the login session information SessionID in each service pressure test request data, and perform a pressure test on the service system according to each service pressure test request.
In the embodiment of the present application, the service stress test request data is short link request data. Therefore, in order to ensure that the session is effective for a long time and the validity of the link is ensured, a heartbeat request can be sent to the service system at regular time so as to prolong the failure time for the login session information in the memory mapping table at regular time.
Fig. 6 is a schematic structural diagram of a pressure testing apparatus of a business system according to another embodiment of the present application. As shown in fig. 6, on the basis of fig. 3, the pressure testing apparatus of the service system further includes: a fourth generation module 370 and a dead time extension module 380.
Specifically, the fourth generation module 370 is configured to periodically generate a plurality of heartbeat requests according to the account information of the plurality of test accounts after the first generation module 320 logs in to the service system according to the plurality of login request information to generate the plurality of login session information, and the failure extension module 380 is configured to send the plurality of heartbeat requests to the service system to perform the failure time extension operation on the plurality of login session information in the memory mapping table. In the embodiment of the present application, the time interval of the period may be smaller than the expiration time of the login session information (i.e., session). Thus, the expiration time extension module 380 periodically extends the expiration time for each session of login session information in the memory mapping table by periodically transmitting the heartbeat request generated by the fourth generation module 370.
The pressure testing device of the service system in the embodiment of the application generates a plurality of login request information according to account configuration file information including account information of a plurality of testing accounts, logs in the service system according to the login request information to generate a plurality of login session information, further stores the account information of the testing accounts and the login session information into a memory mapping table, generates a plurality of service pressure testing requests according to the account information of the testing accounts when the service system is subjected to pressure testing, generates a plurality of service pressure testing request data according to the service pressure testing requests and the memory mapping table, and finally sends the pressure testing request data to the service system to perform pressure testing on the service system. Through the implementation mode, the login part for independently executing a plurality of test accounts is realized, namely, the large-batch test accounts are logged in advance and preheated, and the acquired session is stored, so that the session is directly acquired from the session pool to check the login state when the business pressure test is executed, the influence of the login part on the business system pressure test is avoided, the centralization of the business system pressure test is ensured, the business pressure test can be ensured to be pure, the login influence is avoided, and the flow control is transparent.
In order to improve the practicability of the pressure test and to omit repeated login operation during the pressure test as much as possible, in the embodiment of the present application, the login session information session may be persisted, that is, after the login session information is generated, the account information of each test account and each login session information may be written into a preset file to generate a login session file, so that the pressure test plan for the business system may be dynamically adjusted according to the login session file.
Fig. 7 is a schematic structural diagram of a pressure testing apparatus of a business system according to still another embodiment of the present application. As shown in fig. 7, on the basis of fig. 3, the pressure testing apparatus of the service system further includes: a fifth generation module 390, a detection module 3100, a determination module 3110, and a loading module 3120.
The fifth generating module 390 is configured to, after the first generating module 320 logs in the service system according to the login request information to generate a plurality of login session information, write the account information of the test accounts and the login session information into a preset file to generate a login session file.
In order to facilitate dynamic adjustment of the stress test plan for the business system, to omit repeated login operation during stress test as much as possible, the login session information session may be persisted, that is, the fifth generating module 390 may write the account information of the multiple test accounts and the multiple login session information into a preset file to generate a login session file. It will be appreciated that the account information and corresponding login session information are written to a designated file, for example, in a < user ID, sessionID > format to form a login session file.
In an embodiment of the present application, on the premise that the fifth generating module 390 writes the account information and login session information of each test account into a preset file to generate a login session file, after detecting that the pressure test on the service system is suspended, the detecting module 3100 detects whether a recovery instruction input for the pressure test on the service system is received, and the determining module 3110 determines whether a plurality of login session information in the memory mapping table are invalid when receiving the recovery instruction input for the pressure test on the service system; if the determining module 3110 determines that the multiple login session information in the memory mapping table is not invalid, the loading module 3120 loads the login session file to reload the multiple login session information in the login session file into the memory mapping table; if the determining module 3110 determines that the multiple login session information in the memory mapping table is invalid, the first generating module 320 is further configured to generate multiple login request information according to the test account configuration file information again, and log in the service system according to the multiple login request information to generate multiple login session information.
Specifically, in the process of performing a pressure test on the business system, if the detection module 3100 detects that the pressure test on the business system is suspended halfway, for example, a halfway tester wants to replace a business object to be tested, or replace a test script, or the tester suspends the pressure test on the business system due to other reasons, when the detection module 3100 detects that a recovery instruction for the pressure test on the business system is received, and when the determination module 3110 determines that the session login session information sessionID does not fail, the login session file generated by the previous login preheating may be directly loaded by the loading module 3120, and each login session information in the login session file is reloaded into the memory mapping table in the format of < user ID, sessionID >. Therefore, the first generation module 320 can be prevented from generating the login request again to perform the login operation again to the service system to generate the login session information, and the waste of resources is avoided.
According to the pressure test request device of the business system, after the login session information is generated, the account information of the test accounts and the login session information are written into the preset file to generate the login session file, so that after the pressure test on the business system is suspended, when a recovery instruction input by the pressure test aiming at the business system is detected and the login session information is not invalid, the login session information in the login session file can be directly loaded into the memory mapping table, the waste of resources is avoided, the practicability of the pressure test device is improved, meanwhile, the pressure test plan on the business system can be conveniently and dynamically adjusted, and repeated login operation during the pressure test is omitted as far as possible.
In the description of the present application, it is to be understood that the terms "first", "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implying any number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present application, "plurality" means at least two, e.g., two, three, etc., unless specifically limited otherwise.
In the description herein, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and the scope of the preferred embodiments of the present application includes other implementations in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present application.
It should be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present application may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc. Although embodiments of the present application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present application, and that variations, modifications, substitutions and alterations may be made to the above embodiments by those of ordinary skill in the art within the scope of the present application.