we would like to adapt our Jenkins CI roundtrip as it takes to long (late feedback).
The current flow looks like described below:
OSGi server bundles are checked out and build with ant.
the OSGi bundles are packaged to be used on linux distros.
a server is set up to install the above packages and to run HTTP interface tests (integration tests) against it.
We would like to get rid of creating the linux packages and to install a server with these packages as this consumes most of the time.
Instead we would like to execute the existing tests against a headless eclipse which is running the server (based on compiled jars or imported projects if possible) managed by Jenkins CI.
Now some questions:
Is it possible to run a headless eclipse within Jenkins (I think so as it is just executing a java application)?
Is it possible (and does it makes sense) to have an eclipse instance permanently running and to get used from more than one job? So we have to only update the jars/imported projects that have been changed ... or
do we have to extract eclipse and set it up each test run?
Is it possible to import projects within the headless eclipse or do we have to throw compiled jars into its installation?
Are there any other ways to get HTTP interface tests executed against a running server we are currently not thinking about?
Thanks a lot!
Related
I would have added some JUnit tests to an Eclipse project that test functionality on the server to an Eclipse web project.
I can run the web application from inside Eclipse on an external Tomcat server (Run As | Run on Server) and then run the JUnit tests also from inside Eclipse while the first is still up.
I understand that is should be possible to fully automate both steps as one by making use of a Jetty (instead of Tomcat) server that runs inside Eclipse and that could be booted e.g. in #BeforeClass (or earlier).
Does Eclipse support this kind of unit testing out-of-the-box. I am currently using Eclipse Java EE IDE for Web Developers (Version: Kepler Service Release 2).
Eclipse (and any other IDE for that matter) doesn't stop you from doing anything in unit tests. It doesn't really support much, either, which is the core of your problem: Eclipse won't start a server for your unit tests. The same is true for all other IDEs that I know of.
Instead, you need to read up on how to embed Jetty in a Java application (= your unit tests) so the first test can start the server. Use a lazy init pattern for this:
private static JettyManager jetty;
#Before public void startServer() {
if( null == jetty ) {
jetty = new JettyManager();
jetty.start();
}
}
You can use a JVM shutdown hook to cleanly stop the server.
I use the same pattern to create the database which should be used during the tests to make sure it's clean. For this, I embed an H2 database.
If you want more automation, look at Maven. It can run integration tests (including deploying the WAR before starting the tests). See http://www.benoitschweblin.com/2013/03/run-jetty-in-maven-life-cycle.html
With the Maven Cargo plugin, you can deploy to almost every J2EE container.
Or use Jenkins: http://programmaticponderings.wordpress.com/2013/11/13/building-a-deployment-pipeline-using-git-maven-jenkins-and-glassfish-part-2-of-2/
I'm trying to run the JHipster application via my Eclipse Juno, using jdk 1.7.
The app seems to be loading properly (no console errors), but when i'm trying to reach the server with the client side (or via Postman, by sending a request to the REST servlets in port 8080), it's not responding.
However, when i'm running "mvn spring-boot:run" in the command shell, the server is loaded successfully and is responding to the exact same requests. Also, I managed to run the same command via eclipse with some maven configuration but it seems to be running only the target files (jars) and not the source code. I still haven't been able to run the source code of this app using eclipse in order to properly debug it.
Any suggestions?
Thanks!
So the answer is quite trivial, but since I spent several hours to reach it, it might save some time for others-
Download & install STS IDE.
Import the project as existing Maven project.
Run/Debug the project.
I tried to run it via Eclipse the whole time (wasn't familiar with STS to be honest) and this probably needs some extra configuration (another comment with explanations on eclipse configuration will be much appreciated). Once you work with STS, it's easy.
You should not need STS, just Eclipse with the J2EE stuff.
I've imported the sample jhipster in Eclipse (without STS) as a Maven project and everything was OK, after installing the maven dependencies.
To run the project, run as an application and search for the Application (com.mycompany.myapp.Application)
This app works for me: https://github.com/jhipster/jhipster-sample-app. It is stuck on Boot RC5 which probably means it's a bit old. Maybe Julien can comment on that (or update it)?
The deployment we follow is that we use runAssembler.bat to build an ear file and deploy it in a app server. We are using weblogic and jboss for testing purposes of the modules we built. However for every small change, we need to run runAssembler and build a new ear and deploy it in app server and restart the server.
I would like to find out if anyone figured out a way to do Hotswapping of class files which are generated by the code we write in ATG environment in either weblogic or jboss.
By attaching your IDE to your Application server on the Debug port it is generally possible to do hotswapping. Setting this up on Eclipse and JBoss is documented here, here and here. There is some information for setting it up in WebLogic here.
Attach your debugger, edit the java file, click 'save' and with hot code replacement in your IDE it should now update the running class file. In Eclipse it usually gives a popup if it was unable to do the sync. If you are using Eclipse, make sure the 'Build Automatically' flag under projects is ticked or you'll be waiting forever. I've not had any issues doing this via JBOSS (exploded ATG EAR) and variable success in doing this on WebSphere 7. It may also be prudent to make sure the same JAVAC you use to compile your build is the one loaded into your IDE compile path.
Another way to at least reduce the build/deploy time would be to deploy an unpacked/exploded EAR and simply copy your class files across (you could use the Eclipse FileSync plugin) and restart the server.
There are also some commercial options available, like JRebel
In our organization, we had good success in using DCEVM. It simply patches your JDK (in Windows: jvm.dll).
Download and patch your JDK
Launch your JBoss/Weblogic with the patched JDK
Set up Eclipse's Installed JRE's to point to patched JDK (restart and rebuild once)
Start the server, Launch debugger and connect
Ensure Eclipse's Debug view shows "Dynamic Code Evolution VM" (instead of something like "HotSpot VM")
Change your code, and voila!
You can do this with JRebel. After hotswapping you don't need to restart the server, only reload you deployment from Weblogic.
I have, a few JMeter scripts, which make HTTP calls to test my own web service, written in Spring. I would like the JMeter scripts to be automatically executed for every build and test if the build is good. So, as suggested at:- http://ribblescode.wordpress.com/2012/04/16/how-to-run-jmeter-tests-with-maven/ I have set up my Maven .pom files of my Spring web service project to have the Jmeter plugin stuff defined. And, I have added my JMeter scripts to src/test/JMeter. Now, I use Eclipse as my IDE and when I have my project already running on Tomcat from within Eclipse (Run As-> Run on Server) and then do Run As->Maven Install on my project with this setup, it executes the JMeter scripts and works as intended.
However, if my web service is not already running on Tomcat, the Maven build fails as the JMeter is not able to successfully make the HTTP calls.
Now, my problem is that this setup means the JMeter script is actually making calls to the old build which is already running and not on the new build which was generated when I clicked on Run As-> Maven Install at that point in time.
So, given this scenario how do I have it so that, when I make some code change, and then do a new build using Maven, it first deploys it and then runs the JMeter script on this new build?
Maven is not intended to test the Tomcat running in your Eclipse. Jmeter is an integration test tool, so all you have to do is to haang the appropriate plugins on the appropriate maven lifecycle phases. You actions needed:
pre-integration-test phase steps
download and unzip Tomcat
deploy your packaged webapp
start tomcat
integration-test phase step
Download and unzip Jmeter (for example with maven-dependency-plugin)
run jmeter tests
post-integration-test phase
stop tomcat
Thats all you need. One tool to use could be the Cargo Maven Plugin, which helps you in deployment, start and stop.
An example is here http://www.alexecollins.com/content/jmeter-integration-test-template-pom/
If you are interested, it is also possible to collect coverage info for your JMeter tests: http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Integration+Tests+for+Java+Project
I was wondering if it is possible to make a Java EE application being managed by Maven and automatically deploy it to JBoss all from Eclipse. To my knowledge I current right click on my project and select "Make install". After that completes, I open the server pane and right click on my deployed ear and either select "Full Publish" or "Incremental Publish". Is there a way to condense these actions into one click? I tried to write a windows batch file but I didn't have much luck with that, and it would only work for our devs working on Windows machines. I know I can make run configurations but when I try to make one it is very intimidating and I get frustrated and give up.
Thanks for your help!
You can use JBoss Tools 3.3.0 (Current milestone M4) with the maven integration to easily deploy projects (wars or ears) to your AS7 server.
Once you defined your AS7 instance in eclipse, all you have to do is right click on your project > Run As ...> Run on Server. It'll start your app server if it's stopped, or just deploy your app if it's already running.
See http://vimeo.com/25768303
and http://community.jboss.org/en/tools/blog/2011/11/09/jboss-tools-shift-happens-in-m4
If you are using maven, you can use the cargo plugin: http://cargo.codehaus.org/Maven2+plugin
You just configure where the JBoss is installed, set the plugin to run in the phase you want (or make a new one) and you are all set.
You can also create different configurations for different profiles, so you have local, integration, test, production, etc... And just by running with the selected profile deploys the ear in the server, remote or local.
If you want more control, you can set the path of the container as a variable that you pass in the Eclipse run configuration, that way each developer can have their servers in different paths.