0

I am using Visual Studio Ultimate 2013 to do some load tests. I have some test data attached to my web test, with 10,000 rows of unique data, and i also have a web test plugin in another project, which i have referenced. in the web test.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.QualityTools.WebTestFramework;
using Microsoft.VisualStudio.TestTools.WebTesting;



namespace VUControl
{
    public class VUControl : WebTestPlugin
    {
        public override void PreWebTest(object sender, PreWebTestEventArgs e)
        {
            base.PreWebTest(sender, e);
            e.WebTest.MoveDataTableCursor("testdata", "strictly#csv", e.WebTest.Context.WebTestUserId);
        }
    }
}

I have set the Source table properties to 'Do not move cursor automatically'.

The load test is set to run on the cloud, running for 5 minutes with 500 users.

On running the tests, i am getting around 9500 tests completing succesfully, but i am only getting around 10 unique sets of data generated in the database.

The page i am testing is essentially a registration page on a web site.

can anyone tell me why i would only see 10 random selections of data appear?

Karl
  • 67
  • 1
  • 7
  • As well as adding the plugin project in the web test project's references you must call the plugin - use "Add web test plug-in...". Just because a web test runs without reporting any errors does not mean the individual tests worked. Suggest adding validation rules to several of the requests in the test to check for words like "enter username and password" on the first response. Then check for words like "login successful", "database record created", "logout successful" on the subsequent responses. – AdrianHHH May 27 '15 at 11:47
  • I'll get back on this. In the mean while did you get a chance to look at this http://stackoverflow.com/questions/9704992/how-to-call-movedatatablecursor-in-a-web-test-plugin-to-go-through-a-limited-set – Ranganath Govardhanagiri Jun 26 '15 at 13:16

1 Answers1

0

I would guess that you have 10 load generators? Or maybe a max of 10 threads?

The real problem, in my humble opinion, is that the MoveDataTableCursor() method works in a stand alone webtest, but NOT when that same web or API test is included in a load test. You can workaround this issue by implementing a row count for your dataset, like so:

// datasetRowNumber is a pointer to the row number of an in-memory copy of the dataset. Each agent has a copy of the dataset.
static int datasetRowNumber; 
public override void PreWebTest(object sender, PreWebTestEventArgs e)
    {
        int totalAgentCount = e.WebTest.Context.AgentCount; // Used in a modulus operation to skip rows in the dataset
        int agentID = e.WebTest.Context.AgentId; //Used in conjunction with totalAgentCount in the modulus operation 


        while ((datasetRowNumber++ % totalAgentCount) != (e.WebTest.Context.AgentId - 1))
        {
           // We have incremented datasetRowNumber in the line above. 
           // Here is where we will use it to point to the new row. 
            e.WebTest.MoveDataTableCursor(DSName, tableName, datasetRowNumber);
        }

            string dataValue = e.WebTest.Context["DataSource1.SampleData.PRNCode"].ToString();

        // Logging. Comment this out during a load test!
        // writer.WriteToLog("Value=" + dataValue + ", TotalAgentCount=" + e.WebTest.Context.AgentCount + ", AgentID=" + e.WebTest.Context.AgentId + ", Iteration=" + iteration);

    }

The above code is an implementation of the code in the following blog: https://blogs.msdn.microsoft.com/slumley/2008/03/14/description-of-access-methods-in-data-sources/. Sean Lumley's "Description of Access Methods" works great for a web test, but when placed into a load test, the MoveDataTableCursor() method does not work as expected.

The above code makes use of the overload for MoveDataTableCursor() described subtlety in https://blogs.msdn.microsoft.com/slumley/2010/01/04/vsts-2010-feature-data-source-enhancements

Without the datasetRowNumber variable, Slumley's code does not advance the cursor in a load test; in Lumley's version, the cursor advancement only works in a stand-alone webtest.

Charlesdwm
  • 71
  • 5