spotify / docker-maven-plugin

INACTIVE: A maven plugin for Docker
Apache License 2.0
2.66k stars 575 forks source link

Example of use with Contract Tests #312

Closed swebb99uk closed 7 years ago

swebb99uk commented 7 years ago

Update ReadMe

The pluggin is great however it would be really useful if the readme included some details about how this might be used in conjunction with contract testing.

For instance if you write a service that makes use of JMS a good way of testing is to have a docker image containing ActiveMQ and then test the code using something like BDD (JBehave) against the ActiveMQ service in the docker container. I have some this in the past by having the service I write deployed in to the same Docker image as the services it requires but this isn't actually required.

It is unclear to me how I would use Maven and this plugin to run tests on my service and enable contract tests, so basically running a docker up with the required services and test against it. Oh and maybe even define what goes in the contract test related docker in the maven plugin !

kvfedorov commented 7 years ago

There is plenty on documentation/tutorials out there about integration/functional testing with maven and docker. I do not think there is a need to repeat it here.

swebb99uk commented 7 years ago

Yes I agree about the documentation being available. I'm already using contract testing with several services where I have a different set of config to create a contract specific docker image that allows the service to run with ActiveMQ, Postgres and WireMock. My issue is that I am doing this by using shell scripting to either build the deployed docker or the Contract Docker. What I would really like is to get rid of all scripting and use something like this plugin where I could tie in the testing hooks in Maven in to the plugin and basically the contract testing side of thing. I'm not sure if this is possible using the plugin.

So basically when I run maven test it not only runs the unit tests but if they pass it then goes on to build a contract docker and runs the service (local or in docker) against the contract docker services.

Maybe I'm asking for too much but it would be really nice to have.

kvfedorov commented 7 years ago

You are asking for another plugin. This plugin does packaging (during maven package phase) and no kind of testing must be done during that phase. What you want is test phase plugin which would support docker integration. It could be bundled with this plugin, but still be different thing.

mattnworb commented 7 years ago

You might find https://github.com/spotify/helios/blob/master/docs/integration_tests_with_helios_solo.md helpful.

I would be happy to review and merge a PR that added links to guides or tutorials on what you suggest, but considering that we (the maintainers) don't do the sort of maven-driven stopping and starting of containers I would not know myself what to be added here.

swebb99uk commented 7 years ago

Thanks for the responses, you may be correct that another plugin is required.

Usual patterns of testing in a commercial environment nowdays for Java & Microservices is for contract testing to be used. In most cases a docker image is created which contains services that the service being developed would depend on, so thing such as ActiveMQ, GreenMail and WireMock (to mock out inhouse service rest requests and responses). The service itself could then be hosted in Docker or standalone or within the IDE of choice. You then use something like JBehave to test BDD related stories based on the requirements and what the project manager and or product owner has specified. So all external dependancies to the service are either mocked out or supplied within a docker image (ideally). The service is tested standalone and it is repeatable.

So with this in mind being able to use Maven within the IDE to both package service being tested and the services being used to contract test it would be really useful.