0

When I execute more than 5 tests in parallel using TestNG via Selenium Grid, only 5 are getting executed simultaneously. The rest are getting queued. I have configured my node so that it supports 7 instances of Chrome. Why are the 2 remaining instances not getting utilized?

Here is the node screenshot from Grid Console:

enter image description here

Node Configuration Screenshot:

Node configuration

Node Start Code:

java -jar selenium-server-standalone-3.8.1.jar -role node  -hub http://localhost:4444/grid/register -port 5556 -nodeConfig nodeConfig.json

Node Config JSON:

{
  "capabilities": [

    {
      "browserName": "chrome",
      "platform": "WIN10",
      "maxInstances": 7
    }

  ],
  "hub": "http://selenium-hub-host:4444"
}

TestNG XML (I am using parallel to run all the 7 tests in parallel):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">


<suite name="myTestSuit" parallel="tests" thread-count="10">


    <test name="myTest1">

        <parameter name="browser" value="Chrome"></parameter>

        <classes>

            <class name="testClass1"></class>
            <class name="testClass2"></class>
            <class name="testClass3"></class>

        </classes>

    </test>


    <test name="myTest2">

        <parameter name="browser" value="Chrome"></parameter>

        <classes>

            <class name="testClass1"></class>
            <class name="testClass2"></class>
            <class name="testClass3"></class>

        </classes>

    </test>


    <test name="myTest3">

        <parameter name="browser" value="Chrome"></parameter>

        <classes>

            <class name="testClass1"></class>
            <class name="testClass2"></class>
            <class name="testClass3"></class>

        </classes>

    </test>


    <test name="myTest4">

        <parameter name="browser" value="Chrome"></parameter>

        <classes>

            <class name="testClass1"></class>
            <class name="testClass2"></class>
            <class name="testClass3"></class>

        </classes>

    </test>


    <test name="myTest5">

        <parameter name="browser" value="Chrome"></parameter>

        <classes>

            <class name="testClass1"></class>
            <class name="testClass2"></class>
            <class name="testClass3"></class>

        </classes>

    </test>



    <test name="myTest6">

        <parameter name="browser" value="Chrome"></parameter>

        <classes>

            <class name="testClass1"></class>
            <class name="testClass2"></class>
            <class name="testClass3"></class>

        </classes>

    </test>


    <test name="myTest7">

        <parameter name="browser" value="Chrome"></parameter>

        <classes>

            <class name="testClass1"></class>
            <class name="testClass2"></class>
            <class name="testClass3"></class>

        </classes>

    </test>



</suite>

(I also tried creating two nodes in my system. Each supports 5 Chromes so total I have 10 Chrome instances. In this case, also only 5 of the total available instances are getting utilized).

anandhu
  • 686
  • 2
  • 13
  • 40
  • Check that answer https://stackoverflow.com/questions/13723349/selenium-grid-maxsessions-vs-maxinstances – KunduK Jan 09 '20 at 13:08

3 Answers3

1

You need to change the maxSession parameter in the node's config JSON.

For example,

{
  "capabilities":
  [
    {
      "browserName": "chrome",
      "platform": "WIN10",
      "maxInstances": 7
    }
  ],
  "maxSession": 10,
  "hub": "http://selenium-hub-host:4444",

}
Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
  • I tried this but no luck. When I give maxSession value less than 5, say 4, then it opens only 4 sessions and others 3 tests will be queued. However when I set maxSessio greater than 5, still only 5 sessions are opening and rest 2 tests are geting queued – anandhu Jan 09 '20 at 13:24
  • Finally i was able to fix this by updating the thread count in TestNG xml. That was another issue. Thanks! – anandhu Jan 09 '20 at 14:04
1

By default thread count is 5, so only browsers are opening. Actually you need to specify it in testng.xml file. in suite tag thread-count='7' or '10' as your wish.

murali selenium
  • 3,847
  • 2
  • 11
  • 20
  • 1
  • 1
    Thanks this was indeed an issue. So my tests were getting queued in TestNG itself. Your solution fixed it. But unfortunately still the 2 of my 5 tests are getting queued in Selenium Grid. I can now (after fixing the thread count issue in test NG with your solution), see in the Grid console that 2 of the tests are in queue. (So TestNG is properly triggering the 7 threads now). I have updated my new XML and Node Screenshot(which now shows 2 queued tests) in the question – anandhu Jan 09 '20 at 13:50
  • Finally i fixed this. I updated my json file with maxSession : 10. and now i am able to lauch all 7 sessions. Thank you! – anandhu Jan 09 '20 at 14:05
1

I was able to fix this by applying both the solutions of @murali selenium and @Ratmir Asanov.

  1. First in TestNG XML, set thread-count="10" (Defaul value will be 5)
  2. Now, inside Node config JSON, set "maxSession": 10 (By default only 5 sessions will be allowed in a 'MACHINE')
anandhu
  • 686
  • 2
  • 13
  • 40