instance-zope.cfg.in 22.7 KB
Newer Older
1
{% from "instance_zodb_base" import zodb_dict  with context %}
2
{% set webdav = slapparameter_dict['webdav'] -%}
3
{% set with_max_rlimit_nofile = slapparameter_dict['with-max-rlimit-nofile'] -%}
4
{% set thread_amount = slapparameter_dict['thread-amount'] %}
5
{% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%}
6
{% set ports = itertools.count(slapparameter_dict['port-base']) -%}
7
{% set site_id = slapparameter_dict['site-id'] -%}
8
{% set instance_index_list = range(slapparameter_dict['instance-count']) -%}
9
{% set node_id_base = slapparameter_dict['name'] -%}
10
{% set selenium_server_configuration_dict = slapparameter_dict.get('selenium-server-configuration-dict', None) -%}
11
{% set node_id_index_format = '-%%0%ii' % (len(str(instance_index_list[-1])), ) -%}
12 13
{% set part_list = [] -%}
{% set publish_list = [] -%}
14
{% set test_runner_address_list = [] -%}
15
{% set test_runner_enabled = slapparameter_dict['test-runner-enabled'] -%}
16
{% set test_runner_node_count = slapparameter_dict['test-runner-node-count'] -%}
17
{% set test_runner_random_activity_priority = slapparameter_dict['test-runner-random-activity-priority'] -%}
18
{% set longrequest_logger_base_path = buildout_directory ~ '/var/log/longrequest_logger_' -%}
19 20 21 22 23
{% if webdav -%}
{%   set timerserver_interval = 0 -%}
{% else -%}
{%   set timerserver_interval = slapparameter_dict['timerserver-interval'] -%}
{%- endif %}
24 25 26 27 28 29 30 31
{% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%}
{% set bin_directory = parameter_dict['buildout-bin-directory'] -%}
{#
XXX: This template only supports exactly one IPv4 and one IPv6 per
partition. No more (undefined result), no less (IndexError).
-#}
{% set ipv4 = (ipv4_set | list)[0] -%}

32
{% set publishable_hosts_dict = {} -%}
33 34 35 36 37 38
{% set port_dict = {} -%}
{% for alias, url in (
    ('erp5-memcached-volatile', slapparameter_dict['memcached-url']),
    ('erp5-memcached-persistent', slapparameter_dict['kumofs-url']),
    ('erp5-smtp', slapparameter_dict['smtp-url']),
  ) -%}
39
{%   set parsed_url = urllib_parse.urlparse(url) -%}
40
{%   do port_dict.__setitem__(alias, parsed_url.port)  -%}
41
{%   do publishable_hosts_dict.__setitem__(alias, parsed_url.hostname)  -%}
42 43
{%- endfor %}
{% for i, url in enumerate(slapparameter_dict['mysql-url-list']) -%}
44
{%   do publishable_hosts_dict.__setitem__(
45
       'erp5-catalog-' ~ i,
46
       urllib_parse.urlparse(url).hostname,
47 48
     ) -%}
{%- endfor %}
49 50 51
{% do publishable_hosts_dict.update(slapparameter_dict['hosts-dict']) -%}
{% set hosts_dict = publishable_hosts_dict.copy() -%}
{% do hosts_dict.update(slapparameter_dict['computer-hosts-dict'].get(computer, {})) -%}
52

53 54 55
[jinja2-template-base]
recipe = slapos.recipe.template:jinja2

56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
[erp5-kernel]
recipe = slapos.cookbook:symbolic.link
link-binary = {{ parameter_dict['erp5-kernel-location'] }}/{{ parameter_dict['erp5-kernel-filename'] }}
target-directory = ${directory:erp5-kernel-dir}

[kernel-json-dir]
<= jinja2-template-base
template = {{ parameter_dict['kernel-json-location'] }}/{{ parameter_dict['kernel-json-filename'] }}
rendered = ${directory:erp5-kernel-dir}/kernel.json
context =
  raw erp5_url {{ ipv4 }}
  raw python_executable {{ parameter_dict['python-executable-for-kernel'] }}
  raw kernel_dir ${erp5-kernel:target-directory}/{{ parameter_dict['erp5-kernel-filename'] }}
  raw display_name ERP5
  raw language_name python

72
[run-common]
73
<= userhosts-wrapper-base
74 75 76 77 78
environment-extra =
environment +=
  TMP=${directory:tmp}
  TMPDIR=${directory:tmp}
  HOME=${buildout:directory}
79
  PATH=${binary-link:target-directory}:{{ parameter_dict['coreutils'] }}/bin:{{ parameter_dict['perl_dbd_mariadb_path'] }}
80 81
  TZ={{ slapparameter_dict['timezone'] }}
  MATPLOTLIBRC={{ parameter_dict['matplotlibrc'] }}
82
  PYTHONUNBUFFERED=1
83 84
  OFS_IMAGE_USE_DENYLIST=1
  DISALLOWED_INLINE_MIMETYPES=
85
  INSTANCE_HOME=${:instance-home}
86
  FONTCONFIG_FILE=${fontconfig-conf:output}
87 88 89
  JUPYTER_PATH=${directory:jupyter-dir}
  JUPYTER_CONFIG_DIR=${directory:jupyter-config-dir}
  JUPYTER_RUNTIME_DIR=${directory:jupyter-runtime-dir}
90
{% if slapparameter_dict.get('python-hash-seed') != '' %}
91 92
  PYTHONHASHSEED={{ slapparameter_dict['python-hash-seed'] }}
{% endif %}
93 94
{% if slapparameter_dict.get('wendelin-core-zblk-fmt') %}
  WENDELIN_CORE_ZBLK_FMT={{ slapparameter_dict['wendelin-core-zblk-fmt'] }}
95 96 97 98 99 100
{% endif %}
  WENDELIN_CORE_WCFS_AUTOSTART=no
{% if slapparameter_dict['wcfs_enable'] %}
  WENDELIN_CORE_VIRTMEM=r:wcfs+w:uvmm
{% else %}
  WENDELIN_CORE_VIRTMEM=rw:uvmm
101 102
{% endif %}
  ${:environment-extra}
103

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
[directory]
recipe = slapos.cookbook:mkdirectory
bin = ${buildout:directory}/bin
etc = ${buildout:directory}/etc
instance = ${:srv}/erp5shared
instance-constraint = ${:instance}/Constraint
instance-document = ${:instance}/Document
instance-etc = ${:instance}/etc
instance-etc-package-include = ${:instance}/etc/package-include
instance-extensions = ${:instance}/Extensions
instance-import = ${:instance}/import
instance-lib = ${:instance}/lib
instance-propertysheet = ${:instance}/PropertySheet
instance-tests = ${:instance}/tests
log = ${:var}/log
run = ${:var}/run
services = ${:etc}/run
121
service-on-watch = ${:etc}/service
122
srv = ${buildout:directory}/srv
123
ca-dir = ${:srv}/ssl
124 125
tmp = ${buildout:directory}/tmp
var = ${buildout:directory}/var
126
plugin = ${:etc}/plugin
127
unit-test-path = ${:srv}/test-instance/unit_test
128
fontconfig-cache = ${buildout:directory}/.fontconfig
129 130 131 132 133
jupyter-dir = ${buildout:directory}/jupyter
jupyter-config-dir = ${:jupyter-dir}/etc
jupyter-runtime-dir = ${:jupyter-dir}/runtime
jupyter-kernel-dir = ${:jupyter-dir}/kernels
erp5-kernel-dir = ${:jupyter-kernel-dir}/ERP5
134 135 136

[fontconfig-conf]
recipe = slapos.recipe.template:jinja2
137 138
url = {{ parameter_dict['template-fonts-conf'] }}
output = ${directory:etc}/fonts.conf
139 140 141 142 143 144 145 146 147 148 149 150
context =
    key cachedir directory:fontconfig-cache
    key fonts :fonts
    key includes :includes
fonts =
{% for font in parameter_dict['fonts'].splitlines() %}
   {{ font }}
{% endfor %}
includes =
{% for include in parameter_dict['fontconfig-includes'].splitlines() %}
   {{ include }}
{% endfor %}
151

152 153 154 155 156
# Used for ERP5 resiliency or (more probably)
# webrunner resiliency with erp5 inside.
[{{ section("resiliency-exclude-file") }}]
# Generate rdiff exclude file
recipe = slapos.recipe.template:jinja2
157 158
inline = {{ '{{ "${directory:log}/**\\n${directory:tmp}/**\\n" }}' }}
output = ${directory:srv}/exporter.exclude
159

160 161 162
[{{ section("resiliency-identity-signature-script")}}]
# Generate identity script used by webrunner to check data integrity
recipe = slapos.cookbook:wrapper
163
command-line = {{ bin_directory }}/backup-identity-script-excluding-path --exclude-path "srv/backup/logrotate/**"
164 165 166
wrapper-path = ${directory:srv}/.backup_identity_script
mode = 770

167 168 169
[binary-link]
recipe = slapos.cookbook:symbolic.link
target-directory = ${directory:bin}
170
link-binary = {{ dumps(parameter_dict['link-binary']) }}
171 172 173 174 175 176 177 178 179 180 181 182 183

{% if use_ipv6 -%}
{%   set ipv6 = (ipv6_set | list)[0] -%}

[ipv6toipv4-base]
recipe = slapos.cookbook:ipv6toipv4
runner-path = ${directory:services}/${:base-name}
6tunnel-path = {{ parameter_dict['6tunnel'] }}/bin/6tunnel
shell-path = {{ parameter_dict['dash'] }}/bin/dash
ipv4 = {{ ipv4 }}
ipv6 = {{ ipv6 }}
{% endif -%}

184
[hosts-parameter]
185
# Used for both hosts and hostaliases sections.
186
host-dict = {{ dumps(hosts_dict) }}
187 188 189 190 191 192 193 194 195
hostalias-dict = {{ dumps(slapparameter_dict['hostalias-dict']) }}

# Note: there is a subtle difference between hosts and hostaliases files:
# - hosts files start with resolved, followed by alias(es) (only one alias per
#   line in this case)
# - hostaliases start with alias, followed by resolved
# ...so it's not possible to merge these templates (not a big deal anyway).

[hostaliases]
196
< = jinja2-template-base
197
inline = {{ '
198 199 200 201
  {% for alias, aliased in host_dict.items() -%}
  {{ alias }} {{ aliased }}
  {% endfor %}
' }}
202
output = ${directory:etc}/hostaliases
203
context = key host_dict hosts-parameter:hostalias-dict
204 205

[hosts]
206
< = jinja2-template-base
207
inline = {{ '
208 209 210 211
  {% for alias, aliased in host_dict.items() -%}
  {{ aliased }} {{ alias }}
  {% endfor %}
' }}
212
output = ${directory:etc}/hosts
213 214
context = key host_dict hosts-parameter:host-dict

215 216
[userhosts-bin]
recipe = slapos.recipe.template:jinja2
217 218 219
inline =
  #!{{ parameter_dict['dash'] }}/bin/dash
  export HOSTS_FILE=${hosts:output}
220 221
  export LD_PRELOAD={{ parameter_dict['userhosts'] }}:$LD_PRELOAD
  exec "$@"
222
output = ${directory:bin}/userhosts
223

224 225 226
[userhosts-wrapper-base]
recipe = slapos.cookbook:wrapper
environment =
227 228
  HOSTALIASES=${hostaliases:output}
command-line = '${userhosts-bin:output}' ${:wrapped-command-line}
229

230
{# Hack to deploy SSL certs via instance parameters -#}
231
{% for zodb in six.itervalues(zodb_dict) -%}
232 233 234 235 236 237 238
{%   set storage_dict = zodb.setdefault('storage-dict', {}) -%}
{%   if zodb['type'] == 'neo' and storage_dict.get('ssl', 1) -%}
{%     for k, v in (('_ca', 'ca.crt'),
                    ('_cert', 'neo.crt'),
                    ('_key', 'neo.key')) -%}
{%       if k in storage_dict -%}
[{{ section('neo-ssl-' + k[1:]) }}]
239
< = jinja2-template-base
240
output = ${directory:etc}/{{v}}
241
inline = {{'{{'}}pem}}
242 243 244 245 246 247 248 249 250
context = key pem :pem
pem = {{dumps(storage_dict.pop(k))}}

{%       endif -%}
{%     endfor -%}
{%   endif -%}
{% endfor -%}
{# endhack -#}

251
[{{ section('zcml') }}]
252
recipe = slapos.cookbook:copyfilelist
253
target-directory = ${directory:instance-etc}
254
file-list = {{ parameter_dict['site-zcml'] }}
255 256

[{{ section('zope-inituser') }}]
257
< = jinja2-template-base
258
output = ${directory:instance}/inituser
259
inline = {{ slapparameter_dict['inituser-login'] }}:{{ slapparameter_dict['inituser-password-hashed'] }}
260
once = ${:output}_done
261 262 263 264

[zope-conf-parameter-base]
ip = {{ ipv4 }}
site-id = {{ site_id }}
265 266 267
{% if site_id -%}
mysql-url = {{ slapparameter_dict['mysql-url-list'][0] }}
inituser = {{ slapparameter_dict['inituser-login'] }}
268
{%  set mysql = urllib_parse.urlsplit(slapparameter_dict['mysql-url-list'][0]) -%}
269
{%  set mysql_db = mysql.path.split('/')[1] -%}
270
sql-connection-string = {{ '%s@erp5-catalog-0:%s %s %s' % (
271
    mysql_db, mysql.port, mysql.username, mysql.password) }}
272 273
bt5 = {{ slapparameter_dict['bt5'] }}
bt5-repository-url = {{ slapparameter_dict['bt5-repository-url'] }}
274
id-store-interval = {{ dumps(slapparameter_dict['id-store-interval']) }}
275
home = ${buildout:directory}
276
cloudooo-url = {{ ",".join(slapparameter_dict['cloudooo-url-list']) }}
277 278

{% endif -%}
279
developer-list = {{ dumps(slapparameter_dict['developer-list']) }}
280 281
publisher-timeout = {{ dumps(slapparameter_dict['publisher-timeout']) }}
activity-timeout = {{ dumps(slapparameter_dict['activity-timeout']) }}
282 283 284
instance = ${directory:instance}
deadlock-path = /manage_debug_threads
deadlock-debugger-password = {{ dumps(slapparameter_dict['deadlock-debugger-password']) }}
285 286 287 288
{% if slapparameter_dict.get('tidstorage-ip') -%}
tidstorage-ip = {{ dumps(slapparameter_dict['tidstorage-ip']) }}
tidstorage-port = {{ dumps(slapparameter_dict['tidstorage-port']) }}
{% endif -%}
289 290

[zope-conf-base]
291
< = jinja2-template-base
292
url = {{ parameter_dict['zope-conf-template'] }}
293 294 295 296 297
extensions =
    jinja2.ext.do
    jinja2.ext.loopcontrols
import-list =
    rawfile root_common {{ root_common }}
298 299

{% macro zope(
300
  index,
301 302 303 304
  port,
  longrequest_logger_timeout,
  longrequest_logger_interval
) -%}
305
{% set name = 'zope-' ~ index -%}
306 307 308 309 310 311 312 313 314 315
{% set conf_name = name ~ '-conf' -%}
{% set conf_parameter_name = conf_name ~ '-param' -%}
{% set zope_tunnel_section_name = name ~ '-ipv6toipv4' -%}
{% set zope_tunnel_base_name = zope_tunnel_section_name -%}
[{{ conf_parameter_name }}]
< = zope-conf-parameter-base
pid-file = ${directory:run}/{{ name }}.pid
port = {{ port }}
event-log = ${directory:log}/{{ name }}-event.log
z2-log = ${directory:log}/{{ name }}-Z2.log
316
node-id = {{ dumps(node_id_base ~ (node_id_index_format % index)) }}
317
{% set neo_log_list = [] -%}
318
{% set import_set = set() -%}
319
{% for db_name, zodb in six.iteritems(zodb_dict) -%}
320
{%   do zodb.setdefault('pool-size', thread_amount) -%}
321 322
{%   if zodb['type'] == 'neo' -%}
{%     do import_set.add('neo.client') -%}
323
{%     set log = name ~ '-neo-' ~ db_name ~ '.log' -%}
324
{%     do neo_log_list.append('${directory:log}/' + log) -%}
325
{%     do zodb['storage-dict'].update(logfile='~/var/log/'+log) -%}
326 327
{%   endif -%}
{% endfor -%}
328 329
import-list = {{ dumps(list(import_set)) }}
zodb-dict = {{ dumps(zodb_dict) }}
330 331 332 333 334 335 336
{% if longrequest_logger_interval > 0 -%}
longrequest-logger-file = {{ longrequest_logger_base_path ~ name ~ ".log" }}
longrequest-logger-timeout = {{ longrequest_logger_timeout }}
longrequest-logger-interval = {{ longrequest_logger_interval }}
{% else -%}
longrequest-logger-file =
{% endif -%}
337 338 339

[{{ conf_name }}]
< = zope-conf-base
340
output = ${directory:etc}/{{ name }}.conf
341
context =
342
  section parameter_dict {{ conf_parameter_name }}
343
  import os os
344
  import re re
345

346
[{{ section(name) }}]
347 348 349 350 351 352 353
<= run-common
wrapped-command-line =
  '{{ bin_directory }}/runwsgi'
    --event-log-file={{ '${' ~ conf_parameter_name ~ ':event-log}' }}
    --access-log-file={{ '${' ~ conf_parameter_name ~ ':z2-log}' }}
    {% if longrequest_logger_interval > 0 %} --long-request-log-file={{ '${' ~ conf_parameter_name ~ ':longrequest-logger-file}' }} {% endif %}
    {% if webdav %}-w{% endif %}
354
    {% if slapparameter_dict['xml-rpc'] %}--enable-xml-rpc{% endif %}
355
    {% if with_max_rlimit_nofile %}--with-max-rlimit-nofile{% endif %}
356 357 358 359 360
    {{ ipv4 }}:${:port}
    {% if timerserver_interval %}--timerserver-interval={{ timerserver_interval }}{% endif %}
    '${:configuration-file}'
    --threads={{ thread_amount }}
    --large-file-threshold={{ slapparameter_dict['large-file-threshold'] }}
361
    --pidfile={{ '${' ~ conf_parameter_name ~ ':pid-file}' }}
362 363 364
{%- set private_dev_shm = slapparameter_dict['private-dev-shm'] %}
{%- if private_dev_shm %}
private-tmpfs = {{ private_dev_shm }} /dev/shm
365
{%- endif %}
366
wrapper-path = ${directory:service-on-watch}/{{ name }}
367 368 369 370
hash-files =
  ${:configuration-file}
hash-existing-files =
  ${buildout:directory}/software_release/buildout.cfg
371

372 373 374 375
configuration-file = {{ '${' ~ conf_name ~ ':output}' }}
instance-home = ${directory:instance}
port = {{ port }}

376
[{{ section("promise-" ~ name) }}]
377
<= monitor-promise-base
378
promise = check_socket_listening
379
name = {{ name }}.py
380
config-host = {{ ipv4 }}
381
config-port = {{ port }}
382 383 384 385 386 387 388

{% if use_ipv6 -%}
[{{ zope_tunnel_section_name }}]
< = ipv6toipv4-base
base-name = {{ zope_tunnel_base_name }}
ipv6-port = {{ port }}
ipv4-port = {{ port }}
389
{%   do publish_list.append(("[" ~ ipv6 ~ "]:" ~ port, thread_amount, webdav)) -%}
390 391

[{{ section("promise-tunnel-" ~ name) }}]
392
<= monitor-promise-base
393
promise = check_socket_listening
394
name = {{ zope_tunnel_base_name }}.py
395
config-host = {{ '${' ~ zope_tunnel_section_name ~ ':ipv6}' }}
396
config-port = {{ '${' ~ zope_tunnel_section_name ~ ':ipv6-port}' }}
397
{% else -%}
398
{%   do publish_list.append((ipv4 ~ ":" ~ port, thread_amount, webdav)) -%}
399 400
{% endif -%}

401 402
{% if longrequest_logger_interval > 0 -%}
[{{ section('promise-check-' ~name ~ '-longrequest-error-log') }}]
403
<= monitor-promise-base
404
promise = check_error_on_zope_longrequest_log
405
name = {{'check-' ~ name ~ '-longrequest-error-log.py'}}
406
config-log-file = {{ '${' ~ conf_parameter_name ~ ':longrequest-logger-file}' }}
407 408
config-error-threshold = {{ dumps(slapparameter_dict["zope-longrequest-logger-error-threshold"]) }}
config-maximum-delay = {{ dumps(slapparameter_dict["zope-longrequest-logger-maximum-delay"]) }}
409 410
{% endif -%}

411 412 413
[{{ section('logrotate-entry-' ~ name) }}]
< = logrotate-entry-base
name = {{ name }}
414
log = {{ '${' ~ conf_parameter_name ~ ':event-log}' }} {{ '${' ~ conf_parameter_name ~ ':z2-log}' }} {{ '${' ~ conf_parameter_name ~ ':longrequest-logger-file}' }}
415
copytruncate = true
416 417 418 419 420 421 422 423 424 425

{% if neo_log_list -%}
[{{ section('logrotate-entry-neo-' ~ name) }}]
< = logrotate-entry-base
name = neo-{{ name }}
log = {{ ' '.join(neo_log_list) }}
# we don't use copytruncate on neo logs, they are not regular text files but sqlite databases
copytruncate =
post = test ! -s {{ '${' ~ conf_parameter_name ~ ':pid-file}' }} || {{ bin_directory }}/slapos-kill --pidfile {{ '${' ~ conf_parameter_name ~ ':pid-file}' }} -s USR2
{% endif %}
426 427
{% endmacro -%}

428
{% for i in instance_index_list -%}
429 430
{{   zope(
       i,
431
       next(ports),
432 433 434
       slapparameter_dict['longrequest-logger-timeout'],
       slapparameter_dict['longrequest-logger-interval'],
     ) }}
435 436
{% endfor -%}

437 438 439 440 441 442 443 444 445 446
[{{ section("watch_activities") }}]
<= userhosts-wrapper-base
environment +=
  MYSQL=${binary-link:target-directory}/mysql
wrapped-command-line = {{ parameter_dict['erp5-location'] }}/product/CMFActivity/bin/${:_buildout_section_name_} "-h erp5-catalog-0 -P  {{ mysql.port }}  -u {{ mysql.username }} -p{{ mysql.password}} {{ mysql_db }}" 5 3600
wrapper-path = ${buildout:bin-directory}/${:_buildout_section_name_}

[{{ section("wait_activities") }}]
<= watch_activities

447 448
{% if test_runner_enabled and test_runner_node_count -%}
{% for _ in range(test_runner_node_count) %}
449
{%   do test_runner_address_list.append((ipv4, next(ports))) %}
450
{% endfor %}
451

452
{% if selenium_server_configuration_dict -%}
453
[test-zelenium-runner-parameter]
454
configuration = {{ dumps(selenium_server_configuration_dict) }}
455 456 457 458 459 460
user = {{ dumps(slapparameter_dict['inituser-login']) }}
password = {{ dumps(slapparameter_dict['inituser-password']) }}
bin-path = {{ bin_directory }}/{{ parameter_dict['egg-interpreter'] }}

[{{ section('test-zelenium-runner') }}]
<= jinja2-template-base
461 462
url = {{ parameter_dict['run-zelenium-template'] }}
output = ${directory:bin}/runTestSuite
463 464 465 466 467 468 469 470 471
context =
    import json_module json
    key configuration test-zelenium-runner-parameter:configuration
    key user test-zelenium-runner-parameter:user
    key password test-zelenium-runner-parameter:password
    key bin_path test-zelenium-runner-parameter:bin-path
{% else -%}
[{{ section('run-unit-test-userhosts-wrapper') }}]
<= userhosts-wrapper-base
472
wrapped-command-line = ${run-unit-test-python-hash-seed-wrapper:output}
473 474
wrapper-path = ${buildout:bin-directory}/runUnitTest

475 476 477 478
[{{ section('run-unit-test-python-hash-seed-wrapper') }}]
recipe = slapos.recipe.template
inline =
  #!/bin/sh
479
  {% if slapparameter_dict.get('python-hash-seed') != '' %}
480 481 482 483 484 485 486 487 488 489 490 491
  PYTHONHASHSEED={{ slapparameter_dict['python-hash-seed'] }}
  {% endif %}
  if [ -z "$PYTHONHASHSEED" ]; then
    PYTHONHASHSEED=$(${buildout:bin-directory}/shuf -i 1-1024 -n 1)
    echo "Generated PYTHONHASHSEED: $PYTHONHASHSEED"
  else
    echo "Using PYTHONHASHSEED: $PYTHONHASHSEED"
  fi
  export PYTHONHASHSEED
  exec ${runUnitTest:wrapper-path} "$@"
output = ${buildout:bin-directory}/runUnitTest.python-hash-seed

492 493 494 495 496 497 498
[{{ section('run-test-suite-userhosts-wrapper') }}]
<= userhosts-wrapper-base
wrapped-command-line = ${runTestSuite:wrapper-path}
wrapper-path = ${buildout:bin-directory}/runTestSuite

{%   set connection_string_list = [] -%}
{%   for url in slapparameter_dict['mysql-test-url-list'] -%}
499
{%     set parsed_url = urllib_parse.urlparse(url) -%}
500 501 502
{%     do connection_string_list.append(
         '%s@%s:%s %s %s' % (
           parsed_url.path.lstrip('/'),
503
           parsed_url.hostname,
504 505 506 507 508 509 510 511 512 513
           parsed_url.port,
           parsed_url.username,
           parsed_url.password,
         ),
       ) -%}
{%   endfor -%}
[run-test-common]
< = run-common
environment-extra =
  REAL_INSTANCE_HOME=${:instance-home}
514
  SQLBENCH_PATH={{ parameter_dict['sqlbench_path'] }}
515
  TEST_CA_PATH=${directory:ca-dir}
516
  ERP5_TEST_RUNNER_CONFIGURATION=${test-runner-configuration:output}
517 518 519 520 521
instance-home = ${directory:unit-test-path}
wrapper-path = ${directory:bin}/${:command-name}.real
command-line =
  '{{ parameter_dict['bin-directory'] }}/${:command-name}'
  ${:command-line-extra}
522
  --conversion_server_url={{ ",".join(slapparameter_dict['cloudooo-url-list']) }}
523 524 525 526 527 528
  --conversion_server_retry_count={{ slapparameter_dict.get('cloudooo-retry-count', 2) }}
  --volatile_memcached_server_hostname=erp5-memcached-volatile
  --volatile_memcached_server_port={{ port_dict['erp5-memcached-volatile'] }}
  --persistent_memcached_server_hostname=erp5-memcached-persistent
  --persistent_memcached_server_port={{ port_dict['erp5-memcached-persistent'] }}

529 530
[test-runner-configuration]
recipe = slapos.recipe.template:jinja2
531 532
output = ${directory:etc}/${:_buildout_section_name_}.json
inline =
533 534
  {{ json.dumps(slapparameter_dict['test-runner-configuration']) }}

535 536 537 538 539 540 541
[{{ section('runUnitTest') }}]
< = run-test-common
command-name = runUnitTest
command-line-extra =
  --erp5_sql_connection_string '{{ connection_string_list[0] }}'
  --extra_sql_connection_string_list '{{ ','.join(connection_string_list[1:]) }}'
  --zserver {{ test_runner_address_list[0][0] ~ ':' ~ test_runner_address_list[0][1] }}
542
  --zserver_frontend_url {{ slapparameter_dict['test-runner-balancer-url-list'][0] }}
543 544 545
  {% if test_runner_random_activity_priority is not none %}
    --random_activity_priority={{ test_runner_random_activity_priority }}
  {%- endif %}
546 547 548 549 550 551 552 553 554 555 556 557 558

[{{ section('runTestSuite') }}]
< = run-test-common
command-name = runTestSuite
command-line-extra =
  --db_list '{{ ','.join(connection_string_list) }}'
environment-extra +=
  {#- turn a list of (ip, port) in a list of 'ip:port' #}
  {% set zserver_address_list = [] -%}
  {% for ip, port in test_runner_address_list %}
  {%   do zserver_address_list.append(ip ~ ':' ~ port) %}
  {% endfor -%}
  zserver_address_list={{ ','.join(zserver_address_list) }}
559
  zserver_frontend_url_list={{ ','.join(slapparameter_dict['test-runner-balancer-url-list']) }}
560

561 562
[promise-test-runner-balancer-url-executable]
# promise to wait for balancer partition to have returned the parameter
563
recipe = slapos.cookbook:check_parameter
564
value = {{ slapparameter_dict['test-runner-balancer-url-list'] }}
565
expected-not-value = not-ready
566
path = ${directory:bin}/${:_buildout_section_name_}
567 568
expected-value =

569
[{{ section("promise-test-runner-balancer-url") }}]
570
<= monitor-promise-base
571
promise = check_command_execute
572
name = ${:_buildout_section_name_}.py
573
config-command = ${promise-test-runner-balancer-url-executable:path}
574

575 576 577
{%-   endif %}
{%- endif %}

578
[{{ section('promise-check-computer-memory') }}]
579
<= monitor-promise-base
580
promise = check_command_execute
581 582
name = check-computer-memory.py
config-command = "{{ parameter_dict["check-computer-memory-binary"] }}" -db ${monitor-instance-parameter:collector-db} --threshold "{{ slapparameter_dict["computer-memory-percent-threshold"] }}" --unit percent
583 584


585
[publish]
586 587
recipe = slapos.cookbook:publish.serialised
zope-address-list = {{ dumps(publish_list) }}
588 589 590 591 592 593 594
{#
Note: hosts_dist is generated at zope level rather than at erp5 (root partition)
level, as it is easier: we can access urls as python values trivially here.
This has the downside of making each zope partition publish the (hopefuly) same
dict toward erp5 partition, violating the DRY principle and making the intent
hard to guess.
-#}
595
hosts-dict = {{ dumps(publishable_hosts_dict) }}
596
monitor-base-url = ${monitor-publish-parameters:monitor-base-url}
597
test-runner-address-list = {{ dumps(test_runner_address_list) }}
598
software-release-url = ${slap-connection:software-release-url}
599

600 601
[monitor-instance-parameter]
monitor-httpd-ipv6 = {{ (ipv6_set | list)[0] }}
602
monitor-httpd-port = {{ next(ports) }}
603
monitor-title = {{ slapparameter_dict['name'] }}
604
password = {{ slapparameter_dict['monitor-passwd'] }}
605

606
[buildout]
607
extends =
608
  {{ template_monitor }}
609
parts +=
610
  {{ '\n  '.join(part_list) }}
611
  publish
612 613
  erp5-kernel
  kernel-json-dir