Commit e328aa49 authored by Kirill Smelkov's avatar Kirill Smelkov

component/nxdtest: Prepare for nexedi/nxdtest!13

Prepare for upcoming nxdtest changes to run each testcase with its own
/tmp and /dev/shm:

1) put unshare from SlapOS component into $PATH, so that our version is
   used even if OS provides /bin/unshare. As @jerome explains we need
   features that were added relatively recently and are missing in unshare
   on Debian 10: nexedi/nxdtest!13 (comment 146752)

   It is anyway better to "isolate" from OS by using our own component
   instead of system-provided one.

   Correspondingly adjust util-linux to enable unshare in its build.

2) similarly to "1" adjust util-linux to enable mount so that our version
   is used instead of /bin/mount. For example on Debian 9, even if we
   successfully enter user/mount namespace with `unshare -Umc`

       /bin/mount -t tmpfs none /tmp

   complains that

       mount: only root can use "--types" option

   -> Fix it the same way as with unshare by forcing usage of
   SlapOS-provided mount.

3) rework how nxdtest script is generated and split it into .nxdtest.pyexe and
   nxdtest itself. .nxdtest.pyexe is python interpreter via which nxdtest is run.
   This interpreter has all eggs required by nxdtest in sys.path, so that
   nxdtest could spawn its trun.py via sys.executable. If we don't care to have
   properly setup sys.executable, trun.py will fail when importing any module that
   nxdtest.py could already successfully import.

   Initially I tried to workaround this issue via adjusting $PYTHONPATH <-
   sys.path in main nxdtest script, but @jerome points out that, $PYTHONPATH,
   if set, also affects processes that trun.py spawns, which is not good:

   nexedi/slapos!1095 (comment 146799)

   -> so fix this via running nxdtest via environment where sys.executable is
   properly setup python interpreter with path for all eggs that nxdtest has
   access to.

   Because we already have half-way workarounds for similar problem in several
   places, and because running a script with correctly setup sys.executable is
   generally better, I would say it should be a good idea to rework
   zc.recipe.egg:scripts to generate all scripts to work this way, but I do not
   want to fight about it.

   So let's leave this scheme nxdtest-specific for now.

/cc @tomo
/helped-and-reviewed-by @jerome
/reviewed-on nexedi/slapos!1095
parent 07439e2e
[buildout]
extends =
../pygolang/buildout.cfg
../util-linux/buildout.cfg
../git/buildout.cfg
# nxdtest is bin/ program to run nxdtest.
# use ${nxdtest:exe} to run it.
[nxdtest]
recipe = zc.recipe.egg:scripts
eggs = ${pygolang:egg}
${nxdtest-egg:egg}
scripts = nxdtest
# convenience for nxdtest users
recipe = slapos.recipe.template:jinja2
exe = ${buildout:bin-directory}/nxdtest
rendered= ${:exe}
mode = 755
eggs = ${.nxdtest.pyexe:eggs}
template=
inline:
#!${.nxdtest.pyexe:exe}
# $PATH for unshare and mount
import os
path = os.environ.get('PATH', '')
if path != '':
path = ':' + path
os.environ['PATH'] = '${util-linux:location}/bin' + path
from nxdtest import main; main()
# .nxdtest.pyexe is python interpreter used by nxdtest.
# the interpreter is located at ${.nxdtest.pyexe:exe}.
[.nxdtest.pyexe]
<= python-interpreter
eggs +=
${pygolang:egg}
${nxdtest-egg:egg}
interpreter = ${:_buildout_section_name_}
exe = ${buildout:bin-directory}/${:interpreter}
[nxdtest-egg]
recipe = zc.recipe.egg:develop
......
......@@ -24,7 +24,7 @@ configure-options =
--disable-makeinstall-chown
--disable-makeinstall-setuid
--disable-more
--disable-mount
--enable-mount
--disable-nls
--disable-pivot_root
--disable-pylibmount
......@@ -36,7 +36,7 @@ configure-options =
--without-tinfo
--disable-tls
--disable-ul
--disable-unshare
--enable-unshare
--disable-uuidd
--disable-wall
--without-libiconv-prefix
......
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