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 2021/09/30 13:56:37 UTC

[GitHub] [geode-native] alb3rtobr commented on a change in pull request #864: GEODE-9576: Fix for single-hop function execution

alb3rtobr commented on a change in pull request #864:
URL: https://github.com/apache/geode-native/pull/864#discussion_r719434065



##########
File path: cppcache/integration/test/FunctionExecutionTest.cpp
##########
@@ -175,6 +196,88 @@ TEST(FunctionExecutionTest,
   cache.close();
 }
 
+void populateRegion(const std::shared_ptr<Region> &region) {
+  for (int i = 0; i < PARTITION_REGION_ENTRIES_SIZE; i++) {
+    region->put("KEY--" + std::to_string(i), "VALUE--" + std::to_string(i));
+  }
+}
+
+void waitUntilPRMetadataIsRefreshed(CacheImpl *cacheImpl) {
+  auto end = std::chrono::system_clock::now() + std::chrono::minutes(2);
+  while (!cacheImpl->getAndResetPrMetadataUpdatedFlag()) {
+    std::this_thread::sleep_for(std::chrono::milliseconds(200));
+    ASSERT_FALSE(std::chrono::system_clock::now() > end);
+  }
+}
+
+TEST(FunctionExecutionTest, FunctionExecutionWithIncompleteBucketLocations) {
+  std::vector<uint16_t> serverPorts;
+  serverPorts.push_back(Framework::getAvailablePort());
+  serverPorts.push_back(Framework::getAvailablePort());
+  serverPorts.push_back(Framework::getAvailablePort());
+  Cluster cluster{LocatorCount{1}, ServerCount{3}, serverPorts};
+
+  cluster.start([&]() {
+    cluster.getGfsh()
+        .deploy()
+        .jar(getFrameworkString(FrameworkVariable::JavaObjectJarPath))
+        .execute();
+  });
+
+  cluster.getGfsh()
+      .create()
+      .region()
+      .withName("partition_region")
+      .withType("PARTITION")
+      .execute();
+
+  auto cache = CacheFactory().create();
+  auto poolFactory = cache.getPoolManager().createFactory();
+
+  ServerAddress serverAddress = cluster.getServers()[2].getAddress();
+  cluster.applyServer(poolFactory, serverAddress);
+
+  auto pool =
+      poolFactory.setPRSingleHopEnabled(true).setRetryAttempts(0).create(
+          "pool");
+
+  auto region = cache.createRegionFactory(RegionShortcut::PROXY)
+                    .setPoolName("pool")
+                    .create("partition_region");
+
+  // Populate region in a way that not all buckets are created.
+  // Servers in this case will create 88 of possible 113 buckets.
+  populateRegion(region);
+
+  // Check that PR metadata is updated. This is done to be sure
+  // that client will execute function in a non single hop manner
+  // because metadata doesn't contain all bucket locations.
+  // After metadata is refreshed, it will contain at least one
+  // bucket location.
+  CacheImpl *cacheImpl = CacheRegionHelper::getCacheImpl(&cache);
+  waitUntilPRMetadataIsRefreshed(cacheImpl);
+
+  auto functionService = FunctionService::onRegion(region);
+  auto rc =
+      functionService.withCollector(std::make_shared<TestResultCollector>())
+          .execute("MultiGetAllFunctionNonHA");
+
+  std::shared_ptr<TestResultCollector> resultCollector =
+      std::dynamic_pointer_cast<TestResultCollector>(rc);
+
+  // check that function is not re-executed
+  ASSERT_FALSE(resultCollector->isClearTriggered());
+
+  // check that PR metadata is updated after function is executed
+  waitUntilPRMetadataIsRefreshed(cacheImpl);
+
+  // check that correct nubmer of events is received in function result

Review comment:
       There is a typo here (`nubmer`)




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