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/04/26 16:22:28 UTC

[GitHub] [geode] albertogpz commented on a diff in pull request #7493: GEODE-10155: Avoid threads hanging when function execution times-out

albertogpz commented on code in PR #7493:
URL: https://github.com/apache/geode/pull/7493#discussion_r858918946


##########
geode-core/src/test/java/org/apache/geode/internal/cache/execute/PartitionedRegionFunctionResultSenderTest.java:
##########
@@ -0,0 +1,182 @@
+/*
+ * 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.execute;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
+import java.util.concurrent.TimeUnit;
+
+import org.junit.jupiter.api.Test;
+
+import org.apache.geode.cache.execute.Function;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.cache.execute.ResultCollector;
+import org.apache.geode.distributed.DistributedMember;
+import org.apache.geode.distributed.internal.DistributionManager;
+import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.execute.metrics.FunctionStats;
+
+public class PartitionedRegionFunctionResultSenderTest {
+  DistributionManager dm = mock(DistributionManager.class);
+  PartitionedRegion region = mock(PartitionedRegion.class);
+  ATestResultCollector rc = new ATestResultCollector();
+  ServerToClientFunctionResultSender serverToClientFunctionResultSender =
+      mock(ServerToClientFunctionResultSender.class);
+  FunctionStats functionStats = mock(FunctionStats.class);
+
+  @Test
+  public void whenResponseToClientInLastResultFailsEndResultsIsCalled_OnlyLocal_NotOnlyRemote() {
+    doThrow(new FunctionException()).when(serverToClientFunctionResultSender)
+        .lastResult(any(), any());
+    PartitionedRegionFunctionResultSender sender =
+        new PartitionedRegionFunctionResultSender(dm,
+            region, 1, rc, serverToClientFunctionResultSender, true, false, true,
+            new TestFunction(), new int[2]);
+
+    try {
+      sender.lastResult(new FunctionException());
+    } catch (FunctionException expected) {
+    }

Review Comment:
   I did not add the assertion because it was not something I wanted to verify in the test. Nevertheless, thanks to your comment I have seen that the exception is not thrown so I have removed it.
   I have also changed the test cases so that instead of sending an exception, an object is sent.



-- 
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