[ 
https://issues.apache.org/jira/browse/GEODE-4238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16331173#comment-16331173
 ] 

ASF GitHub Bot commented on GEODE-4238:
---------------------------------------

kirklund closed pull request #1292: GEODE-4238: rewrite flaky region expiration 
tests
URL: https://github.com/apache/geode/pull/1292
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/geode-core/src/test/java/org/apache/geode/cache/RegionExpirationDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/cache/RegionExpirationDUnitTest.java
new file mode 100644
index 0000000000..63dc650372
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/cache/RegionExpirationDUnitTest.java
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You 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.
+ */
+package org.apache.geode.cache;
+
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.geode.test.dunit.Host.getHost;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.timeout;
+
+import java.io.Serializable;
+import java.util.function.Consumer;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import junitparams.naming.TestCaseName;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.rules.CacheRule;
+import org.apache.geode.test.dunit.rules.DistributedTestRule;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
+
+/**
+ * Test Region expiration - both time-to-live and idle timeout.
+ *
+ * <p>
+ * Note: See LocalRegionTest and MultiVMRegionTestCase for more expiration 
tests.
+ *
+ * <p>
+ * Single-JVM tests were extracted to {@link RegionExpirationIntegrationTest}.
+ *
+ * @since GemFire 3.0
+ */
+@Category(DistributedTest.class)
+@RunWith(JUnitParamsRunner.class)
+@SuppressWarnings("serial")
+public class RegionExpirationDUnitTest implements Serializable {
+
+  private static final int TTL_SECONDS = 10;
+  private static final String KEY = "key";
+  private static final String VALUE = "value";
+
+  private static CacheListener<String, String> spyCacheListener;
+
+  private String regionName;
+  private VM withExpirationVM0;
+  private VM withoutExpirationVM1;
+
+  @ClassRule
+  public static DistributedTestRule distributedTestRule = new 
DistributedTestRule();
+
+  @Rule
+  public CacheRule cacheRule = CacheRule.builder().createCacheInAll().build();
+
+  @Rule
+  public SerializableTestName testName = new SerializableTestName();
+
+  @Before
+  public void setUp() {
+    regionName = getClass().getSimpleName() + "_" + testName.getMethodName();
+
+    withExpirationVM0 = getHost(0).getVM(0);
+    withoutExpirationVM1 = getHost(0).getVM(1);
+  }
+
+  @Test
+  @Parameters({"LOCAL_DESTROY", "DESTROY", "LOCAL_INVALIDATE", "INVALIDATE"})
+  @TestCaseName("{method}({params})")
+  public void regionExpiresAfterTtl(final Verification verification) throws 
Exception {
+    // In withoutExpirationVM1, create the region - no ttl
+    withoutExpirationVM1.invoke(() -> {
+      cacheRule.getCache().createRegionFactory(REPLICATE).create(regionName);
+    });
+
+    // In withExpirationVM0, create the region with ttl, and put value
+    withExpirationVM0.invoke(() -> {
+      spyCacheListener = spy(CacheListener.class);
+
+      RegionFactory<String, String> regionFactory =
+          cacheRule.getCache().createRegionFactory(REPLICATE);
+      regionFactory.setRegionTimeToLive(
+          new ExpirationAttributes(TTL_SECONDS, 
verification.expirationAction()));
+      regionFactory.addCacheListener(spyCacheListener);
+      Region<String, String> region = regionFactory.create(regionName);
+
+      region.put(KEY, VALUE);
+      assertThat(region.get(KEY)).isEqualTo(VALUE);
+      assertThat(region.containsValueForKey(KEY)).isTrue();
+    });
+
+    withoutExpirationVM1.invoke(() -> {
+      
assertThat(cacheRule.getCache().getRegion(regionName).get(KEY)).isEqualTo(VALUE);
+    });
+
+    // Wait for expiration to occur
+    // In withExpirationVM0, region should be absent (for destroy, 
localDestroy), or entry invalid
+    withExpirationVM0.invoke(() -> {
+      verification.verify(spyCacheListener);
+      Region<String, String> region = 
cacheRule.getCache().getRegion(regionName);
+      verification.assertThatExpirationOccurredInLocalMember(region);
+    });
+
+    // In withoutExpirationVM1, region should be absent (for destroy), or 
entry invalid
+    // (invalidate).
+    withoutExpirationVM1.invoke(() -> {
+      
verification.assertRegionStateInRemoteMember(cacheRule.getCache().getRegion(regionName));
+    });
+  }
+
+  private static final long TIMEOUT_MILLIS = MINUTES.toMillis(2);
+
+  private static final Consumer<CacheListener<String, String>> 
VERIFY_AFTER_REGION_DESTROY =
+      (spyCacheListener) -> Mockito.verify(spyCacheListener, 
timeout(TIMEOUT_MILLIS))
+          .afterRegionDestroy(any());
+
+  private static final Consumer<CacheListener<String, String>> 
VERIFY_AFTER_REGION_INVALIDATE =
+      (spyCacheListener) -> Mockito.verify(spyCacheListener, 
timeout(TIMEOUT_MILLIS))
+          .afterRegionInvalidate(any());
+
+  private enum Verification {
+    LOCAL_DESTROY(VERIFY_AFTER_REGION_DESTROY, ExpirationAction.LOCAL_DESTROY),
+    DESTROY(VERIFY_AFTER_REGION_DESTROY, ExpirationAction.DESTROY),
+    LOCAL_INVALIDATE(VERIFY_AFTER_REGION_INVALIDATE, 
ExpirationAction.LOCAL_INVALIDATE),
+    INVALIDATE(VERIFY_AFTER_REGION_INVALIDATE, ExpirationAction.INVALIDATE);
+
+    private final Consumer<CacheListener<String, String>> strategy;
+    private final ExpirationAction expirationAction;
+
+    Verification(final Consumer<CacheListener<String, String>> strategy,
+        final ExpirationAction evictionAction) {
+      this.strategy = strategy;
+      this.expirationAction = evictionAction;
+    }
+
+    void verify(final CacheListener<String, String> spyCacheListener) {
+      strategy.accept(spyCacheListener);
+    }
+
+    ExpirationAction expirationAction() {
+      return expirationAction;
+    }
+
+    void assertThatExpirationOccurredInLocalMember(final Region<String, 
String> region) {
+      if (expirationAction().isInvalidate() || 
expirationAction().isLocalInvalidate()) {
+        // invalidate region
+        assertThat(region.containsValueForKey(KEY)).isFalse();
+
+      } else {
+        // destroy region
+        assertThat(region).isNull();
+      }
+    }
+
+    void assertRegionStateInRemoteMember(final Region<String, String> region) {
+      if (expirationAction().isInvalidate()) {
+        // distributed invalidate region
+        assertThat(region.containsKey(KEY)).isTrue();
+        assertThat(region.containsValueForKey(KEY)).isFalse();
+
+      } else if (expirationAction().isDestroy()) {
+        // distributed destroy region
+        assertThat(region).isNull();
+
+      } else {
+        // for LOCAL_DESTROY or LOCAL_INVALIDATE, the value should be present
+        assertThat(region.containsValueForKey(KEY)).isTrue();
+        assertThat(region.get(KEY)).isEqualTo(VALUE);
+      }
+    }
+  }
+}
diff --git 
a/geode-core/src/test/java/org/apache/geode/cache/RegionExpirationIntegrationTest.java
 
b/geode-core/src/test/java/org/apache/geode/cache/RegionExpirationIntegrationTest.java
new file mode 100644
index 0000000000..9d2cda26bc
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/cache/RegionExpirationIntegrationTest.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You 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.
+ */
+package org.apache.geode.cache;
+
+import static java.lang.System.nanoTime;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.apache.geode.cache.ExpirationAction.DESTROY;
+import static org.apache.geode.cache.ExpirationAction.INVALIDATE;
+import static org.apache.geode.cache.RegionShortcut.LOCAL;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+import org.mockito.InOrder;
+
+import org.apache.geode.test.junit.categories.IntegrationTest;
+
+/**
+ * Extracted from {@link RegionExpirationDUnitTest}.
+ */
+@Category(IntegrationTest.class)
+public class RegionExpirationIntegrationTest {
+
+  private Cache cache;
+  private String regionName;
+  private CacheListener<String, String> spyCacheListener;
+
+  @Rule
+  public TestName testName = new TestName();
+
+  @Before
+  public void setUp() {
+    regionName = getClass().getSimpleName() + "_" + testName.getMethodName();
+    spyCacheListener = mock(CacheListener.class);
+
+    cache = new CacheFactory().set(LOCATORS, "").set(MCAST_PORT, "0").create();
+  }
+
+  @Test
+  public void increaseRegionTtl() throws Exception {
+    int firstTtlSeconds = 3;
+    int secondTtlSeconds = 8;
+    long startNanos = nanoTime();
+
+    RegionFactory<String, String> regionFactory = 
cache.createRegionFactory(LOCAL);
+    regionFactory.setRegionTimeToLive(new 
ExpirationAttributes(firstTtlSeconds, DESTROY));
+    Region<String, String> region = regionFactory.create(regionName);
+
+    region.getAttributesMutator()
+        .setRegionTimeToLive(new ExpirationAttributes(secondTtlSeconds, 
DESTROY));
+
+    await().atMost(30, SECONDS).until(() -> region.isDestroyed());
+    assertThat(NANOSECONDS.toSeconds(nanoTime() - startNanos))
+        .isGreaterThanOrEqualTo(secondTtlSeconds);
+  }
+
+  @Test
+  public void decreaseRegionTtl() throws Exception {
+    int firstTtlSeconds = 5;
+    int secondTtlSeconds = 1;
+    long startNanos = nanoTime();
+
+    RegionFactory<String, String> regionFactory = 
cache.createRegionFactory(LOCAL);
+    regionFactory.setRegionTimeToLive(new 
ExpirationAttributes(firstTtlSeconds, DESTROY));
+    Region<String, String> region = regionFactory.create(regionName);
+
+    region.getAttributesMutator()
+        .setRegionTimeToLive(new ExpirationAttributes(secondTtlSeconds, 
DESTROY));
+
+    await().atMost(10, SECONDS).until(() -> 
assertThat(region.isDestroyed()).isTrue());
+    assertThat(NANOSECONDS.toSeconds(nanoTime() - 
startNanos)).isLessThan(firstTtlSeconds);
+  }
+
+  @Test
+  public void regionTtlWithIdleMock() throws Exception {
+    int ttlSeconds = 5;
+    int idleSeconds = 1;
+
+    RegionFactory<String, String> regionFactory = 
cache.createRegionFactory(LOCAL);
+    regionFactory.setRegionTimeToLive(new ExpirationAttributes(ttlSeconds, 
DESTROY));
+    regionFactory.setRegionIdleTimeout(new ExpirationAttributes(idleSeconds, 
INVALIDATE));
+    regionFactory.addCacheListener(spyCacheListener);
+    Region<String, String> region = regionFactory.create(regionName);
+
+    region.create("key", "val");
+
+    // await Region INVALIDATE
+
+    verify(spyCacheListener, 
timeout(SECONDS.toMillis(10))).afterRegionInvalidate(any());
+    assertThat(region.get("key")).isNull();
+
+    // await Region DESTROY
+
+    verify(spyCacheListener, 
timeout(SECONDS.toMillis(30))).afterRegionDestroy(any());
+    assertTrue(region.isDestroyed());
+
+    InOrder inOrder = inOrder(spyCacheListener);
+    inOrder.verify(spyCacheListener).afterRegionInvalidate(any());
+    inOrder.verify(spyCacheListener).afterRegionDestroy(any());
+  }
+}
diff --git 
a/geode-core/src/test/java/org/apache/geode/cache30/RegionExpirationDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/cache30/RegionExpirationDUnitTest.java
deleted file mode 100644
index 916f7b504d..0000000000
--- 
a/geode-core/src/test/java/org/apache/geode/cache30/RegionExpirationDUnitTest.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
- * agreements. See the NOTICE file distributed with this work for additional 
information regarding
- * copyright ownership. The ASF licenses this file to You 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.
- */
-package org.apache.geode.cache30;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.CacheException;
-import org.apache.geode.cache.ExpirationAction;
-import org.apache.geode.cache.ExpirationAttributes;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionAttributes;
-import org.apache.geode.cache.Scope;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.LogWriterUtils;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.Wait;
-import org.apache.geode.test.dunit.WaitCriterion;
-import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase;
-import org.apache.geode.test.junit.categories.DistributedTest;
-
-/**
- * Test Region expiration - both time-to-live and idle timeout.
- *
- * Note: See LocalRegionTest and MultiVMRegionTestCase for more expiration 
tests.
- *
- *
- * @since GemFire 3.0
- */
-@Category(DistributedTest.class)
-public class RegionExpirationDUnitTest extends JUnit4CacheTestCase {
-
-  public RegionExpirationDUnitTest() {
-    super();
-  }
-
-  // /**
-  // * Returns the attributes of a region to be tested.
-  // */
-  // private RegionAttributes getRegionAttributes() {
-  // AttributesFactory factory = new AttributesFactory();
-  // factory.setScope(Scope.LOCAL);
-  // factory.setStatisticsEnabled(true);
-  // return factory.create();
-  // }
-
-  /**
-   * Test internal methods that encode & decode time
-   */
-  /*
-   * The encode and decode time methods are now private in MetaMap
-   *
-   * @Test public void testTimeEncoding() throws CacheException { Region r =
-   * createRegion(getUniqueName(), getRegionAttributes()); long start =
-   * 
((InternalDistributedSystem)getCache().getDistributedSystem()).getStartTime(); 
long timeMs =
-   * System.currentTimeMillis(); assertTrue(timeMs >= start); int encoded =
-   * ((LocalRegion)r).encodeTime(timeMs); long decoded = 
((LocalRegion)r).decodeTime(encoded);
-   * getLogWriter().info( "testTimeEncoding: timeMs: " + timeMs + ", ds start: 
" + start +
-   * ", encoded: " + encoded + ", decoded: " + decoded); 
assertTrue(Math.abs(timeMs - decoded) <=
-   * 100); }
-   */
-
-  @Test
-  public void testRegionTTLLocalDestroy() throws CacheException, 
InterruptedException {
-    _testRegionTTL(getUniqueName(), ExpirationAction.LOCAL_DESTROY);
-  }
-
-  @Test
-  public void testRegionTTLDestroy() throws CacheException, 
InterruptedException {
-    _testRegionTTL(getUniqueName(), ExpirationAction.DESTROY);
-  }
-
-  @Test
-  public void testRegionTTLLocalInvalidate() throws CacheException, 
InterruptedException {
-    _testRegionTTL(getUniqueName(), ExpirationAction.LOCAL_INVALIDATE);
-  }
-
-  @Test
-  public void testRegionTTLInvalidate() throws CacheException, 
InterruptedException {
-    _testRegionTTL(getUniqueName(), ExpirationAction.INVALIDATE);
-  }
-
-  @Test
-  public void testRegionTTLAfterMutating() throws InterruptedException, 
CacheException {
-    String regionName = getUniqueName();
-    int firstTimeout = 2;
-    int secondTimeout = 6;
-    createWithExpiration(regionName,
-        new ExpirationAttributes(firstTimeout, ExpirationAction.DESTROY), 
null);
-    long startTime = System.currentTimeMillis();
-    final Region region = getOrCreateRootRegion().getSubregion(regionName);
-    region.getAttributesMutator()
-        .setRegionTimeToLive(new ExpirationAttributes(secondTimeout, 
ExpirationAction.DESTROY));
-    Thread.sleep(firstTimeout * 1000 + 100);
-    if (region.isDestroyed()) {
-      assertTrue(System.currentTimeMillis() >= startTime + secondTimeout * 
1000);
-    }
-
-    Thread.sleep((secondTimeout - firstTimeout) * 1000 + 100);
-    WaitCriterion wc = new WaitCriterion() {
-      public boolean done() {
-        return region.isDestroyed();
-      }
-
-      public String description() {
-        return "region never destroyed";
-      }
-    };
-    Wait.waitForCriterion(wc, 30 * 1000, 1000, true);
-  }
-
-  @Test
-  public void testWhenBothTtlAndIdleAreSet() throws InterruptedException, 
CacheException {
-    String regionName = getUniqueName();
-    int ttlTimeout = 4;
-    int idleTimeout = 3;
-    createWithExpiration(regionName, new ExpirationAttributes(ttlTimeout, 
ExpirationAction.DESTROY),
-        new ExpirationAttributes(idleTimeout, ExpirationAction.INVALIDATE));
-    Region region = getOrCreateRootRegion().getSubregion(regionName);
-    region.create("key", "val");
-    Thread.sleep(idleTimeout * 1000 + 200);
-    assertFalse(region.isDestroyed());
-
-    // Touch the lastAccessedTime
-    assertNull(region.get("key"));
-
-    // Next action that occurs should be ttl - the destroy
-    Thread.sleep(((ttlTimeout - idleTimeout) * 1000) + 5000);
-    assertTrue(region.isDestroyed());
-  }
-
-
-  /////////////// Utility methods ///////////////////////////
-
-  private void _testRegionTTL(final String regionName, final ExpirationAction 
action)
-      throws InterruptedException {
-    final int timeoutSecs = 10;
-    final Object key = "key";
-    final Object originalValue = "original value";
-    Host host = Host.getHost(0);
-    VM vm0 = host.getVM(0);
-    VM vm1 = host.getVM(1);
-    LogWriterUtils.getLogWriter().info("vm0 is " + vm0.getId() + ", vm1 is " + 
vm1);
-
-    LogWriterUtils.getLogWriter().info("2: " + regionName + " action is " + 
action);
-
-    final long tilt = System.currentTimeMillis() + timeoutSecs * 1000;
-
-    // In vm0, create the region with ttl, and put value
-    vm0.invoke(new CacheSerializableRunnable("Create Region & Key") {
-      public void run2() throws CacheException {
-        createWithExpiration(regionName, new ExpirationAttributes(timeoutSecs, 
action), null);
-        Region region = getOrCreateRootRegion().getSubregion(regionName);
-        region.put(key, originalValue);
-        assertEquals(originalValue, region.get(key));
-        assertTrue(region.containsValueForKey(key));
-      }
-    });
-    // In vm1, create the region - no ttl
-    vm1.invoke(new CacheSerializableRunnable("Create Region & Key") {
-      public void run2() throws CacheException {
-        createWithExpiration(regionName, null, null);
-      }
-    });
-
-    // In vm1, do get() to cause netsearch
-    vm1.invoke(new CacheSerializableRunnable("Get") {
-      public void run2() throws CacheException {
-        Region region = getOrCreateRootRegion().getSubregion(regionName);
-        Object newVal = region.get(key);
-
-        if (!originalValue.equals(newVal)) {
-          assertTrue("expected original value but got " + newVal,
-              System.currentTimeMillis() + 1000 >= tilt);
-        }
-        if (!region.containsValueForKey(key)) {
-          assertTrue("Region doesn't hold key", System.currentTimeMillis() + 
1000 >= tilt);
-        }
-      }
-    });
-
-    // Wait for expiration to occur
-    Thread.sleep(timeoutSecs * 1000 + 2000);
-
-    // In vm0, region should be absent (for destroy, localDestroy), or
-    // entry invalid
-    vm0.invoke(new CacheSerializableRunnable("Get") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(regionName);
-        LogWriterUtils.getLogWriter()
-            .info("3: " + regionName + ", " + region + ", action is " + 
action);
-        if (action.isInvalidate() || action.isLocalInvalidate()) {
-          assertTrue(!region.containsValueForKey(key));
-        } else {
-          assertTrue(region == null);
-        }
-      }
-    });
-    // In vm1, region should be absent (for destroy), or entry invalid 
(invalidate).
-    // For LOCAL_DESTROY or LOCAL_INVALIDATE, the value should be intact
-    vm1.invoke(new CacheSerializableRunnable("Get") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(regionName);
-        if (action.isInvalidate()) {
-          assertTrue(region.containsKey(key));
-          assertTrue(!region.containsValueForKey(key));
-        } else if (action.isDestroy()) {
-          assertTrue(region == null);
-        } else {
-          assertTrue(region.containsValueForKey(key));
-          assertEquals(originalValue, region.get(key));
-        }
-      }
-    });
-  }
-
-  protected void createWithExpiration(String regionName, ExpirationAttributes 
ttl,
-      ExpirationAttributes idle) throws CacheException {
-    AttributesFactory factory = new AttributesFactory();
-    factory.setStatisticsEnabled(true);
-    if (ttl != null)
-      factory.setRegionTimeToLive(ttl);
-    if (idle != null)
-      factory.setRegionIdleTimeout(idle);
-    factory.setScope(Scope.DISTRIBUTED_ACK);
-    factory.setEarlyAck(false);
-    RegionAttributes attrs = factory.create();
-    LogWriterUtils.getLogWriter().info("4: " + regionName + " ttl action is " 
+ ttl);
-    getOrCreateRootRegion().createSubregion(regionName, attrs);
-  }
-
-  protected Region getOrCreateRootRegion() throws CacheException {
-    Region root = getRootRegion();
-    if (root == null) {
-      AttributesFactory factory = new AttributesFactory();
-      factory.setScope(Scope.DISTRIBUTED_ACK);
-      factory.setEarlyAck(false);
-      factory.setStatisticsEnabled(true);
-      root = createRootRegion(factory.create());
-    }
-    return root;
-  }
-
-}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> CI failure: RegionExpirationDUnitTest.testRegionTTLInvalidate
> -------------------------------------------------------------
>
>                 Key: GEODE-4238
>                 URL: https://issues.apache.org/jira/browse/GEODE-4238
>             Project: Geode
>          Issue Type: Bug
>          Components: expiration
>            Reporter: Nick Reich
>            Assignee: Kirk Lund
>            Priority: Major
>              Labels: pull-request-available
>
> {noformat}
> org.apache.geode.cache30.RegionExpirationDUnitTest > testRegionTTLInvalidate 
> FAILED
>         org.apache.geode.test.dunit.RMIException: While invoking 
> org.apache.geode.cache30.RegionExpirationDUnitTest$6.run in VM 1 running on 
> Host cad33bfaeb5e with 4 VMs
>         at org.apache.geode.test.dunit.VM.invoke(VM.java:393)
>         at org.apache.geode.test.dunit.VM.invoke(VM.java:363)
>         at org.apache.geode.test.dunit.VM.invoke(VM.java:308)
>         at 
> org.apache.geode.cache30.RegionExpirationDUnitTest._testRegionTTL(RegionExpirationDUnitTest.java:217)
>         at 
> org.apache.geode.cache30.RegionExpirationDUnitTest.testRegionTTLInvalidate(RegionExpirationDUnitTest.java:96)
> Caused by:
>         java.lang.AssertionError
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to