buildah/tests/test_buildah.sh

61 lines
1.6 KiB
Bash
Raw Normal View History

#!/bin/bash
#
# Simple buildah tests
#
export PATH=/usr/local/bin:/usr/sbin:/usr/bin
export TMPDIR=/var/tmp
TEST_LOG=/tmp/test.$(id -un).log
FULL_LOG=/tmp/test.$(id -un).debug.log
rm -f $TEST_LOG $FULL_LOG
# Log program versions
rpm -q buildah buildah-tests > $FULL_LOG
cd /usr/share/buildah/test/system || exit 1
start_registry() {
AUTHDIR=/tmp/buildah-tests-auth.$$
mkdir -p $AUTHDIR
CERT=$AUTHDIR/domain.crt
if [ ! -e $CERT ]; then
openssl req -newkey rsa:4096 -nodes -sha256 \
-keyout $AUTHDIR/domain.key -x509 -days 2 \
-out $AUTHDIR/domain.crt \
-subj "/C=US/ST=Foo/L=Bar/O=Red Hat, Inc./CN=localhost"
fi
if [ ! -e $AUTHDIR/htpasswd ]; then
podman run --entrypoint htpasswd registry:2 \
-Bbn testuser testpassword > $AUTHDIR/htpasswd
fi
podman run -d -p 5000:5000 \
--name registry \
-v $AUTHDIR:/auth:Z \
-e "REGISTRY_AUTH=htpasswd" \
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/auth/domain.crt \
-e REGISTRY_HTTP_TLS_KEY=/auth/domain.key \
registry:2
}
export BUILDAH_BINARY=/usr/bin/buildah
export IMGTYPE_BINARY=/usr/bin/buildah-imgtype
start_registry >> $FULL_LOG 2>&1
bats . &> $TEST_LOG
rc=$?
echo "------------------------------" >> $FULL_LOG
echo "bats completed with status $rc" >> $FULL_LOG
podman rm -f registry >> $FULL_LOG
exit $rc