How to get the agentID of every virtual user in the cloud based load test

We have created a simple web performance test using visual studio which connect to an application by using the password.
For that we had to provide a password to each user. That is why we have created 5 users MYUSER1, MYUSER2, MYUSER3, MYUSER4 & MYUSER5 in the database.
We have used a csv file that have 5 Users and then try to bind a password to each user, but it is not working because all the access method did not fit.
Sequential & Random : We got the issue that two users trying to connect with same password.
Unique : Virtual user is taking one record every time and will execute the test.
So We have 5 records the test will be executed once per virtual user, and this is what we did not want to do.
Our expectation is every virtual user takes one record and use it to execute the same webtest as many times with the same password until the load test Finish.

So have written the code as a testPlugin is given below:
int AgentId = e.WebTest.Context.AgentId;
e.WebTest.Context["Password"] = "USER" + e.WebTest.Context.AgentId;
It works good locally for every agentID, but in the cloud all agentIds are the same like 1, So two users try to authenticate with the same password and that occure errors.
How to Fix an id to every testAgent that will use until the end of the load test no matter how many webtests they execute.
Please help us on this.
Thanks in advance.

Comments

  • The web test context also contains the field $WebTestUserId. If the scenario property "Percentage of new users" is set to zero (0%) then the maximum value of $WebTestUserId will be the number of virtual users in the test.
    As you have 5 users in the CSV and 5 matching passwords then your 5 virtual users should work fine after changing the plugin code to be:
    string UserId = e.WebTest.Context["$WebTestUserId"].ToString()
    e.WebTest.Context["TestAgentPassword"] = "USER" + UserId ;

Sign In or Register to comment.