Skip to content

Commit ee1ff45

Browse files
authored
Fix CacheSettings::openOptions not used by cache. (#1206)
Mutable cache always created with OpenOptions::Default instead of one provided by CacheSettings. This makes impossible to enable leveldb crc check for the cache. Added somehow missed include needed for std::this_thread::sleep_for. Relates-To: OAM-1088 Signed-off-by: Kostiantyn Zvieriev <[email protected]>
1 parent 6226950 commit ee1ff45

27 files changed

+59
-21
lines changed

olp-cpp-sdk-authentication/src/AuthenticationClientImpl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <chrono>
2323
#include <iomanip>
2424
#include <sstream>
25+
#include <thread>
2526

2627
#include <rapidjson/document.h>
2728
#include <rapidjson/istreamwrapper.h>

olp-cpp-sdk-core/src/cache/DefaultCacheImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ DefaultCache::StorageOpenResult DefaultCacheImpl::SetupMutableCache() {
851851
mutable_cache_ = std::make_unique<DiskCache>();
852852
auto status = mutable_cache_->Open(settings_.disk_path_mutable.get(),
853853
settings_.disk_path_mutable.get(),
854-
storage_settings, OpenOptions::Default);
854+
storage_settings, settings_.openOptions);
855855
if (status == OpenResult::Repaired) {
856856
OLP_SDK_LOG_INFO(kLogTag, "Mutable cache was repaired");
857857
} else if (status == OpenResult::Fail) {

olp-cpp-sdk-core/tests/cache/DefaultCacheImplTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20-
#include <gtest/gtest.h>
2120
#include <chrono>
21+
#include <thread>
22+
23+
#include <gtest/gtest.h>
2224

2325
#include <cache/DefaultCacheImpl.h>
2426
#include <olp/core/utils/Dir.h>

olp-cpp-sdk-core/tests/cache/DefaultCacheTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20-
#include <gtest/gtest.h>
21-
2220
#include <chrono>
2321
#include <fstream>
2422
#include <string>
2523
#include <thread>
2624

25+
#include <gtest/gtest.h>
26+
2727
#include <olp/core/cache/CacheSettings.h>
2828
#include <olp/core/cache/DefaultCache.h>
2929
#include <olp/core/porting/make_unique.h>

olp-cpp-sdk-core/tests/client/OlpClientTest.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20-
#include <gmock/gmock.h>
21-
#include <gtest/gtest.h>
22-
2320
#include <chrono>
2421
#include <future>
2522
#include <queue>
2623
#include <string>
24+
#include <thread>
25+
26+
#include <gmock/gmock.h>
27+
#include <gtest/gtest.h>
2728

2829
#include <olp/core/client/ApiError.h>
2930
#include <olp/core/client/OlpClient.h>

olp-cpp-sdk-core/tests/client/PendingUrlRequestsTest.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20-
#include <gmock/gmock.h>
21-
#include <gtest/gtest.h>
22-
2320
#include <chrono>
2421
#include <future>
2522
#include <queue>
2623
#include <sstream>
2724
#include <string>
25+
#include <thread>
26+
27+
#include <gmock/gmock.h>
28+
#include <gtest/gtest.h>
2829

2930
#include <olp/core/client/ApiError.h>
3031
#include <olp/core/client/OlpClient.h>

olp-cpp-sdk-core/tests/thread/SyncQueueTest.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20-
#include <gmock/gmock.h>
21-
#include <gtest/gtest.h>
2220
#include <atomic>
2321
#include <chrono>
2422
#include <thread>
2523

24+
#include <gmock/gmock.h>
25+
#include <gtest/gtest.h>
26+
2627
#include <olp/core/thread/SyncQueue.h>
2728

2829
using SyncTaskType = std::function<void()>;
@@ -34,8 +35,7 @@ using SyncQueueIncFifo = olp::thread::SyncQueueFifo<SyncIncType>;
3435
using SharedQueueType = std::shared_ptr<std::string>;
3536
using SyncQueueShared = olp::thread::SyncQueueFifo<SharedQueueType>;
3637

37-
using namespace ::testing;
38-
using namespace std::chrono;
38+
using milliseconds = std::chrono::milliseconds;
3939

4040
TEST(SyncQueueTest, Initialize) {
4141
SCOPED_TRACE("Default initialized not closed");
@@ -190,11 +190,12 @@ TEST(SyncQueueTest, ConcurrentUsage) {
190190
}
191191

192192
// Wait for threads to finish but do not exceed 1min
193-
const auto start = system_clock::now();
193+
const auto start = std::chrono::system_clock::now();
194194
auto check_condition = [&]() {
195195
return counter.load() < kNumThreads &&
196-
duration_cast<milliseconds>(system_clock::now() - start).count() <
197-
1000u;
196+
std::chrono::duration_cast<milliseconds>(
197+
std::chrono::system_clock::now() - start)
198+
.count() < 1000u;
198199
};
199200

200201
while (check_condition()) {
@@ -203,7 +204,7 @@ TEST(SyncQueueTest, ConcurrentUsage) {
203204

204205
// Each thread should have run once, each task executed
205206
const std::vector<uint32_t> expected(kNumThreads, 1u);
206-
EXPECT_THAT(thread_counter, ContainerEq(expected));
207+
EXPECT_THAT(thread_counter, ::testing::ContainerEq(expected));
207208
EXPECT_EQ(kNumThreads, counter.load());
208209

209210
// Close and join all threads

olp-cpp-sdk-core/tests/thread/ThreadPoolTaskSchedulerTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20+
#include <thread>
2021
#include <unordered_map>
2122

2223
#include <gmock/gmock.h>

olp-cpp-sdk-dataservice-read/tests/StreamLayerClientImplTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20+
#include <thread>
21+
2022
#include <gtest/gtest.h>
2123
#include <matchers/NetworkUrlMatchers.h>
2224
#include <mocks/CacheMock.h>

olp-cpp-sdk-dataservice-read/tests/VersionedLayerClientImplTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* License-Filename: LICENSE
1818
*/
1919

20+
#include <thread>
21+
2022
#include <gtest/gtest.h>
2123
#include <matchers/NetworkUrlMatchers.h>
2224
#include <mocks/CacheMock.h>

0 commit comments

Comments
 (0)