Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: untangle getting test images #2741

Merged
merged 4 commits into from
Feb 5, 2021

Commits on Feb 2, 2021

  1. tests/helpers.bash: rm GOPATH

    It is not used anywhere since commit 30601ef.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Feb 2, 2021
    Configuration menu
    Copy the full SHA
    bc175ba View commit details
    Browse the repository at this point in the history

Commits on Feb 3, 2021

  1. ci: untangle getting test images

    This simplifies and optimizes getting container images used for tests.
    
    Currently, we have three different ways of getting images:
    
    1. (for hello-world) the image is in this repo under tests/integration/testdata.
    
    2. (for busybox) download it from github (the repo that is used for
       preparing official Docker image) using curl.
    
    3. (for debian) download from Docker hub, using skopeo and umoci.
    
    To further complicate things, we have to do this downloading in multiple
    scenarios (at least 4): locally, in github CI, from Dockefile, inside a
    Vagrant VM. For each scenario, we have to install skopeo and umoci, and
    those two are not yet universally available for all the distros that we
    use.
    
    Yet another complication is those images are used for tests/integration
    (bats-driven tests) as well as for libcontainer/integration (go tests).
    The tests in libcontainer/integration rely on busybox being available
    from /busybox, and the bats tests just download the images to a
    temporary location during every run.
    
    It is also hard to support CI for other architectures, because all
    the machinery for preparing images is so complicated.
    
    This commit is an attempt to simplify and optimize getting images,
    mostly by getting rid of skopeo and umoci dependencies, but also
    by moving the download logic into one small shell script, which
    is used from all the places.
    
    Benefits:
    
     - images (if not present) are only downloaded once;
     - same images are used for both kind of tests (go and bats);
     - same images are used for local and inside-docker tests
       (because source directory is mounted into container);
     - the download logic is located within 1 simple shell script.
    
    [v2: fix eval; more doc to get-images; print URL if curl failed]
    [v3: use "slim" debian, twice as small]
    [v4: fix not using $image in setup_bundle]
    [v5: don't remove TESTDATA from helpers.bash]
    [v6: add i386 support]
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Feb 3, 2021
    Configuration menu
    Copy the full SHA
    5ab0588 View commit details
    Browse the repository at this point in the history
  2. tests/rootless.sh: use set -e -u -o pipefail

    Currently, set -e ("exit on error") is only set before running tests.
    The bad consequence is the script may fail to set up test environment
    but will still run the tests.
    
    Use "set -e -u -o pipefail" for the whole script to catch potential
    issues with test setup and/or the script itself.
    
    A few caveats:
    
    1. We have to set RUNC_USE_SYSTEMD to an empty value if it is unset, so
       that the subsequent checks like [ -z "$RUNC_USE_SYSTEMD" ] won't
       trigger a "unbound variable" error. Same for ROOTLESS_TESTPATH.
    
    2. Functions that have code like [ -f $file ] && do_something towards
       the end may return 1 in case $file does not exist (as test aka [
       was the last operation performed, and its exit code is returned.
       This is why we had to add return 0.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Feb 3, 2021
    Configuration menu
    Copy the full SHA
    1143759 View commit details
    Browse the repository at this point in the history
  3. tests/rootless.sh: fix/ignore shellcheck warnings

    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Feb 3, 2021
    Configuration menu
    Copy the full SHA
    c348b98 View commit details
    Browse the repository at this point in the history