5

My team deploys code to production every week or so. We have a large set of post-deployment validations, e.g.:

  • New log lines are appended to Tomcat log (ssh to machine, tail -f the log)
  • Database table has more than 100 new rows in a minute (ssh to machine, run some sql commands)
  • A GET call with a given parameter returns the right value (browser or wget)

The tests are done manually, and takes 2-4 agonizing hours.

Since we have a Jenkins CI system, I would like to automate these tests to small units which produce JUnit XMLS which can be analyzed by the Jenkins web UI.

Is there a test suite capable of easily ssh-ing servers with JUnit output?

2
  • 3
    You're looking for something that wraps it all? I mean, there's open source SSH libraries you could use, and you could use them inside a JUnit test.
    – corsiKa
    Jun 26, 2013 at 15:25
  • I can build my own framework, but I'd rather use a ready-made, all-included open source solution.
    – Adam Matan
    Jun 27, 2013 at 7:06

2 Answers 2

4
  1. Use JUnit to handle the running of the tests from the Jenkins server.
  2. Use JDBC to query the DB for new rows.
  3. Change up the Tomcat servers so they send logging events back to the Jenkins serverJUnit test. You'll need to write a little socket listener for the JUnit test to gather the Tomcat events (Writing an LoggingEvent listener isn't hard. I'm not brilliant coder and I got the event listener with Observer-Observables working in less than a day.)
  4. Java has tons of http(s) GET/POST capabilities so wget shouldn't be hard to implement either.

I don't know of a testing framework that will let you abstract away all the boilerplate code of building JDBC connections, SSH output, etc. Maybe Spring does that kind of abstraction.

Have you looked at JBehave? It's an acceptance testing framework that sits on top of JUnit.

4
  • +1 for listing simple and doable solutions for each aspect. Just one question. How JBehave is going to help here?
    – dzieciou
    Sep 12, 2013 at 20:16
  • And... I was completely surprised Spring can be used for something else than just Inversion of Control (IoC). Thanks for opening my eyes on that :-)
    – dzieciou
    Sep 12, 2013 at 20:17
  • Spring is incredibly powerful because it allows you to wrap a ton of boilerplate code into a few snippets. Oh, and it does IoC too :)
    – Green
    Sep 13, 2013 at 13:58
  • JBehave is an acceptance testing framework. The distinction is that acceptance testing is the kind of testing you do after all the parts are put together; after the final product has been created. The degree of granularity from least to greatest is unit testing, integration testing then acceptance testing. JUnit addresses unit testing. Don't know of a product that handles integration testing specifically (though there probably is one) and JBehave is focused on acceptance testing.
    – Green
    Sep 13, 2013 at 14:01
0

Using the Jenkins server is a great idea. You just need to create Maven projects that run basic JUnit or TestNG tests. The JUnit or TestNG tests should accomplish your tasks and provide assertions. At least, that is how I would do it. You just use the post-build action in Jenkins to find your JUnit output .xml files (requires a special plugin to do that).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.