1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-06 03:45:28 +01:00
Files
atomic/vagrant.sh
Brent Baude 8ea8d1e82e make vagrant-check: Run tests with vagrant
Run tests in a vagrant session (w/libvirt for now).  This allows
the tests to occur similar to the way our jenkins tests work. Run
make vagrant-check and we created an F24 session and install
the proper deps.  We then call the .redhat-ci.sh script inside
the vagrant session and the tests are executed.  At this time, you
will need to vagrant halt to shutdown the session when comlete.

By default, the tests will exeute on an instance of fedora-24-atomic.
You can test on Colin's CAHC centos-atomic by:

make vagrant-check BOX=centos_atomic

Closes: #736
Approved by: rhatdan
2016-11-07 17:01:06 +00:00

61 lines
1.4 KiB
Bash

#!/bin/bash
set -euo pipefail
_FINISH(){
RESULT=($?)
if [ ${RESULT} -eq 0 ]; then
echo ""
echo "Tests completed normally..."
vagrant destroy ${BOX}
echo ""
else
echo ""
echo "** Test failed. Leaving '${BOX}' running for debug." 2>&1 | tee -a ${tee_file}
echo "** Be sure to halt or destroy prior to re-running the check" 2>&1 | tee -a ${tee_file}
echo "** Logs are stored at ${tee_file}"
echo ""
exit 1
fi
}
# When make calls bash, the real signals are not surfaced
# correctly to trap. So we trap on EXIT and then sort it
# out in _FINISH
trap _FINISH EXIT
BOXES="fedora_atomic centos_atomic"
is_running() {
status=$(vagrant status | grep ${BOX} | awk '{print $2}')
if [ ${status} == "running" ]; then
RUNNING=true
else
RUNNING=false
fi
}
if [[ ! $BOXES =~ $BOX ]]; then
echo ""
echo "Invalid BOX name: $BOX. Valid choices are $BOXES"
echo ""
exit 1
fi
echo "Testing on ${BOX}"
timestamp=$(date +%Y_%m_%d_%H_%M)
tee_file="${BOX}_${timestamp}.log"
is_running
if ${RUNNING}; then
echo ""
echo "*** '${BOX}' is already running. Re-syncing and rerunning test ..."
echo ""
vagrant rsync ${BOX}
else
vagrant up ${BOX} 2>&1 | tee ${tee_file}
fi
vagrant ssh ${BOX} -c "cd /home/vagrant/atomic && sudo sh ./.redhat-ci.sh" 2>&1 | tee -a ${tee_file}