[geode] 02/02: GEODE-9295: Added dunit test
This is an automated email from the ASF dual-hosted git repository. nnag pushed a commit to branch support/1.12 in repository https://gitbox.apache.org/repos/asf/geode.git commit 63a8fb1a7ab847f908f83a74b274e8d8fd55ccdc Author: Barry Oglesby AuthorDate: Tue Jun 15 13:54:24 2021 -0700 GEODE-9295: Added dunit test (cherry picked from commit c9d4f681d0700bd5344960f2da83ae960fc0b778) --- ...LatestLastAccessTimeMessageDistributedTest.java | 94 ++ 1 file changed, 94 insertions(+) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java new file mode 100644 index 000..c622701 --- /dev/null +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java @@ -0,0 +1,94 @@ +/* + * 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.apache.geode.test.awaitility.GeodeAwaitility.getTimeout; +import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; + +import java.io.Serializable; +import java.util.Objects; +import java.util.Set; + +import org.junit.Rule; +import org.junit.Test; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.RegionShortcut; +import org.apache.geode.cache.partition.PartitionRegionHelper; +import org.apache.geode.distributed.internal.DistributionManager; +import org.apache.geode.distributed.internal.membership.InternalDistributedMember; +import org.apache.geode.test.dunit.rules.ClusterStartupRule; +import org.apache.geode.test.dunit.rules.MemberVM; +import org.apache.geode.test.junit.rules.serializable.SerializableTestName; + +public class LatestLastAccessTimeMessageDistributedTest implements Serializable { + + @Rule + public ClusterStartupRule cluster = new ClusterStartupRule(); + + @Rule + public SerializableTestName testName = new SerializableTestName(); + + @Test + public void testSendLatestLastAccessTimeMessageToMemberWithNoRegion() { +// Start Locator +MemberVM locator = cluster.startLocatorVM(0); + +// Start servers +int locatorPort = locator.getPort(); +MemberVM server1 = +cluster.startServerVM(1, s -> s.withConnectionToLocator(locatorPort).withRegion( +RegionShortcut.PARTITION_REDUNDANT, testName.getMethodName())); +cluster.startServerVM(2, s -> s.withConnectionToLocator(locatorPort)); + +// Assign buckets to create the BucketRegions +server1.invoke(this::assignBucketsToPartitions); + +// Send LastAccessTimeMessage from server1 to server2 +server1.invoke(this::sendLastAccessTimeMessage); + } + + private void assignBucketsToPartitions() { +Cache cache = Objects.requireNonNull(ClusterStartupRule.getCache()); +PartitionedRegion pr = (PartitionedRegion) cache.getRegion(testName.getMethodName()); +PartitionRegionHelper.assignBucketsToPartitions(pr); + } + + private void sendLastAccessTimeMessage() throws InterruptedException { +// Get a BucketRegion +Cache cache = Objects.requireNonNull(ClusterStartupRule.getCache()); +PartitionedRegion pr = (PartitionedRegion) cache.getRegion(testName.getMethodName()); +BucketRegion br = pr.getBucketRegion(0); + +// Get the recipients +DistributionManager dm = br.getDistributionManager(); +Set recipients = dm.getOtherNormalDistributionManagerIds(); + +// Create and sent the LatestLastAccessTimeMessage +LatestLastAccessTimeReplyProcessor replyProcessor = +new LatestLastAccessTimeReplyProcessor(dm, recipients); +dm.putOutgoing(new LatestLastAccessTimeMessage<>(replyProcessor, recipients, br, (Object) 0)); + +// Wait for the reply. Timeout if no reply is received. +// boolean success = replyProcessor.waitForReplies(getTimeout().toMillis()); +boolean success = replyProcessor.waitForReplies(getTimeout().getValueInMS()); + +// Assert the wait was successful +assertThat(success).isTrue(); + +// Assert the latest last accessed time is 0 +
[geode] 02/02: GEODE-9295: Added dunit test
This is an automated email from the ASF dual-hosted git repository. nnag pushed a commit to branch support/1.13 in repository https://gitbox.apache.org/repos/asf/geode.git commit a56883dd8777200f64ae7778c48e52399f49e011 Author: Barry Oglesby AuthorDate: Tue Jun 15 13:54:24 2021 -0700 GEODE-9295: Added dunit test (cherry picked from commit c9d4f681d0700bd5344960f2da83ae960fc0b778) --- ...LatestLastAccessTimeMessageDistributedTest.java | 93 ++ 1 file changed, 93 insertions(+) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java new file mode 100644 index 000..098b572 --- /dev/null +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java @@ -0,0 +1,93 @@ +/* + * 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.apache.geode.test.awaitility.GeodeAwaitility.getTimeout; +import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; + +import java.io.Serializable; +import java.util.Objects; +import java.util.Set; + +import org.junit.Rule; +import org.junit.Test; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.RegionShortcut; +import org.apache.geode.cache.partition.PartitionRegionHelper; +import org.apache.geode.distributed.internal.DistributionManager; +import org.apache.geode.distributed.internal.membership.InternalDistributedMember; +import org.apache.geode.test.dunit.rules.ClusterStartupRule; +import org.apache.geode.test.dunit.rules.MemberVM; +import org.apache.geode.test.junit.rules.serializable.SerializableTestName; + +public class LatestLastAccessTimeMessageDistributedTest implements Serializable { + + @Rule + public ClusterStartupRule cluster = new ClusterStartupRule(); + + @Rule + public SerializableTestName testName = new SerializableTestName(); + + @Test + public void testSendLatestLastAccessTimeMessageToMemberWithNoRegion() { +// Start Locator +MemberVM locator = cluster.startLocatorVM(0); + +// Start servers +int locatorPort = locator.getPort(); +MemberVM server1 = +cluster.startServerVM(1, s -> s.withConnectionToLocator(locatorPort).withRegion( +RegionShortcut.PARTITION_REDUNDANT, testName.getMethodName())); +cluster.startServerVM(2, s -> s.withConnectionToLocator(locatorPort)); + +// Assign buckets to create the BucketRegions +server1.invoke(this::assignBucketsToPartitions); + +// Send LastAccessTimeMessage from server1 to server2 +server1.invoke(this::sendLastAccessTimeMessage); + } + + private void assignBucketsToPartitions() { +Cache cache = Objects.requireNonNull(ClusterStartupRule.getCache()); +PartitionedRegion pr = (PartitionedRegion) cache.getRegion(testName.getMethodName()); +PartitionRegionHelper.assignBucketsToPartitions(pr); + } + + private void sendLastAccessTimeMessage() throws InterruptedException { +// Get a BucketRegion +Cache cache = Objects.requireNonNull(ClusterStartupRule.getCache()); +PartitionedRegion pr = (PartitionedRegion) cache.getRegion(testName.getMethodName()); +BucketRegion br = pr.getBucketRegion(0); + +// Get the recipients +DistributionManager dm = br.getDistributionManager(); +Set recipients = dm.getOtherNormalDistributionManagerIds(); + +// Create and sent the LatestLastAccessTimeMessage +LatestLastAccessTimeReplyProcessor replyProcessor = +new LatestLastAccessTimeReplyProcessor(dm, recipients); +dm.putOutgoing(new LatestLastAccessTimeMessage<>(replyProcessor, recipients, br, (Object) 0)); + +// Wait for the reply. Timeout if no reply is received. +boolean success = replyProcessor.waitForReplies(getTimeout().toMillis()); + +// Assert the wait was successful +assertThat(success).isTrue(); + +// Assert the latest last accessed time is 0 +assertThat(replyProcessor.getLatestLastAccessTime()).isEqualTo(0L); + } +}
[geode] 02/02: GEODE-9295: Added dunit test
This is an automated email from the ASF dual-hosted git repository. nnag pushed a commit to branch support/1.14 in repository https://gitbox.apache.org/repos/asf/geode.git commit 509c96b640d1d595103f6caecffa41c31194e995 Author: Barry Oglesby AuthorDate: Tue Jun 15 13:54:24 2021 -0700 GEODE-9295: Added dunit test (cherry picked from commit c9d4f681d0700bd5344960f2da83ae960fc0b778) --- ...LatestLastAccessTimeMessageDistributedTest.java | 93 ++ 1 file changed, 93 insertions(+) diff --git a/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java new file mode 100644 index 000..098b572 --- /dev/null +++ b/geode-core/src/distributedTest/java/org/apache/geode/internal/cache/LatestLastAccessTimeMessageDistributedTest.java @@ -0,0 +1,93 @@ +/* + * 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.apache.geode.test.awaitility.GeodeAwaitility.getTimeout; +import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; + +import java.io.Serializable; +import java.util.Objects; +import java.util.Set; + +import org.junit.Rule; +import org.junit.Test; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.RegionShortcut; +import org.apache.geode.cache.partition.PartitionRegionHelper; +import org.apache.geode.distributed.internal.DistributionManager; +import org.apache.geode.distributed.internal.membership.InternalDistributedMember; +import org.apache.geode.test.dunit.rules.ClusterStartupRule; +import org.apache.geode.test.dunit.rules.MemberVM; +import org.apache.geode.test.junit.rules.serializable.SerializableTestName; + +public class LatestLastAccessTimeMessageDistributedTest implements Serializable { + + @Rule + public ClusterStartupRule cluster = new ClusterStartupRule(); + + @Rule + public SerializableTestName testName = new SerializableTestName(); + + @Test + public void testSendLatestLastAccessTimeMessageToMemberWithNoRegion() { +// Start Locator +MemberVM locator = cluster.startLocatorVM(0); + +// Start servers +int locatorPort = locator.getPort(); +MemberVM server1 = +cluster.startServerVM(1, s -> s.withConnectionToLocator(locatorPort).withRegion( +RegionShortcut.PARTITION_REDUNDANT, testName.getMethodName())); +cluster.startServerVM(2, s -> s.withConnectionToLocator(locatorPort)); + +// Assign buckets to create the BucketRegions +server1.invoke(this::assignBucketsToPartitions); + +// Send LastAccessTimeMessage from server1 to server2 +server1.invoke(this::sendLastAccessTimeMessage); + } + + private void assignBucketsToPartitions() { +Cache cache = Objects.requireNonNull(ClusterStartupRule.getCache()); +PartitionedRegion pr = (PartitionedRegion) cache.getRegion(testName.getMethodName()); +PartitionRegionHelper.assignBucketsToPartitions(pr); + } + + private void sendLastAccessTimeMessage() throws InterruptedException { +// Get a BucketRegion +Cache cache = Objects.requireNonNull(ClusterStartupRule.getCache()); +PartitionedRegion pr = (PartitionedRegion) cache.getRegion(testName.getMethodName()); +BucketRegion br = pr.getBucketRegion(0); + +// Get the recipients +DistributionManager dm = br.getDistributionManager(); +Set recipients = dm.getOtherNormalDistributionManagerIds(); + +// Create and sent the LatestLastAccessTimeMessage +LatestLastAccessTimeReplyProcessor replyProcessor = +new LatestLastAccessTimeReplyProcessor(dm, recipients); +dm.putOutgoing(new LatestLastAccessTimeMessage<>(replyProcessor, recipients, br, (Object) 0)); + +// Wait for the reply. Timeout if no reply is received. +boolean success = replyProcessor.waitForReplies(getTimeout().toMillis()); + +// Assert the wait was successful +assertThat(success).isTrue(); + +// Assert the latest last accessed time is 0 +assertThat(replyProcessor.getLatestLastAccessTime()).isEqualTo(0L); + } +}