alcounit / selenosis

Scalable, stateless selenium hub for Kubernetes cluster
Apache License 2.0
81 stars 24 forks source link

Selenosis always starts default version of browser, capabilities version ignored #23

Closed alcounit closed 3 years ago

alcounit commented 3 years ago

Browser version passed via capabilities is ignored and default version selected by default. Looks like broken by https://github.com/alcounit/selenosis/pull/19.

{
   "desiredCapabilities":{
      "browserName":"chrome",
      "version":"85.0",
      "enableVNC":true,
      "name":"TestName",
      "screenResolution": "1920x1080x24"
   },
   "capabilities":{
      "alwaysMatch":{
         "browserName":"chrome",
         "browserVersion":"85.0"
      }
   }
}

log:

time="2021-03-10T15:13:09Z" level=info msg=session request="POST /wd/hub/session" request_id=c0a6a600-b49b-4d5d-9c26-8bdfda6628e8 time_elapsed=0.00s
time="2021-03-10T15:13:09Z" level=info msg="starting browser from image: selenoid/vnc:chrome_89.0" request="POST /wd/hub/session" request_id=c0a6a600-b49b-4d5d-9c26-8bdfda6628e8 time_elapsed=0.00s
time="2021-03-10T15:13:13Z" level=info msg="browser sessionId: selenoid-vnc-chrome-89-0-2c7d05ae-40ba-4b4a-8faa-bb4d54bee59d" request="POST /wd/hub/session" request_id=c0a6a600-b49b-4d5d-9c26-8bdfda6628e8 time_elapsed=4.43s
RouR commented 3 years ago

I see regression in v1.0.5

alcounit commented 3 years ago

Reopen to investigate

alcounit commented 3 years ago

Can't reproduce

POST http://cluster_local:31000/wd/hub/session

{
   "desiredCapabilities":{
      "browserName":"chrome",
      "version":"85.0",
      "enableVNC":true,
      "name":"TestName",
      "screenResolution": "1920x1080x24"
   },
   "capabilities":{
      "alwaysMatch":{
         "browserName":"chrome",
         "browserVersion":"85.0"
      }
   }
}

My config:

chrome:
  defaultVersion: "90.0"
  path: "/"
  kernelCaps:
  - SYS_ADMIN
  spec:
    resources:
      requests:
        memory: 512Mi
        cpu: '500m'
      limits:
        memory: 1Gi
        cpu: '500m'
  versions:
    '85.0':
      image: selenoid/vnc:chrome_85.0
    '90.0':
      image: selenoid/vnc:chrome_90.0
    '91.0':
      image: selenoid/vnc:chrome_91.0

Selenosis log:

time="2021-06-09T10:21:10Z" level=info msg="starting selenosis v1.0.5"
time="2021-06-09T10:21:10Z" level=info msg="browsers config file loaded"
time="2021-06-09T10:21:10Z" level=info msg="config watcher started"
time="2021-06-09T10:21:10Z" level=info msg="kubernetes client created"
time="2021-06-09T10:21:10Z" level=info msg="current cluster state: sessions - 1, workers - 2, session limit - 40"
time="2021-06-09T10:21:10Z" level=info msg="selenosis worker: selenoid-ui-847c76bf88-rvmq4 added, current namespace quota limit: 42"
time="2021-06-09T10:21:10Z" level=info msg="selenosis worker: selenosis-7989c7d794-w2hzg added, current namespace quota limit: 42"
time="2021-06-09T10:21:57Z" level=info msg=session request="POST /wd/hub/session" request_id=f809143a-66a3-4d01-9f2a-bcc4307ed8fb time_elapsed=0.00s
time="2021-06-09T10:21:57Z" level=info msg="starting browser from image: selenoid/vnc:chrome_85.0" request="POST /wd/hub/session" request_id=f809143a-66a3-4d01-9f2a-bcc4307ed8fb time_elapsed=0.00s
time="2021-06-09T10:22:07Z" level=info msg="browser sessionId: vnc-chrome-85-0-1f92985e-dbbe-42f6-8081-5f44a8f22bed" request="POST /wd/hub/session" request_id=f809143a-66a3-4d01-9f2a-bcc4307ed8fb time_elapsed=9.71s

@RouR Please provide steps to reproduce

RouR commented 3 years ago
{
   "desiredCapabilities":{
      "browserName":"chrome",
      "browserVersion":"79",
      "goog:chromeOptions":{
         "args":[           
            "--ignore-certificate-errors",
            "--disable-notifications"
         ],
         "localState":{
            "reader.parse-on-load.enabled":true
         }
      }
   },
   "capabilities":{
      "firstMatch":[
         {
            "browserName":"chrome",
            "browserVersion":"79",
            "goog:chromeOptions":{
               "args":[                 
                  "--ignore-certificate-errors",
                  "--disable-notifications"
               ],
               "localState":{
                  "reader.parse-on-load.enabled":true
               }
            }
         }
      ]
   }
}
time="2021-06-09T10:52:56Z" level=info msg=session request="POST /wd/hub/session" request_id=46d424f8-1b03-4f3c-b716-9402f09f6b24 time_elapsed=0.00s
time="2021-06-09T10:52:56Z" level=info msg="starting browser from image: selenoid/vnc:chrome_90.0" request="POST /wd/hub/session" request_id=46d424f8-1b03-4f3c-b716-9402f09f6b24 time_elapsed=0.00s
time="2021-06-09T10:53:05Z" level=info msg="browser sessionId: vnc-chrome-90-0-e3c134c1-eb8f-4769-af38-a5b1bbfd21cc" request="POST /wd/hub/session" request_id=46d424f8-1b03-4f3c-b716-9402f09f6b24 time_elapsed=8.79s

I guess the reason is "firstMatch". https://w3c.github.io/webdriver/#new-session

alcounit commented 3 years ago

Thanks @RouR , I assume your browser config file something like this:

chrome:
  defaultVersion: "90.0"
  path: "/"
  versions:
    '79.0':
      image: selenoid/vnc:chrome_79.0
    '90.0':
      image: selenoid/vnc:chrome_90.0
    '91.0':
      image: selenoid/vnc:chrome_91.0

In your session create request you are passing browser version as 79, try to change it to 79.0 or update browser config version to '79'

{
   "desiredCapabilities":{
      "browserName":"chrome",
      "browserVersion":"79",
      "goog:chromeOptions":{
         "args":[           
            "--ignore-certificate-errors",
            "--disable-notifications"
         ],
         "localState":{
            "reader.parse-on-load.enabled":true
         }
      }
   },
   "capabilities":{
      "firstMatch":[
         {
            "browserName":"chrome",
            "browserVersion":"79",
            "goog:chromeOptions":{
               "args":[                 
                  "--ignore-certificate-errors",
                  "--disable-notifications"
               ],
               "localState":{
                  "reader.parse-on-load.enabled":true
               }
            }
         }
      ]
   }
}

Please close the bug if the issue solved.

RouR commented 3 years ago

Yes, changing browserVersion from "79" to "79.0" was helpfull. This issue can be closed, but i hope that converting from "79" to "79.0" would be default behaviour.

RouR commented 3 years ago

(i don`t have permissions to close this issue)

alcounit commented 3 years ago

@RouR thanks for the feedback.