|
| 1 | +#! /bin/bash |
| 2 | +# |
| 3 | +# test.sh is provided for local testing, since we likely cannot connect to |
| 4 | +# priviledged daemon on circleci easily. |
| 5 | +# |
| 6 | +# USAGE: ./test.sh ubuntu:14.04 |
| 7 | +# |
| 8 | +# |
| 9 | +# Copyright (c) 2018 Vanessa Sochat, All Rights Reserved |
| 10 | +# |
| 11 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 12 | +# of this software and associated documentation files (the "Software"), to deal |
| 13 | +# in the Software without restriction, including without limitation the rights |
| 14 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 15 | +# copies of the Software, and to permit persons to whom the Software is |
| 16 | +# furnished to do so, subject to the following conditions: |
| 17 | +# |
| 18 | +# The above copyright notice and this permission notice shall be included in all |
| 19 | +# copies or substantial portions of the Software. |
| 20 | +# |
| 21 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 22 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 23 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 24 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 25 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 26 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 27 | +# SOFTWARE. |
| 28 | + |
| 29 | +set -o errexit |
| 30 | +set -o nounset |
| 31 | + |
| 32 | +testing_container="vanessa/salad" |
| 33 | +testing_version=v$(cat VERSION) |
| 34 | + |
| 35 | +if [ $# == 1 ] ; then |
| 36 | + testing_container="${1:-}" |
| 37 | +fi |
| 38 | + |
| 39 | +image="singularityware/singularity2docker:${testing_version}" |
| 40 | + |
| 41 | +echo "" |
| 42 | +echo "Testing Container: ${testing_container}"; |
| 43 | +echo "singularity2docker: v${testing_version}"; |
| 44 | +echo "" |
| 45 | + |
| 46 | +echo "Pulling ${testing_container}"; |
| 47 | +docker pull "${testing_container}"; |
| 48 | + |
| 49 | +################################################################################ |
| 50 | +# Test 1. Entrypoint functions |
| 51 | +################################################################################ |
| 52 | + |
| 53 | +echo "1. Testing simple run of container to verify entrypoint is working." |
| 54 | +echo "docker run ${image}" |
| 55 | +docker run "${image}" |
| 56 | +test "$?" -eq "0" && echo "PASS" || echo "FAIL" |
| 57 | + |
| 58 | +################################################################################ |
| 59 | +# Test 2. Basic Build |
| 60 | +################################################################################ |
| 61 | + |
| 62 | +echo "2. Testing docker2singularity build with ${testing_container}" |
| 63 | +TMPDIR=$(mktemp -d) |
| 64 | +echo "docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${TMPDIR}:/output --privileged -t --rm ${image} ${testing_container}" |
| 65 | +docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${TMPDIR}:/output --privileged -t --rm ${image} "${testing_container}" |
| 66 | +ls ${TMPDIR}; |
| 67 | +test "$?" -eq "0" && echo "PASS" || echo "FAIL" |
| 68 | + |
| 69 | +################################################################################ |
| 70 | +# Test 3. Build with Name |
| 71 | +################################################################################ |
| 72 | + |
| 73 | +echo "3. Testing docker2singularity build with custom name" |
| 74 | +echo "docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${TMPDIR}:/output --privileged -t --rm ${image} --name chimichanga.simg ${testing_container}" |
| 75 | +docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${TMPDIR}:/output --privileged -t --rm ${image} --name chimichanga.simg "${testing_container}" |
| 76 | +ls ${TMPDIR}; |
| 77 | +test "$?" -eq "0" && echo "PASS" || echo "FAIL" |
| 78 | + |
| 79 | +################################################################################ |
| 80 | +# Test 4. Testing that container runs! |
| 81 | +################################################################################ |
| 82 | + |
| 83 | +echo "4. Testing that container runs!" |
| 84 | +echo "singularity run --pwd /go/src/github.com/vsoch/salad $TMPDIR/chimichanga.simg fork" |
| 85 | +singularity run --pwd /go/src/github.com/vsoch/salad $TMPDIR/chimichanga.simg fork |
| 86 | +test "$?" -eq "0" && echo "PASS" || echo "FAIL" |
| 87 | + |
| 88 | +echo "Cleaning up..." |
| 89 | +rm -rf "${TMPOIR}" |
0 commit comments