Reputation: 415
I've created a web performance test using visual studio. it's for a simple scénario that connect to an application giving only the password, so to simulate many users i had to give a password to everyone so that in my database i've created 5 employes USER1, USER2, USER3, USER4 & USER5. So that every virtual user will use one password.
First, i've used a csv file containing the 5 Users and then try to bind a password to everyone, but it does not work because all the access method didn't fit :
Sequential & Random
: i got the problème that two users try to connect with the same password.Unique
: the virtual user takes one record every time he will execute the test. so that i have 5 records the test will be executed once per virtual user, and it's not what i wanted to do.What i wanted to do is that : 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, i've searched a lot and then found this on StackOverFlow : How to use different .csv for each core agent for Visual Studio Cloud Testing?
So i wrot this code as a testPlugin :
int AgentId = e.WebTest.Context.AgentId;
e.WebTest.Context["TestAgentPassword"] = "USER" + e.WebTest.Context.AgentId;
Locally, it works like a charm unique identifier for every agentID(1..5), but in the cloud all agentIds are the same = 1, so two users try to authenticate with the same password and that generate errors.
How can i Fix an id to every testAgent that will use until the end of the load test no matter how many webtests he execute.
Upvotes: 0
Views: 227
Reputation: 14076
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 ;
Upvotes: 1