AdrianHHH
AdrianHHH

Reputation: 14038

How can I start a new user when I want in a Visual Studio Load test

How can I end one virtual user and start another new user at the time of my choosing in a Visual Studio (2012 ultimate) Load test.

For my system I need to do some activity in a loop. There are too many iterations and over too long a time span to run it all in one Web Performance Test. Hence I must have a login test and a series of other tests for the same virtual user. After some unknown number of these other tests the system sends a "You have finished" message in a response. Then I need to logout and have that virtual user finish and another virtual user start.

The website itself determines the number of activities and the number cannot be predicted in advance. That is an important aspect of the testing. The website asks the user questions, the next question asked and the number of questions to be asked is chosen dynamically based on various factors including the users' previous answers and the responses of other users. At some point the website will display a "Thank you for answering these questions" message and then the user should logout. Distinguishing between the Thank you message and a question is easy in the web test and hence doing the logout or answer, respectively.

This seems similar to the function used by the percentage of new users control. But I need to control when a new user starts based on data found on the web response.

After the tests complete I would like each horizontal line in the Detail chart in the load test results to show one login, a variable number of activities, and finally one logout. Thus each login should start a new virtual user.

Web searching for load test plugins quickly finds ways of altering the number of Virtual Users, up or down. But no results for controlling the current virtual user.

Upvotes: 1

Views: 805

Answers (2)

Daileyo
Daileyo

Reputation: 720

I have run into a similar hurdle from time to time, and have not yet found a solution that I really like as the "end-all" solution. There are, however, some ways of getting close to what you want.

I am using Visual Studio 2010 still, but assume that you may be able to do this in later versions as well. I am also speaking from the perspecive of using declarative web tests and not coded. I am certain the same can be don in a coded web test, but I don't directly work with them on a regular basis.

Most of what you want to be done with existing plugins. The tricky part can (and will likely be) how you handle session data after the logout of the user. The high level steps, if I understood your question correctly, will be to:

  1. Run initialization test for virtual user (your login portion of the test.)
  2. Execute your series of tests based on one of the load profiles
  3. Logout the user based on a specific response.
  4. Log a "new" user in after step 3.

I am sure you already have steps 1 and 2 handled. So I'll focus on ideas for steps 3 and 4.

Step 3.

This step can be handled as a two step process, within the web test(s). This assumes you know which response(s) will generate the "you have finished" message.

  1. Extraction rule to extract the information from the response.
  2. A conditional step that executes based on the information extracted by your extraction rule.

Within you Conditional statement you can execute your logout. Given the nature of how you are wanting to do this, I'd make the logout a separate test that you reference... but you can alternatively insert the logout request(s) into the conditional section of the test.

Step 4.

The simplest thing would be to call you login test again, right after the logout, within your conditional loop. Depending on what kind of session information you need to persist across tests... this is the part that can become tricky. Logging back in from within a web test can result in some data that was being persisted by the initialize test, to become invalid. As such, you would need to handle this by updating the existing context parameters. If you don't have any context parameters that are carried across tests from your initialize test...then you are set.

Also, if you are not wanting the "new" user to login immediately after the existing one has finished... then some additional creativity would be required.

Unless you need to vary the max number of virtual users, you never really need to log in a new vitual user. Rather, you can just execute the login test again with that existing virtual user. If you need to vary the total number of virtual users that are available, than it will become necessary to get creative with load test plugins. There are ways to do it, and some good examples can be found on one of Sean Lumley's Blog entries: http://blogs.msdn.com/b/slumley/archive/2009/04/10/load-test-plug-ins.aspx

I hope this information helps.

Upvotes: 0

John O.
John O.

Reputation: 708

As far as I know there is no way to control virtual users outside of the load test settings.

However there is nothing preventing a running virtual user from performing a log off based on a response then logging on with a new set of credentials.

For the load test this is a single user running continuously but for the system under test this is a user finishing and a new user starting.

Upvotes: 0

Related Questions