Hi,
after reading the Arquillian reference guide today, I am just wondering if it would be possible to test the persistence by persistence extension in connection with performance extension. By this way, it would be pretty nice benchmarking tool to benchmark database performance ...
I imagine something like this:
@PerformanceTest(resultsThreshold=2) @RunWith(Arquillian.class) public class UserPersistenceTest { @Deployment public static Archive<?> createDeploymentPackage() { return ShrinkWrap.create(JavaArchive.class, "test.jar") .addPackage(UserAccount.class.getPackage()) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsManifestResource("test-persistence.xml", "persistence.xml"); } @PersistenceContext EntityManager em; @Test @UsingDataSet("datasets/users.yml") @ShouldMatchDataSet("datasets/expected-users.yml") @Performance(time=2000) public void persistBenchmarkTest() throws Exception { saveAccounts(100000); } private void saveAccounts(int count) { for (int i = 0; i < count; i++) { UserAccount user = new UserAccount(); user.setName("something random"); em.persist(user); } } }
So by this way I can test that not even the data are stored but the actual saving time was not bigger then 2 seconds for example.
What are pros and cons of this approach? Are there some implementation drawbacks of how the two extensions work internally? Is it even possible to combine them?
Thank you for the answer.