selenium grid is not starting more than 5 sessions

[亡魂溺海] 提交于 2019-12-24 20:03:04

问题


I have done grid setup as follows:

Hub: iMAC

Started with: java -jar Downloads/selenium-server-standalone-2.52.0.jar -port 4444 -role hub

Node1: Win8 system

Started with: java -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-2.52.0.jar -role webdriver -hub http://192.168.1.103:4444/grid/register -nodeConfig Node1.json

Node2: Win10 system

Started with: java -Dwebdriver.chrome.driver=chromedriver.exe -jar selenium-server-standalone-2.52.0.jar -role webdriver -hub http://192.168.1.103:4444/grid/register -nodeConfig Node2.json

The contents of the json is as follows:

    {
  "capabilities":
      [
        {
          "browserName": "firefox",
          "maxInstances": 5,
          "seleniumProtocol": "WebDriver"
        },
        {
          "browserName": "chrome",
          "maxInstances": 5,
          "seleniumProtocol": "WebDriver"
        },
        {
          "platform": "WINDOWS",
          "browserName": "internet explorer",
          "maxInstances": 1,
          "seleniumProtocol": "WebDriver"
        }
      ],
  "configuration":
  {
    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "maxSession": 10,
    "port": 5557,
    "host": ip address of node1,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4444,
    "hubHost": ip address of hub
  }
}

Hub and nodes are started correctly. When i run a testng suite with 20 tests in the suite xml, with thread-count="10"

I see only 5 sessions are triggered,

  • 3 on Node1
  • 2 on Node2

Expected/Want to achieve: 10 sessions should be triggered, 5 on each nodes.

I tried the same setup with different versions of selenium server standalone, no luck though!!!

Please let me know if i'm doing any configuration mistakes.


回答1:


I haven't been able to reproduce your problem. Here's what I have.

Hub started using the command :

java -jar selenium-server-standalone-2.53.1.jar -role hub

Node #1 started using the command :

java -jar selenium-server-standalone-2.53.1.jar -role node -nodeConfig nodev2.json

Node #2 started using the command :

java -jar selenium-server-standalone-2.53.1.jar -role node -nodeConfig nodev2.json -port 5556

The contents of the node configuration file nodev2.json is as below :

{
    "capabilities": [
        {
            "browserName": "chrome",
            "maxInstances": 10,
            "seleniumProtocol": "WebDriver"
        }
    ],
    "configuration": {
        "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
        "maxSession": 10
    }
}

At this point, I have a hub which has 2 nodes and each of the nodes can support 10 concurrent sessions at any given point in time.

I now run the below shell script (which would try to create 21 sessions). The script will stall and not exit, at the 21st attempt of creating a new session, because the 21st session is going to go into the Hub's waiting queue. You can confirm that there are 20 chrome sessions consumed by opening up the Grid console : http://localhost:4444/grid/console

The shell script can look like below :

#!/bin/bash
counter=1
for number in {1..21}
do
    curl -i \
    -H "Accept: application/json" \
    -X POST -d '{"desiredCapabilities":{"browserName":"chrome"}}' \
    http://localhost:4444/wd/hub/session
    echo "Created session " $counter
    let counter++
done 


来源:https://stackoverflow.com/questions/45577761/selenium-grid-is-not-starting-more-than-5-sessions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!