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 2020/11/16 20:17:55 UTC

[GitHub] [geode-native] pdxcodemonkey commented on a change in pull request #690: GEODE-8693: throw NotConnectedException if server goes down while exe…

pdxcodemonkey commented on a change in pull request #690:
URL: https://github.com/apache/geode-native/pull/690#discussion_r524546236



##########
File path: cppcache/integration/test/FunctionExecutionTest.cpp
##########
@@ -251,3 +253,79 @@ TEST(FunctionExecutionTest, OnServersWithReplicatedRegionsInPool) {
               resultList[i + ON_SERVERS_TEST_REGION_ENTRIES_SIZE / 2]);
   }
 }
+
+void executeTestFunctionOnLoopAndExpectNotConnectedException(
+    std::shared_ptr<apache::geode::client::Pool> pool) {
+  // Filter on odd keys
+  auto routingObj = CacheableVector::create();
+  for (int i = 0; i < ON_SERVERS_TEST_REGION_ENTRIES_SIZE; i++) {
+    if (i % 2 == 0) {
+      continue;
+    }
+    routingObj->push_back(CacheableString::create("KEY--" + std::to_string(i)));
+  }
+
+  auto execution = FunctionService::onServers(pool);
+
+  ASSERT_THROW(
+      {
+        while (true) {
+          // This call must eventually throw the NotConnectedException
+          auto rc =
+              execution.withArgs(routingObj).execute("MultiGetFunctionISlow");
+
+          auto executeFunctionResult = rc->getResult();
+
+          auto resultList = serverResultsToStrings(executeFunctionResult);
+
+          // Executed on 2 servers, we should have two sets of results
+          ASSERT_EQ(resultList.size(), ON_SERVERS_TEST_REGION_ENTRIES_SIZE);
+        }
+      },
+      apache::geode::client::NotConnectedException);
+}
+
+TEST(FunctionExecutionTest, OnServersOneServerGoesDown) {
+  Cluster cluster{
+      LocatorCount{1}, ServerCount{2},
+      CacheXMLFiles(
+          {std::string(getFrameworkString(FrameworkVariable::TestCacheXmlDir)) +
+               "/func_cacheserver1_pool.xml",
+           std::string(getFrameworkString(FrameworkVariable::TestCacheXmlDir)) +
+               "/func_cacheserver2_pool.xml"})};
+
+  cluster.start([&]() {
+    cluster.getGfsh()
+        .deploy()
+        .jar(getFrameworkString(FrameworkVariable::JavaObjectJarPath))
+        .execute();
+  });
+
+  auto cache = CacheFactory().set("log-level", "debug").create();
+  auto poolFactory = cache.getPoolManager().createFactory();
+
+  cluster.applyLocators(poolFactory);
+
+  auto pool =
+      poolFactory.setLoadConditioningInterval(std::chrono::milliseconds::zero())
+          .setIdleTimeout(std::chrono::milliseconds::zero())
+          .create("pool");
+
+  auto region = cache.createRegionFactory(RegionShortcut::PROXY)
+                    .setPoolName("pool")
+                    .create("partition_region");
+
+  for (int i = 0; i < ON_SERVERS_TEST_REGION_ENTRIES_SIZE; i++) {
+    region->put("KEY--" + std::to_string(i), "VALUE--" + std::to_string(i));
+  }
+
+  auto threadAux = std::make_shared<std::thread>(
+      executeTestFunctionOnLoopAndExpectNotConnectedException, pool);
+
+  // Sleep a bit to allow for some successful responses before the exception
+  sleep(5);

Review comment:
       This doesn't build on Windows:
   ```
   C:\nativeclient\cppcache\integration\test\FunctionExecutionTest.cpp(326): error C3861: 'sleep': identifier not found 
   ```
   Looks like we use `std::this_thread::sleep_for` in the rest of the code




----------------------------------------------------------------
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:
users@infra.apache.org