#!/bin/bash #------------------------------------------------------------------------------ set -u declare OpMode=Standard declare BuildCmd= declare OSList= declare OS= declare DockerDir= declare DockerfileBase= declare DockerfileSDP= declare ScriptDir= declare WorkDir=${HOME}/podman_tmp declare -i ErrorCount=0 function msg () { echo -e "$*"; } function errmsg () { msg "\\nError: ${1:-Unknown Error}\\n"; ErrorCount+=1; } function bail () { errmsg "${1:-Unknown Error}"; exit "$ErrorCount"; } #------------------------------------------------------------------------------ # Build the Docker containers for the SDP - now using podman instead of docker # Usage: # build_docker_image.sh [<OS>] [-clean] # Usage Examples from 'test' dir under workspace branch root: # sdp/test/build_docker_image.sh # sdp/test/build_docker_image.sh ubuntu20 # sdp/test/build_docker_image.sh centos7 ubuntu20 # sdp/test/build_docker_image.sh all # sdp/test/build_docker_image.sh ALL -clean # # Goes together with run_docker_tests.sh # This is provided as a useful tool for testing! # # Note that this file is expecting to be mapped into the root of the workspace # and with the sdp directory in the same root. # So workspace view should look something like: # View: # //guest/perforce_software/sdp/main/... //myws.sdp/sdp/... # This file should be in <workspace-root>/sdp/test/ # We calculate dir relative to directory of script ScriptDir="${0%/*}" # shellcheck disable=SC2164 root_dir="$(cd "$ScriptDir/../.."; pwd -P)" for arg in $(echo "$@" | tr ',' ' '); do case "$arg" in (-clean) OpMode=Clean;; (all) OSList="rocky9 ubuntu22";; (ALL) OSList="centos7 rocky8 rocky9 ubuntu20 ubuntu22";; (ubuntu20) OSList+="ubuntu20";; (ubuntu22) OSList+="ubuntu22";; (centos7) OSList+="centos7";; (rocky8) OSList+="rocky8";; (rocky9) OSList+="rocky9";; (-*) echo "Warning: Unknown option [$arg]." ;; (*) echo "Warning: Unknown OS [$arg]." OSList+="$arg" ;; esac done # Default is currently Rocky 9 only. [[ -z "$OSList" ]] && OSList="rocky9" mkdir -p "$WorkDir" || bail "Could not do: mkdir -p \"$WorkDir\"" export TMPDIR="$WorkDir" echo Building SDP docker containers for OS in $OSList; do DockerDir="$root_dir/sdp/test/docker" DockerfileBase="${DockerDir}/Dockerfile.${OS}.base" DockerfileSDP="${DockerDir}/Dockerfile.${OS}.sdp" # Build the base Docker for the OS, and then the SDP variant on top BuildCmd="podman build --rm=true -t=perforce/${OS}-base -f ${DockerfileBase} ${DockerDir}" [[ "$OpMode" == Clean ]] && BuildCmd=${BuildCmd/--rm=true/--rm=true --no-cache} msg "Running: $BuildCmd" $BuildCmd || errmsg "Error building Base OS container." BuildCmd="podman build --rm=true -t=perforce/${OS}-sdp -f ${DockerfileSDP} ${DockerDir}" [[ "$OpMode" == Clean ]] && BuildCmd=${BuildCmd/--rm=true/--rm=true --no-cache} msg "Running: $BuildCmd" $BuildCmd || errmsg "Error building SDP container." done if [[ "$ErrorCount" -eq 0 ]]; then msg "\\nAll processing completed OK." else msg "\\nProcessing completed, but with $ErrorCount errors." fi exit "$ErrorCount"
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#7 | 30356 | C. Thomas Tyler |
Added Rocky 9 and Ubuntu 22 to test suite. Dropped CentOS 6. Changed default OS for tests from CentOS 7 to Rocky 9. Adapted to using podman for the test suite. Reduced minimum disk space requirement for testing from 1G to 10M. To be revisited: * Disabled OOM killer defenese feature and systemd due to compatibility issues with the test environment. * Disabled systemd by moving systemctl aside Enhanced build_docker_image.sh; added '-clean' option and added support for more platforms. Updated OS-specific packages as needed for all platforms, e.g. adding 'file' and 'rsync' utils as needed in Docker definitions. Added minimum performance recommendations for test containers in config. Updated env.sh utilities. This change test on: [X] centos7 [X] rocky8 [X] rocky9 [X] ubuntu20 [X] ubuntu22 #review-30357 @robert_cowham TO DO: * This builds using the official SDP test suite run manually on Tom's laptop. Next step: Get it working on our shiny new Jenkins Rocky 9 server machine. |
||
#6 | 30295 | Robert Cowham | Fix tests to run under podman SDP-1106 | ||
#5 | 28850 | C. Thomas Tyler |
Test suite tweaks: * Added command line usage notes in scripts. * Enhanced comand line processing. * Added aliases for building on Rocky Linux 8. #review-28851 |
||
#4 | 28137 | C. Thomas Tyler |
Added Rocky Linux 8 test image. Added 'all' argument to build on all OSes except unsupported ones ( e.g. CentOS 6). Added 'ALL' argument to build on all OSes, including unsupported ones. |
||
#3 | 27002 | C. Thomas Tyler |
Updated ubuntu tests to add needed utilities, and change from testing Ubuntu 16.04 to 20.04. Changed 'centos' to imply cento7 rather than centos6 (which we shoud drop soon). |
||
#2 | 25153 | Robert Cowham |
Change scripts to be able to be run from workspace root sdp/test/run_docker_tests.sh So no longer requires funny mapping in workspace view (see README.md for view) |
||
#1 | 25150 | Robert Cowham | Utiltiy script to help build docker images | ||
//guest/robert_cowham/perforce/sdp/test/build_docker_image.sh | |||||
#5 | 25116 | Robert Cowham | Docker compose tests starting to get there... | ||
#4 | 23433 | Robert Cowham | Got it working with basic ssh stuff if sshd run manually on a box | ||
#3 | 22485 | Robert Cowham |
Update python to 3.5 Refactor tests to simplify workspace (no mapping into root), and to allow easy setup |
||
#2 | 20827 | Robert Cowham | Default to centos6 for nowç | ||
#1 | 20813 | Robert Cowham | Using docker-compose |