From 978f513abb4a5e2ee99e391455ead2675f08af8f Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 15 Oct 2014 23:57:19 +0200 Subject: [PATCH] Created "dbtest" profile for extensive db-specific tests (multithreaded consistency, performance). Small test fixes. --- repo/repo-sql-impl-test/pom.xml | 19 ++++++++++ .../closure/OrgClosureConcurrencyTest.java | 38 +++++++++++++------ .../closure/OrgClosurePerformanceTest1.java | 5 +-- .../src/test/resources/logback-test.xml | 2 +- .../repo-sql-impl-test/testng-db-specific.xml | 32 ++++++++++++++++ 5 files changed, 80 insertions(+), 16 deletions(-) create mode 100644 repo/repo-sql-impl-test/testng-db-specific.xml diff --git a/repo/repo-sql-impl-test/pom.xml b/repo/repo-sql-impl-test/pom.xml index 8df882996ed..ef6d6728e6f 100644 --- a/repo/repo-sql-impl-test/pom.xml +++ b/repo/repo-sql-impl-test/pom.xml @@ -108,5 +108,24 @@ + + dbtest + + false + + + + + maven-surefire-plugin + + + testng.xml + testng-db-specific.xml + + + + + + diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureConcurrencyTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureConcurrencyTest.java index 2ca51bf6e3f..01f9823ab3c 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureConcurrencyTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureConcurrencyTest.java @@ -61,6 +61,18 @@ public class OrgClosureConcurrencyTest extends AbstractOrgClosureTest { private static final int[] NODE_ROUNDS_FOR_LEVELS = { 5, 15, 45, 100 }; // large number of deletes public static final int THREADS = 4; + /* + * H2 seems to have a problem in that one of the worker threads freezes when running the following statement: + * + * select distinct rparentorg0_.owner_oid as col_0_0_ from m_reference rparentorg0_ + * inner join m_object robject1_ on rparentorg0_.owner_oid=robject1_.oid where rparentorg0_.reference_type=0 and rparentorg0_.targetOid=? and robject1_.objectTypeClass=? + * + * (selecting child nodes to be registered into orgGraph) + * + * Dunno why. Let's use a timeout of 30 minutes so that the tests would not loop indefinitely. + */ + public static final long TIMEOUT = 1800L*1000L; + // very small scenario // private static final int[] ORG_CHILDREN_IN_LEVEL = { 1, 2, 1 }; // private static final int[] USER_CHILDREN_IN_LEVEL = null; @@ -183,9 +195,7 @@ public void run() { t.start(); } - while (!runners.isEmpty()) { - Thread.sleep(100); // primitive way of waiting - } + waitForRunnersCompletion(runners); if (!edgesToRemove.isEmpty()) { throw new AssertionError("Edges to remove is not empty, see the console or log: " + edgesToRemove); @@ -230,9 +240,7 @@ public void run() { t.start(); } - while (!runners.isEmpty()) { - Thread.sleep(100); // primitive way of waiting - } + waitForRunnersCompletion(runners); if (!edgesToAdd.isEmpty()) { throw new AssertionError("Edges to add is not empty, see the console or log: " + edgesToAdd); @@ -247,6 +255,16 @@ public void run() { info("Consistency after re-adding OK"); } + private void waitForRunnersCompletion(List runners) throws InterruptedException { + long start = System.currentTimeMillis(); + while (!runners.isEmpty()) { + Thread.sleep(100); // primitive way of waiting + if (System.currentTimeMillis()-start > TIMEOUT) { + throw new AssertionError("Test is running for too long. Probably caused by a locked-up thread. Runners = " + runners); + } + } + } + private synchronized T getNext(Set items, boolean random) { if (items.isEmpty()) { return null; @@ -344,9 +362,7 @@ public void run() { t.start(); } - while (!runners.isEmpty()) { - Thread.sleep(100); // primitive way of waiting - } + waitForRunnersCompletion(runners); if (!nodesToRemove.isEmpty()) { throw new AssertionError("Nodes to remove is not empty, see the console or log: " + nodesToRemove); @@ -401,9 +417,7 @@ public void run() { t.start(); } - while (!runners.isEmpty()) { - Thread.sleep(100); // primitive way of waiting - } + waitForRunnersCompletion(runners); if (!nodesToAdd.isEmpty()) { throw new AssertionError("Nodes to add is not empty, see the console or log: " + nodesToAdd); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosurePerformanceTest1.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosurePerformanceTest1.java index f6c40c58db3..7a2e3c0d020 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosurePerformanceTest1.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosurePerformanceTest1.java @@ -27,13 +27,12 @@ @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class OrgClosurePerformanceTest1 extends AbstractOrgClosureTest { - // relatively smaller graph (OrgClosure has cca 12K rows) + // relatively smaller graph private static final int[] ORG_CHILDREN_IN_LEVEL = { 1, 2, 3, 4, 5, 0}; - private static final int[] USER_CHILDREN_IN_LEVEL = { 0, 1, 2, 3, 4, 5}; + private static final int[] USER_CHILDREN_IN_LEVEL = null; private static final int[] PARENTS_IN_LEVEL = { 0, 1, 2, 3, 3, 3}; private static final int[] LINK_ROUNDS_FOR_LEVELS = { 0, 5, 15,15,15,0 }; private static final int[] NODE_ROUNDS_FOR_LEVELS = { 1, 5, 15,15,15,0 }; - private static final int[] USER_ROUNDS_FOR_LEVELS = { 0, 10,10,20,20,20}; private OrgClosureTestConfiguration configuration; diff --git a/repo/repo-sql-impl-test/src/test/resources/logback-test.xml b/repo/repo-sql-impl-test/src/test/resources/logback-test.xml index 36efa0321ac..b28ebc63259 100644 --- a/repo/repo-sql-impl-test/src/test/resources/logback-test.xml +++ b/repo/repo-sql-impl-test/src/test/resources/logback-test.xml @@ -33,7 +33,7 @@ - + diff --git a/repo/repo-sql-impl-test/testng-db-specific.xml b/repo/repo-sql-impl-test/testng-db-specific.xml new file mode 100644 index 00000000000..29c5577e360 --- /dev/null +++ b/repo/repo-sql-impl-test/testng-db-specific.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + +