Execute bash tests for composer-cli
these are built on top of beakerlib and we use its internal protocol to figure out the result without relying on the full test runner that is tipically used inside of a RHEL environment! Includes a disabled test snippet for Issue #460
This commit is contained in:
parent
ccf34b1913
commit
1ba7613036
@ -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
|
||||
|
3
Makefile
3
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 ***"
|
||||
|
45
tests/cli/test_blueprints_sanity.sh
Executable file
45
tests/cli/test_blueprints_sanity.sh
Executable file
@ -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
|
33
tests/test_cli.sh
Executable file
33
tests/test_cli.sh
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user