locked
Load Test datasource distribution RRS feed

  • Question

  • Hello, I'm working on a set of load tests to have a set amount of users iterating through a website in the same order as each other.

    I have 2 datasources - one for the usernames and one for id's which are used in a loop within the web test so that each user will hit each part of the website once (driven from databindings to both URL's and querystring parameters).

    The usernames datasource works fine with an access method of unique so there are no clashes.

    I am not worried about clashes in the id datasource as I wish users to go through the same part of the website as each other in the same order (makes it easier to identify which parts of the site are slower under load).

    I have tried the access method of sequential and from my observations the load test passes each agent a datasource and depending on how many users each agent runs they alternate through the datasource. As I only have a handful of agents to use this means the users don't step through in the same order as they only get a percentage of the datasource to loop through depending on their pace.

    Currently my 'fix' is a complete fudge as I have an access method of unique with each id duplicated within the datasource to try and make it that when the datasource is split among agents at the start that each user effectively gets a set of unique id's which is the same as each user in the test.

    The 'fix' is far from ideal as it is increasingly leading to a larger and larger datsource and I have to have a new datasource for each user load - e.g. 10 users need 300 rows (10x30 unique id's), 20 users need 600 rows(20x30 unique id's) etc.

    An ideal solution would be a datasource with unique id's and when the load test runs each user gets a copy to iterate through at their own pace. I'm thinking the best way to achieve this is through a web-plugin or a load-plugin but I'm quite new to coding (C#) and I don't know where to begin. Has anyone got any ideas/ examples of this being done already?

    mercredi 15 février 2012 17:33

Réponses

  • I've found a way around this issue now by using plugins which ignore the datasource rows and select the next row based on the username which is a context parameter and the loop counter which is also a context parameter, once the relevant value is selected it is passed into the test as the desired context parameter.
    • Marqué comme réponse Nick_Sandel jeudi 12 avril 2012 15:40
    jeudi 12 avril 2012 15:40

Toutes les réponses

  • Nick_Sandel,

    Yes, you will have to write plug-in to achive this. With Sequential access method, each agent will have its own datasource copy that will be distributed across virtual users that the agent is running. See Description of Access methods in data sources.

    To enable each user to use each row of the datasource, you can use 'Do Not Move Cursor Automatically' access method in the datasource so that the same row will be used as input to all the virtual user tests. To manually move the cursor to next row, you can aply a condition i.e. when last user uses the same row, move cursor to next row using a WebTestPlugin.

     public class DatasourcePlugin : WebTestPlugin
        {
            public override void PreWebTest(object sender, PreWebTestEventArgs e)
            {
                if (int.Parse(e.WebTest.Context["$WebTestUserId"]) == 1)//you will have to replace '1' with the a suitable count according to the v users on the agent.
                    e.WebTest.MoveDataTableCursor("DataSource1", "Products#csv");
            }
        } 

    See VSTS 2010 Feature: Data Source Enhancements.

    -Tejas.

    jeudi 16 février 2012 08:04
  • Tejas,

    Thanks for another really quick response! Your solution sounds interesting, however I am concerned if this would work as I wish. Although the users need to step through in the same order they will not necessarily step through at the same pace, so if I move a cursor after a particular user has accessed the data source it could lead to some users duplicating access to rows and some missing rows entirely (if I'm understanding how this would work properly).

    Is there a way I could instruct the load test to distribute one data source for each test iteration instead of one for each test agent and then bind each data source to each iteration/virtual user?

    jeudi 16 février 2012 09:23
  • I've found a way around this issue now by using plugins which ignore the datasource rows and select the next row based on the username which is a context parameter and the loop counter which is also a context parameter, once the relevant value is selected it is passed into the test as the desired context parameter.
    • Marqué comme réponse Nick_Sandel jeudi 12 avril 2012 15:40
    jeudi 12 avril 2012 15:40