Skip to content

Commit 15d241f

Browse files
Fix the flaky test RequestTokenConcurrent
Test expects that the total time taken to run 5 threads (each thread runs a auth request) is less than the total time spent in the thread during running the requests. Resolves: OLPEDGE-843 Signed-off-by: Mykhailo Kuchma <[email protected]>
1 parent 750b641 commit 15d241f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/functional/olp-cpp-sdk-authentication/HereAccountOauth2ProductionTest.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <olp/core/http/NetworkProxySettings.h>
3131
#include <testutils/CustomParameters.hpp>
3232

33+
#include "Utils.h"
34+
3335
using namespace ::olp::authentication;
3436

3537
namespace {
@@ -420,7 +422,8 @@ TEST_F(HereAccountOuauth2ProductionTest, RequestTokenConcurrent) {
420422
TokenRequest{},
421423
[&, barrier, start](TokenEndpoint::TokenResponse token_response) {
422424
auto delta = std::chrono::high_resolution_clock::now() - start;
423-
EXPECT_TRUE(token_response.IsSuccessful());
425+
EXPECT_TRUE(token_response.IsSuccessful())
426+
<< token_response.GetError().GetMessage();
424427
EXPECT_FALSE(token_response.GetResult().GetAccessToken().empty());
425428
{
426429
std::lock_guard<std::mutex> guard(global_state_mutex);
@@ -441,7 +444,7 @@ TEST_F(HereAccountOuauth2ProductionTest, RequestTokenConcurrent) {
441444

442445
auto delta_total_time =
443446
std::chrono::high_resolution_clock::now() - start_total_time;
444-
EXPECT_LE((delta_total_time * 2), delta_sum)
447+
EXPECT_LT(delta_total_time, delta_sum)
445448
<< "Expect token request operations to have happened in parallel";
446449

447450
EXPECT_EQ(access_tokens.size(), 5u);
@@ -462,7 +465,8 @@ TEST_F(HereAccountOuauth2ProductionTest, RequestTokenConcurrentFuture) {
462465
auto start = std::chrono::high_resolution_clock::now();
463466
auto token_response = token_endpoint_.RequestToken().get();
464467
auto delta = std::chrono::high_resolution_clock::now() - start;
465-
EXPECT_TRUE(token_response.IsSuccessful());
468+
EXPECT_TRUE(token_response.IsSuccessful())
469+
<< token_response.GetError().GetMessage();
466470
EXPECT_FALSE(token_response.GetResult().GetAccessToken().empty());
467471
{
468472
std::lock_guard<std::mutex> guard(global_state_mutex);
@@ -478,7 +482,7 @@ TEST_F(HereAccountOuauth2ProductionTest, RequestTokenConcurrentFuture) {
478482
threads[i].join();
479483
}
480484

481-
EXPECT_LE((delta_total_time * 2), delta_sum)
485+
EXPECT_LT(delta_total_time, delta_sum)
482486
<< "Expect token request operations to have happened in parallel";
483487

484488
EXPECT_EQ(access_tokens.size(), 5u);

0 commit comments

Comments
 (0)