mirror of
https://github.com/containers/podman.git
synced 2025-06-26 12:56:45 +08:00
Merge pull request #1780 from cevich/un-magic
Reveal magic, parallel system-testing and system-testing simplification
This commit is contained in:
48
.cirrus.yml
48
.cirrus.yml
@ -63,24 +63,52 @@ full_vm_testing_task:
|
|||||||
|
|
||||||
integration_test_script: $SCRIPT_BASE/integration_test.sh
|
integration_test_script: $SCRIPT_BASE/integration_test.sh
|
||||||
|
|
||||||
optional_system_test_script: $SCRIPT_BASE/optional_system_test.sh
|
|
||||||
|
|
||||||
success_script: $SCRIPT_BASE/success.sh
|
success_script: $SCRIPT_BASE/success.sh
|
||||||
|
|
||||||
|
|
||||||
# This task build new images for future PR testing, but only after a PR merge.
|
# Because system tests are stored within the repository, it is sometimes
|
||||||
# These images save needing to install/setup the same environment to test every
|
# necessary to execute them within a PR to validate changes.
|
||||||
# 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
|
optional_system_testing_task:
|
||||||
# be automated (see comment at end).
|
|
||||||
|
# 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
|
||||||
|
system_test_script: $SCRIPT_BASE/system_test.sh
|
||||||
|
success_script: $SCRIPT_BASE/success.sh
|
||||||
|
|
||||||
|
|
||||||
|
# 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:
|
build_vm_images_task:
|
||||||
# Only produce new images after a PR merge
|
# Only produce new cache-images after a PR merge, and if a magic string
|
||||||
only_if: $CIRRUS_BRANCH == 'master'
|
# 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.
|
# Require tests to pass first.
|
||||||
depends_on:
|
depends_on:
|
||||||
- test # i.e. 'test_task'
|
- full_vm_testing # i.e. 'full_vm_testing_task'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# CSV of packer builder names to enable (see $PACKER_BASE/libpod_images.json)
|
# CSV of packer builder names to enable (see $PACKER_BASE/libpod_images.json)
|
||||||
|
@ -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)
|
Total execution time is capped at 2-hours (includes all the above)
|
||||||
but this script normally completes in less than an hour.
|
but this script normally completes in less than an hour.
|
||||||
|
|
||||||
|
### ``optional_system_testing`` Task
|
||||||
|
|
||||||
|
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. ``setup_environment.sh``: Same as for other tasks.
|
||||||
|
|
||||||
|
3. ``system_test.sh``: Build both dependencies and libpod, install them,
|
||||||
|
then execute `make localsystem` from the repository root.
|
||||||
|
|
||||||
### ``build_vm_images`` Task
|
### ``build_vm_images`` Task
|
||||||
|
|
||||||
1. When a PR is merged (``$CIRRUS_BRANCH`` == ``master``), run another
|
1. When a PR is merged (``$CIRRUS_BRANCH`` == ``master``), Cirrus
|
||||||
round of the ``full_vm_testing`` task (above).
|
checks the last commit message. If it contains the magic string
|
||||||
|
``***CIRRUS: REBUILD IMAGES***``, then this task continues.
|
||||||
|
|
||||||
2. After confirming the tests all pass post-merge, spin up a special VM
|
2. Execute run another round of the ``full_vm_testing`` task (above).
|
||||||
capable of communicating with the GCE API. Once accessible, ``ssh`` into
|
After the tests pass (post-merge), spin up a special VM
|
||||||
the special VM and run the following scripts.
|
(from the `image-builder-image`) capable of communicating with the
|
||||||
|
GCE API. Once accessible, ``ssh`` into the VM and run the following scripts.
|
||||||
|
|
||||||
3. ``setup_environment.sh``: Configure root's ``.bash_profile``
|
3. ``setup_environment.sh``: Same as for other tasks.
|
||||||
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.
|
4. ``build_vm_images.sh``: Utilize [the packer tool](http://packer.io/docs/)
|
||||||
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 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
|
to them with ``ssh``, and perform the steps as defined by the
|
||||||
``libpod_images.json`` file.
|
``$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
|
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
|
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.
|
named after the base image and the commit sha of the merge.
|
||||||
|
|
||||||
|
@ -22,8 +22,6 @@ SCRIPT_BASE $SCRIPT_BASE
|
|||||||
PACKER_BASE $PACKER_BASE
|
PACKER_BASE $PACKER_BASE
|
||||||
"
|
"
|
||||||
|
|
||||||
require_regex '\*\*\*\s*CIRRUS:\s*REBUILD\s*IMAGES\s*\*\*\*' 'Not re-building VM images'
|
|
||||||
|
|
||||||
show_env_vars
|
show_env_vars
|
||||||
|
|
||||||
# Everything here is running on the 'image-builder-image' GCE image
|
# Everything here is running on the 'image-builder-image' GCE image
|
||||||
|
@ -120,23 +120,6 @@ cdsudo() {
|
|||||||
sudo --preserve-env=GOPATH --non-interactive bash -c "$CMD"
|
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
|
# Helper/wrapper script to only show stderr/stdout on non-zero exit
|
||||||
install_ooe() {
|
install_ooe() {
|
||||||
req_env_var "SCRIPT_BASE $SCRIPT_BASE"
|
req_env_var "SCRIPT_BASE $SCRIPT_BASE"
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
#!/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
|
|
33
contrib/cirrus/system_test.sh
Executable file
33
contrib/cirrus/system_test.sh
Executable file
@ -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
|
Reference in New Issue
Block a user