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 --- contrib/cirrus/build_vm_images.sh | 2 -- contrib/cirrus/lib.sh | 17 ----------------- contrib/cirrus/optional_system_test.sh | 8 -------- 3 files changed, 27 deletions(-) (limited to 'contrib') 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') 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') 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