Commit 56e15aa2 authored by Michael Völske's avatar Michael Völske

new docker-based test script

parent dde30e3c
Vagrant.configure("2") do |config|
config.vm.synced_folder ".", "/code-webis-cmd"
config.vm.provider "docker" do |docker|
docker.has_ssh = false
docker.remains_running = false
end
config.vm.define :nopython do |np|
np.vm.provider "docker" do |d|
d.image = 'alpine:latest'
d.name = 'webiscmd-no-python'
end
end
config.vm.define :oldpython do |op|
op.vm.provider "docker" do |d|
d.image = 'python:2.7'
d.name = 'webiscmd-old-python'
end
end
config.vm.define :newpython do |np|
np.vm.provider "docker" do |d|
d.image = 'python:3'
d.name = 'webiscmd-new-python'
end
end
end
#!/bin/bash
if [ -z ${WCMD_TEST_RUNNING+x} ]; then
# outside docker
D=$( realpath $( dirname ${0} ) )
. "${D}/libs/shflags"
DEFINE_string py '3.5' "Python version to test against" p
DEFINE_boolean preserve_wdir "${FLAGS_FALSE}" "Don't use a temporary working directory during tests, but mount the host directory given as --wdir instead." s
DEFINE_string wdir "${D}/webis-cmd-test-tmp/" "Working directory to use, if preserve_wdiris set." t
FLAGS_HELP="Usage: ${0} [flags] -- <command>
Test webis-cmd against a python docker container with specified version.
<command> : the webis-cmd command to run. "
FLAGS "$@" || exit $?
eval set -- "${FLAGS_ARGV}"
WDIR=/tmp/wcmd-tmp
[ "${FLAGS_preserve_wdir}" = "${FLAGS_TRUE}" ] && {
mkdir -vp ${FLAGS_wdir}
WDIR=${FLAGS_wdir}
}
docker run --rm -it \
--net host \
-v "${D}:/webis-cmd" \
-v "${HOME}:/wcmd-home" \
-e "PYTHONPATH=/webis-cmd" \
-e "HOME=/wcmd-home" \
-e "WCMD_TEST_RUNNING=1" \
-e "WCMD_WDIR=${WDIR}" \
-e "WCMD_UID=$(id -u)" \
-e "WCMD_USER=$(whoami)" \
python:${FLAGS_py} /webis-cmd/$(basename ${0}) $@
else
# inside docker
useradd -d ${HOME} -M --password '...' --uid ${WCMD_UID} ${WCMD_USER}
mkdir -p ${WCMD_WDIR}
ln -s /webis-cmd/webis.py /bin/webis
chmod +x /bin/webis
chown ${WCMD_USER} ${WCMD_WDIR}
cd ${WCMD_WDIR}
echo "echo 'Executing <${@}>...'" >> /tmp/run
echo "$@" >> /tmp/run
echo "echo 'Finished executing <${@}>. Working dir contents now:'" >> /tmp/run
echo "ls -ahl " >> /tmp/run
chmod +x /tmp/run
su --preserve-environment ${WCMD_USER} -c '. /tmp/run'
fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment