1

I'm searching for a solution to clean up after doing integration Tests in CQ5. We did manage after a while of research to run JUnit tests in CQ5 (this is bad documented). Now that everything is working as expected we are searching for a solution to run those Tests on a CQ5 server right with the maven-deployment, and cleaning up the test data afterwards. Like for example a test user or a test page we created for test purposes we don't want to have in the system afterwards. Is there a solution build in crx to do something like that? So far we also thought about doing a deployment with tests and afterwards again without tests, or doing a deployment with a snapshot right after, than run the tests and install the snapshot again. But all those solutions would be very time consuming, since we have many servers to deploy to, time is precious :)

Robin
  • 35
  • 4

1 Answers1

1

About tests being badly documented, I have recently written http://sling.apache.org/site/testing-sling-based-applications.html as an overview of testing techniques for Sling-based applications. As CQ5 is based on Sling, all those techniques apply to it.

To cleanup your test content, I don't think CQ5.5 or the CRX version that it uses provide a fast "take snapshot before tests and revert to it after them" feature.

If you can run on a filesystem that supports snapshots, like ZFS, you could take a filesystem snapshot before running the tests, start CQ5, run them, stop CQ5 and go back to that snapshot.

You could also run the tests on a throwaway instance used just for tests - setting up a CQ5 instance is easy and should not take more than 4-5 minutes on a decent test box. We do that with Maven builds that setup an instance from scratch like in the Sling integration tests sample.

Apart from that, you could also put all your test content under specific paths like /content/test, /var/test, etc. so you can delete it after the tests. Or add a my:toDelete mixin to all test content nodes to be able to find them before. But content that CQ5 itself creates during your tests (workflow instances for example) wouldn't be deleted in this case.

Bertrand Delacretaz
  • 6,100
  • 19
  • 24
  • Thank you for you answer! As a last hope we found this: [link](http://www.infoq.com/articles/spring-modules-jcr) and this: [link](http://se-jcr.sourceforge.net/project-info.html). We hope with transactions a simple rollback of testdata will be possible, let's hope for the best, otherwise i think we go with a test box. – Robin Jun 21 '12 at 14:35
  • @Robin did you find a way to rollback test data? If so could you please add your findings as an answer? – Behrang Jul 14 '14 at 22:57