Commit f1c06315 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

Seleniumserver: set slot quantity as an instance parameter

See merge request !1336
parents 553d2429 28f115bc
......@@ -56,6 +56,8 @@ install =
# FATAL:platform_font_linux.cc(83)] Check failed: InitDefaultFont(). Could not find the default font
export LD_LIBRARY_PATH=$d:%s
export PATH=%s:$PATH
# --disable-setuid-sandbox --no-sandbox --disable-gpu arguments are only required for chromium-wrapper-91
# they should be removed once we drop supporting this version
exec $d/chrome --disable-setuid-sandbox --no-sandbox --disable-gpu "$@"
""" % (
part['location'],
......
......@@ -15,8 +15,8 @@
[template]
filename = instance.cfg.in
md5sum = b443da6792bdde1218076a3a1ce50b11
md5sum = 58f6d112c90a23ae39f07a96fa5c8f1c
[template-selenium]
filename = instance-selenium.cfg.in
md5sum = 9bef75759623a660cfaf4b6f5a48a923
\ No newline at end of file
md5sum = 7d8bdc03f8feadc83d70f71df2ebb42d
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"description": "Parameters to request selenium instance",
"additionalProperties": false,
"properties": {
"ssh-authorized-key": {
"title": "SSH Key",
"description": "ssh public key",
"type": "string",
"default": ""
},
"slotQuantity": {
"title": "Slot quantity",
"description": "Number of slot per selenium node",
"type": "integer",
"default": 3
}
}
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"description": "Values returned by Selenium instanciation",
"properties": {
"backend-url": {
"description": "Selenium hub URL",
"type": "string"
},
"url": {
"description": "Selenium instance URL",
"type": "string"
},
"admin-url": {
"description": "Selenium admin URL",
"type": "string"
},
"ssh-url": {
"description": "Selenium ssh URL",
"type": "string"
},
"ssh-fingerprint": {
"description": "Selenium ssh key fingerprint",
"type": "string"
},
"run-node-command": {
"description": "Command to run a local Selenium node",
"type": "string"
}
}
}
{% set parameter_dict = dict(default_parameter_dict, **parameter_dict) -%}
[buildout]
parts =
monitor-base
......@@ -54,7 +55,6 @@ command-line =
-host $${:hostname}
-port $${:port}
-role hub
-maxSession 20
-newSessionWaitTimeout 600000
--debug
......@@ -82,6 +82,7 @@ command-line =
-host $${:hostname}
-port $${:port}
-role node
-maxSession {{ parameter_dict['slotQuantity'] }}
-timeout 300
-hub $${selenium-server-hub-instance:register-url}
-capabilities $${:capabilities}
......@@ -99,25 +100,25 @@ hostname = $${slap-configuration:ipv4-random}
[selenium-server-node-instance-firefox-102]
<= selenium-server-node-instance
capabilities = browserName=firefox,maxInstances=3,marionette=true,platform=LINUX,version=${firefox-102:version},firefox_binary=${firefox-wrapper-102:location}
capabilities = browserName=firefox,maxInstances={{ parameter_dict['slotQuantity'] }},marionette=true,platform=LINUX,version=${firefox-102:version},firefox_binary=${firefox-wrapper-102:location}
java-args = -Dwebdriver.gecko.driver=${geckodriver-0.33.0:location}
port = 7779
[selenium-server-node-instance-firefox-115]
<= selenium-server-node-instance
capabilities = browserName=firefox,maxInstances=3,marionette=true,platform=LINUX,version=${firefox-115:version},firefox_binary=${firefox-wrapper-115:location}
capabilities = browserName=firefox,maxInstances={{ parameter_dict['slotQuantity'] }},marionette=true,platform=LINUX,version=${firefox-115:version},firefox_binary=${firefox-wrapper-115:location}
java-args = -Dwebdriver.gecko.driver=${geckodriver-0.33.0:location}
port = 7780
[selenium-server-node-instance-chromium-91]
<= selenium-server-node-instance
capabilities = browserName=chrome,maxInstances=3,platform=LINUX,version=${chromium-91:version},chrome_binary=${chromium-wrapper-91:location}
capabilities = browserName=chrome,maxInstances={{ parameter_dict['slotQuantity'] }},platform=LINUX,version=${chromium-91:version},chrome_binary=${chromium-wrapper-91:location}
java-args = -Dwebdriver.chrome.driver=${chromedriver-wrapper-91:location}
port = 7781
[selenium-server-node-instance-chromium-120]
<= selenium-server-node-instance
capabilities = browserName=chrome,maxInstances=3,platform=LINUX,version=${chromium-120:version},chrome_binary=${chromium-wrapper-120:location}
capabilities = browserName=chrome,maxInstances={{ parameter_dict['slotQuantity'] }},platform=LINUX,version=${chromium-120:version},chrome_binary=${chromium-wrapper-120:location}
java-args = -Dwebdriver.chrome.driver=${chromedriver-wrapper-120:location}
port = 7782
......@@ -321,8 +322,8 @@ promise = check_command_execute
name = $${:_buildout_section_name_}.py
config-command =
$${selenium-server-check-nodes-registered:output} $${selenium-server-hub-instance:api-url} $${:expected-node-count}
# We have 4 nodes with 3 slots each
expected-node-count = 12
# We have 4 nodes with slotQuantity slots each
expected-node-count = {{ 4 * int(parameter_dict['slotQuantity']) }}
[selenium-server-check-nodes-registered]
recipe = slapos.recipe.template
......
......@@ -12,7 +12,13 @@ url = ${template-selenium:output}
output = $${buildout:parts-directory}/$${:_buildout_section_name_}/$${:filename}
filename = instance-selenium.cfg
context =
jsonkey default_parameter_dict :default-parameters
key parameter_dict slap-configuration:configuration
key partition_ipv6 slap-configuration:ipv6-random
default-parameters =
{
"slotQuantity": 3
}
[switch-softwaretype]
recipe = slapos.cookbook:switch-softwaretype
......
{
"name": "Selenium Server",
"description": "Selenium server running chromium and firefox nodes",
"serialisation": "xml",
"software-type": {
"default": {
"title": "Default",
"software-type": "default",
"description": "Request a selenium server",
"request": "instance-input-schema.json",
"response": "instance-output-schema.json",
"index": 0
}
}
}
......@@ -45,7 +45,6 @@ import requests
from PIL import Image
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.remote.remote_connection import RemoteConnection
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
......@@ -252,7 +251,7 @@ class TestBrowserSelection(WebServerMixin, SeleniumServerTestCase):
driver = webdriver.Remote(
command_executor=webdriver_url,
desired_capabilities=DesiredCapabilities.CHROME)
desired_capabilities=webdriver.ChromeOptions().to_capabilities())
driver.get(self.server_url)
self.assertEqual('Test page', driver.title)
......@@ -268,7 +267,7 @@ class TestBrowserSelection(WebServerMixin, SeleniumServerTestCase):
driver = webdriver.Remote(
command_executor=webdriver_url,
desired_capabilities=DesiredCapabilities.FIREFOX)
desired_capabilities=webdriver.FirefoxOptions().to_capabilities())
driver.get(self.server_url)
self.assertEqual('Test page', driver.title)
......@@ -281,7 +280,7 @@ class TestBrowserSelection(WebServerMixin, SeleniumServerTestCase):
parameter_dict = self.computer_partition.getConnectionParameterDict()
webdriver_url = parameter_dict['backend-url']
desired_capabilities = DesiredCapabilities.FIREFOX.copy()
desired_capabilities = webdriver.FirefoxOptions().to_capabilities()
desired_capabilities['version'] = '102.15.1esr'
driver = webdriver.Remote(
command_executor=webdriver_url,
......@@ -339,7 +338,7 @@ class TestFrontend(WebServerMixin, SeleniumServerTestCase):
driver = webdriver.Remote(
command_executor=executor,
desired_capabilities=DesiredCapabilities.CHROME)
desired_capabilities=webdriver.ChromeOptions().to_capabilities())
driver.get(self.server_url)
self.assertEqual('Test page', driver.title)
......@@ -414,7 +413,8 @@ class TestFirefox102(
SeleniumServerTestCase,
ImageComparisonTestCase,
):
desired_capabilities = dict(DesiredCapabilities.FIREFOX, version='102.15.1esr')
desired_capabilities = dict(webdriver.FirefoxOptions().to_capabilities(),
version='102.15.1esr')
user_agent = 'Gecko/20100101 Firefox/102.0'
def test_resize_window(self):
......@@ -426,7 +426,8 @@ class TestFirefox115(
SeleniumServerTestCase,
ImageComparisonTestCase,
):
desired_capabilities = dict(DesiredCapabilities.FIREFOX, version='115.3.1esr')
desired_capabilities = dict(webdriver.FirefoxOptions().to_capabilities(),
version='115.3.1esr')
user_agent = 'Gecko/20100101 Firefox/115.0'
def test_resize_window(self):
......@@ -438,7 +439,8 @@ class TestChrome91(
SeleniumServerTestCase,
ImageComparisonTestCase,
):
desired_capabilities = dict(DesiredCapabilities.CHROME, version='91.0.4472.114')
desired_capabilities = dict(webdriver.ChromeOptions().to_capabilities(),
version='91.0.4472.114')
user_agent = 'Chrome/91.0.4472.0'
......@@ -447,5 +449,6 @@ class TestChrome120(
SeleniumServerTestCase,
ImageComparisonTestCase,
):
desired_capabilities = dict(DesiredCapabilities.CHROME, version='120.0.6099.109')
desired_capabilities = dict(webdriver.ChromeOptions().to_capabilities(),
version='120.0.6099.109')
user_agent = 'Chrome/120.0.0.0'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment