mirror of https://github.com/containers/podman.git
Merge pull request #3193 from cevich/check_image
Cirrus: More tests to verify cache_images
This commit is contained in:
commit
fccf4ad503
|
@ -410,7 +410,7 @@ verify_test_built_images_task:
|
||||||
# "probably" work. A full round of testing will happen again after $*_CACHE_IMAGE_NAME
|
# "probably" work. A full round of testing will happen again after $*_CACHE_IMAGE_NAME
|
||||||
# are updated in this or another PR (w/o '***CIRRUS: TEST IMAGES***').
|
# are updated in this or another PR (w/o '***CIRRUS: TEST IMAGES***').
|
||||||
environment_script: '$SCRIPT_BASE/setup_environment.sh |& ${TIMESTAMP}'
|
environment_script: '$SCRIPT_BASE/setup_environment.sh |& ${TIMESTAMP}'
|
||||||
|
check_image_script: '$SCRIPT_BASE/check_image.sh'
|
||||||
integration_test_script: '$SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP}'
|
integration_test_script: '$SCRIPT_BASE/integration_test.sh |& ${TIMESTAMP}'
|
||||||
|
|
||||||
always:
|
always:
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
source $(dirname $0)/lib.sh
|
||||||
|
|
||||||
|
RET=0
|
||||||
|
echo "Validating VM image"
|
||||||
|
|
||||||
|
MIN_SLASH_GIGS=50
|
||||||
|
read SLASH_DEVICE SLASH_FSTYPE SLASH_SIZE JUNK <<<$(findmnt --df --first-only --noheadings / | cut -d '.' -f 1)
|
||||||
|
SLASH_SIZE_GIGS=$(echo "$SLASH_SIZE" | sed -r -e 's/G|g//')
|
||||||
|
item_test "Minimum available disk space" $SLASH_SIZE_GIGS -gt $MIN_SLASH_GIGS || let "RET+=1"
|
||||||
|
|
||||||
|
MIN_MEM_MB=2000
|
||||||
|
read JUNK TOTAL USED MEM_FREE JUNK <<<$(free -tm | tail -1)
|
||||||
|
item_test 'Minimum available memory' $MEM_FREE -ge $MIN_MEM_MB || let "RET+=1"
|
||||||
|
|
||||||
|
item_test "podman command NOT found on path" -z "$(type -P podman)" || let "RET+=1"
|
||||||
|
|
||||||
|
MIN_ZIP_VER='3.0'
|
||||||
|
VER_RE='.+([[:digit:]]+\.[[:digit:]]+).+'
|
||||||
|
ACTUAL_VER=$(zip --version 2>&1 | egrep -m 1 "Zip$VER_RE" | sed -r -e "s/$VER_RE/\\1/")
|
||||||
|
item_test "minimum zip version" "$MIN_ZIP_VER" = $(echo -e "$MIN_ZIP_VER\n$ACTUAL_VER" | sort -V | head -1) || let "RET+=1"
|
||||||
|
|
||||||
|
for REQ_UNIT in google-accounts-daemon.service \
|
||||||
|
google-clock-skew-daemon.service \
|
||||||
|
google-instance-setup.service \
|
||||||
|
google-network-daemon.service \
|
||||||
|
google-shutdown-scripts.service \
|
||||||
|
google-startup-scripts.service
|
||||||
|
do
|
||||||
|
item_test "required $REQ_UNIT enabled" \
|
||||||
|
"$(systemctl list-unit-files --no-legend $REQ_UNIT)" = "$REQ_UNIT enabled" || let "RET+=1"
|
||||||
|
done
|
||||||
|
|
||||||
|
exit $RET
|
|
@ -114,6 +114,30 @@ req_env_var() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item_test() {
|
||||||
|
ITEM="$1"
|
||||||
|
shift
|
||||||
|
TEST_ARGS="$@"
|
||||||
|
req_env_var ITEM TEST_ARGS
|
||||||
|
|
||||||
|
if ERR=$(test "$@" 2>&1)
|
||||||
|
then
|
||||||
|
echo "ok $ITEM"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
RET=$?
|
||||||
|
echo -n "not ok $ITEM: $TEST_ARGS"
|
||||||
|
if [[ -z "$ERR" ]]
|
||||||
|
then
|
||||||
|
echo ""
|
||||||
|
else # test command itself failed
|
||||||
|
echo -n ":" # space follows :'s in $ERR
|
||||||
|
echo "$ERR" | cut -d : -f 4- # omit filename, line number, and command
|
||||||
|
fi
|
||||||
|
return $RET
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
show_env_vars() {
|
show_env_vars() {
|
||||||
echo "Showing selection of environment variable definitions:"
|
echo "Showing selection of environment variable definitions:"
|
||||||
_ENV_VAR_NAMES=$(awk 'BEGIN{for(v in ENVIRON) print v}' | \
|
_ENV_VAR_NAMES=$(awk 'BEGIN{for(v in ENVIRON) print v}' | \
|
||||||
|
|
|
@ -12,7 +12,7 @@ function check_result {
|
||||||
testnum=$(expr $testnum + 1)
|
testnum=$(expr $testnum + 1)
|
||||||
MSG=$(echo "$1" | tr -d '*>\012'|sed -e 's/^ \+//')
|
MSG=$(echo "$1" | tr -d '*>\012'|sed -e 's/^ \+//')
|
||||||
if [ "$MSG" = "$2" ]; then
|
if [ "$MSG" = "$2" ]; then
|
||||||
echo "ok $testnum $3 = $MSG"
|
echo "ok $testnum $(echo $3) = $(echo $MSG)"
|
||||||
else
|
else
|
||||||
echo "not ok $testnum $3"
|
echo "not ok $testnum $3"
|
||||||
echo "# expected: $2"
|
echo "# expected: $2"
|
||||||
|
@ -83,6 +83,41 @@ test_rev "FOO BAR" 9 'FATAL: test_rev() requires $BAR to be non-empty'
|
||||||
BAR=1
|
BAR=1
|
||||||
test_rev "FOO BAR" 0 ''
|
test_rev "FOO BAR" 0 ''
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# tests for test_okay()
|
||||||
|
|
||||||
|
function test_item_test {
|
||||||
|
local exp_msg=$1
|
||||||
|
local exp_ret=$2
|
||||||
|
local item=$3
|
||||||
|
shift 3
|
||||||
|
local test_args="$@"
|
||||||
|
local msg
|
||||||
|
msg=$(item_test "$item" "$@")
|
||||||
|
local status=$?
|
||||||
|
|
||||||
|
check_result "$msg" "$exp_msg" "test_item $item $test_args"
|
||||||
|
check_result "$status" "$exp_ret" "test_item $item $test_args (actual rc $status)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# negative tests
|
||||||
|
test_item_test "FATAL: item_test() requires \$ITEM to be non-empty" 9 "" ""
|
||||||
|
test_item_test "FATAL: item_test() requires \$TEST_ARGS to be non-empty" 9 "foo" ""
|
||||||
|
test_item_test "not ok foo: -gt 5 ~= bar: too many arguments" 2 "foo" "-gt" "5" "~=" "bar"
|
||||||
|
test_item_test "not ok bar: a -ge 10: a: integer expression expected" 2 "bar" "a" "-ge" "10"
|
||||||
|
test_item_test "not ok basic logic: 0 -ne 0" 1 "basic logic" "0" "-ne" "0"
|
||||||
|
|
||||||
|
# positive tests
|
||||||
|
test_item_test "ok snafu" 0 "snafu" "foo" "!=" "bar"
|
||||||
|
test_item_test "ok foobar" 0 "foobar" "one two three" "=" "one two three"
|
||||||
|
test_item_test "ok oh boy" 0 "oh boy" "line 1
|
||||||
|
line2" "!=" "line 1
|
||||||
|
|
||||||
|
line2"
|
||||||
|
test_item_test "ok okay enough" 0 "okay enough" "line 1
|
||||||
|
line2" "=" "line 1
|
||||||
|
line2"
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
exit $rc
|
exit $rc
|
||||||
|
|
Loading…
Reference in New Issue