Skip to content

Commit

Permalink
other ways to run docker (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
mccalluc committed Mar 22, 2018
1 parent 405afd3 commit e4f7e48
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
2 changes: 2 additions & 0 deletions context/app_runner_refinery.py
Expand Up @@ -31,6 +31,7 @@ def __init__(self, refinery_args):

input_json = self._get_input_json(refinery_args.input)
if input_json:
print('input_json:' + input_json)
input = json.loads(input_json)
parameters = {
p['name']: p['value'] for p in input['parameters']
Expand Down Expand Up @@ -73,6 +74,7 @@ def _get_input_json(self, possible_input_file):

url = os.environ.get('INPUT_JSON_URL')
if url:
print('url: ' + url)
return requests.get(url).text

return None
Expand Down
50 changes: 33 additions & 17 deletions test.sh
Expand Up @@ -59,15 +59,17 @@ Update README.md:
end usage


start refinery_envvar
# Reading the JSON is covered by the Docker test below.
FIXTURES='https://raw.githubusercontent.com/refinery-platform/heatmap-scatter-dash/v0.1.3/fixtures/good/data'
FILE_URLS="$FIXTURES/counts-copy.csv.gz" \
start refinery_data_envvar
# Since the input.json specifies a data directory which might not exist,
# and we want to minimize changes to the host running the test,
# we will check the other modes with the docker tests.
FIXTURES_URL_BASE='https://raw.githubusercontent.com/refinery-platform/heatmap-scatter-dash/v0.1.3/fixtures'
FILE_URLS="$FIXTURES_URL_BASE/good/data/counts-copy.csv.gz" \
DATA_DIR='/tmp' \
python context/app_runner_refinery.py --input /no/such/file --port $PORT &
retry
kill `jobs -p`
end refinery_envvar
end refinery_data_envvar


start cypress
Expand Down Expand Up @@ -103,7 +105,7 @@ $OPT_SUDO docker build --cache-from $REPO --tag $IMAGE context
end docker_build


start docker_json
start docker_json_file
CONTAINER_NAME=$IMAGE-container
# Preferred syntax, Docker version >= 17.06
# --mount type=bind,src=$(pwd)/fixtures/good/input.json,dst=/data/input.json \
Expand All @@ -112,24 +114,38 @@ $OPT_SUDO docker run --name $CONTAINER_NAME --detach --publish $PORT:80 \
--volume $(pwd)/fixtures/good/input.json:/data/input.json \
--volume /refinery-data/ \
$IMAGE
retry
docker stop $CONTAINER_NAME | xargs docker rm
end docker_json


start docker_json_envvar
INPUT_JSON=`cat $(pwd)/fixtures/good/input.json`
$OPT_SUDO docker run --name $CONTAINER_NAME --detach --publish $PORT:80 \
--volume /refinery-data/ \
-e "INPUT_JSON=$INPUT_JSON" \
$IMAGE
retry
echo "docker is responsive with input.json"
docker stop $CONTAINER_NAME | xargs docker rm
end docker_json_envvar

docker stop $CONTAINER_NAME
docker rm $CONTAINER_NAME
echo "container cleaned up"
end docker_json

start docker_json_url_envvar
INPUT_JSON_URL="$FIXTURES_URL_BASE/good/input.json"
$OPT_SUDO docker run --name $CONTAINER_NAME --detach --publish $PORT:80 \
--volume /refinery-data/ \
-e "INPUT_JSON_URL=$INPUT_JSON_URL" \
$IMAGE
retry
docker stop $CONTAINER_NAME | xargs docker rm
end docker_json_url_envvar


start docker_envvars
FILE_URLS="$FIXTURES_URL_BASE/good/data/counts.csv"
$OPT_SUDO docker run --name $CONTAINER_NAME --detach --publish $PORT:80 \
-e "FILE_URLS=$FIXTURES/counts.csv" \
-e "FILE_URLS=$FILE_URLS" \
$IMAGE
retry
echo "docker is responsive with envvars"

docker stop $CONTAINER_NAME
docker rm $CONTAINER_NAME
echo "container cleaned up"
docker stop $CONTAINER_NAME | xargs docker rm
end docker_envvars

0 comments on commit e4f7e48

Please sign in to comment.