1
0
Fork 0

try to make the tests cope with async execution (#3982)

This commit is contained in:
Jan 2017-12-11 11:28:51 +01:00 committed by GitHub
parent 74347827bf
commit 5a4613c0bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -192,6 +192,7 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
id_first = testme.getResponse(0).result->operationID;
id_other = testme.getResponse(1).result->operationID;
startTime = TRI_microtime();
std::future<void> f1(std::async(std::launch::async, [&]{
timespec ts={0,15000000};
std::this_thread::sleep_for(std::chrono::microseconds(ts.tv_nsec / 1000L));
@ -200,7 +201,6 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
} // lambda
));
startTime = TRI_microtime();
result = testme.wait("", transId, 0, "", 0.1);
endTime = TRI_microtime();
diff = endTime - startTime;
@ -210,6 +210,7 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
f1.get();
// do second time to get other response
startTime = TRI_microtime();
std::future<void> f2(std::async(std::launch::async, [&]{
timespec ts={0, 30000000};
std::this_thread::sleep_for(std::chrono::microseconds(ts.tv_nsec / 1000L));
@ -218,7 +219,6 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
} // lambda
));
startTime = TRI_microtime();
result = testme.wait("", transId, 0, "", 0.1);
endTime = TRI_microtime();
diff = endTime - startTime;
@ -241,6 +241,7 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
id_first = testme.getResponse(0).result->operationID;
id_other = testme.getResponse(1).result->operationID;
startTime = TRI_microtime();
std::future<void> f3(std::async(std::launch::async, [&]{
timespec ts={0,15000000};
std::this_thread::sleep_for(std::chrono::microseconds(ts.tv_nsec / 1000L));
@ -249,7 +250,6 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
} // lambda
));
startTime = TRI_microtime();
result = testme.wait("", transId, 0, "", 0.1);
endTime = TRI_microtime();
diff = endTime - startTime;
@ -259,6 +259,7 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
f3.get();
// do second time to get other response
startTime = TRI_microtime();
std::future<void> f4(std::async(std::launch::async, [&]{
timespec ts={0, 30000000};
std::this_thread::sleep_for(std::chrono::microseconds(ts.tv_nsec / 1000L));
@ -267,7 +268,6 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
} // lambda
));
startTime = TRI_microtime();
result = testme.wait("", transId, 0, "", 0.1);
endTime = TRI_microtime();
diff = endTime - startTime;
@ -278,6 +278,7 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
// infinite wait
id_first = testme.addSimpleRequest(transId, CL_COMM_SUBMITTED);
startTime = TRI_microtime();
std::future<void> f5(std::async(std::launch::async, [&]{
timespec ts={0, 500000000}; //0.5 seconds
std::this_thread::sleep_for(std::chrono::microseconds(ts.tv_nsec / 1000L));
@ -286,7 +287,6 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
} // lambda
));
startTime = TRI_microtime();
result = testme.wait("", transId, 0, "", 0.0);
endTime = TRI_microtime();
diff = endTime - startTime;