-
Notifications
You must be signed in to change notification settings - Fork 36
Adding my attempt at running tests in Docker #547
Conversation
|
As it stands now, the tests don't pass for a variety of reasons:
I'm leaving it in this state because I need to start working on dayjob stuff 😄. I'll come back to it later. |
|
Thanks Ian! I got some excellent Docker understanding help from Jamie yesterday that's making this easier to understand. |
jalessio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added my two cents based on having setup something similar in a few projects before.
Dockerfile.test
Outdated
|
|
||
| RUN apt-get update \ | ||
| && apt-get upgrade -y \ | ||
| && apt-get install -y libgdal1-dev gdal-bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommendations based on Docker's Best practices for writing Dockerfiles
- Sort multi-line arguments
- apt-get
- You should avoid
RUN apt-get upgradeordist-upgrade, as many of the "essential" packages from the base images won’t upgrade inside an unprivileged container. - cleaning up the apt cache and removing
/var/lib/apt/listshelps keep the image size down
- You should avoid
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
gdal-bin \
libgdal1-dev && \
rm -rf /var/lib/apt/lists/*
Also, I'm not sure I would apt-get upgrade in the Dockerfile -- I'd let the upstream python image take care of that, so I might change this to:
RUN apt-get update \
&& apt-get install -y \
gdal-bin \
libgdal1-dev && \
rm -rf /var/lib/apt/lists/*
and if we really want to get picky, I find this style to be easier to read (possibly just personal preference?):
RUN apt-get update && \
apt-get install -y \
gdal-bin \
libgdal1-dev && \
rm -rf /var/lib/apt/lists/*
Dockerfile.test
Outdated
| RUN gdalinfo --version | ||
|
|
||
| RUN pip install cairocffi gdal==1.10.0 \ | ||
| && pip install -U . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here on Dockerfile style guide. Maybe something like this:
RUN pip install \
cairocffi \
gdal==1.10.0 && \
pip install -U .
| @@ -0,0 +1,12 @@ | |||
| machine-test: | |||
| build: . | |||
| dockerfile: Dockerfile.test | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My hunch is that you could rename this file to docker-compose.yml, remove the Dockerfile line for the compose yml file, and not make the default CMD in the Dockerfile run the tests.
Instead, have the docker-compose.yml file look like this:
machine:
build: .
environment:
- DATABASE_URL=postgresql://openaddr:openaddr@postgres/openaddr
links:
- postgres
postgres:
image: mdillon/postgis
environment:
- POSTGRES_USER=openaddr
- POSTGRES_PASSWORD=openaddr
and then run tests like this:
docker-compose run --rm machine python setup.py test
or maybe just
docker-compose run --rm machine ./setup.py test
Once you're there you could add a Makefile that turns that into a call to make test :)
|
The latest commit is based on @jalessio's feedback (but of course I forgot to alphabetize, woops). Using Traceback (most recent call last):
File "/machine/openaddr/tests/conform.py", line 634, in test_lake_man_gdb
rc, dest_path = self._run_conform_on_source('lake-man-gdb', 'gdb')
File "/machine/openaddr/tests/conform.py", line 597, in _run_conform_on_source
rc = conform_cli(source_definition, source_path, dest_path)
File "/machine/openaddr/conform.py", line 1187, in conform_cli
extract_to_source_csv(source_definition, source_path, extract_path)
File "/machine/openaddr/conform.py", line 1134, in extract_to_source_csv
ogr_source_to_csv(source_definition, ogr_source_path, extract_path)
File "/machine/openaddr/conform.py", line 605, in ogr_source_to_csv
in_layer = in_datasource.GetLayerByIndex(layer_id)
AttributeError: 'NoneType' object has no attribute 'GetLayerByIndex'... I bet I'm missing something in OGR. Also note that I removed the Note 3: I started |
|
You're missing GDAL 2.1.0 and GDB support. I'm working on a Dockerfile for this myself as part of the work I'm doing this week and next. Here's a working version I have going right now, a straightforward copy of the work that our Chef recipes are doing for us: I'm reading back through @jalessio’s comments to figure out how to think about |
|
I have committed the file above to a new branch, here: https://github.com/openaddresses/machine/blob/migurski/docker-docker-docker/Dockerfile I’ll write more about what this is later on, but the short version is that I’m working on #559 and I view the Vagrant approach as a potential stepping stone on the way to a Docker setup. Right now, I’m doing some basic sanity checks on how large the built image is, how long it takes to build from scratch, and whether it can be used to run real OpenAddresses tasks. Answers so far:
|
|
If you move |
|
I tried that first, but |
|
I’ve incorporated this work into #587, and merged changes to that branch. Closing this now to get us closer to a resolution on Docker things! |
While trying to get tests to run for #523, I started putting together a Docker setup for the tests.
The
Dockerfile.testfile describes how Docker should build the image that will run the tests. Thedocker-compose.test.ymlfile describes how the test image should connect to a container running thepostgisimage.Once Docker is installed, running the tests should be as simple as: