instance-selenium.cfg.in 13.8 KB
Newer Older
1 2
[buildout]
parts =
3
  monitor-base
4 5 6
  promises
  publish-connection-parameter

7
extends = ${monitor-template:rendered}
8
eggs-directory = ${buildout:eggs-directory}
9
develop-eggs-directory = ${buildout:develop-eggs-directory}
10 11
offline = true

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
[fontconfig-conf]
recipe = slapos.recipe.template:jinja2
template = ${template-fonts-conf:output}
rendered = $${directory:etc}/fonts.conf
context =
    key cachedir directory:fontconfig-cache
    key fonts :fonts
    key includes :includes
fonts =
    ${android-fonts:location}
    ${dejavu-fonts:location}
    ${ipa-fonts:location}
    ${ipaex-fonts:location}
    ${liberation-fonts:location}
    ${ocrb-fonts:location}
    $${directory:fonts}
# XXX we don't include conf.d for now, to keep compatibility with current font selection problems.
includes =
#    ${fontconfig:location}/etc/fonts/conf.d
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68

[xvfb-instance]
recipe = slapos.cookbook:wrapper
wrapper-path = $${directory:services}/$${:_buildout_section_name_}
command-line =
  ${xserver:location}/bin/Xvfb
    $${:display}
    -screen 0 1024x768x24
    -fbdir $${directory:framebuffer}

environment=
  XORG_LOCK_DIR=$${directory:tmp}
# We can safely use any $DISPLAY, because our slapos patched X11 isolate $DISPLAYs
# by placing sockets in $XORG_LOCK_DIR and using different $XORG_LOCK_DIR per partitions.
display = :0

# For selenium server options:
# https://github.com/SeleniumHQ/selenium/wiki/Grid2#configuring-the-nodes-by-command-line
[selenium-server-hub-instance]
recipe = slapos.cookbook:wrapper
wrapper-path = $${directory:services}/$${:_buildout_section_name_}
command-line =
  ${java-re-8:location}/bin/java
    -jar ${selenium-server:target}
    -host $${:hostname}
    -port $${:port}
    -role hub
    -maxSession 20
    -newSessionWaitTimeout 600000
    --debug

# newSessionWaitTimeout: let clients wait in the queue when no node are available
# maxSession: to accept enough clients
hostname = $${instance-parameter:ipv4-random}
port = 4444
base-url = http://$${:hostname}:$${:port}
url = $${:base-url}/wd/hub
register-url = $${:base-url}/grid/register/
69
api-url = $${:base-url}/grid/api/hub
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95


[selenium-server-node-instance]
# Macro for a selenium server node
capabilities =
port =
java-args =

recipe = slapos.cookbook:wrapper
wrapper-path = $${directory:services}/$${:_buildout_section_name_}
command-line =
  ${java-re-8:location}/bin/java $${:java-args}
    -jar ${selenium-server:target}
    -host $${:hostname}
    -port $${:port}
    -role node
    -timeout 300
    -hub $${selenium-server-hub-instance:register-url}
    -capabilities $${:capabilities}
    --debug

# browsers and drivers are in buildout bin-directory, so we add that directory to to $PATH
environment =
  PATH=${buildout:bin-directory}
  XORG_LOCK_DIR=$${directory:tmp}
  DISPLAY=$${xvfb-instance:display}
96
  FONTCONFIG_FILE=$${fontconfig-conf:rendered}
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
hostname = $${instance-parameter:ipv4-random}


[selenium-server-node-instance-firefox-52]
<= selenium-server-node-instance
capabilities = browserName=firefox,maxInstances=3,marionette=true,platform=LINUX,version=${firefox-52:version},firefox_binary=${firefox-wrapper-52:location}
java-args = -Dwebdriver.gecko.driver=${geckodriver-0.16.1:location}
port = 7777

[selenium-server-node-instance-firefox-60]
<= selenium-server-node-instance
capabilities = browserName=firefox,maxInstances=3,marionette=true,platform=LINUX,version=${firefox-60:version},firefox_binary=${firefox-wrapper-60:location}
java-args = -Dwebdriver.gecko.driver=${geckodriver-0.22.0:location}
port = 7778

112 113 114 115 116 117
[selenium-server-node-instance-firefox-68]
<= selenium-server-node-instance
capabilities = browserName=firefox,maxInstances=3,marionette=true,platform=LINUX,version=${firefox-68:version},firefox_binary=${firefox-wrapper-68:location}
java-args = -Dwebdriver.gecko.driver=${geckodriver-0.24.0:location}
port = 7779

118 119 120 121 122 123
[selenium-server-node-instance-firefox-78]
<= selenium-server-node-instance
capabilities = browserName=firefox,maxInstances=3,marionette=true,platform=LINUX,version=${firefox-78:version},firefox_binary=${firefox-wrapper-78:location}
java-args = -Dwebdriver.gecko.driver=${geckodriver-0.24.0:location}
port = 7780

124 125 126 127
[selenium-server-node-instance-chromium-69]
<= selenium-server-node-instance
capabilities = browserName=chrome,maxInstances=3,platform=LINUX,version=${chromium-69:version},chrome_binary=${chromium-wrapper-69:location}
java-args = -Dwebdriver.chrome.driver=${chromedriver-wrapper-2.41:location}
128
port = 7781
129

130 131 132 133
[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}
java-args = -Dwebdriver.chrome.driver=${chromedriver-wrapper-91:location}
134
port = 7782
135

136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151

[selenium-server-admin-password]
recipe = slapos.cookbook:generate.password
username = admin
bytes = 12

[selenium-server-selenium-password]
recipe = slapos.cookbook:generate.password
username = selenium
bytes = 12


[selenium-server-frontend-config]
recipe = slapos.recipe.template:jinja2
rendered = $${directory:etc}/$${:_buildout_section_name_}
template = inline:
152
  https://[$${:ip}]:$${:port} {
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
    bind $${:ip}
    tls self_signed # TODO
    proxy / $${selenium-server-hub-instance:base-url} {
      transparent
    }
    basicauth $${selenium-server-admin-password:username} $${selenium-server-admin-password:passwd} {
      realm "Grid Admin"
      $${:path-admin}
    }
    basicauth $${selenium-server-selenium-password:username} $${selenium-server-selenium-password:passwd} {
      realm "Selenium Server"
      $${:path-hub}
    }
  }
ip = $${instance-parameter:ipv6-random}
hostname = [$${:ip}]
port = 9443
path-admin = /grid/console
path-hub = /wd/hub


[selenium-server-frontend-instance]
recipe = slapos.cookbook:wrapper
wrapper-path = $${directory:services}/$${:_buildout_section_name_}
command-line =
  ${caddy:output} -conf $${selenium-server-frontend-config:rendered}

ip = $${selenium-server-frontend-config:ip}
hostname = $${selenium-server-frontend-config:hostname}
port = $${selenium-server-frontend-config:port}

admin-url = https://$${selenium-server-admin-password:username}:$${selenium-server-admin-password:passwd}@$${:hostname}:$${:port}$${selenium-server-frontend-config:path-admin}
url = https://$${selenium-server-selenium-password:username}:$${selenium-server-selenium-password:passwd}@$${:hostname}:$${:port}$${selenium-server-frontend-config:path-hub}


[userinfo]
recipe = slapos.cookbook:userinfo

[sshd-address]
recipe = slapos.cookbook:free_port
minimum = 22222
maximum = 22231
ip = $${slap-network-information:global-ipv6}
hostname = $${:ip}

[ssh-keygen-base]
recipe = plone.recipe.command
output = $${directory:etc}/$${:_buildout_section_name_}
command = ${openssh-output:keygen} -f $${:output} -N '' $${:extra-args}

[ssh-host-rsa-key]
<=ssh-keygen-base
extra-args=-t rsa
[ssh-host-dsa-key]
<=ssh-keygen-base
extra-args=-t dsa
[ssh-host-ecdsa-key]
<=ssh-keygen-base
extra-args=-t ecdsa -b 521

213
[ssh-key-fingerprint-shelloutput]
214
recipe = collective.recipe.shelloutput
215
# recent openssh client display ECDSA key's fingerprint as SHA256
216
commands =
217
  fingerprint = ${openssh-output:keygen} -lf $${ssh-host-ecdsa-key:output}
218

219 220 221 222 223 224 225 226 227 228 229
[ssh-key-fingerprint]
recipe = plone.recipe.command
stop-on-error = true
# XXX because collective.recipe.shelloutput ignore errors and capture output
# "Error ...", we use a plone.recipe.command to check that this command did
# not fail.
# This command will always fail on first buildout run, because
# collective.recipe.shelloutput is evaluated at buildout recipes __init__ step,
# but the key file is created later at install step.
command = echo "$${:fingerprint}" | ( grep ^Error || exit 0 && exit 1 )
fingerprint = $${ssh-key-fingerprint-shelloutput:fingerprint}
230

231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
[sshd-config]
recipe = slapos.recipe.template:jinja2
rendered = $${directory:etc}/sshd.conf
path_pid = $${directory:run}/sshd.pid
template = inline:
  PidFile $${:path_pid}
  Port $${sshd-address:port}
  ListenAddress $${sshd-address:ip}
  Protocol 2
  HostKey $${ssh-host-rsa-key:output}
  HostKey $${ssh-host-dsa-key:output}
  HostKey $${ssh-host-ecdsa-key:output}
  PasswordAuthentication no
  PubkeyAuthentication yes
  AuthorizedKeysFile $${sshd-authorized-key:authorized-keys-file}

  ClientAliveInterval 30
  ClientAliveCountMax 10
  ForceCommand echo "Welcome to SlapOS Selenium Server."; ${coreutils:location}/bin/sleep infinity

[sshd-service]
recipe = slapos.cookbook:wrapper
command-line = ${openssh:location}/sbin/sshd -D -e -f $${sshd-config:rendered}
wrapper-path = $${directory:services}/$${:_buildout_section_name_}
username = $${userinfo:pw-name}
ip = $${sshd-address:ip}
port = $${sshd-address:port}
url = ssh://$${:username}@[$${:ip}]:$${:port}


[sshd-authorized-key]
recipe = plone.recipe.command
stop-on-error = true
location = $${buildout:directory}/.ssh
authorized-keys-file = $${:location}/authorized_keys
command = mkdir -p $${:location} && echo '$${instance-parameter:configuration.ssh-authorized-key}' > $${:authorized-keys-file}


[promises]
recipe =
instance-promises =
272 273 274
  $${sshd-listen-promise:name}
  $${selenium-server-frontend-listen-promise:name}
  $${selenium-server-hub-listen-promise:name}
275
  $${selenium-server-hub-nodes-registered-promise:name}
276 277 278
  $${selenium-server-node-firefox-52-listen-promise:name}
  $${selenium-server-node-firefox-60-listen-promise:name}
  $${selenium-server-node-firefox-68-listen-promise:name}
279
  $${selenium-server-node-firefox-78-listen-promise:name}
280
  $${selenium-server-node-instance-chromium-69-listen-promise:name}
281
  $${selenium-server-node-instance-chromium-91-listen-promise:name}
282 283 284


[check-port-listening-promise]
285
<= monitor-promise-base
286
module = check_socket_listening
287
name = $${:_buildout_section_name_}.py
288 289 290

[sshd-listen-promise]
<= check-port-listening-promise
291
config-host = $${sshd-address:hostname}
292
config-port = $${sshd-address:port}
293 294 295

[selenium-server-frontend-listen-promise]
<= check-port-listening-promise
296
config-host = $${selenium-server-frontend-instance:ip}
297
config-port = $${selenium-server-frontend-instance:port}
298 299 300

[selenium-server-hub-listen-promise]
<= check-port-listening-promise
301
config-host = $${selenium-server-hub-instance:hostname}
302
config-port = $${selenium-server-hub-instance:port}
303

304 305 306 307 308 309 310
# Promise waiting for all nodes to be registered
[selenium-server-hub-nodes-registered-promise]
<= monitor-promise-base
module = check_command_execute
name = $${:_buildout_section_name_}.py
config-command =
  $${selenium-server-check-nodes-registered:rendered} $${selenium-server-hub-instance:api-url} $${:expected-node-count}
311 312
# We have 6 nodes with 3 slots each
expected-node-count = 18
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327

[selenium-server-check-nodes-registered]
recipe = slapos.recipe.template:jinja2
rendered = $${directory:bin}/$${:_buildout_section_name_}
mode = 0755
template =
  inline:
  #!${buildout:executable}
  import json, urllib, sys
  api_url = sys.argv[1]
  expected_node_count = int(sys.argv[2])
  actual_node_count = json.load(urllib.urlopen(api_url))['slotCounts']['total']
  sys.exit(0 if expected_node_count == actual_node_count else 1)


328 329
[selenium-server-node-firefox-52-listen-promise]
<= check-port-listening-promise
330
config-host = $${selenium-server-node-instance-firefox-52:hostname}
331
config-port = $${selenium-server-node-instance-firefox-52:port}
332 333 334

[selenium-server-node-firefox-60-listen-promise]
<= check-port-listening-promise
335
config-host = $${selenium-server-node-instance-firefox-60:hostname}
336
config-port = $${selenium-server-node-instance-firefox-60:port}
337

338 339
[selenium-server-node-firefox-68-listen-promise]
<= check-port-listening-promise
340
config-host = $${selenium-server-node-instance-firefox-68:hostname}
341
config-port = $${selenium-server-node-instance-firefox-68:port}
342

343 344 345 346 347
[selenium-server-node-firefox-78-listen-promise]
<= check-port-listening-promise
config-host = $${selenium-server-node-instance-firefox-78:hostname}
config-port = $${selenium-server-node-instance-firefox-78:port}

348 349
[selenium-server-node-instance-chromium-69-listen-promise]
<= check-port-listening-promise
350
config-host = $${selenium-server-node-instance-chromium-69:hostname}
351
config-port = $${selenium-server-node-instance-chromium-69:port}
352

353 354 355 356 357
[selenium-server-node-instance-chromium-91-listen-promise]
<= check-port-listening-promise
config-host = $${selenium-server-node-instance-chromium-91:hostname}
config-port = $${selenium-server-node-instance-chromium-91:port}

358 359 360 361 362 363 364 365

[publish-connection-parameter]
recipe = slapos.cookbook:publish
backend-url = $${selenium-server-hub-instance:url}
url = $${selenium-server-frontend-instance:url}
admin-url = $${selenium-server-frontend-instance:admin-url}

ssh-url = $${sshd-service:url}
366
ssh-fingerprint = $${ssh-key-fingerprint:fingerprint}
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
# to run a local node - useful to see what tests are doing or
# using to use unsupported browsers like safari or edge or to test
# on mobile using appium.
# $PORT must be free on both hosts, different clients must use different ports.
run-node-command = PORT=7999 bash -c 'trap '"'"'kill -TERM $SSHPID; wait $SSHPID '"'"' TERM INT; ssh -L 4444:$${selenium-server-hub-instance:hostname}:$${selenium-server-hub-instance:port} -R $PORT:127.0.0.1:$PORT -p $${sshd-service:port} $${sshd-service:username}@$${sshd-service:ip} & SSHPID=$!; java -jar selenium-server-standalone-3.14.0.jar -role node -host 127.0.0.1 -port $PORT ; wait "$SSHPID"'


[instance-parameter]
recipe = slapos.cookbook:slapconfiguration
computer = $${slap-connection:computer-id}
partition = $${slap-connection:partition-id}
url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}
# A ssh public key, as found in ~/.ssh/authorized_keys
# multiple keys can be given, indented in a buildout compatible format (mmmh)
configuration.ssh-authorized-key =

[directory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc
var = $${buildout:directory}/var
srv = $${buildout:directory}/srv
bin = $${buildout:directory}/bin
tmp = $${buildout:directory}/tmp

services = $${:etc}/service
framebuffer = $${:srv}/framebuffer
fonts = $${:srv}/fonts/
396 397
fontconfig-cache = $${buildout:directory}/.fontconfig

398
ssh = $${:etc}/ssh
399
run = $${:var}/run