Performance Testing (PTS) provides the data export feature. You can use the feature to export cookies and share the cookies in a session or scenario. This topic describes how to use exported cookies to simulate logons.
Background information
PTS allows cookie sharing in a session or scenario.
Cookie sharing in a session: PTS allows you to share cookies in a session without the need for additional settings. Similar to a browser, PTS automatically includes obtained cookies in subsequent requests.
Cookie sharing in a scenario: Logon cookies can be shared in a scenario. In a scenario, you can share a cookie in a session with other sessions.
For example, you want to perform stress testing in a scenario in which 10,000 users log on to a shopping website. The scenario includes the following sessions:
Session 1: logging on to the shopping website.
Session 2: viewing products, purchasing products, and completing the payments.
In this scenario, the logon cookie in Session 1 must be shared with Session 2. You can specify whether to cyclically reuse exported cookies based on your business requirements.
If you want to cyclically reuse exported cookies in subsequent sessions, follow the instructions in Cyclically reuse exported cookies in this topic.
If you want to poll exported cookies only once, you must add a parameter node to subsequent sessions and configure a parameter to set the number of polling times to only once. For more information, see Poll exported cookies only once in this topic.
Cyclically reuse exported cookies
Log on to the PTS console, choose , and then click PTS.
On the Scenario Settings tab, configure Session 1.
Click Data Source Management. In the panel that appears, upload a parameter file that contains the username and password used to log on to the shopping website. For more information, see File data sources.
In the Business Session1 section, click the drop-down arrow next to Add Instruction, and then click Parameter.
In the Data Settings section, click the Data Source Parameters tab and configure the parameters.
NoteTo ensure that the shared cookie is unique, select the check box in the Use Once column. For more information, see Use a parameter instruction.
Add an API operation for logon and configure the basic request information and body. For more information, see HTTP APIs.
In the Business Session1 section, click the drop-down arrow next to Add Instruction, and select Data Export. Set the Select Data parameter to Cookie and the Export Level parameter to 10000. For more information about how to export data, see Use a data export instruction.
NoteOther sessions created in this scenario automatically include the cookie information.
Click + Add Business Session to add Session 2. In the Business Session2 section, click the drop-down arrow next to Add API and select HTTP. Add the API operations for viewing products, purchasing products, and completing payments. Then, configure the parameters on the Basic Request Information subtab.
Poll exported cookies only once
Log on to the PTS console, choose , and then click PTS.
On the Scenario Settings tab, configure Session 1.
Click Data Source Management. In the panel that appears, upload a parameter file that contains the username and password used to log on to the shopping website. For more information, see File data sources.
In the Business Session1 section, click the drop-down arrow next to Add Instruction, and then click Parameter.
In the Data Settings section, click the Data Source Parameters tab and configure the parameters.
NoteTo ensure that the shared cookie is unique, select the check box in the Use Once column. For more information, see Use a parameter instruction.
Add an API operation for logon and configure the basic request information and body. For more information, see HTTP APIs.
In the Business Session1 section, click the drop-down arrow next to Add Instruction, and select Data Export. Set the Select Data parameter to Cookie and the Export Level parameter to 10000. For more information about how to export data, see Use a data export instruction.
NoteOther sessions created in this scenario automatically include the cookie information.
In the Business Session2 section, add a data setting node. Select productID in the Parameter Name column and then select the check box in the Use Once column. For more information, see Use a parameter instruction.
ImportantThis step ensures that the cookies exported in the previous step are polled only once.
In the Business Session2 section, add the API operations for viewing products, purchasing products, and completing payments. Then, configure the parameters on the Basic Request Information subtab.
What to do next
After you configure the testing scenario, you must configure stress settings and debug the scenario. Then, click Save and Start Testing in the lower-left corner of the page.
For more information about how to configure stress settings, see Configure the stress testing model and level.
For more information about how to bind domain names, see Configure domain name and IP address bindings.
For more information about how to debug a scenario, see Debug a stress testing scenario.
During stress testing, you can make adjustments at the API operation, session, or scenario level. For more information, see Adjust the number of concurrent users.