Skip to content

Commit d0d29ac

Browse files
committed
adding testing script for local testing
1 parent 8c9ff4d commit d0d29ac

File tree

3 files changed

+110
-10
lines changed

3 files changed

+110
-10
lines changed

.circleci/config.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ defaults: &defaults
2020
working_directory: /tmp/src
2121
environment:
2222
- CONTAINER_NAME: singularityware/docker2singularity
23-
- TESTING_CONTAINER: vanessa/salad
2423

2524
# Installation
2625

@@ -78,9 +77,7 @@ dockerbuild: &dockerbuild
7877
test: &test
7978
name: Test using docker2singularity
8079
command: |
81-
echo "Testing docker2singularity with ${TESTING_CONTAINER}"
82-
docker pull "${TESTING_CONTAINER}"
83-
echo "docker pull ${TESTING_CONTAINER}"
80+
echo "Testing docker2singularity entrypoint"
8481
DOCKER_TAG="v$(cat VERSION)"
8582
echo "1. Testing run without arguments..."
8683
echo "docker run ${CONTAINER_NAME}:${DOCKER_TAG}"

README.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ Intermediate versions built on [Docker Hub](https://hub.docker.com/r/singularity
6565

6666
## Examples
6767

68-
## Build a Squashfs Image
68+
### Build a Squashfs Image
69+
6970
Squashfs is the recommended image type, it is compressed and less prone to degradation over time. You don't need to specify anything special to create it:
7071

7172
This is a path on my host, the image will be written here
@@ -136,7 +137,8 @@ sudo singularity build --sandbox sandbox/ production.simg
136137
sudo singularity build --writable ext3.img production.simg
137138
```
138139

139-
## Custom Naming
140+
### Custom Naming
141+
140142
Added for version 2.5.1, you can specify the name of your container with the `-n/--name` argument, as follows:
141143

142144
```bash
@@ -153,7 +155,7 @@ meatballs.simg
153155
```
154156

155157

156-
## Inspect Your Image
158+
### Inspect Your Image
157159
New with `docker2singularity` 2.4, the labels for the container are available with `inspect`:
158160

159161
```bash
@@ -186,7 +188,7 @@ singularity inspect --json -e -r ubuntu_14.04-2017-09-13-3e51deeadc7b.simg
186188

187189
```
188190

189-
## Build a Sandbox Image
191+
### Build a Sandbox Image
190192
A sandbox image is a folder that is ideal for development. You can view it on your desktop, cd inside and browse, and it works like a Singularity image. To create a sandbox, specify the `-f` flag:
191193

192194
```bash
@@ -203,7 +205,7 @@ Importantly, you can use `--writable`, and if needed, you can convert a sandbox
203205
sudo singularity build sandbox/ production.simg
204206
```
205207

206-
## Build a Legacy (ext3) Image
208+
### Build a Legacy (ext3) Image
207209
You can build a legacy ext3 image (with `--writable`) with the `-w` flag. This is an older image format that is more prone to degradation over time, and (building) may not be supported for future versions of the software.
208210

209211
```bash
@@ -221,12 +223,13 @@ sudo singularity build ext3.img production.simg
221223
```
222224

223225
### Contributed Examples
226+
224227
The following are a list of brief examples and tutorials generated by the Singularity community for using **docker2singularity**. If you have an example of your own, please [let us know](https://www.github.com/singularityware/docker2singularity/issues)!
225228

226229
- [docker2singularity-demo](https://github.com/stevekm/docker2singularity-demo): an example of using docker2singularity on MacOS and using Vagrant to test the output Singularity image, complete with notes and a nice Makefile.
227230

228231

229-
## Tips for making Docker images compatible with Singularity
232+
### Tips for making Docker images compatible with Singularity
230233

231234
- Define all environmental variables using the `ENV` instruction set. Do not rely on `.bashrc`, `.profile`, etc.
232235
- Define an `ENTRYPOINT` instruction set pointing to the command line interface to your pipeline
@@ -237,6 +240,17 @@ The following are a list of brief examples and tutorials generated by the Singul
237240
- Don’t rely on having elevated user permissions
238241
- Don’t use the USER instruction set
239242

243+
## Testing
244+
245+
We have a [Circle CI](.circleci/config.yml) builder that tests generation of the final
246+
image, and basic running to ensure the entrypoint is functioning. Since we cannot run
247+
the priviledged Docker daemon on Circle, a [test.sh](test.sh) script is provided for local testing.
248+
249+
```bash
250+
chmod u+x
251+
/bin/bash test.sh
252+
```
253+
240254
## FAQ
241255
Here are some frequently asked questions if you run into trouble!
242256

test.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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

Comments
 (0)