Projects STRLCPY criu Commits eba1fba8
🤬
  • tests: fix builds on alpine and centos

    Install sudo, create test user with ID 1000, install bash,
    fix pidfile creation and pidfile chmod.
    
    v2:
     * use sleep to give the criu daemon some time to start up
    
    v3:
     * Andrei is of course right and sleep is not good solution.
       After adding --status-fd support to criu service, this
       is how we now detect that criu is ready.
    
    v4:
     * This was much more complicated than expected which is related
       to the different versions of the tools on the different travis
       test targets. There seems to be a bug in bash on Ubuntu
        https://lists.gnu.org/archive/html/bug-bash/2017-07/msg00039.html
       which prevents using 'read -n1' on Ubuntu. As a workaround
       the result from CRIU's status FD is now read via python.
    
       Another problem was discovered on alpine with the loop restore test.
       CRIU says to use setsid even if the process is already using setsid.
       As a workaround, still with setsid, this process is now using
       shell-job true for checkpoint and restore.
    
    Parts of v2 have been committed before. So the changes from this commit
    are partially already in another commit.
    
    Signed-off-by: Adrian Reber <[email protected]>
    Signed-off-by: Andrei Vagin <[email protected]>
  • Loading...
  • Adrian Reber committed with Andrei Vagin 6 years ago
    eba1fba8
    1 parent ae76eb34
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    scripts/build/Dockerfile.centos
    skipped 39 lines
    40 40  ENV CCACHE_DIR=/tmp/.ccache CCACHE_NOCOMPRESS=1 $ENV1=yes
    41 41  RUN mv .ccache /tmp && make mrproper && ccache -sz && \
    42 42   date && make -j $(nproc) CC="$CC" && date && ccache -s
     43 + 
     44 +# The rpc test cases are running as user #1000, let's add the user
     45 +RUN adduser -u 1000 test
     46 + 
    43 47  RUN make -C test/zdtm -j $(nproc)
    44 48   
  • ■ ■ ■ ■ ■
    test/others/rpc/Makefile
    skipped 3 lines
    4 4  CFLAGS += -g -Werror -Wall -I.
    5 5  LDLIBS += -lprotobuf-c
    6 6   
     7 +PYTHON ?= python
     8 + 
    7 9  run: all
    8 10   mkdir -p build
    9 11   chmod a+rwx build
    10  - @# need to start the criu daemon here to access the pidfile
    11  - sudo -g '#1000' -u '#1000' ./criu service -v4 -W build -o service.log --address criu_service.socket -d --pidfile pidfile
    12  - # Give the criu daemon some time to start up
    13  - sleep 0.5
     12 + rm -f build/status
     13 + sudo -g '#1000' -u '#1000' mkfifo build/status
     14 + @# Need to start the criu daemon here to access the pidfile.
     15 + @# The script read.py is used to wait until 'criu service'
     16 + @# is ready. As 'read -n 1' in some releases has a bug and does
     17 + @# not read correctly a \0, using python is a workaround.
     18 + sudo -g '#1000' -u '#1000' -- bash -c "exec 200<>build/status; \
     19 + ./criu service -v4 -W build --address criu_service.socket \
     20 + -d --pidfile pidfile -o service.log --status-fd 200; \
     21 + $(PYTHON) read.py build/status"
     22 + rm -f build/status
    14 23   chmod a+rw build/pidfile
    15 24   sudo -g '#1000' -u '#1000' ./run.sh
    16 25   sudo -g '#1000' -u '#1000' ./version.py
    skipped 19 lines
  • ■ ■ ■ ■ ■ ■
    test/others/rpc/read.py
     1 +# This script is used to read a single character from CRIU's status FD.
     2 +# That way we know when the CRIU service is ready. CRIU writes a \0 to
     3 +# the status FD.
     4 +# In theory this could be easily done using 'read -n 1' from bash, but
     5 +# but the bash version on Ubuntu has probably the following bug:
     6 +# https://lists.gnu.org/archive/html/bug-bash/2017-07/msg00039.html
     7 + 
     8 +import os
     9 +import sys
     10 + 
     11 + 
     12 +f=open(sys.argv[1])
     13 +r = f.read(1)
     14 + 
     15 +if r == '\0':
     16 + sys.exit(0)
     17 + 
     18 +sys.exit(-1)
     19 + 
  • ■ ■ ■ ■ ■
    test/others/rpc/restore-loop.py
    skipped 18 lines
    19 19  req = rpc.criu_req()
    20 20  req.type = rpc.RESTORE
    21 21  req.opts.images_dir_fd = os.open(args['dir'], os.O_DIRECTORY)
     22 +# As the dumped process is running with setsid this should not
     23 +# be necessary. There seems to be a problem for this testcase
     24 +# in combination with alpine's setsid.
     25 +# The dump is now done with -j and the restore also.
     26 +req.opts.shell_job = True
    22 27   
    23 28  # Send request
    24 29  s.send(req.SerializeToString())
    skipped 17 lines
  • ■ ■ ■ ■ ■
    test/others/rpc/run.sh
    skipped 49 lines
    50 50   echo "pid ${P}"
    51 51   
    52 52   title_print "Dump loop.sh"
    53  - ${CRIU} dump -v4 -o dump-loop.log -D build/imgs_loop -t ${P}
     53 + # So theoretically '-j' (--shell-job) should not be necessary, but on alpine
     54 + # this test fails without it.
     55 + ${CRIU} dump -j -v4 -o dump-loop.log -D build/imgs_loop -t ${P}
    54 56   
    55 57   title_print "Run restore-loop"
    56 58   ./restore-loop.py build/criu_service.socket build/imgs_loop
    skipped 29 lines
Please wait...
Page is in error, reload to recover