Commit 42188d7b authored by Jérome Perrin's avatar Jérome Perrin

software/erp5: add control for PYTHONHASHSEED

See https://docs.python.org/3/using/cmdline.html#envvar-PYTHONHASHSEED

Setting a value will set the environment variable for all processes
and for the test runner.

Default behavior is:
  - for zope, do not set the variable, so default python behavior will
  be used ( equivalent to setting `0` on python2 and `random` on python3)
  - for test runner, generate a random value for each execution and
  print it, to make it easy to re-run a failing test with the same seed.
parent 7ff43824
Pipeline #32950 running with stage
in 0 seconds
......@@ -107,6 +107,18 @@
"description": "Set open file descriptors soft limit to hard limit",
"type": "boolean"
},
"python-hash-seed": {
"description": "Sets the value of `PYTHONHASHSEED` environment variable for zope processes and test runner. If not provided, zope processes use python default (`0` for python2, `random` for python3) and test runner generates a random `PYTHONHASHSEED`.",
"oneOf": [
{
"type": "number"
},
{
"const": "random",
"type": "string"
}
]
},
"family-override": {
"description": "Family-wide options, possibly overriding global options",
"default": {},
......
......@@ -272,6 +272,7 @@ link-binary =
${sed:location}/bin/sed
${tesseract:location}/bin/tesseract
${w3m:location}/bin/w3m
${coreutils:location}/bin/shuf
fonts =
${liberation-fonts:location}
${ipaex-fonts:location}
......
......@@ -86,7 +86,7 @@ md5sum = 0ac4b74436f554cd677f19275d18d880
[template-zope]
filename = instance-zope.cfg.in
md5sum = 6178ba7b42848f9e2412ab898a7b026c
md5sum = 51ce470811f4ad0f1e3e44505acf4045
[template-balancer]
filename = instance-balancer.cfg.in
......
......@@ -85,6 +85,9 @@ environment +=
JUPYTER_PATH=${directory:jupyter-dir}
JUPYTER_CONFIG_DIR=${directory:jupyter-config-dir}
JUPYTER_RUNTIME_DIR=${directory:jupyter-runtime-dir}
{% if slapparameter_dict.get('python-hash-seed') %}
PYTHONHASHSEED={{ slapparameter_dict['python-hash-seed'] }}
{% endif %}
{% if slapparameter_dict.get('wendelin-core-zblk-fmt') %}
WENDELIN_CORE_ZBLK_FMT={{ slapparameter_dict['wendelin-core-zblk-fmt'] }}
{% endif %}
......@@ -469,9 +472,23 @@ context =
{% else -%}
[{{ section('run-unit-test-userhosts-wrapper') }}]
<= userhosts-wrapper-base
wrapped-command-line = ${runUnitTest:wrapper-path}
wrapped-command-line = ${run-unit-test-python-hash-seed-wrapper:output}
wrapper-path = ${buildout:bin-directory}/runUnitTest
[{{ section('run-unit-test-python-hash-seed-wrapper') }}]
recipe = slapos.recipe.template
inline =
#!/bin/sh
if [ -z "$PYTHONHASHSEED" ]; then
PYTHONHASHSEED=$(${buildout:bin-directory}/shuf -i 1-1024 -n 1)
export PYTHONHASHSEED
echo "Generated PYTHONHASHSEED: $PYTHONHASHSEED"
else
echo "Using PYTHONHASHSEED: $PYTHONHASHSEED"
fi
exec ${runUnitTest:wrapper-path} "$@"
output = ${buildout:bin-directory}/runUnitTest.python-hash-seed
[{{ section('run-test-suite-userhosts-wrapper') }}]
<= userhosts-wrapper-base
wrapped-command-line = ${runTestSuite:wrapper-path}
......
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