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

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

jinmeiliao commented on a change in pull request #5823:
URL: https://github.com/apache/geode/pull/5823#discussion_r539699863



##########
File path: 
geode-core/src/integrationTest/java/org/apache/geode/cache/query/partitioned/PRClearIntegrationTest.java
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.query.partitioned;
+
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.IntStream;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.geode.cache.EntryNotFoundException;
+import org.apache.geode.cache.Region;
+import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.test.junit.rules.ExecutorServiceRule;
+import org.apache.geode.test.junit.rules.ServerStarterRule;
+
+public class PRClearIntegrationTest {
+
+  @Rule
+  public ServerStarterRule server = new ServerStarterRule().withAutoStart();
+
+  @Rule
+  public ExecutorServiceRule executor = new ExecutorServiceRule();
+
+  @Test
+  public void doesNotHangWhenClearWithConcurrentPutsAndInvalidates() throws 
Exception {
+    InternalCache cache = server.getCache();
+    Region<Object, Object> region = server.createPartitionRegion("regionA", f 
-> {
+    }, f -> f.setTotalNumBuckets(1));
+    cache.getQueryService().createIndex("indexA", "r", "/regionA r");
+    region.put(0, "value0");
+
+    CompletableFuture<Void> put = executor.runAsync(() -> {
+      Thread.currentThread().setName("put-Thread");
+      IntStream.range(0, 10).forEach(i -> region.put(i, "value" + i));
+    });
+
+    CompletableFuture<Void> invalidate = executor.runAsync(() -> {
+      Thread.currentThread().setName("invalidate-Thread");
+      IntStream.range(0, 10).forEach(i -> {
+        try {
+          region.invalidate(i);
+        } catch (EntryNotFoundException e) {
+          // ignore
+        }
+      });
+    });
+
+    CompletableFuture<Void> clear = executor.runAsync(() -> {
+      Thread.currentThread().setName("Clear-Thread");
+      region.clear();
+    });
+
+    put.get(5, TimeUnit.SECONDS);

Review comment:
       that's not the purpose of this test and if we want to do that, we would 
make the test far more complicated since it's multi-threading and when we do 
assert after clear it's not guaranteed this region content is empty. 
   
   I am sure we have plenty of other tests that verifies this.




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

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


> concurrent puts and invalidates will cause PR clear to hang
> -----------------------------------------------------------
>
>                 Key: GEODE-8771
>                 URL: https://issues.apache.org/jira/browse/GEODE-8771
>             Project: Geode
>          Issue Type: Sub-task
>          Components: core
>            Reporter: Jinmei Liao
>            Assignee: Jinmei Liao
>            Priority: Major
>              Labels: GeodeOperationAPI, pull-request-available
>
> On current feature/GEODE-7665 feature branch. The below test will hang:
> {quote}public class PRClearIntegrationTest {
> @Rule
>  public ServerStarterRule server = new ServerStarterRule().withAutoStart();
> @Rule
>  public ExecutorServiceRule executor = new ExecutorServiceRule();
> @Test
>  public void test() throws Exception {
>  InternalCache cache = server.getCache();
>  Region<Object, Object> region = server.createPartitionRegion("regionA", 
> f->{}, f->f.setTotalNumBuckets(1));
>  cache.getQueryService().createIndex("indexA", "r", "/regionA r");
>  region.put(0, "value0");
> CompletableFuture<Void> put = executor.runAsync(() ->
> { 
> Thread.currentThread().setName("put-Thread");
> IntStream.range(0, 1).forEach(i-> region.invalidate(i, i)); }
> );
> CompletableFuture<Void> invalidate = executor.runAsync(() ->
> { 
> Thread.currentThread().setName("invalidate-Thread"); 
> IntStream.range(0, 1).forEach(i-> region.invalidate(0)); }
> );
> CompletableFuture<Void> clear = executor.runAsync(() ->
> { 
> Thread.currentThread().setName("Clear-Thread"); 
> region.clear(); }
> );
> put.get();
>  clear.get();
>  invalidate.get();
>  }
>  }
> {quote}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to