Skip to content
Snippets Groups Projects
Commit de4eb612 authored by Andrew Rabert's avatar Andrew Rabert
Browse files

Let Docker decide container ports

parent 7ca11d77
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -11,6 +11,9 @@ python:
before_install:
- docker run -d --name=dynalite -p 8000:8000 rajatvig/dynalite-alpine:latest
- docker run -d --name=s3 -p 4567:4567 verespej/fake-s3:latest
env:
DYNAMODB_ENDPOINT: http://localhost:8000
S3_ENDPOINT: http://localhost:4567
install:
- pip install -r requires/testing.txt
script: nosetests
Loading
Loading
#!/bin/sh
#
# NAME
# bootstrap -- initialize/update docker environment
#
# SYNOPSIS
# bootstrap
# bootstrap shellinit
#
# DESCRIPTION
# Execute this script without parameters to build the local docker
# environment. Once bootstrapped, dependent services are running
# via docker-compose and the environment variables are written to
# *build/test-environment* for future use.
#
# Running this script with the _shellinit_ command line parameter
# causes it to simply interrogate the running docker environment,
# update *build/test-environment*, and print the environment to
# the standard output stream in a shell executable manner. This
# makes the following pattern for setting environment variables
# in the current shell work.
#
# prompt% $(./bootstrap shellinit)
#
# vim: set ts=2 sts=2 sw=2 et:
if test -e /var/run/docker.sock
then
DOCKER_IP=127.0.0.1
else
echo "Failed to initialize docker environment"
exit 2
fi
get_exposed_port() {
docker-compose port $1 $2 | cut -d: -f2
}
build_env_file() {
cat > $1<<EOF
export DYNAMODB_ENDPOINT=http://${DOCKER_IP}:$(get_exposed_port dynalite 8000)
export S3_ENDPOINT=http://${DOCKER_IP}:$(get_exposed_port s3 4567)
EOF
}
set -e
mkdir -p build
if test "$1" = 'shellinit'
then
# just build the environment file from docker containers
build_env_file build/test-environment
else
docker-compose down --volumes --remove-orphans
docker-compose up -d
build_env_file build/test-environment
fi
cat build/test-environment
dynalite:
image: rajatvig/dynalite-alpine:latest
ports:
- 8000:8000
- 8000
 
s3:
image: verespej/fake-s3:latest
ports:
- 4567:4567
- 4567
Loading
Loading
@@ -24,6 +24,9 @@ CREATE_BUCKET_BODY = """\
</CreateBucketConfiguration>
"""
 
DYNAMODB_ENDPOINT = os.environ['DYNAMODB_ENDPOINT']
S3_ENDPOINT = os.environ['S3_ENDPOINT']
 
class DynamoDBTestCase(testing.AsyncTestCase):
 
Loading
Loading
@@ -84,7 +87,7 @@ class DynamoDBTestCase(testing.AsyncTestCase):
os.environ['AWS_SECRET_ACCESS_KEY'] = str(uuid.uuid4())
os.environ['AWS_DEFAULT_REGION'] = 'local'
self.client = tornado_aws.AsyncAWSClient(
'dynamodb', endpoint='http://localhost:8000')
'dynamodb', endpoint=DYNAMODB_ENDPOINT)
 
@testing.gen_test
def test_create_table(self):
Loading
Loading
@@ -111,7 +114,7 @@ class UseCurlDynamoDBTestCase(DynamoDBTestCase):
os.environ['AWS_SECRET_ACCESS_KEY'] = str(uuid.uuid4())
os.environ['AWS_DEFAULT_REGION'] = 'local'
self.client = tornado_aws.AsyncAWSClient(
'dynamodb', endpoint='http://localhost:8000', use_curl=True)
'dynamodb', endpoint=DYNAMODB_ENDPOINT, use_curl=True)
 
@unittest.skipIf(curl_httpclient is None, 'pycurl not installed')
def test_create_table(self):
Loading
Loading
@@ -141,7 +144,7 @@ class S3TestCase(testing.AsyncTestCase):
os.environ['AWS_SECRET_ACCESS_KEY'] = str(uuid.uuid4())
os.environ['AWS_DEFAULT_REGION'] = 'local'
self.client = tornado_aws.AsyncAWSClient(
's3', endpoint='http://localhost:4567')
's3', endpoint=S3_ENDPOINT)
self.bucket = uuid.uuid4().hex
self.headers = {'Host': '{}.s3.amazonaws.com'.format(self.bucket)}
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment