1

I am setting up performance tests and am testing the performance of an Upload function. I want to now test performance when 5 users click the upload button at the same time. I don't know how to implement a way to do this. Below is the test I have setup for one user.

    [Test]
    [Category("PerfSingleUser")]
    public void PerfSingleUserUploadLargeDataSet()
    {
        driver.GoToHomePage();

        DateTime startDateTime = DateTime.Now;
        var sw = Stopwatch.StartNew();
        UploadFiles();
        sw.Stop();

        //Logging of performance results
        var testDesc = string.Format("Time for ALEX to upload a large data set (AC2Q15Files) in a {0} browser", Browser.GetType());
        StoreResultsInCSV(startDateTime, testDesc, elapsed);

        Assert.IsTrue(sw.Elapsed < TimeSpan.FromSeconds(20), "Uploading large data set, AC2Q15Files, in a {0} browser exceeded" +
             "20 seconds", browser.GetType());
    }
Mike Johnston
  • 237
  • 6
  • 20
  • What are you trying to test: the UI, the network, or the server? I can help with UI, but would generally test uploads with a low-level HTTP tools like `curl` (or Windows equivalent)... – Andrew Regan Feb 11 '16 at 23:16
  • The C# code inside of UploadFiles() just uploads a CSV file, then it waits for a button to become enabled. So the testing is handled within UploadFiles(). I am just measuring the time it takes for UploadFiles() to complete. The code works, I just need a way to measure each timing from 5 users at once using the UploadFiles() method. I think this may be better suited for JMeter, but I wanted to know if there was a way in Selenium/VS to be able to do things simultaneously within multiple tests. – Mike Johnston Feb 12 '16 at 15:46
  • Yes, with multiple browsers/sessions, I just wanted to check what you were trying to achieve. I'd agree that JMeter is probably a better fit, assuming you just want to 'drive' the uploads rather than test UI responsiveness, user experience etc. 5 is probably the upper limit of the number of browser sessions I'd want running. – Andrew Regan Feb 12 '16 at 15:49
  • Well actually for now, testing the UI responsiveness is really all that I am doing. There are no other metrics that I need to gather for now. I wait until a button becomes enabled after the Upload is complete, then gather those Wall Clock timings. – Mike Johnston Feb 12 '16 at 17:21
  • I'm not sure what test framework you're using, but you could just explicitly create 5 IWebDriver instances of your choice, parameterise `PerfSingleUserUploadLargeDataSet` to accept a driver parameter rather than a member variable, and just call the method explicitly for each driver, via a separate thread for each. Might be messy, but it should give you parallel testing of the uploads. – Andrew Regan Feb 12 '16 at 20:16
  • I am using Selenium with NUNIT framework. I thought about parallel testing, but cant figure out how accomplish kicking off the exact line of code simultaneously for all 5 tests. Running tests parallel now kicks off the test within a few seconds from eachother and then runs the lines of code also within more seconds. I need the UploadFiles method to run EXACTLY at the same time for each test – Mike Johnston Feb 16 '16 at 15:30

1 Answers1

0

I'd just use scheduled task threads - I don't do C# but perhaps similarly to this.

You can start up all your WebDriver instances up in one go (5 is probably the most you'd really want to have running at one). Once they're all ready, and the page you're testing has fully loaded within each, create a separate task thread for each that will perform the actual uploads.

Then simply schedule all the task threads to run at a fixed offset (or at a fixed time, e.g. one second in the future). That should kick them off within a few milliseconds of one another, and that's probably as close to simultaneous as you can get using real browsers.

Community
  • 1
  • 1
Andrew Regan
  • 5,087
  • 6
  • 37
  • 73