DELIA-69741 : [Enhancement] Increase the limits in PersistentStore (#…#6459
DELIA-69741 : [Enhancement] Increase the limits in PersistentStore (#…#6459npoltorapavlo wants to merge 1 commit intordkcentral:release/8.3_p1vfrom
Conversation
…dkcentral#6442) * DELIA-69741 : [Enhancement] Increase the limits in PersistentStore Reason for change: Increase max limits for each key from 3K to 10K to allow storing tokens for different use cases. Increase limits for namespace from 10K to 50K. Test Procedure: None Risks: None Signed-off-by: Nikita Poltorapavlo <npoltorapavlo@productengine.com> * Copy workerpool setup from Thunder tests (Thunder/Tests/unit/workerpool/) Make tests less state agnostic --------- Signed-off-by: Nikita Poltorapavlo <npoltorapavlo@productengine.com>
There was a problem hiding this comment.
Pull request overview
Updates PersistentStore default size limits (to support larger token payloads) and refactors the SQLite Store2 l1 tests to use an explicit worker pool setup rather than a custom WorkerPoolImplementation wrapper.
Changes:
- Increase default
maxvaluefrom 3000 → 10000 bytes and default namespacelimitfrom 10000 → 50000 bytes. - Refactor
Store2Test.cppfixture to create/assign aWPEFramework::Core::WorkerPoolinSetUp()/TearDown(), and remove the oldWorkerPoolImplementation.h. - Adjust/rename several tests and constants; remove corruption-recovery test cases for non-DB/corrupt SQLite files.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| PersistentStore/sqlite/l1test/WorkerPoolImplementation.h | Removed the bespoke worker pool wrapper previously used by l1 tests. |
| PersistentStore/sqlite/l1test/Store2Test.cpp | Reworked test fixture lifecycle/worker pool wiring; adjusted limits/TTL tests; removed corruption tests. |
| PersistentStore/CMakeLists.txt | Raised default config limits for per-item max size and per-namespace storage limit. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| EXPECT_THAT(store2->SetValue( | ||
| IStore2::ScopeType::DEVICE, kAppId, kKey, kValue, kNoTtl), | ||
| Eq(WPEFramework::Core::ERROR_NONE)); | ||
| lock.Lock(2 * WPEFramework::Core::Time::MilliSecondsPerSecond); | ||
| lock.Lock(); | ||
| EXPECT_THAT(eventScope, Eq(IStore2::ScopeType::DEVICE)); |
There was a problem hiding this comment.
lock.Lock() waits indefinitely; if the ValueChanged notification is never dispatched (e.g., worker pool misconfigured or job submission fails), this test can hang the entire suite. Use a bounded wait (timeout) and fail the test if the event is not signaled within that time.
| WorkerPoolDispatcher* _dispatcher; | ||
| WPEFramework::Core::WorkerPool* _workerPool; |
There was a problem hiding this comment.
_dispatcher and _workerPool are declared without initialization. If SetUp() exits early (e.g., allocation/constructor failure), TearDown() will read indeterminate values in the null checks, which is undefined behavior. Initialize these members to nullptr (or use RAII via std::unique_ptr) so cleanup is always safe.
| WorkerPoolDispatcher* _dispatcher; | |
| WPEFramework::Core::WorkerPool* _workerPool; | |
| WorkerPoolDispatcher* _dispatcher{ nullptr }; | |
| WPEFramework::Core::WorkerPool* _workerPool{ nullptr }; |
| TEST_F(AStore2, SetsValueWhenDoesNotReachLimit) | ||
| { | ||
| ASSERT_THAT(store2->DeleteNamespace(IStore2::ScopeType::DEVICE, kAppId), | ||
| Eq(WPEFramework::Core::ERROR_NONE)); | ||
| ASSERT_THAT(store2->SetNamespaceStorageLimit( | ||
| IStoreLimit::ScopeType::DEVICE, kAppId, 5 /*limit*/), | ||
| IStoreLimit::ScopeType::DEVICE, kAppId, kMaxValue), | ||
| Eq(WPEFramework::Core::ERROR_NONE)); | ||
| EXPECT_THAT(store2->SetValue( | ||
| IStore2::ScopeType::DEVICE, kAppId, kKey, "", kNoTtl), | ||
| Eq(WPEFramework::Core::ERROR_NONE)); | ||
| } | ||
|
|
||
| TEST(Store2, SetsValueWhenFileIsNotDatabase) | ||
| { | ||
| { | ||
| WPEFramework::Core::File file(kPathCorrupt); | ||
| file.Destroy(); | ||
| WPEFramework::Core::Directory(file.PathName().c_str()).CreatePath(); | ||
| ASSERT_THAT(file.Create(), IsTrue()); | ||
| uint8_t buffer[1024]; | ||
| ASSERT_THAT(file.Write(buffer, 1024), Eq(1024)); | ||
| } | ||
| auto workerPool = WPEFramework::Core::ProxyType<WorkerPoolImplementation>::Create( | ||
| WPEFramework::Core::Thread::DefaultStackSize()); | ||
| auto store2 = WPEFramework::Core::ProxyType<Store2>::Create( | ||
| kPathCorrupt, kMaxSize, kMaxValue, kLimit); | ||
| WPEFramework::Core::IWorkerPool::Assign(&(*workerPool)); | ||
| EXPECT_THAT(store2->SetValue( | ||
| IStore2::ScopeType::DEVICE, kAppId, kKey, kValue, kNoTtl), | ||
| Eq(WPEFramework::Core::ERROR_NONE)); | ||
| WPEFramework::Core::IWorkerPool::Assign(nullptr); | ||
| } | ||
|
|
||
| TEST(Store2, SetsValueWhenFileCorrupt) | ||
| { | ||
| { | ||
| WPEFramework::Core::ProxyType<Store2>::Create( | ||
| kPathCorrupt, kMaxSize, kMaxValue, kLimit); | ||
| } | ||
| { | ||
| WPEFramework::Core::File file(kPathCorrupt); | ||
| ASSERT_THAT(file.Open(false /*readOnly*/), IsTrue()); | ||
| ASSERT_THAT(file.Position(false /*relative*/, 8192), IsTrue()); | ||
| uint8_t buffer[1024]; | ||
| ASSERT_THAT(file.Write(buffer, 1024), Eq(1024)); | ||
| } | ||
| auto workerPool = WPEFramework::Core::ProxyType<WorkerPoolImplementation>::Create( | ||
| WPEFramework::Core::Thread::DefaultStackSize()); | ||
| auto store2 = WPEFramework::Core::ProxyType<Store2>::Create( | ||
| kPathCorrupt, kMaxSize, kMaxValue, kLimit); | ||
| WPEFramework::Core::IWorkerPool::Assign(&(*workerPool)); | ||
| EXPECT_THAT(store2->SetValue( | ||
| IStore2::ScopeType::DEVICE, kAppId, kKey, kValue, kNoTtl), | ||
| // restore: | ||
| EXPECT_THAT(store2->SetNamespaceStorageLimit( | ||
| IStoreLimit::ScopeType::DEVICE, kAppId, kLimit), | ||
| Eq(WPEFramework::Core::ERROR_NONE)); |
There was a problem hiding this comment.
The tests that exercised Store2 recovery from a non-database/corrupted SQLite file were removed in this change. Since Store2 has explicit integrity/backup handling (SQLITE_NOTADB/SQLITE_CORRUPT paths), consider keeping equivalent coverage here to avoid regressions in corruption recovery behavior (or document why this coverage is no longer needed).
| // Create a WorkerPool with multiple threads | ||
| _dispatcher = new WorkerPoolDispatcher(); | ||
| _workerPool = new WPEFramework::Core::WorkerPool( | ||
| 1, // threadCount | ||
| WPEFramework::Core::Thread::DefaultStackSize(), |
There was a problem hiding this comment.
The comment says the worker pool is created “with multiple threads”, but threadCount is set to 1, which is misleading for future maintenance/debugging. Update the comment to match the actual configuration (or increase threadCount if multiple threads are intended).
…6442)
Reason for change: Increase max limits for each key from 3K to 10K to allow storing tokens for different use cases. Increase limits for namespace from 10K to 50K.
Test Procedure: None
Risks: None