开发者

Grid Hub http client timeout if waiting for a slot to be free

Is there a way to query my grid hub (2.6.0) to see if there are slots free for a particular desired capability?

Example:

Grid Hub web page at

http://localhost:4444/grid/console

Shows properly that 1 request should wait for a slot to be free so that test can continue after cu开发者_如何学Gorrent one finishes:


Grid Hub 2.6.0

WebDriverRemoteProxy listening on http://192.168.3.15:5523/wd/hub

test session time out after 300 sec.

Supports up to 1 concurrent tests

1 requests waiting for a slot to be free.

  • {platform=ANY, javascriptEnabled=true, cssSelectorsEnabled=true, browserName=firefox, nativeEvents=false, rotatable=false, takesScreenshot=true, version=}

view config


But the hub instead of returning some kind of json notification that it should hold on and wait it retuns nothing and client connection may simply timeout (depending on the http client library you are using).

I'm using ruby bindings but i can reproduce the error with plain curl, following in these steps:

Step 1. Server hub and node setup:

My Hub setup (on ubuntu server)

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

My Node setup (on windows xp machine):

java -jar selenium-server-standalone.jar -role webdriver -hub $HUBURL -port 5522 -maxSession 1 -browser "maxInstances=1,browserName=firefox"

Note maxSession and maxInstances are intentionally put at 1 to easily reproduce the issue.

Step 2. Run some long duration test to occupy the first and only available slot

(for the sake of the example)

Step 3. Emulate the running of another test with this curl request:

curl -L --max-redirs 20 -v -i -H "Accept: application/json" -X POST http://localhost:4444/wd/hub/session -d '{"desiredCapabilities":{"javascriptEnabled":false,"version":"","rotatable":false,"takesScreenshot":true,"cssSelectorsEnabled":true,"browserName":"firefox","nativeEvents":false,"platform":"ANY"}}'

Result:

Connection is left on hold, no server message indicating what's going on, a json message telling that you are waiting for a slot to be free should do it. On some http libraries this will simply timeout as it currently does on ruby gem 'selenium-webdriver' <= 2.6.0

So i need a way to query if there are slots free (for a particular desiredcapability) in order to avoid a client timeout error.

I checked JsonWireProtocol but couldn't find a path to request that info. JsonWireProtocol


Apparently ruby client can't wait and will timeout at a low-level.

Fortunately you can make Grid2 to throw an RuntimeException after certain amount of time:

Changing Maximum Wait Time for New Session

You can pass that parameter in ms when launching your grid hub:-newSessionWaitTimeout 25000

java -jar selenium-server-standalone.jar -role hub -newSessionWaitTimeout 25000

Using the curl params you provided you will see that now, after 25 seconds you will get:

{
  "status":13,
  "value":{
     "message":"java.lang.RuntimeException: Request timed out waiting 
      for a node to become available."...
}

Which is something you can work and handle on your ruby side.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜