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

7
extends = ${monitor-template:rendered}
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 69 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 96 97
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} 
offline = true

[fontconfig-instance]
recipe = slapos.cookbook:fontconfig
conf-path = $${directory:etc}/font.conf
font-system-folder = ${fonts:location}
font-folder = $${directory:fonts}
service-folder = $${directory:services}

[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/


[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}
  FONTCONFIG_FILE=$${fontconfig-instance:conf-path}
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

98 99 100 101 102 103
[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

104 105 106 107
[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}
108
port = 7780
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125


[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:
126
  https://[$${:ip}]:$${:port} {
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 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
    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

187 188 189 190 191 192 193 194 195 196 197 198 199
[ssh-key-fingerprint-command]
recipe = plone.recipe.command
# recent openssh client display ECDSA key's fingerprint as SHA256
command = ${openssh-output:keygen} -lf $${ssh-host-ecdsa-key:output}

[ssh-key-fingerprint]
recipe = collective.recipe.shelloutput
# XXX because collective.recipe.shelloutput ignore errors, we run the same
# command in a plone.recipe.command so that if fails if something goes wrong.
commands =
  fingerprint = $${ssh-key-fingerprint-command:command}


200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
[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
  UsePrivilegeSeparation no
  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 =
242 243 244 245 246 247 248
  $${sshd-listen-promise:name}
  $${selenium-server-frontend-listen-promise:name}
  $${selenium-server-hub-listen-promise:name}
  $${selenium-server-node-firefox-52-listen-promise:name}
  $${selenium-server-node-firefox-60-listen-promise:name}
  $${selenium-server-node-firefox-68-listen-promise:name}
  $${selenium-server-node-instance-chromium-69-listen-promise:name}
249 250 251


[check-port-listening-promise]
252 253 254
<= monitor-promise-base
module = check_port_listening
name = $${:_buildout_section_name_}.py
255 256 257

[sshd-listen-promise]
<= check-port-listening-promise
258 259
config-hostname = $${sshd-address:hostname}
config-port = $${sshd-address:port}
260 261 262

[selenium-server-frontend-listen-promise]
<= check-port-listening-promise
263 264
config-hostname = $${selenium-server-frontend-instance:ip}
config-port = $${selenium-server-frontend-instance:port}
265 266 267

[selenium-server-hub-listen-promise]
<= check-port-listening-promise
268 269
config-hostname = $${selenium-server-hub-instance:hostname}
config-port = $${selenium-server-hub-instance:port}
270 271 272

[selenium-server-node-firefox-52-listen-promise]
<= check-port-listening-promise
273 274
config-hostname = $${selenium-server-node-instance-firefox-52:hostname}
config-port = $${selenium-server-node-instance-firefox-52:port}
275 276 277

[selenium-server-node-firefox-60-listen-promise]
<= check-port-listening-promise
278 279
config-hostname = $${selenium-server-node-instance-firefox-60:hostname}
config-port = $${selenium-server-node-instance-firefox-60:port}
280

281 282
[selenium-server-node-firefox-68-listen-promise]
<= check-port-listening-promise
283 284
config-hostname = $${selenium-server-node-instance-firefox-68:hostname}
config-port = $${selenium-server-node-instance-firefox-68:port}
285

286 287
[selenium-server-node-instance-chromium-69-listen-promise]
<= check-port-listening-promise
288 289
config-hostname = $${selenium-server-node-instance-chromium-69:hostname}
config-port = $${selenium-server-node-instance-chromium-69:port}
290 291 292 293 294 295 296 297 298


[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}
299
ssh-fingerprint = $${ssh-key-fingerprint:fingerprint}
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
# 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/
ssh = $${:etc}/ssh
run = $${:var}/run