You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2022/09/07 10:27:24 UTC

[GitHub] [geode] mivanac commented on a diff in pull request #7839: GEODE-10409: Fix rebalance load model missing collocated regions at s…

mivanac commented on code in PR #7839:
URL: https://github.com/apache/geode/pull/7839#discussion_r964666813


##########
geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PartitionedRegionRebalanceOpTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.partitioned;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Map;
+
+import org.junit.Test;
+
+import org.apache.geode.cache.PartitionAttributes;
+import org.apache.geode.cache.PartitionAttributesFactory;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.PartitionedRegionTestHelper;
+import org.apache.geode.internal.cache.control.InternalResourceManager;
+import org.apache.geode.internal.cache.partitioned.rebalance.model.Member;
+import org.apache.geode.internal.cache.partitioned.rebalance.model.PartitionedRegionLoadModel;
+
+
+public class PartitionedRegionRebalanceOpTest {
+  private PartitionedRegion leaderRegion;
+  private PartitionedRegion colocRegion1;
+  private PartitionedRegion colocRegion2;
+  private static final long MB = 1024 * 1024;
+
+  @Test
+  public void testAllCollocatedRegionsSetWhenRebalanceTargetIsLeaderRegion() {
+    leaderRegion = (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("leader");
+    PartitionAttributesFactory paf = new PartitionAttributesFactory();
+    PartitionAttributes pa = paf.setColocatedWith("/leader").create();
+    colocRegion1 =
+        (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("colo1", pa);
+    colocRegion2 =
+        (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("colo2", pa);
+
+    try {
+      PartitionedRegionRebalanceOp part_op =
+          new PartitionedRegionRebalanceOp(leaderRegion, false, null, false, false, null, null);
+      part_op.checkAndSetColocatedRegions();
+      assertEquals(3, part_op.colocatedRegions.size());

Review Comment:
   Please replace all with AssertJ.



##########
geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/PartitionedRegionRebalanceOpTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.partitioned;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Map;
+
+import org.junit.Test;
+
+import org.apache.geode.cache.PartitionAttributes;
+import org.apache.geode.cache.PartitionAttributesFactory;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.PartitionedRegionTestHelper;
+import org.apache.geode.internal.cache.control.InternalResourceManager;
+import org.apache.geode.internal.cache.partitioned.rebalance.model.Member;
+import org.apache.geode.internal.cache.partitioned.rebalance.model.PartitionedRegionLoadModel;
+
+
+public class PartitionedRegionRebalanceOpTest {
+  private PartitionedRegion leaderRegion;
+  private PartitionedRegion colocRegion1;
+  private PartitionedRegion colocRegion2;
+  private static final long MB = 1024 * 1024;
+
+  @Test
+  public void testAllCollocatedRegionsSetWhenRebalanceTargetIsLeaderRegion() {
+    leaderRegion = (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("leader");
+    PartitionAttributesFactory paf = new PartitionAttributesFactory();
+    PartitionAttributes pa = paf.setColocatedWith("/leader").create();
+    colocRegion1 =
+        (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("colo1", pa);
+    colocRegion2 =
+        (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("colo2", pa);
+
+    try {
+      PartitionedRegionRebalanceOp part_op =
+          new PartitionedRegionRebalanceOp(leaderRegion, false, null, false, false, null, null);
+      part_op.checkAndSetColocatedRegions();
+      assertEquals(3, part_op.colocatedRegions.size());
+    } finally {
+      colocRegion1.destroyRegion();
+      colocRegion2.destroyRegion();
+      leaderRegion.destroyRegion();
+    }
+  }
+
+  @Test
+  public void testAllCollocatedRegionsSetWhenRebalanceTargetIsCollocatedRegion() {
+    leaderRegion = (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("leader");
+    PartitionAttributesFactory paf = new PartitionAttributesFactory();
+    PartitionAttributes pa = paf.setColocatedWith("/leader").create();
+    colocRegion1 =
+        (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("colo1", pa);
+    colocRegion2 =
+        (PartitionedRegion) PartitionedRegionTestHelper.createPartionedRegion("colo2", pa);
+
+    try {
+      PartitionedRegionRebalanceOp part_op =
+          new PartitionedRegionRebalanceOp(colocRegion1, false, null, false, false, null, null);
+      part_op.checkAndSetColocatedRegions();
+      assertEquals(3, part_op.colocatedRegions.size());

Review Comment:
   Please replace all with AssertJ.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org