Add mimic support for docker api

Added mimic docker file and included support for running a
poppy/cassandra/mimic in containers for api testing. The fig_mimic
file will also run any local changes.

Change-Id: I6cd321229d9867d145b0347b59cbe9236cdea25c
This commit is contained in:
Chris Powell 2014-12-02 13:59:25 -05:00
parent 5b4361bc0b
commit 8321022664
10 changed files with 234 additions and 1 deletions

36
docker/api_ci/Dockerfile Normal file
View File

@ -0,0 +1,36 @@
## Poppy Dockerfile for CI
FROM ubuntu:14.04
MAINTAINER Chris Powell <chris.powell@rackspace.com>
RUN apt-get update && apt-get install -y \
curl \
python-dev \
git
# Get a working version of pip for ubuntu 14.04:
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=744145
RUN /usr/bin/curl -s https://bootstrap.pypa.io/get-pip.py | python
# Seed the initial requirements to make startups faster
ADD ./requirements /root/requirements
RUN pip install -r /root/requirements/requirements.txt
# Pip install uwsgi rather than use the system version
RUN pip install uwsgi
# Set up the configuration files
ADD ./docker/api_ci/poppy.conf /etc/poppy.conf
ADD ./docker/api_ci/logging.conf /etc/logging.conf
ADD ./docker/api_ci/uwsgi.ini /root/uwsgi.ini
# ADD start_poppy script
ADD ./docker/api_ci/start_poppy.sh /root/start_poppy.sh
# create uwsgi log directory
RUN mkdir -p /var/log/poppy && chmod -R +w /var/log/poppy
# create uwsgi pid directory
RUN mkdir -p /var/run/poppy && chmod -R +w /var/run/poppy
EXPOSE 8081

View File

@ -0,0 +1,49 @@
[loggers]
keys=root,server,combined
[formatters]
keys=normal,normal_with_name,debug
[handlers]
keys=production,file,devel
[logger_root]
level=NOTSET
handlers=devel
[logger_server]
level=DEBUG
handlers=devel
qualname=poppy-server
[logger_combined]
level=DEBUG
handlers=devel,file
qualname=poppy-combined
[handler_production]
class=handlers.SysLogHandler
level=ERROR
formatter=normal_with_name
args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
[handler_file]
class=FileHandler
level=DEBUG
formatter=normal_with_name
args=('poppy.log', 'w')
[handler_devel]
class=StreamHandler
level=NOTSET
formatter=debug
args=(sys.stdout,)
[formatter_normal]
format=%(asctime)s %(levelname)s %(message)s
[formatter_normal_with_name]
format=(%(name)s): %(asctime)s %(levelname)s %(message)s
[formatter_debug]
format=(%(name)s): %(asctime)s %(levelname)s %(module)s %(funcName)s %(message)s

55
docker/api_ci/poppy.conf Normal file
View File

@ -0,0 +1,55 @@
# By default, this should live in one of:
# ~/.poppy/poppy.conf
# /etc/poppy/poppy.conf
[DEFAULT]
# Show more verbose log output (sets INFO log level output)
verbose = True
# Show debugging output in logs (sets DEBUG log level output)
;debug = False
# Log to this file
log_file = poppy.log
;auth_strategy =
# ================= Syslog Options ============================
# Send logs to syslog (/dev/log) instead of to file specified
# by `log_file`
;use_syslog = False
# Facility to use. If unset defaults to LOG_USER.
;syslog_log_facility = LOG_LOCAL0
# ================= Driver Options ============================
[drivers]
# Transport driver module (e.g., falcon, pecan)
transport = pecan
# Manager driver module (e.g. default)
manager = default
# Storage driver module (e.g., mongodb, sqlite, cassandra)
storage = cassandra
# Provider modules list (a list of comma separated provider module list)
providers = fastly
# DNS driver module (e.g., default, designate, rackspace)
dns = rackspace
#[drivers:transport:pecan]
#bind = 0.0.0.0
#port = 8081
[drivers:storage:cassandra]
cluster = "cassandra"
keyspace = poppy
[drivers:provider:fastly]
apikey = "MYAPIKEY"
scheme = "http"
host = "mimic:8900/fastly"

4
docker/api_ci/start_poppy.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
/usr/local/bin/pip install -e /home/poppy/.
exec /usr/local/bin/uwsgi --ini /root/uwsgi.ini

15
docker/api_ci/uwsgi.ini Normal file
View File

@ -0,0 +1,15 @@
[uwsgi]
master = true
chdir = /home/poppy/
workers = 4
http-socket = 0.0.0.0:8081
logger = file:/var/log/poppy/poppy.log
pidfile = /var/run/poppy/poppy.pid
die-on-term = true
enable-threads = true
buffer-size = 32768
max-requests = 15000
no-orphans = true
vacuum = true
module = poppy.transport.app:app
py-auto-reload = 1

View File

@ -34,4 +34,4 @@ Access the running poppy api instance home document::
Next Steps
----------
If running locally with Cassandra, ensure the Cassandra Docker Container is running and linked.
If running locally with Cassandra, ensure the Cassandra Docker Container is running and linked.

View File

@ -49,3 +49,32 @@ Testing
Access the running poppy api instance home document::
$ curl <docker_ip>/v1.0/
Building and Running the Poppy API Server w/Mimic
-------------------------------------------------
From this folder, run:
$ ./dev_mimic up -d
This will bring up a poppy server with your local poppy repository mounted as a volume
and will run it with any local changes. Cassandra and Mimic will also be started and
wired together.
If you are running docker locally, you can then access the API at:
$ curl http://localhost/v1.0/
If local changes are made, simply restart the services to run them:
$ ./dev_mimic restart
You can run the API tests against the poppy container according to the
[API testing](https://github.com/stackforge/poppy/blob/master/tests/api/README.rst)
documentation.
Note that `dev_mimic` is a wrapper around [`fig`](http://www.fig.sh/cli.html) so
any sub-commands that work with the fig CLI will work with `dev_mimic` as well.
Note that `dev_mimic` does not run a repose container.

10
docker/fig/dev_mimic Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
THIS_DIR=$(dirname $0)
PROJECT_ROOT_DIR=$THIS_DIR/../..
# Copy Dockerfile from this folder to project root folder
cp -f $PROJECT_ROOT_DIR/docker/api_ci/Dockerfile $PROJECT_ROOT_DIR/Dockerfile
# Bring up development environment
FIG_FILE=fig_mimic.yml fig $@

15
docker/fig/fig_mimic.yml Normal file
View File

@ -0,0 +1,15 @@
cassandra:
build: ../cassandra/.
mimic:
build: ../mimic/.
poppy:
build: ../../.
ports:
- "80:8081"
volumes:
- ../../:/home/poppy
command:
- /root/start_poppy.sh
links:
- cassandra
- mimic

20
docker/mimic/Dockerfile Normal file
View File

@ -0,0 +1,20 @@
## Mimic
FROM ubuntu:14.04
MAINTAINER Chris Powell <chris.powell@rackspace.com>
RUN apt-get update && apt-get install -y \
curl \
python-dev \
git
# Get a working version of pip for ubuntu 14.04:
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=744145
RUN /usr/bin/curl -s https://bootstrap.pypa.io/get-pip.py | python
WORKDIR /home/source
RUN git clone https://github.com/malini-kamalambal/mimic .
RUN pip install -r requirements.txt
EXPOSE 8900
CMD ["twistd", "-n", "mimic"]