I have created some Load Tests. All my load tests are consist of one unit test.
I have also created a LoadTest Plug-in and assigned it to all my load tests.
Each unit test updates some custom performance counters that I create in the LoadTest Plug-in (more details here) with the following code.
PlugIn code:
private void m_loadTest_LoadTestStarting(object sender, System.EventArgs e)
{
CounterCreationDataCollection counters = new CounterCreationDataCollection();
counters.Add(new CounterCreationData("CustomCoumter", "Custom Coumter description", PerformanceCounterType.AverageCount64));
PerformanceCounterCategory.Create("CustomCounterCategory", "Custom Performance Counters", PerformanceCounterCategoryType.MultiInstance, counters);
}
UnitTest code:
[TestClass]
public class UnitTest1
{
PerformanceCounter customCounter;
[ClassInitialize]
public static void ClassInitialize(TestContext TestContext)
{
// Create the instances of the counters for the current test
customCounter= new PerformanceCounter("CustomCounterCategory", "CustomCoumter", "UnitTest1", false));
}
[TestMethod]
public void TestMethod1()
{
// ... Testing
customCounter.Incerement(time);
}
}
Since the plugin is running in the Test Controller the custom counter category is created in the pc where the controller is running. Now I am running my Load Tests in a Test Rig using many Test Agents. When a unit test is executing in a pc other than this where the Test Controller is running the counter is not updated. I think this happens because with my code I am updating the counter in the pc where the test is running, NOT in the controller’s pc.
How can I update my custom counter in the controller’s pc? Do I have to create the counter’s instance in my unit tests with a different way?
Performance counters are usually used to monitor performance for components that are running locally on the machine. perfmon can then be used to monitor the performance counter for that machine. From what you describe, this is exactly what is happening.
So you would have to monitor the performance counter on the agent machines (after installing it there, of course) in order to get the data about the counter.
I assume that this counter is in some way measuring how long the test is taking. Because, if you were measuring the system under test then the performance counter increment would be integrated into the production code that is under test.
I’m not aware of any way to increment a performance counter on a remote machine, but this seems to be against the usual patten. However, there are ways to read remote performance counters (from the agent machines, for instance). I think this would be best in your circumstance.