refactor test script

This commit is contained in:
Nadezhda Fedorova 2024-12-16 14:55:51 +03:00 committed by Надежда Краснобородько
parent 78daf7d9bb
commit ff20da92a8

View File

@ -6,44 +6,46 @@
#$4 - ${{ needs.build-process.outputs.repo }}
#$5 - ${{ gitea.workspace }}
branch=${1:-"sisyphus"}
org=${2:-"alt"}
url=${3:-"gitea.basealt.ru"}
repo=${4:-"alt"}
wosp=${5:-"."}
errors=''
haserr=false
for IM in $(ls $5/org/$2/ | xargs)
for IM in $(ls $wosp/org/$org/ | xargs)
do
echo "image=$IM"
if test -f $5/org/$2/$IM/test
if test -f $wosp/org/$org/$IM/test
then
test=$(cat $5/org/$2/$IM/test)
test=$(cat $wosp/org/$org/$IM/test)
else test=''
fi
echo "test script=$test"
imgpath="$2/$IM:$1"
if [[ $2 == 'k8s' ]]
then imgpath="$2-$1/$IM:latest"
fi
imgpath="$repo/$branch/$IM:latest"
entrypoint='/bin/sh'
command="echo empty_command"
if [[ $test != '' ]]; then
command="podman run --rm --entrypoint=\"$entrypoint\" $3/$imgpath -c \"$test\""
if [ -n "$test" ]; then
command="podman run --rm --entrypoint=\"$entrypoint\" $url/$imgpath -c \"$test\""
else
if [[ $IM == 'distroless-toybox' ]]; then
command="podman run --rm $3/$imgpath toysh -c true"
if [[ "$IM" == distroless-toybox ]]; then
command="podman run --rm $url/$imgpath toysh -c true"
fi
if [[ $IM == 'distroless-true' ]]; then
command="podman run --rm $3/$imgpath \"true\""
if [ "$IM" = distroless-true ]; then
command="podman run --rm $url/$imgpath \"true\""
fi
if [[ $IM == 'distroless-gotop' ]]; then
command="podman run --rm $3/$imgpath \"--version\""
if [ "$IM" = distroless-gotop ]; then
command="podman run --rm $url/$imgpath \"--version\""
fi
if [[ $IM == 'flannel-cni-plugin' ]]; then
command="podman run --rm $3/$imgpath \"/flannel\""
if [ "$IM" = flannel-cni-plugin ]; then
command="podman run --rm $url/$imgpath \"/flannel\""
fi
if [[ $IM == 'pause' ]]; then
command="podman run --rm $3/$imgpath \"/pause\" \"-v\""
if [ "$IM" == pause ]; then
command="podman run --rm $url/$imgpath \"/pause\" \"-v\""
fi
fi
echo $command
@ -52,9 +54,9 @@ do
echo "podman rmi --all"
podman rmi --all
if [ "$haserr" = true ]
if [ "$haserr" ]
then
if [[ $(cat $IM.log) != '' ]]
if [[ -n $(cat $IM.log) ]]
then errors="TEST ERROR OF IMAGE $IM: $(cat $IM.log); $errors"
else errors="TEST ERROR OF IMAGE $IM: test returned empty error, but exit status was nozero; $errors"
fi
@ -63,7 +65,7 @@ do
done
echo "$errors"
if [[ $errors != '' ]]
if [ -n "$errors" ]
then haserr=true
fi
echo "ERR=$haserr" > haserr.log