another attempt to fix the intermitent datacache test failures as the persist() is taking 1.2 secs on some test machines

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1031116 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2010-11-04 18:10:00 +00:00
parent 531381429d
commit 33c8d872b4
1 changed files with 7 additions and 4 deletions

View File

@ -1071,13 +1071,13 @@ public abstract class CacheTest extends AbstractTestCase {
diff = (currentTime.getTime() - startTime.getTime()); diff = (currentTime.getTime() - startTime.getTime());
diff2 = (currentTime.getTime() - persistTime.getTime()); diff2 = (currentTime.getTime() - persistTime.getTime());
diff = Math.max(diff, diff2); diff = Math.max(diff, diff2);
if (sleep >= 0 && diff > 600 && diff < 900) { if (diff > 600 && diff < 900) {
// only h should be dropped // only h should be dropped
checkCache(cache, ids, new boolean[]{ true, true, true, false }); checkCache(cache, ids, new boolean[]{ true, true, true, false });
} else { } else {
// need to skip the test on slow systems or when using remote DB connections // need to skip the test on slow systems or when using remote DB connections
getLog().warn("CacheTest.timeoutsHelper() skipping checkCache(h=500) because sleep="+sleep+ getLog().warn("CacheTest.timeoutsHelper() skipping checkCache(h=500) because diff=" + diff +
" and final diff=" + diff + " and diff2=" + diff2); " and diff2=" + diff2);
} }
// if this run has a default timeout (set to 1 sec in the test // if this run has a default timeout (set to 1 sec in the test
@ -1093,7 +1093,10 @@ public abstract class CacheTest extends AbstractTestCase {
diff2 = (currentTime.getTime() - persistTime.getTime()); diff2 = (currentTime.getTime() - persistTime.getTime());
diff = Math.max(diff, diff2); diff = Math.max(diff, diff2);
sleep = 2000 - diff; sleep = 2000 - diff;
if (sleep > 10) { if (sleep < 0) {
// we already missed the window
getLog().warn("CacheTest.timeoutsHelper() skipping sleep for checkCache(f=000) because sleep="+sleep);
} else if (sleep > 10) {
getLog().info("CacheTest.timeoutsHelper() testing f to be dropped by waiting sleep="+sleep); getLog().info("CacheTest.timeoutsHelper() testing f to be dropped by waiting sleep="+sleep);
Thread.currentThread().sleep(sleep); Thread.currentThread().sleep(sleep);
Thread.yield(); Thread.yield();