Skip to content

Commit 1e717e9

Browse files
Add callback count check for performance test
Add logic to count callback invocations and compare it with number of API calls. Relates-To: OLPEDGE-1115 Signed-off-by: Diachenko Mykahilo <[email protected]>
1 parent efbb216 commit 1e717e9

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

tests/performance/MemoryTest.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ class MemoryTest : public ::testing::TestWithParam<TestConfiguration> {
8787
std::atomic<olp::http::RequestId> request_counter_;
8888
std::vector<std::thread> client_threads_;
8989

90-
std::atomic_int success_responses_{0};
91-
std::atomic_int failed_responses_{0};
90+
std::atomic_size_t total_requests_{0};
91+
std::atomic_size_t success_responses_{0};
92+
std::atomic_size_t failed_responses_{0};
9293

9394
std::mutex errors_mutex_;
9495
std::map<int, int> errors_;
@@ -141,6 +142,7 @@ void MemoryTest::SetUp() {
141142
using namespace olp;
142143
request_counter_.store(
143144
static_cast<http::RequestId>(http::RequestIdConstants::RequestIdMin));
145+
total_requests_.store(0);
144146
success_responses_.store(0);
145147
failed_responses_.store(0);
146148
errors_.clear();
@@ -152,14 +154,19 @@ void MemoryTest::TearDown() {
152154
}
153155
client_threads_.clear();
154156

155-
OLP_SDK_LOG_CRITICAL_INFO_F(
156-
"MemoryTest", "Test finished. Succeed responses %d, failed responses %d",
157-
success_responses_.load(), failed_responses_.load());
157+
OLP_SDK_LOG_CRITICAL_INFO_F("MemoryTest",
158+
"Test finished. Total requests %zu, succeed "
159+
"responses %zu, failed responses %zu",
160+
total_requests_.load(), success_responses_.load(),
161+
failed_responses_.load());
158162

159163
for (const auto& error : errors_) {
160164
OLP_SDK_LOG_CRITICAL_INFO_F("MemoryTest", "error %d - count %d",
161165
error.first, error.second);
162166
}
167+
168+
size_t total_requests = success_responses_.load() + failed_responses_.load();
169+
EXPECT_EQ(total_requests_.load(), total_requests);
163170
}
164171

165172
void MemoryTest::StartThreads(TestFunction test_body) {
@@ -214,7 +221,7 @@ TEST_P(MemoryTest, ReadNPartitionsFromVersionedLayer) {
214221

215222
auto request = olp::dataservice::read::DataRequest().WithPartitionId(
216223
std::to_string(partition_id));
217-
224+
total_requests_.fetch_add(1);
218225
service_client.GetData(
219226
request, [&](olp::dataservice::read::DataResponse response) {
220227
if (response.IsSuccessful()) {
@@ -260,7 +267,7 @@ TEST_P(MemoryTest, PrefetchPartitionsFromVersionedLayer) {
260267
.WithMinLevel(level)
261268
.WithVersion(17)
262269
.WithTileKeys(tile_keys);
263-
270+
total_requests_.fetch_add(1);
264271
service_client.PrefetchTiles(
265272
std::move(request),
266273
[&](olp::dataservice::read::PrefetchTilesResponse response) {

0 commit comments

Comments
 (0)