You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2017/10/12 23:33:46 UTC

[geode] branch develop updated (dbda0f4 -> d0b663f)

This is an automated email from the ASF dual-hosted git repository.

klund pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git.


    from dbda0f4  GEODE-3797: Removal of CorrelationId and MessageHeader from protobuf definitions
     new 7271cbc  GEODE-3825: upgrade to JUnitParams 1.1.0
     new d0b663f  GEODE-3792: add new test PartitionedRegionCloseDUnitTest

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../cache/PartitionedRegionCloseDUnitTest.java     | 196 +++++++++++++++++++++
 gradle/dependency-versions.properties              |   2 +-
 2 files changed, 197 insertions(+), 1 deletion(-)
 create mode 100644 geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionCloseDUnitTest.java

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].

[geode] 01/02: GEODE-3825: upgrade to JUnitParams 1.1.0

Posted by kl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 7271cbcd89eaef531e8fb72f3e2fa251daf55b8a
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Thu Oct 12 10:24:26 2017 -0700

    GEODE-3825: upgrade to JUnitParams 1.1.0
---
 gradle/dependency-versions.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index a8affaa..1e2a6e5 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -63,7 +63,7 @@ json-path.version = 2.2.0
 json-path-assert.version = 2.2.0
 junit.version = 4.12
 junit-quickcheck.version = 0.7
-JUnitParams.version = 1.0.6
+JUnitParams.version = 1.1.0
 log4j.version = 2.8.2
 lucene.version = 6.4.1
 mockito-core.version = 2.8.9

-- 
To stop receiving notification emails like this one, please contact
"commits@geode.apache.org" <co...@geode.apache.org>.

[geode] 02/02: GEODE-3792: add new test PartitionedRegionCloseDUnitTest

Posted by kl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git

commit d0b663ff90c534ca71b453219341d2434fcd55c1
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Tue Oct 10 13:49:08 2017 -0700

    GEODE-3792: add new test PartitionedRegionCloseDUnitTest
---
 .../cache/PartitionedRegionCloseDUnitTest.java     | 196 +++++++++++++++++++++
 1 file changed, 196 insertions(+)

diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionCloseDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionCloseDUnitTest.java
new file mode 100644
index 0000000..e67ba2d
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionCloseDUnitTest.java
@@ -0,0 +1,196 @@
+/*
+ * 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.internal.cache;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+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.apache.geode.cache.DataPolicy;
+import org.apache.geode.cache.PartitionAttributesFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.internal.cache.partitioned.RegionAdvisor;
+import org.apache.geode.test.dunit.Host;
+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;
+
+@Category(DistributedTest.class)
+@RunWith(JUnitParamsRunner.class)
+@SuppressWarnings("serial")
+public class PartitionedRegionCloseDUnitTest implements Serializable {
+
+  private static final int TOTAL_NUM_BUCKETS = 3;
+  private static final int NUM_PUTS = 3;
+  private static final int REDUNDANT_COPIES = 1;
+
+  private String regionName;
+  private VM accessor;
+  private VM[] datastores;
+
+  @ClassRule
+  public static DistributedTestRule distributedTestRule = new DistributedTestRule();
+
+  @Rule
+  public CacheRule cacheRule = CacheRule.builder().createCacheInAll().build();
+
+  @Before
+  public void setUp() throws Exception {
+    regionName = getClass().getSimpleName();
+
+    accessor = Host.getHost(0).getVM(0);
+    datastores = new VM[3];
+    datastores[0] = Host.getHost(0).getVM(1);
+    datastores[1] = Host.getHost(0).getVM(2);
+    datastores[2] = Host.getHost(0).getVM(3);
+  }
+
+  @Test
+  @Parameters({"CLOSE_REGION", "LOCAL_DESTROY_REGION"})
+  @TestCaseName("{method}({params})")
+  public void redundantDataIsAvailableAfterRemovingOneDatastore(final RegionRemoval regionRemoval)
+      throws Exception {
+    accessor.invoke("create accessor", () -> createAccessor());
+    for (VM vm : datastores) {
+      vm.invoke("create datastore", () -> createDataStore());
+    }
+
+    accessor.invoke("put operations", () -> {
+      Region<Integer, String> region = cacheRule.getCache().getRegion(regionName);
+      for (int i = 0; i < NUM_PUTS; i++) {
+        region.put(i, "VALUE-" + i);
+      }
+    });
+
+    Node datastoreToRemove = datastores[0].invoke("get datastore node to remove", () -> {
+      Region<Integer, String> region = cacheRule.getCache().getRegion(regionName);
+      return ((PartitionedRegion) region).getNode();
+    });
+
+    datastores[0].invoke("remove PR from one datastore", () -> {
+      Region<Integer, String> region = cacheRule.getCache().getRegion(regionName);
+      regionRemoval.remove(region);
+    });
+
+    datastores[1].invoke("validate PR metadata", () -> {
+      InternalCache cache = cacheRule.getCache();
+      Region<Integer, String> region = cache.getRegion(regionName);
+
+      PartitionedRegion partitionedRegion = (PartitionedRegion) region;
+      RegionAdvisor advisor = partitionedRegion.getRegionAdvisor();
+      for (int bucketId : advisor.getBucketSet()) {
+        assertThat(advisor.getBucketOwners(bucketId))
+            .doesNotContain(datastoreToRemove.getMemberId());
+      }
+
+      Region<String, PartitionRegionConfig> prMetaData = PartitionedRegionHelper.getPRRoot(cache);
+      PartitionRegionConfig prConfig = prMetaData.get(partitionedRegion.getRegionIdentifier());
+      assertThat(prConfig.containsNode(datastoreToRemove)).isFalse();
+    });
+
+    accessor.invoke("get operations", () -> {
+      Region<Integer, String> region = cacheRule.getCache().getRegion(regionName);
+      for (int i = 0; i < NUM_PUTS; i++) {
+        assertThat(region.get(i)).isEqualTo("VALUE-" + i);
+      }
+    });
+  }
+
+  /**
+   * This test case checks that a closed PR (accessor/datastore) can be recreated.
+   */
+  @Test
+  public void closeAndRecreateInAllHasNoData() throws Exception {
+    accessor.invoke("create accessor", () -> createAccessor());
+    for (VM vm : datastores) {
+      vm.invoke("create datastore", () -> createDataStore());
+    }
+
+    accessor.invoke("put operations", () -> {
+      Region<Integer, String> region = cacheRule.getCache().getRegion(regionName);
+      for (int i = 0; i < NUM_PUTS; i++) {
+        region.put(i, "VALUE-" + i);
+      }
+    });
+
+    for (VM vm : datastores) {
+      vm.invoke("close datastore", () -> cacheRule.getCache().getRegion(regionName).close());
+    }
+    accessor.invoke("close accessor", () -> cacheRule.getCache().getRegion(regionName).close());
+
+    accessor.invoke("recreate accessor", () -> createAccessor());
+    for (VM vm : datastores) {
+      vm.invoke("recreate datastore", () -> createDataStore());
+    }
+
+    accessor.invoke("get operations", () -> {
+      Region<Integer, String> region = cacheRule.getCache().getRegion(regionName);
+      for (int i = 0; i < NUM_PUTS; i++) {
+        assertThat(region.get(i)).isNull();
+      }
+    });
+  }
+
+  private void createAccessor() {
+    createRegion(true);
+  }
+
+  private void createDataStore() {
+    createRegion(false);
+  }
+
+  private void createRegion(final boolean accessor) {
+    PartitionAttributesFactory partitionFactory = new PartitionAttributesFactory();
+    partitionFactory.setRedundantCopies(REDUNDANT_COPIES);
+    if (accessor) {
+      partitionFactory.setLocalMaxMemory(0);
+    }
+    partitionFactory.setTotalNumBuckets(TOTAL_NUM_BUCKETS);
+
+    RegionFactory<String, Integer> regionFactory = cacheRule.getCache().createRegionFactory();
+    regionFactory.setDataPolicy(DataPolicy.PARTITION);
+    regionFactory.setPartitionAttributes(partitionFactory.create());
+
+    regionFactory.create(regionName);
+  }
+
+  private enum RegionRemoval {
+    CLOSE_REGION((region) -> region.close()),
+    LOCAL_DESTROY_REGION((region) -> region.localDestroyRegion());
+
+    private final Consumer<Region> strategy;
+
+    RegionRemoval(final Consumer<Region> strategy) {
+      this.strategy = strategy;
+    }
+
+    void remove(final Region region) {
+      strategy.accept(region);
+    }
+  }
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@geode.apache.org" <co...@geode.apache.org>.