diff --git a/Dockerfile.test b/Dockerfile.test index 6f1a13de..045cb49d 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -3,18 +3,21 @@ FROM centos:7 COPY epel.repo /etc/yum.repos.d/ RUN yum -y install --nogpgcheck epel-release && \ rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-* && \ - yum -y install make libgit2-glib tito python-pylint \ + yum -y install make libgit2-glib tito pylint \ python-nose python-mako python-flask \ python-coverage libselinux-python sudo \ pykickstart python2-pytoml python-sphinx \ python2-mock python-semantic_version \ - anaconda-tui && \ + anaconda-tui python-gevent beakerlib && \ yum clean all && \ - rm -rf /var/cache/yum - + rm -rf /var/cache/yum && \ + useradd weldr RUN mkdir /lorax COPY . /lorax +# remove byte-compiled files to avoid issues between Python 2/3 +# this can happen when you switch between rhel7 and master branches +RUN find /lorax -name "*.pyc" -exec rm -f {} \; WORKDIR /lorax RUN make test diff --git a/Makefile b/Makefile index 2ce4b668..8388bd92 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,9 @@ test: docs coverage combine coverage report -m [ -f "/usr/bin/coveralls" ] && [ -n "$(COVERALLS_REPO_TOKEN)" ] && coveralls || echo + + ./tests/test_cli.sh + check: @echo "*** Running pylint ***" diff --git a/tests/cli/test_blueprints_sanity.sh b/tests/cli/test_blueprints_sanity.sh new file mode 100755 index 00000000..a97f425a --- /dev/null +++ b/tests/cli/test_blueprints_sanity.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Note: execute this file from the project root directory + +. /usr/share/beakerlib/beakerlib.sh + +CLI="./src/bin/composer-cli" + + +rlJournalStart + rlPhaseStartTest "blueprints list" + for bp in http-server development atlas; do + rlRun -t -c "$CLI blueprints list | grep $bp" + done + rlPhaseEnd + + rlPhaseStartTest "blueprints save" + rlRun -t -c "$CLI blueprints save http-server" + rlAssertExists "http-server.toml" + rlAssertGrep "http-server" "http-server.toml" + rlAssertGrep "httpd" "http-server.toml" + + # non-existing blueprint +# enable test for https://github.com/weldr/lorax/issues/460 +# rlRun -t -c "$CLI blueprints save non-existing-bp" 1 +# rlAssertNotExists "non-existing-bp.toml" + rlPhaseEnd + + rlPhaseStartTest "blueprints push" + + cat > beakerlib.toml << __EOF__ +name = "beakerlib" +description = "Start building tests with beakerlib." +version = "0.0.1" + +[[modules]] +name = "beakerlib" +version = "*" +__EOF__ + + rlRun -t -c "$CLI blueprints push beakerlib.toml" + rlRun -t -c "$CLI blueprints list | grep beakerlib" + rlPhaseEnd + +rlJournalEnd +rlJournalPrintText diff --git a/tests/test_cli.sh b/tests/test_cli.sh new file mode 100755 index 00000000..740fea44 --- /dev/null +++ b/tests/test_cli.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# Note: execute this file from the project root directory + +# setup + +export TESTRESULT_BEAKERLIB_DIR=`mktemp -d /var/tmp/beakerlib-composer-XXXXXX` +export top_srcdir=`pwd` +. ./tests/testenv.sh + +if [ ! -d "/var/lib/lorax/composer" ]; then + mkdir -p /var/lib/lorax/composer + chown -R root:weldr /var/lib/lorax/ + chmod -R 775 /var/lib/lorax/ +fi + +# start the lorax-composer daemon +./src/sbin/lorax-composer ./tests/pylorax/blueprints/ & + +# wait for the backend to become ready +until curl --unix-socket /run/weldr/api.socket http://localhost:4000/api/status | grep '"db_supported": true'; do + sleep 2 + echo "DEBUG: Waiting for backend API to become ready before testing ..." +done; + +# invoke cli/ tests +./tests/cli/test_blueprints_sanity.sh + + +# look for failures +grep RESULT_STRING $TESTRESULT_BEAKERLIB_DIR/TestResults | grep -v PASS && exit 1 + +# explicit return code for Makefile +exit 0