I have a microservice which I am testing (Java maven project with JUnit). This has a dependency on another microservice. I am writing an e-2-e system test and want to spin up the external service from a Docker image for a full automated test.
My question is what is the best way to have a maven project spin up a docker image instance which can then be used in an automated test suite?
At the moment I a using maven-exec plugin to call a shell script during the integration-phase which starts the docker container. It may not be the most elegant solution, and I also have no way of knowing when the container is ready.
Any thoughts or help would be appreciated.
Please note: This is for full system testing against real services so I don't want to mock or stub the external service.
Take a look at Spotify maven plugin for docker or Fabric8 maven pluign
Fabric8 has goals as build, run and stop. This may not help you knowing if a container is ready for testing. (Could you have a sort of ping service in your test code that suspended tests until you got a OK 200?)
Related
I have Spring Boot Integration tests (IT) that connect to a real DB or to a real 3rd parties. I use them during development but I find them quite usefull to check the real behaviour of the application therefore I would like to run them during CI process. The goal is to run them on the environment on which the application is deployed and not on CI machine where Jenkins is running. Is there a way how to achieve this? I know I can use for example SOAP UI maven plugin and execute tests against REST endpoints, but I would prefer to use Spring Boot IT tests already written.
Many thanks
Running tests against your production database is a really bad idea. Please please please reconsider. It is better to have your test database updated to be more like production than to run your tests on production data.
That being said, you can point your database configuration to your production machine via the application.properties file (mongo example):
spring.data.mongodb.uri=mongodb://user:pass#production.myhost.com:27017/mydb
I'm guessing that it defaults to localhost:27017. In your test/resources folder you can setup a differing application.properties. Check out the spring-boot externalized properties details.
I've been uploading java app to AWS by extracting a war file from eclipse,
But now I've moved my code to github and,
I want to pull it from github onto my AWS server without generating a war file.
I've tried pulling it but it gives me an error. The requested resource is not available.
You can use Jenkins or other CI tool. Jenkins will fetch code from GitHub, compile it and push it to AWS. You only need to specify deploy script.
The CI enthusiast within me suggests to automate the entire thing, going as far as creating an AWS CodePipeline with 3 steps:
(I have three of these pipelines active and am very happy I created them.)
Listen to GitHub repository for changes.
Pull latest repo changes and push code to a Jenkins instance
To save money on the Jenkins instance running 24/7 you could even create AWS Lambda functions to automate the starting up and shutting down of the Jenkins server
Output Jenkins artifact (your war file) to AWS Elastic Beanstalk.
The AWS Documentation as with most services is pretty elaborate on this subject as is Jenkins'. You shouldn't have too much trouble setting this up and it'll save you a lot of time as the WAR file transfer between each step happens on the internal magically-high speed network of AWS.
It will cost some time to set up, especially if you're not that familiar with CI and this process but so very worth it to be familiar with these type of stacks.
We are working on a project and Im involved in continuous integration testing.
I need to
deploy the new project code on a staging server, not using Jenkins, but ftp;
after the deploy an email is sent to indicate successfull deploy and we need it to start my integration tests;
integration tests, if successfull, will start a deploy on integration server.
I am going to write a java program that will login to Jenkins and execute the integration tests.
Question is: how can the email message activate the java program?
EDIT: Normally, jenkins offers a feature that starts a job after getting an email, but we are having a security problem with that
Make a program or script which will peridically poll a mail server box and upon getting an appropirate email will run another java program.
Please read Jenkins documentation thoroughly. If you are using a version control system, Jenkins can automatically pull the code and run test cases on it. You can notify Jenkins using various methods... including webhooks.
Do go through various plugins for Jenkins.
Update:
I have not used this myself. But looks like this is what you want: Mail Commander Plugin
And the command you send can be something like this:
curl --data '' http://<server>:<port>/job/<projectname>/build
This might be confusing, so bear with me.
I am not interested in running maven behind a proxy. I understand how to configure maven, eclipse or the JVM itself to get web access via proxies.
However, in my project, I have a component that will retrieve the contents of a given URL and analyze it. It uses Apache Http Components underneath, coated with a little predefined configuration and error handling (really just a wrapper to hide boiler plate code). Since apache-httpcomponents itself can make use of proxies, my component will accept a proxy configuration that can be passed to apache-httpcomponents.
Does anyone know of any proxy plugin that allows this type of integration test, like "maven-simpleproxy-plugin" or anything like that?
I want to test the ability of my component to run well behind a proxy. I imagine that I would need to run some sort of plugin which will start up a dummy proxy server along with maven-embedded-glassfish-plugin. I can host a dummy content inside glassfish and make my component try to access it via this "maven-simpleproxy-plugin" instance... thus allowing me to test the component's ability to handle its proxy configuration correctly.
Does anything like that exist?
I would use maven exec plugin to start up the proxy server you want to test. Then write a script which is called at the post-integration-test phase that shuts the proxy server down. Then you are testing through the same proxy server type as your production environment.
I think you are looking for MockServer. It looks pretty active on github with 1.000+ stars and 25+ contributors and can do the following, as explained on their website:
MockServer Proxy can:
proxy all requests using any of the following proxying methods:
Port Forwarding
Web Proxying (i.e. HTTP proxy)
HTTPS Tunneling Proxying (using HTTP CONNECT)
SOCKS Proxying (i.e. dynamic port forwarding)
verify requests have been sent (i.e. in a test assertion)
record requests and responses to analyse how a system behaves
Regarding the different deployment/usage options you've been asking for, let me again copy from their website:
The MockServer and MockServer Proxy can be run:
via a Maven Plugin as part of a Maven build cycle
programmatically via a Java API in an #Before or #After method
using a JUnit #Rule via a #Rule annotated field in a JUnit test
from the command line as a stand-alone process in a test environment
as a deployable WAR to an existing application server
as a Grunt plugin as part of a Grunt build cycle
as a Node.js (npm) module from any Node.js code
as a Docker container in any Docker enabled environment
ps: I'm not affiliated in any way with the project
Can I use Jenkins to test to see if a VM(server) is up and running? We have alot of VMs(servers) with JBoss, LDAP, MySQL etc on them and I would like to know if I can somehow have Jenkins ping a server to see if the SA shut it down or something..
I was thinking of using a selenium test. I was going to have a Maven project with a selenium java test in it to check of the server is up. but how can I tell Jenkins to run the test every hour and do you think this is the right way to go?
I would say the simplest possible solution is to use Site Monitor plug-in.
It is simple, reliable and it also allows to reuse build status notifications, provided by your jenkins instance. The only limitation is you should have some http server up and running, but I bet you have at least default page available.
Configuration is simple:
Jenkins does not have a plugin for managing (or monitoring) VMs, AFAIK, but you can use Perl or PowerShell for that - both have a good set of tools for that.
Let that tool return error when the server is not available, and you can even use the API to boot a hosted machine.
Cheers