Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
*/
package org.apache.geode.cache30;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.List;
import java.util.Properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import java.io.StringWriter;
import java.net.URL;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

import org.apache.commons.io.FileUtils;
import org.awaitility.Awaitility;
import org.junit.Rule;

import org.apache.geode.cache.Cache;
Expand All @@ -35,6 +37,7 @@
import org.apache.geode.internal.cache.xmlcache.CacheXml;
import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator;
import org.apache.geode.internal.cache.xmlcache.ClientCacheCreation;
import org.apache.geode.test.dunit.Invoke;
import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
import org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties;
import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
Expand Down Expand Up @@ -68,6 +71,23 @@ public final void postSetUp() throws Exception {
public final void preTearDownCacheTestCase() throws Exception {
this.xmlFile = null;
GemFireCacheImpl.testCacheXml = null;

waitForNoRebalancing();
Invoke.invokeInEveryVM(CacheXmlTestCase::waitForNoRebalancing);

super.preTearDownCacheTestCase();
}

/**
* Some tests run so quickly that the rebalance operation doesn't even have time to start before
* regions are already being destroyed - GEDOE-4312.
*/
private static void waitForNoRebalancing() {
if (cache != null && !cache.isClosed()) {
Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> {
return cache.getResourceManager().getRebalanceOperations().size() == 0;
});
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public abstract class JUnit4CacheTestCase extends JUnit4DistributedTestCase
* <p>
* Field is static so it doesn't get serialized with SerializableRunnable inner classes.
*/
private static InternalCache cache;
protected static InternalCache cache;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has the access been changed? There aren't any direct references to cache in this change set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change I made is in a subclass (CacheXmlTestCase) and references cache there.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I missed that reference to the cache during my review.


private final CacheTestFixture cacheTestFixture;

Expand Down