From ed67d302ef0c838ecb85e87b5b81cae45adefa5b Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Wed, 10 Oct 2018 14:29:19 -0400 Subject: Cirrus: Enable updating F28 image Previously this was disabled as some package was breaking networking on GCE after updating + rebooting. This is fixed now, so we should update packages when building the fedora test VM image. https://pagure.io/cloud-sig/issue/292 Signed-off-by: Chris Evich --- contrib/cirrus/lib.sh | 2 +- contrib/cirrus/packer/fedora_setup.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'contrib/cirrus') diff --git a/contrib/cirrus/lib.sh b/contrib/cirrus/lib.sh index 1e0052a65..fbde7e5eb 100644 --- a/contrib/cirrus/lib.sh +++ b/contrib/cirrus/lib.sh @@ -263,7 +263,7 @@ install_varlink(){ _finalize(){ echo "Removing leftover giblets from cloud-init" cd / - sudo rm -rf /var/lib/cloud + sudo rm -rf /var/lib/cloud/instance? sudo rm -rf /root/.ssh/* sudo rm -rf /home/* } diff --git a/contrib/cirrus/packer/fedora_setup.sh b/contrib/cirrus/packer/fedora_setup.sh index 16b6e4e6b..f9fea04a7 100644 --- a/contrib/cirrus/packer/fedora_setup.sh +++ b/contrib/cirrus/packer/fedora_setup.sh @@ -21,8 +21,7 @@ install_ooe export GOPATH="$(mktemp -d)" trap "sudo rm -rf $GOPATH" EXIT -# breaks networking on f28/29 in GCE -# ooe.sh sudo dnf update -y +ooe.sh sudo dnf update -y ooe.sh sudo dnf install -y \ atomic-registries \ -- cgit v1.2.3-54-g00ecf From 4929662c8a3154fb002ddb3c943e776c755ec89a Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Mon, 8 Oct 2018 10:50:57 -0400 Subject: Ubuntu VM image build: try update twice Occasionally, short-term temporary connectivity problems prevent ubuntu from updating on GCE. As a workaround, attempt these commands twice. Signed-off-by: Chris Evich --- contrib/cirrus/packer/ubuntu_setup.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'contrib/cirrus') diff --git a/contrib/cirrus/packer/ubuntu_setup.sh b/contrib/cirrus/packer/ubuntu_setup.sh index ff20944dc..4cf1f335b 100644 --- a/contrib/cirrus/packer/ubuntu_setup.sh +++ b/contrib/cirrus/packer/ubuntu_setup.sh @@ -21,9 +21,10 @@ install_ooe export GOPATH="$(mktemp -d)" trap "sudo rm -rf $GOPATH" EXIT -ooe.sh sudo apt-get -qq update -ooe.sh sudo apt-get -qq update # sometimes it needs to get it twice :S -ooe.sh sudo apt-get -qq upgrade +# Try twice as workaround for minor networking problems +echo "Updating system and installing package dependencies" +ooe.sh sudo apt-get -qq update || sudo apt-get -qq update +ooe.sh sudo apt-get -qq upgrade || sudo apt-get -qq upgrade ooe.sh sudo apt-get -qq install --no-install-recommends \ apparmor \ autoconf \ -- cgit v1.2.3-54-g00ecf From 021ca5780cdcdcb482716ea771118728affa4a77 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Mon, 8 Oct 2018 13:11:53 -0400 Subject: Cirrus: Add a readme Signed-off-by: Chris Evich --- contrib/cirrus/README.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 contrib/cirrus/README.md (limited to 'contrib/cirrus') diff --git a/contrib/cirrus/README.md b/contrib/cirrus/README.md new file mode 100644 index 000000000..0d315c4f5 --- /dev/null +++ b/contrib/cirrus/README.md @@ -0,0 +1,75 @@ +![PODMAN logo](../../logo/podman-logo-source.svg) + +# Cirrus-CI + +Similar to other integrated github CI/CD services, Cirrus utilizes a simple +YAML-based configuration/description file: ``.cirrus.yml``. Ref: https://cirrus-ci.org/ + +## Workflow + +All tasks execute in parallel, unless there are conditions or dependencies +which alter this behavior. Within each task, each script executes in sequence, +so long as any previous script exited successfully. The overall state of each +task (pass or fail) is set based on the exit status of the last script to execute. + +### ``full_vm_testing`` Task + +1. Unconditionally, spin up one VM per ``matrix: image_name`` item defined + in ``.cirrus.yml``. Once accessible, ``ssh`` into each VM and run the following + scripts. + +2. ``setup_environment.sh``: Configure root's ``.bash_profile`` + for all subsequent scripts (each run in a new shell). Any + distribution-specific environment variables are also defined + here. For example, setting tags/flags to use compiling. + +3. ``verify_source.sh``: Perform per-distribution source + verification, lint-checking, etc. This acts as a minimal + gate, blocking extended use of VMs when a PR's code or commits + would otherwise not be accepted. Should run for less than a minute. + +4. ``unit_test.sh``: Execute unit-testing, as defined by the ``Makefile``. + This should execute within 10-minutes, but often much faster. + +5. ``integration_test.sh``: Execute integration-testing. This is + much more involved, and relies on access to external + resources like container images and code from other repositories. + Total execution time is capped at 2-hours (includes all the above) + but this script normally completes in less than an hour. + +### ``build_vm_images`` Task + +1. When a PR is merged (``$CIRRUS_BRANCH`` == ``master``), run another + round of the ``full_vm_testing`` task (above). + +2. After confirming the tests all pass post-merge, spin up a special VM + capable of communicating with the GCE API. Once accessible, ``ssh`` into + the special VM and run the following scripts. + +3. ``setup_environment.sh``: Configure root's ``.bash_profile`` + for all subsequent scripts (each run in a new shell). Any + distribution-specific environment variables are also defined + here. For example, setting tags/flags to use compiling. + +4. ``build_vm_images.sh``: Examine the merged PR's description on github. + If it contains the magic string ``***CIRRUS: REBUILD IMAGES***``, then + continue. Otherwise display a message, take no further action, and + exit successfully. This prevents production of new VM images unless + they are called for, thereby saving the cost of needlessly storing them. + +5. If the magic string was found, utilize [the packer tool](http://packer.io/docs/) + to produce new VM images. Create a new VM from each base-image, connect + to them with ``ssh``, and perform these steps as defined by the + ``libpod_images.json`` file. + + 1. Copy the current state of the repository into ``/tmp/libpod``. + 2. Execute distribution-specific scripts to prepare the image for + use by the ``full_vm_testing`` task (above). + 3. If successful, shut down each VM and create a new GCE Image + named after the base image and the commit sha of the merge. + +***Note:*** The ``.cirrus.yml`` file must be manually updated with the new +images names, then the change sent in via a secondary pull-request. This +ensures that all the ``full_vm_testing`` tasks can pass with the new images, +before subjecting all future PRs to them. A workflow to automate this +process is described in comments at the end of the ``.cirrus.yml`` file. -- cgit v1.2.3-54-g00ecf From 91f398db4c92056bc77c1c82fe9a61e2c8739e8d Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Mon, 8 Oct 2018 09:40:31 -0400 Subject: Cirrus: Skip rebuilding images unless instructed Given frequent merges, it doesn't make sense to rebuild the VM testing images every time. Instead, monitor the PR title and description for a magic string, only triggering builds on a match: ***CIRRUS: REBUILD IMAGES*** Signed-off-by: Chris Evich --- contrib/cirrus/build_vm_images.sh | 4 +--- contrib/cirrus/lib.sh | 34 +++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 12 deletions(-) (limited to 'contrib/cirrus') diff --git a/contrib/cirrus/build_vm_images.sh b/contrib/cirrus/build_vm_images.sh index 80c689a6c..ffbb2d5d5 100755 --- a/contrib/cirrus/build_vm_images.sh +++ b/contrib/cirrus/build_vm_images.sh @@ -22,9 +22,7 @@ SCRIPT_BASE $SCRIPT_BASE PACKER_BASE $PACKER_BASE " -# TODO: Skip building images if $CIRRUS_BRANCH =~ "master" and -# commit message of $CIRRUS_CHANGE_IN_REPO contains a magic word -# produced by 'commit_and_create_upstream_pr.sh' script (see .cirrus.yml) +require_regex '\*\*\*\s*CIRRUS:\s*REBUILD\s*IMAGES\s*\*\*\*' 'Not re-building VM images' show_env_vars diff --git a/contrib/cirrus/lib.sh b/contrib/cirrus/lib.sh index 1e0052a65..12d24042f 100644 --- a/contrib/cirrus/lib.sh +++ b/contrib/cirrus/lib.sh @@ -117,6 +117,22 @@ cdsudo() { sudo --preserve-env=GOPATH --non-interactive bash -c "$CMD" } +# Skip a build if $1 does not match in the PR Title/Description with message $2 +require_regex() { + req_env_var " + CIRRUS_CHANGE_MESSAGE $CIRRUS_CHANGE_MESSAGE + 1 $1 + 2 $2 + " + regex="$1" + msg="$2" + if ! echo "$CIRRUS_CHANGE_MESSAGE" | egrep -q "$regex" + then + echo "***** The PR Title/Description did not match the regular expression: $MAGIC_RE" + echo "***** $msg" + exit 0 + fi +} # Helper/wrapper script to only show stderr/stdout on non-zero exit install_ooe() { @@ -142,8 +158,8 @@ EOF install_cni_plugins() { echo "Installing CNI Plugins from commit $CNI_COMMIT" req_env_var " - GOPATH $GOPATH - CNI_COMMIT $CNI_COMMIT + GOPATH $GOPATH + CNI_COMMIT $CNI_COMMIT " DEST="$GOPATH/src/github.com/containernetworking/plugins" rm -rf "$DEST" @@ -160,9 +176,9 @@ install_runc(){ echo "Installing RunC from commit $RUNC_COMMIT" echo "Platform is $OS_RELEASE_ID" req_env_var " - GOPATH $GOPATH - RUNC_COMMIT $RUNC_COMMIT - OS_RELEASE_ID $OS_RELEASE_ID + GOPATH $GOPATH + RUNC_COMMIT $RUNC_COMMIT + OS_RELEASE_ID $OS_RELEASE_ID " if [[ "$OS_RELEASE_ID" =~ "ubuntu" ]]; then echo "Running make install.libseccomp.sudo for ubuntu" @@ -202,8 +218,8 @@ install_buildah() { install_conmon(){ echo "Installing conmon from commit $CRIO_COMMIT" req_env_var " - GOPATH $GOPATH - CRIO_COMMIT $CRIO_COMMIT + GOPATH $GOPATH + CRIO_COMMIT $CRIO_COMMIT " DEST="$GOPATH/src/github.com/kubernetes-sigs/cri-o.git" rm -rf "$DEST" @@ -234,8 +250,8 @@ install_criu(){ install_testing_dependencies() { echo "Installing ginkgo, gomega, and easyjson into \$GOPATH=$GOPATH" req_env_var " - GOPATH $GOPATH - GOSRC $GOSRC + GOPATH $GOPATH + GOSRC $GOSRC " cd "$GOSRC" ooe.sh go get -u github.com/onsi/ginkgo/ginkgo -- cgit v1.2.3-54-g00ecf From 989affa2ddc5a3ba23342a9d70f975c3f8ad0519 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Wed, 10 Oct 2018 09:42:09 -0400 Subject: Cirrus-CI: Add option to run system-tests Normally, we would not run system-tests as part of PR-level CI, they're simply too heavy-weight and complex. However, in some instances it may be desirable to provide a quick feedback loop, prior to release packaging and official testing. Enable this by executing the system-tests when a magic string is present in the PR description: ``***CIRRUS: SYSTEM TEST***`` Signed-off-by: Chris Evich --- .cirrus.yml | 2 ++ contrib/cirrus/optional_system_test.sh | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 contrib/cirrus/optional_system_test.sh (limited to 'contrib/cirrus') diff --git a/.cirrus.yml b/.cirrus.yml index ae660394b..65aef4b2f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -62,6 +62,8 @@ full_vm_testing_task: integration_test_script: $SCRIPT_BASE/integration_test.sh + optional_system_test_script: $SCRIPT_BASE/optional_system_test.sh + success_script: $SCRIPT_BASE/success.sh diff --git a/contrib/cirrus/optional_system_test.sh b/contrib/cirrus/optional_system_test.sh new file mode 100755 index 000000000..705dda5ad --- /dev/null +++ b/contrib/cirrus/optional_system_test.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e +source $(dirname $0)/lib.sh + +MAGIC_RE='\*\*\*\s*CIRRUS:\s*SYSTEM\s*TEST\s*\*\*\*' +if ! echo "$CIRRUS_CHANGE_MESSAGE" | egrep -q "$MAGIC_RE" +then + echo "Skipping system-testing because PR title or description" + echo "does not match regular expression: $MAGIC_RE" + exit 0 +fi + +req_env_var " +GOSRC $GOSRC +OS_RELEASE_ID $OS_RELEASE_ID +OS_RELEASE_VER $OS_RELEASE_VER +" + +show_env_vars + +set -x +cd "$GOSRC" +make localsystem -- cgit v1.2.3-54-g00ecf From 916a3ba9d14d436ea4c68660c33b35d51a8ddee6 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 8 Nov 2018 13:51:36 -0500 Subject: Cirrus: Ignore any error from the IRC messenger Signed-off-by: Chris Evich --- contrib/cirrus/lib.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'contrib/cirrus') diff --git a/contrib/cirrus/lib.sh b/contrib/cirrus/lib.sh index 2fa91258b..4a3efb8ff 100644 --- a/contrib/cirrus/lib.sh +++ b/contrib/cirrus/lib.sh @@ -106,7 +106,10 @@ ircmsg() { SCRIPT="$GOSRC/$SCRIPT_BASE/podbot.py" NICK="podbot_$CIRRUS_TASK_ID" NICK="${NICK:0:15}" # Any longer will break things + set +e $SCRIPT $NICK $1 + echo "Ignoring exit($?)" + set -e } # Run sudo in directory with GOPATH set -- cgit v1.2.3-54-g00ecf From aa742e9e681d91cf23a7e4e496358cab4d0ececa Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 8 Nov 2018 09:28:48 -0500 Subject: Cirrus: Reveal magic, parallel system-testing Previously, several magic strings were in place to affect cirrus-ci operations. Two were buried within scripts. One to optionally execute system-tests within a PR. Another to avoid re-building cache-images upon every merge. Move these magic strings out into the open, buy locating their logic up-front in the ``.cirrus.yml`` file. This improves readability and reduces surprise/astonishment at runtime. Signed-off-by: Chris Evich --- .cirrus.yml | 49 +++++++++++++++++++++++++++------- contrib/cirrus/build_vm_images.sh | 2 -- contrib/cirrus/lib.sh | 17 ------------ contrib/cirrus/optional_system_test.sh | 8 ------ 4 files changed, 40 insertions(+), 36 deletions(-) (limited to 'contrib/cirrus') diff --git a/.cirrus.yml b/.cirrus.yml index f78205a49..6fd9dc444 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -63,24 +63,55 @@ full_vm_testing_task: integration_test_script: $SCRIPT_BASE/integration_test.sh - optional_system_test_script: $SCRIPT_BASE/optional_system_test.sh + success_script: $SCRIPT_BASE/success.sh + + +# Because system tests are stored within the repository, it is sometimes +# necessary to execute them within a PR to validate changes. + +optional_system_testing_task: + + # Only run system tests in PRs (not on merge) if magic string is present + # in the PR description. Post-merge system testing is assumed to happen + # later from OS distribution's build systems. + only_if: >- + $CIRRUS_BRANCH != 'master' && + $CIRRUS_CHANGE_MESSAGE =~ '\*\*\*\s*CIRRUS:\s*SYSTEM\s*TEST\s*\*\*\*' + gce_instance: + matrix: + image_name: "ubuntu-1804-bionic-v20180911-libpod-63a86a18" + # TODO: Make these work (also build_images_task below) + #image_name: "rhel-server-ec2-7-5-165-1-libpod-fce09afe" + #image_name: "centos-7-v20180911-libpod-fce09afe" + #image_name: "fedora-cloud-base-28-1-1-7-libpod-fce09afe" + + timeout_in: 60m + + setup_environment_script: $SCRIPT_BASE/setup_environment.sh + verify_source_script: $SCRIPT_BASE/verify_source.sh + unit_test_script: $SCRIPT_BASE/unit_test.sh + integration_test_script: $SCRIPT_BASE/integration_test.sh + system_test_script: $SCRIPT_BASE/optional_system_test.sh success_script: $SCRIPT_BASE/success.sh -# This task build new images for future PR testing, but only after a PR merge. -# These images save needing to install/setup the same environment to test every -# PR. The 'active' image for testing is selected by the 'image_name' items in -# task above. Currently this requires manually updating them, but this could -# be automated (see comment at end). +# This task builds new cache-images for future PR testing. These images save +# time installing/setting up the environment while an engineer is waiting. +# The 'active' cache-images for full_vm_testing are selected by the +# 'image_name' keys. Updating those items requires manually modification, +# but this could be automated (see comment at end of build_vm_images_task). build_vm_images_task: - # Only produce new images after a PR merge - only_if: $CIRRUS_BRANCH == 'master' + # Only produce new cache-images after a PR merge, and if a magic string + # is present in the most recent commit-message. + only_if: >- + $CIRRUS_BRANCH == 'master' && + $CIRRUS_CHANGE_MESSAGE =~ '\*\*\*\s*CIRRUS:\s*REBUILD\s*IMAGES\s*\*\*\*' # Require tests to pass first. depends_on: - - test # i.e. 'test_task' + - full_vm_testing # i.e. 'full_vm_testing_task' env: # CSV of packer builder names to enable (see $PACKER_BASE/libpod_images.json) diff --git a/contrib/cirrus/build_vm_images.sh b/contrib/cirrus/build_vm_images.sh index ffbb2d5d5..c8ff55445 100755 --- a/contrib/cirrus/build_vm_images.sh +++ b/contrib/cirrus/build_vm_images.sh @@ -22,8 +22,6 @@ SCRIPT_BASE $SCRIPT_BASE PACKER_BASE $PACKER_BASE " -require_regex '\*\*\*\s*CIRRUS:\s*REBUILD\s*IMAGES\s*\*\*\*' 'Not re-building VM images' - show_env_vars # Everything here is running on the 'image-builder-image' GCE image diff --git a/contrib/cirrus/lib.sh b/contrib/cirrus/lib.sh index 4a3efb8ff..6d43c6ea5 100644 --- a/contrib/cirrus/lib.sh +++ b/contrib/cirrus/lib.sh @@ -120,23 +120,6 @@ cdsudo() { sudo --preserve-env=GOPATH --non-interactive bash -c "$CMD" } -# Skip a build if $1 does not match in the PR Title/Description with message $2 -require_regex() { - req_env_var " - CIRRUS_CHANGE_MESSAGE $CIRRUS_CHANGE_MESSAGE - 1 $1 - 2 $2 - " - regex="$1" - msg="$2" - if ! echo "$CIRRUS_CHANGE_MESSAGE" | egrep -q "$regex" - then - echo "***** The PR Title/Description did not match the regular expression: $MAGIC_RE" - echo "***** $msg" - exit 0 - fi -} - # Helper/wrapper script to only show stderr/stdout on non-zero exit install_ooe() { req_env_var "SCRIPT_BASE $SCRIPT_BASE" diff --git a/contrib/cirrus/optional_system_test.sh b/contrib/cirrus/optional_system_test.sh index 705dda5ad..dfe8e8a2c 100755 --- a/contrib/cirrus/optional_system_test.sh +++ b/contrib/cirrus/optional_system_test.sh @@ -3,14 +3,6 @@ set -e source $(dirname $0)/lib.sh -MAGIC_RE='\*\*\*\s*CIRRUS:\s*SYSTEM\s*TEST\s*\*\*\*' -if ! echo "$CIRRUS_CHANGE_MESSAGE" | egrep -q "$MAGIC_RE" -then - echo "Skipping system-testing because PR title or description" - echo "does not match regular expression: $MAGIC_RE" - exit 0 -fi - req_env_var " GOSRC $GOSRC OS_RELEASE_ID $OS_RELEASE_ID -- cgit v1.2.3-54-g00ecf From 2cc9b78ab97dea596e4c2ca6df0aac930046d626 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 8 Nov 2018 09:41:15 -0500 Subject: Cirrus: Simplify optional system-test script Previously it was required to call the verify, unit, and integration scripts in order to build/install dependencies, and libpod. This wastes time during the (optional) system-testing, since the actual unit/integration testing is also happening in parallel. Consolidate only the distribution-specific build steps into the system-testing script. This way, only the required steps are performed in their respective (parallel) tasks. Signed-off-by: Chris Evich --- .cirrus.yml | 9 +++------ contrib/cirrus/optional_system_test.sh | 16 ---------------- contrib/cirrus/system_test.sh | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 22 deletions(-) delete mode 100755 contrib/cirrus/optional_system_test.sh create mode 100755 contrib/cirrus/system_test.sh (limited to 'contrib/cirrus') diff --git a/.cirrus.yml b/.cirrus.yml index 6fd9dc444..c5b73fdc9 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -76,7 +76,7 @@ optional_system_testing_task: # later from OS distribution's build systems. only_if: >- $CIRRUS_BRANCH != 'master' && - $CIRRUS_CHANGE_MESSAGE =~ '\*\*\*\s*CIRRUS:\s*SYSTEM\s*TEST\s*\*\*\*' + $CIRRUS_CHANGE_MESSAGE =~ '.*\*\*\*\s*CIRRUS:\s*SYSTEM\s*TEST\s*\*\*\*.*' gce_instance: matrix: @@ -89,10 +89,7 @@ optional_system_testing_task: timeout_in: 60m setup_environment_script: $SCRIPT_BASE/setup_environment.sh - verify_source_script: $SCRIPT_BASE/verify_source.sh - unit_test_script: $SCRIPT_BASE/unit_test.sh - integration_test_script: $SCRIPT_BASE/integration_test.sh - system_test_script: $SCRIPT_BASE/optional_system_test.sh + system_test_script: $SCRIPT_BASE/system_test.sh success_script: $SCRIPT_BASE/success.sh @@ -107,7 +104,7 @@ build_vm_images_task: # is present in the most recent commit-message. only_if: >- $CIRRUS_BRANCH == 'master' && - $CIRRUS_CHANGE_MESSAGE =~ '\*\*\*\s*CIRRUS:\s*REBUILD\s*IMAGES\s*\*\*\*' + $CIRRUS_CHANGE_MESSAGE =~ '.*\*\*\*\s*CIRRUS:\s*REBUILD\s*IMAGES\s*\*\*\*.*' # Require tests to pass first. depends_on: diff --git a/contrib/cirrus/optional_system_test.sh b/contrib/cirrus/optional_system_test.sh deleted file mode 100755 index dfe8e8a2c..000000000 --- a/contrib/cirrus/optional_system_test.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -e -source $(dirname $0)/lib.sh - -req_env_var " -GOSRC $GOSRC -OS_RELEASE_ID $OS_RELEASE_ID -OS_RELEASE_VER $OS_RELEASE_VER -" - -show_env_vars - -set -x -cd "$GOSRC" -make localsystem diff --git a/contrib/cirrus/system_test.sh b/contrib/cirrus/system_test.sh new file mode 100755 index 000000000..7c727d336 --- /dev/null +++ b/contrib/cirrus/system_test.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -e +source $(dirname $0)/lib.sh + +req_env_var " +GOSRC $GOSRC +OS_RELEASE_ID $OS_RELEASE_ID +OS_RELEASE_VER $OS_RELEASE_VER +" + +show_env_vars + +set -x +cd "$GOSRC" + +case "${OS_RELEASE_ID}-${OS_RELEASE_VER}" in + ubuntu-18) + make install.tools "BUILDTAGS=$BUILDTAGS" + make "BUILDTAGS=$BUILDTAGS" + make test-binaries "BUILDTAGS=$BUILDTAGS" + ;; + fedora-28) ;& + centos-7) ;& + rhel-7) + make install.tools + make + make test-binaries + ;; + *) bad_os_id_ver ;; +esac + +make localsystem -- cgit v1.2.3-54-g00ecf From 8b3fcb374ba15ee1d56f4b9c5ebd6e9372575471 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 8 Nov 2018 11:06:02 -0500 Subject: Cirrus: Add documentation for system-testing ***CIRRUS: REBUILD IMAGES*** Signed-off-by: Chris Evich --- contrib/cirrus/README.md | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'contrib/cirrus') diff --git a/contrib/cirrus/README.md b/contrib/cirrus/README.md index 0d315c4f5..fa233a2cb 100644 --- a/contrib/cirrus/README.md +++ b/contrib/cirrus/README.md @@ -37,34 +37,41 @@ task (pass or fail) is set based on the exit status of the last script to execut Total execution time is capped at 2-hours (includes all the above) but this script normally completes in less than an hour. -### ``build_vm_images`` Task +### ``optional_system_testing`` Task -1. When a PR is merged (``$CIRRUS_BRANCH`` == ``master``), run another - round of the ``full_vm_testing`` task (above). +1. Optionally executes in parallel with ``full_vm_testing``. Requires + **prior** to job-start, the magic string ``***CIRRUS: SYSTEM TEST***`` + is found in the pull-request *description*. The *description* is the first + text-box under the main *summary* line in the github WebUI. -2. After confirming the tests all pass post-merge, spin up a special VM - capable of communicating with the GCE API. Once accessible, ``ssh`` into - the special VM and run the following scripts. +2. ``setup_environment.sh``: Same as for other tasks. -3. ``setup_environment.sh``: Configure root's ``.bash_profile`` - for all subsequent scripts (each run in a new shell). Any - distribution-specific environment variables are also defined - here. For example, setting tags/flags to use compiling. +3. ``system_test.sh``: Build both dependencies and libpod, install them, + then execute `make localsystem` from the repository root. + +### ``build_vm_images`` Task + +1. When a PR is merged (``$CIRRUS_BRANCH`` == ``master``), Cirrus + checks the last commit message. If it contains the magic string + ``***CIRRUS: REBUILD IMAGES***``, then this task continues. + +2. Execute run another round of the ``full_vm_testing`` task (above). + After the tests pass (post-merge), spin up a special VM + (from the `image-builder-image`) capable of communicating with the + GCE API. Once accessible, ``ssh`` into the VM and run the following scripts. -4. ``build_vm_images.sh``: Examine the merged PR's description on github. - If it contains the magic string ``***CIRRUS: REBUILD IMAGES***``, then - continue. Otherwise display a message, take no further action, and - exit successfully. This prevents production of new VM images unless - they are called for, thereby saving the cost of needlessly storing them. +3. ``setup_environment.sh``: Same as for other tasks. -5. If the magic string was found, utilize [the packer tool](http://packer.io/docs/) +4. ``build_vm_images.sh``: Utilize [the packer tool](http://packer.io/docs/) to produce new VM images. Create a new VM from each base-image, connect - to them with ``ssh``, and perform these steps as defined by the - ``libpod_images.json`` file. + to them with ``ssh``, and perform the steps as defined by the + ``$PACKER_BASE/libpod_images.json`` file: - 1. Copy the current state of the repository into ``/tmp/libpod``. + 1. On a base-image VM, as root, copy the current state of the repository + into ``/tmp/libpod``. 2. Execute distribution-specific scripts to prepare the image for - use by the ``full_vm_testing`` task (above). + use by the ``full_vm_testing`` task (above). These scripts all + end with the suffix `_setup.sh` within the `$PACKER_BASE` directory. 3. If successful, shut down each VM and create a new GCE Image named after the base image and the commit sha of the merge. -- cgit v1.2.3-54-g00ecf From 2842b8ad403e99268f40ad29e453d43bbc3e3a4f Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 30 Nov 2018 19:26:28 +0100 Subject: cirrus: make apt noninteractive Signed-off-by: Giuseppe Scrivano --- contrib/cirrus/packer/ubuntu_setup.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'contrib/cirrus') diff --git a/contrib/cirrus/packer/ubuntu_setup.sh b/contrib/cirrus/packer/ubuntu_setup.sh index 4cf1f335b..ef209a4a4 100644 --- a/contrib/cirrus/packer/ubuntu_setup.sh +++ b/contrib/cirrus/packer/ubuntu_setup.sh @@ -21,11 +21,13 @@ install_ooe export GOPATH="$(mktemp -d)" trap "sudo rm -rf $GOPATH" EXIT +export DEBIAN_FRONTEND=noninteractive + # Try twice as workaround for minor networking problems echo "Updating system and installing package dependencies" -ooe.sh sudo apt-get -qq update || sudo apt-get -qq update -ooe.sh sudo apt-get -qq upgrade || sudo apt-get -qq upgrade -ooe.sh sudo apt-get -qq install --no-install-recommends \ +ooe.sh sudo -E apt-get -qq update || sudo -E apt-get -qq update +ooe.sh sudo -E apt-get -qq upgrade || sudo -E apt-get -qq upgrade +ooe.sh sudo -E apt-get -qq install --no-install-recommends \ apparmor \ autoconf \ automake \ -- cgit v1.2.3-54-g00ecf From deeb3eaf7dde436fd23f8bcb03d30021e2b27c0b Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 30 Nov 2018 21:27:21 +0100 Subject: tests: always install runc on Ubuntu Signed-off-by: Giuseppe Scrivano --- contrib/cirrus/lib.sh | 22 ++++++++++++++-------- contrib/cirrus/setup_environment.sh | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'contrib/cirrus') diff --git a/contrib/cirrus/lib.sh b/contrib/cirrus/lib.sh index 6d43c6ea5..04314e5fe 100644 --- a/contrib/cirrus/lib.sh +++ b/contrib/cirrus/lib.sh @@ -157,6 +157,19 @@ install_cni_plugins() { sudo cp bin/* /usr/libexec/cni } +install_runc_from_git(){ + wd=$(pwd) + DEST="$GOPATH/src/github.com/opencontainers/runc" + rm -rf "$DEST" + ooe.sh git clone https://github.com/opencontainers/runc.git "$DEST" + cd "$DEST" + ooe.sh git fetch origin --tags + ooe.sh git checkout -q "$RUNC_COMMIT" + ooe.sh make static BUILDTAGS="seccomp selinux" + sudo install -m 755 runc /usr/bin/runc + cd $wd +} + install_runc(){ OS_RELEASE_ID=$(os_release_id) echo "Installing RunC from commit $RUNC_COMMIT" @@ -179,14 +192,7 @@ install_runc(){ cd "$GOPATH/src/github.com/containers/libpod" ooe.sh sudo make install.libseccomp.sudo fi - DEST="$GOPATH/src/github.com/opencontainers/runc" - rm -rf "$DEST" - ooe.sh git clone https://github.com/opencontainers/runc.git "$DEST" - cd "$DEST" - ooe.sh git fetch origin --tags - ooe.sh git checkout -q "$RUNC_COMMIT" - ooe.sh make static BUILDTAGS="seccomp selinux" - sudo install -m 755 runc /usr/bin/runc + install_runc_from_git } install_buildah() { diff --git a/contrib/cirrus/setup_environment.sh b/contrib/cirrus/setup_environment.sh index 167db127f..2563b5f43 100755 --- a/contrib/cirrus/setup_environment.sh +++ b/contrib/cirrus/setup_environment.sh @@ -53,6 +53,8 @@ then # Some setup needs to vary between distros case "${OS_RELEASE_ID}-${OS_RELEASE_VER}" in ubuntu-18) + # Always install runc on Ubuntu + install_runc_from_git envstr='export BUILDTAGS="seccomp $($GOSRC/hack/btrfs_tag.sh) $($GOSRC/hack/btrfs_installed_tag.sh) $($GOSRC/hack/ostree_tag.sh) varlink exclude_graphdriver_devicemapper"' ;; fedora-28) ;& # Continue to the next item -- cgit v1.2.3-54-g00ecf