[ https://issues.apache.org/jira/browse/GEODE-8693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17233057#comment-17233057 ]
ASF GitHub Bot commented on GEODE-8693: --------------------------------------- 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: us...@infra.apache.org > C++ native client Function.execute() with onServers does not throw exception > if one of the servers goes down while executing the function. > ------------------------------------------------------------------------------------------------------------------------------------------ > > Key: GEODE-8693 > URL: https://issues.apache.org/jira/browse/GEODE-8693 > Project: Geode > Issue Type: Bug > Components: native client > Reporter: Alberto Gomez > Assignee: Alberto Gomez > Priority: Major > Labels: pull-request-available > > According to the Apache Geode Native C++ API documentation, the > FunctionService.onServers() function will throw an Exception if one of the > servers goes down while dispatching or executing the function on the server. > Nevertheless, currently no exception is thrown in that case. -- This message was sent by Atlassian Jira (v8.3.4#803005)