Skip to content

Commit

Permalink
Created "dbtest" profile for extensive db-specific tests (multithread…
Browse files Browse the repository at this point in the history
…ed consistency, performance). Small test fixes.
  • Loading branch information
mederly committed Oct 15, 2014
1 parent ee3dd98 commit 978f513
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 16 deletions.
19 changes: 19 additions & 0 deletions repo/repo-sql-impl-test/pom.xml
Expand Up @@ -108,5 +108,24 @@
</plugins>
</build>
</profile>
<profile>
<id>dbtest</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
<suiteXmlFile>testng-db-specific.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -247,6 +255,16 @@ public void run() {
info("Consistency after re-adding OK");
}

private void waitForRunnersCompletion(List<Thread> 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> T getNext(Set<T> items, boolean random) {
if (items.isEmpty()) {
return null;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Expand Up @@ -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;

Expand Down
Expand Up @@ -33,7 +33,7 @@
<!--<logger name="org.springframework" level="INFO" />-->

<logger name="org.hibernate.SQL" level="DEBUG"/>
<logger name="com.evolveum.midpoint.repo" level="TRACE"/>
<logger name="com.evolveum.midpoint.repo" level="DEBUG"/>
<logger name="com.evolveum.midpoint.repo.sql.OrgClosureManager" level="TRACE"/>
<logger name="com.evolveum.midpoint.testing" level="TRACE"/>

Expand Down
32 changes: 32 additions & 0 deletions repo/repo-sql-impl-test/testng-db-specific.xml
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (c) 2010-2014 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="db-specific" parallel="false">
<test name="Concurrency Tests" parallel="false" preserve-order="true" verbose="10" enabled="true">
<classes>
<class name="com.evolveum.midpoint.repo.sql.ConcurrencyTest"/>
<class name="com.evolveum.midpoint.repo.sql.closure.OrgClosureConcurrencyTest"/>
</classes>
</test>
<test name="Performance Tests" parallel="false" preserve-order="true" verbose="10" enabled="true">
<classes>
<class name="com.evolveum.midpoint.repo.sql.closure.OrgClosurePerformanceTest1"/>
<class name="com.evolveum.midpoint.repo.sql.closure.OrgClosurePerformanceTest2"/>
</classes>
</test>
</suite>

0 comments on commit 978f513

Please sign in to comment.