I am looking for help/Suggestion about automating the docker-compose.yml file.
I have automated test scripts(testing xml suite) which verifies multiple micro API services, they are developed using Rest Assured, java and TestNG. Now these micro API services and DB are available on docker as image.
Currently I am executing this automation while running this automation in following way
Making the docker-compose up
Waiting for the services to get up
Updating the end points in my configuration(Automation suite) which we see in docker container
And finally running the automation suite
I want to do all the above 4 points in one go as following. However unable to find any docs or anything open maven lib for it.
Run the docker-compose in beforeSuite method. Should work on all operating system wherever the docker and docker-compose is installed eg. Windows, centOS , linux, ubuntu
Once the services are up in docker container , it should update the end points in configuration file
Docker-compose down in aftersuite method
How we can achieve this or any kind open source lib available?
I think fabric8 docker-maven-plugin suits your needs. You can run your it tests against containers you configure by docker-compose, dockerfile or plugin's configuration. I used the pluging in this dummy project. Have a look.
Related
I just created a sample Quarkus CLI app. When I run it in dev mode, pressing [enter] does not restart the application.
Steps to reproduce:
I am using the quarkus CLI, on macOS Big Sur, default Terminal app. I generate a default cli app with the following command:
quarkus create cli --group-id=test --artifact-id=test --maven --java --code
Then, once I am inside the test folder, I run:
quarkus dev
The example code runs and dev mode stays waiting for changes, but if I update the sample code and press [enter] on the terminal as described in the quarkus guide for CLI apps, the app is not rerun.
I also tried maven directly as suggested on the guide:
mvn compile quarkus:dev
But the result is the same.
The example generated is very simple, and uses Quarkus 2.0.1 with the picocli extension. Works fine when compiled and run standalone.
Does anyone know what am I missing?
Thanks for any suggestions.
I think what you are seeing is a bug in 2.0 cli where create cli does not create a cli but just the standard app. Thus it won't reload until you hit localhost:8080.
it will be fixed in next version. sorry for inconvenience.
In the mean time you can use https://quarkus.io/guides/command-mode-reference which explains the minimal code and dependencies needed for a Quarkus cli.
Does your project have any tests? The picocli project created by the cli doesn't by default (yet?).
https://github.com/quarkusio/quarkus/pull/18700 should fix your issue (behavior of dev mode for projects without tests).
For a new Spring project I'd like to setup a Docker container to build + run + debug my application.
At the moment I'm using this Dockerfile:
FROM maven:3.6.2-jdk-8-slim
COPY . /app/
WORKDIR /app/
RUN mvn clean package
FROM maven:3.6.2-jdk-8-slim
COPY target/app.jar app.jar
ENTRYPOINT ["java","-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-jar","/app.jar"]
EXPOSE 5005
In the first step the project is built. In the second step the application is run exposing a 5005 port for "remote" debugging.
Then from my IDE (IntelliJ IDEA) I'm configuring a remote debugging configuration to execute debug on the container.
As you may guess is a bit awkward to execute these steps for every little edit I'd like to debug in the project.
So, I'm wondering if there's a more practical approach using IntelliJ to automatically build and attach the debugger to my application just like when developing directly on my dev machine...
First of all, you can open a pom.xml right from IntelliJ and run the application without the need to run maven (IntelliJ has an excellent maven plugin).
Since you're running it as a java -jar you don't even need an ultimate version of IntelliJ.
Now this is how we develop usually, even before maven. You can run mvn clean package locally as well if you want to, say, check that the tests are run (again, you can also do that in Idea). And when you push your changes create a docker and deploy on server.
This is by far the best solution I can recommend. The way you've described in the question suites more to debugging the remote servers (read ready environments).
If you absolutely need this way, you still can use HotSwap feature of JVM for small changes (as longs as these changes are inside the method): While connected via Remote Debugger, right click and "Recompile" the class that has a change. It will be automatically loaded to remote JVM so that you don't actually need to trigger all this process.
You also don't have to run all the tests in maven (mvn clean package -Dmaven.tests.skip)
A couple of ideas that you can implement:
Use CI/CD to build your docker images
Instead of offloading this work to docker files, let your CI/CD pipeline to build your artifact and then pack it into a docker image ( you'll have more control over the process ). Finally, you can also deploy it to a targeted environment.
Use IntelliJ to run and debug your project on the DEV machine
You gain almost no benefit by running your project using Docker on your DEV machine, only a lot of hassle.
I am new to Docker and currently working on a project which uses docker for build and deployment. I have installed Docker for windows on my Windows 10 machine and currently running docker in windows environment.
I am using Jenkins for creating the docker image for a project which has Integration tests coded inside it.
I need to create new Job in Jenkins which will take docker image from previous job and run Integration tests on this image and not on the code base. I am not sure if we can do it for Windows. I have searched online but have not found any articles or tutorials which explain how to achieve this.
Can someone help me with this problem or guide me to a solution which i can refer.
Thanks
Vikeng
Your question is a few months old, but still :)
You can have a look at the Fabric8 Docker Maven Plugin https://dmp.fabric8.io/
It integrates very well with the Maven workflow: you describe how to build your image (with a DockerFile or in the pom directly), as well as how to run it (in a 'docker run' manner or with a docker-compose.yaml). Of course, Windows is supported, since it is your use case :)
Then, the phases of the plugin integrate well, the build of the image is made at the 'package' phase, and the containers are started at 'pre-integration' and stopped and removed at 'post-integration'.
One small thing to remember is if you have a multi-module project, the integration tests are run by module, so if you have several images that integrate together, make sure to define them in the same pom.
Hope this helps
friends. I try to understand how does selenium work. I written some tests with JUnit 4. These tests works fine when my app is running and I put as URL localhost:8077 where my app is started. All tests pass as I need. But now I want that my war build will depend by these tests. After these I want that the automated release (Jenkins) will also depend by selenium tests.
I don't understand some things:
Should the selenium test be included in my application or they should be assembled in a standalone application? (I read about Selenium Grid but I am not sure that I need it)?
I have one developer machine, one server with jenkins and the production server. What are the needed steps to implement Selenium test? What Url should be used in test? Is it needed to install Tomcat Server on the same server with Jenkins?
Can I invalidate the build and drop the release on Jenkins if selenium tests are not passed?
Should the selenium test be included in my application or they should be assembled in a standalone application? (I read about Selenium Grid but I am not sure that I need it)?
It depends on how you want to run your tests. Best practice is to call the test configuration inside your maven project and tests will run during your build job. You can also call your maven target after the build is completed.
Selenium Grid is useful but only if you have dedicated machines having proper setup to run those tests, else your tests may often fail. You should consider running your tests remotely on cloud using services like Saucelabs, etc.
I have one developer machine, one server with jenkins and the production server. What are the needed steps to implement Selenium test? What Url should be used in test? Is it needed to install Tomcat Server on the same server with Jenkins?
Selenium tests can be implemented with Maven on Jenkins following the step from here, here and here.
Dev or Test URLs should be used for running the test.
I think you would need Tomcat Server if you are hosting your application on the Jenkins machine or else it should not be needed.
Can I invalidate the build and drop the release on Jenkins if selenium tests are not passed?
When you include the test configuration in your project configurations, the build may fail during the build job if your test fails. You can set how you want to proceed with your build when you test fails like failing the build or pass the build with warning. You may want to get notifications for failed build also.
Ex. Jenkins marks good build as failure because of test failed
Jenkins plugins can be used based on the needs.
You may like to read more about How to do Integration tests here.
I'll do my best to answer your questions, and hopefully clear a few things up for you.
From my experience each test should be created as a new item and then configured to run after your app is deployed or periodically. No you dont need Selenium Grid. It is used for parallel execution of tests.
You'll need to configure your machines as nodes on jenkins and install the jenkins agent on the slave machines. Setting up selenium tests differs depending on how you have written the tests, for example i use maven as my build tool. So for each new test i only need to point towards svn and give the maven launch commands. The url is whatever url you use to access your app. There is a very good article on how to setup jenkins on their site, you can find it here
Yes.
I have an build file located on a remote system. I want to run it there itself.It would be good if I can invoke it using a java program from my local system only.I tried using google but no success.Is it possible at all?
(extending comments on jenkins into answer)
I suggest Jenkins with master slave configuration to fully automate your build process. It comes with hundreds of plugin (You have plugins for static code analsys, test, test report, publishing , deployment.., supports many VCS).
Jenkins exposes operations via web-gui. It also has command line tool to aid in automation . You can easily add multiple machines into build and extend your workflow..
If your slaves are on windows, only trouble you have is an FAQ: https://wiki.jenkins-ci.org/display/JENKINS/Windows+slaves+fail+to+start+via+DCOM