10BC0 feat(Makefile): containerize dev workflow by Joshua-Anderson · Pull Request #1049 · deis/controller · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

feat(Makefile): containerize dev workflow#1049

Closed
Joshua-Anderson wants to merge 1 commit intodeis:masterfrom
Joshua-Anderson:docker-dev
Closed

feat(Makefile): containerize dev workflow#1049
Joshua-Anderson wants to merge 1 commit intodeis:masterfrom
Joshua-Anderson:docker-dev

Conversation

@Joshua-Anderson
Copy link
Contributor
@Joshua-Anderson Joshua-Anderson commented Sep 9, 2016

Fixes #18

Right now you have to manually start and stop postgres, but hopefully that can be improved so we don't have to in the future.

Does anyone know how to always run the target make stop-postgres after make test-unit?

@Joshua-Anderson Joshua-Anderson added this to the v2.6 milestone Sep 9, 2016
@Joshua-Anderson Joshua-Anderson self-assigned this Sep 9, 2016
@deis-bot
Copy link
deis-bot commented Sep 9, 2016

@mboersma, @bacongobbler and @sgoings are potential reviewers of this pull request based on my analysis of git blame information. Thanks @Joshua-Anderson!

@vdice
Copy link
Member
vdice commented Sep 9, 2016

Nice! Very excited for this.

Does anyone know how to always run the target make stop-postgres after make test-unit?

@Joshua-Anderson first thought would be to have a separate target for the actual unit test command(s), say, make do-test-unit and then the actual test-unit target would just be a 'meta' target and look something like:

test-unit: docker-build-dev start-postgres do-test-unit stop-postgres

@helgi
Copy link
Contributor
helgi commented Sep 9, 2016

Why is the Dockerfile duplicated from rootfs ?

@Joshua-Anderson
Copy link
Contributor Author

@helgi The main difference in the two is that this one has dev-dependencies installed and doesn't expose any ports. Any ideas on how to combine the two?

@Joshua-Anderson
Copy link
Contributor Author

first thought would be to have a separate target for the actual unit test command(s), say, make do-test-unit and then the actual test-unit target would just be a 'meta'

@vdice but if the unit tests fail, postgres wouldn't be stopped, would it?

@helgi
Copy link
Contributor
helgi commented Sep 9, 2016

@helgi The main difference in the two is that this one has dev-dependencies installed and doesn't expose any ports. Any ideas on how to combine the two?

No idea tbh - Having 2 Dockerfiles is going to be confusing as they look near identical. I'm not sure I'm seeing the benefit of containerizing the dev env here, not off the bat. It solves the "I'm running one of the make targets" problem but while developing on the Controller at least I commonly run python rootfs/manage.py test etc etc to have granularity on a particular test module or test method

@Joshua-Anderson
Copy link
Contributor Author

This solves the problem of needing to have the right python version installed, all the dependencies, and python configured to talk to a postgres database you need to install and run. This sort of stuff can be a big hurdle for community contributors and people like me who don't want to spend 30 minutes getting my computer properly configured. Now a developer can just run make test-unit and if they have docker installed they can run the unit tests.

You're right that it doesn't solve the problem of running a particular test target. However, you can copy-paste the docker command from the makefile and edit it, or run the tests locally, since most core developers like you already have the environment setup.

@helgi
Copy link
Contributor
helgi commented Sep 9, 2016

Again, not a fan of this. However if this is to be done I want a clearer distinction between the Dockerfiles. Would be ideal if it was possible to combine together with the current sha image at least and then at in the dev tooling only. Not sure how you'd do that without magic? sed replace on the base image at the top? Not sure

@bacongobbler
Copy link
Member
bacongobbler commented Sep 9, 2016

I'm not a fan of two Dockerfiles either. We should repurpose the Dockerfile in rootfs.

If we are forced to go the two Dockerfile path, then perhaps a Dockerfile.dev file in rootfs that has a FROM clause, building on top of quay.io/deis/controller:canary would be ideal. That way we don't have to maintain two Dockerfiles that are exact copies of eachother.

@vdice
Copy link
Member
vdice commented Sep 9, 2016

but if the unit tests fail, postgres wouldn't be stopped, would it?

@Joshua-Anderson good point; although it would involve a bit of duplicated deispg container teardown logic, extending the suggestion above, do-test-unit might look like:

start-postgres:
  docker run ...
stop-postgres:
  docker stop deispg && docker rm deispg
do-test-unit: start-postgres
  docker run <unit test command> || (docker stop deispg && docker rm deispg)
test-unit: do-test-unit stop-postgres

@Joshua-Anderson
Copy link
Contributor Author

I updated the test-unit targets to automatically start/stop the database. I moved the main rootfs Dockerfile to be the root dockerfile and renamed the development dockerfile to Dockerfile.test, which @helgi suggested to avert confusion.

@helgi and I talked and we're thinking the longer term solution is to update docker-python-dev and use that as a base for the test image.

@Joshua-Anderson
Copy link
Contributor Author

I tested test-unit-quick with and without the container and the both were within 5 secs of each other in a 3:30 test run.

Makefile Outdated
&& coverage run manage.py test --settings=api.settings.testing --noinput registry api scheduler.tests \
&& coverage report -m
test-unit: start-postgres do-test-unit stop-postgres
do-test-unit: docker-build-dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd propose we remove the docker-build-dev dependency here (as, if it fails, the deispg stop logic won't be executed) and place it into the above test-unit target, to look like:

test-unit: docker-build-dev start-postgres do-test-unit stop-postgres
do-test-unit: 
...

(and same for the -quick variants below)

@Joshua-Anderson Joshua-Anderson force-pushed the docker-dev branch 2 times, most recently from b478153 to cd71204 Compare September 9, 2016 19:43
@Joshua-Anderson
Copy link
Contributor Author

@vdice Fixed!

@vdice
Copy link
Member
vdice commented Sep 9, 2016

I'm not a regular controller contributor or maintainer, but as regards the Makefile/Dockerfile code here, LGTM, on top of the huge ease-of-use gains both for devs/contributors and ci. Tested manually via running make test-unit.

@vdice
Copy link
Member
vdice commented Sep 9, 2016

One more thought @Joshua-Anderson -- should we perhaps update the .travis.yml accordingly to now run the containerized test target(s) and get its blessing? (We currently do not run unit tests in the Jenkins build jobs, though with this effort we are very close if not ready to revisit)

ln -s /usr/bin/python3 /usr/bin/python && \
curl -sSL https://bootstrap.pypa.io/get-pip.py | python - pip==8.1.2 && \
mkdir -p /configs && chown -R deis:deis /configs && \
apt-get clean && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to cleanup 2x

Copy link
Contributor Author
@Joshua-Anderson Joshua-Anderson Sep 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because you have to cleanup in the same layer you add the files. Deleting files in a different layer would make the image larger.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough

@Joshua-Anderson Joshua-Anderson force-pushed the docker-dev branch 5 times, most recently from 2c9f0cc to 5dbdfeb Compare September 9, 2016 23:30
@Joshua-Anderson Joshua-Anderson force-pushed the docker-dev branch 3 times, most recently from ef36d76 to d74c4c8 Compare September 10, 2016 00:00
@Joshua-Anderson
Copy link
Contributor Author

I got this almost all working, but it's having codecov issues. If anyone is interested in going the last mile 😄 all deis maintainers have permission to push to this PR branch (thanks to a new GH feature), so you can update it.

@helgi
Copy link
Contributor
helgi commented Sep 14, 2016

@Joshua-Anderson what's wrong with the codecov? I see it got posted in the travis build but also didn't see it post to GH.

@Joshua-Anderson
Copy link
Contributor Author

@helgi even though I specifically selected the file no test coverage reports were found.

@helgi
Copy link
Contributor
helgi commented Sep 14, 2016

@Joshua-Anderson curious... the CLI system is having problems talking to codecov so that was my first instinct (that it was identical problems)

@helgi
Copy link
Contributor
helgi commented Sep 16, 2016

Leaving this here http://docs.codecov.io/docs/testing-with-docker if anyone wants to take a crack at this

@bacongobbler
Copy link
Member

Shall we punt this to another release or is someone planning on picking this back up this week?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

0