diff --git a/tests/ci_test.sh b/tests/ci_test.sh new file mode 100755 index 0000000..8d0a9e4 --- /dev/null +++ b/tests/ci_test.sh @@ -0,0 +1,49 @@ +#!/usr/bin/bash + +function _chk +{ + echo "executing: $@" + eval "$@" + local rc=$? + if [ $rc -ne 0 ]; then + echo "Failed: $rc" + # Dump log for targetd + echo "journalctl -u targetd" + journalctl -u targetd + + # On failure dump the audit logs + echo "ausearch ..." + ausearch -i -m avc,user_avc,selinux_err,user_selinux_err -ts recent + exit 1 + fi +} + +SOURCE_DIR="targetd_src" +BASE=$PWD + +# TODO REMOVE THIS WHEN RAWHIDE PICKS UP +# https://github.com/fedora-selinux/selinux-policy-contrib/pull/334 +_chk setenforce 0 + +# Run the upstream setup script +_chk cd $SOURCE_DIR +_chk ./test/test.sh setup + +# Pick up new changes from setup +_chk systemctl restart targetd + +# Try stopping the firewall, but don't fail if this fails +systemctl stop firewalld + +# Give the service a moment to start up. +_chk sleep 10 + +# See if the daemon is up and accepting ... +netstat -anp | grep LISTEN | grep 18700 + +# Go back to start directory and run unit test. +_chk cd $BASE + +SRC="$BASE/$SOURCE_DIR" +_chk TARGETD_UT_CERTFILE=/etc/target/targetd_cert.pem PYTHONPATH=$SRC python3 $SRC/test/targetd_test.py -v +exit 0 \ No newline at end of file diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..428377f --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,22 @@ +- hosts: localhost + roles: + - role: standard-test-basic + tags: + - classic + tests: + - simple: + dir: . + run: ./ci_test.sh + required_packages: + - targetd + - util-linux + - lvm2 + - procps-ng + - coreutils + - openssl + - btrfs-progs + - audit + - python3-requests + repositories: + - repo: "https://github.com/open-iscsi/targetd.git" + dest: "targetd_src"