This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/split_celix_cxx_option in repository https://gitbox.apache.org/repos/asf/celix.git
commit e556626ad7caf81a2969ceecc9a2a3266a3dc9e7 Author: Pepijn Noltes <[email protected]> AuthorDate: Sun Dec 4 16:36:16 2022 +0100 Change test order of promise and pushstream in cxx rsa. The test order of a remote promise and pushstream is inverted to ensure that the pubsub connection is established before testing the remote promise. --- .../gtest/src/RemoteServicesIntegrationTestSuite.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/bundles/cxx_remote_services/integration/gtest/src/RemoteServicesIntegrationTestSuite.cc b/bundles/cxx_remote_services/integration/gtest/src/RemoteServicesIntegrationTestSuite.cc index 63d47ba2..d7bd87d9 100644 --- a/bundles/cxx_remote_services/integration/gtest/src/RemoteServicesIntegrationTestSuite.cc +++ b/bundles/cxx_remote_services/integration/gtest/src/RemoteServicesIntegrationTestSuite.cc @@ -116,26 +116,33 @@ TEST_F(RemoteServicesIntegrationTestSuite, InvokeRemoteCalcService) { }) .build(); std::shared_ptr<celix::PushStream<double>> stream; - //When I call the calculator service from the client, I expect a answer - std::atomic<int> streamCount = 0; - std::atomic<double> lastValue = 0.0; + //When I call the calculator service from the client, I expect an answer count = clientCtx->useService<ICalculator>() .addUseCallback([&](auto& calc) { + std::atomic<int> streamCount{0}; + std::atomic<double> lastValue{0.0}; stream = calc.result(); auto streamEnded = stream->forEach([&](double event){ lastValue = event; streamCount++; }); + auto start = std::chrono::system_clock::now(); + auto elapsed = std::chrono::system_clock::now() - start; + while (streamCount.load() == 0 && elapsed < std::chrono::seconds{5}) { + std::this_thread::sleep_for(std::chrono::milliseconds{10}); + elapsed = std::chrono::system_clock::now() - start; + } + EXPECT_GE(streamCount,0 ); + EXPECT_GE(lastValue, 0.0); + + //note, because stream event is received the pubsub connection is ensured to be connected. auto promise = calc.add(2, 4); promise.wait(); EXPECT_TRUE(promise.isSuccessfullyResolved()); if (promise.isSuccessfullyResolved()) { EXPECT_EQ(6, promise.getValue()); } - sleep(1); - EXPECT_GE(streamCount,0 ); - EXPECT_GE(lastValue, 0.0); }) .build(); EXPECT_EQ(count, 1);
