From ba809b9ba876ceb1b9472ca1f1e4ddf9a533c1cc Mon Sep 17 00:00:00 2001 From: chenchaohao Date: Mon, 1 Apr 2024 10:30:03 +0800 Subject: [PATCH] value max size 16M Signed-off-by: chenchaohao --- .../test/unittest/device_kvstore_test.cpp | 2 +- .../unittest/single_kvstore_client_test.cpp | 2 +- .../kvdb/include/single_store_impl.h | 2 +- .../kvdb/test/single_store_impl_test.cpp | 4 +- .../common/include/db_constant.h | 2 +- .../src/oh_adapter/src/rd_sqlite_utils.cpp | 2 +- .../relational_store_sqlite_ext.cpp | 2 +- .../storage/src/sqlite/sqlite_utils.cpp | 2 +- ...stributeddb_interfaces_index_unit_test.cpp | 4 +- .../distributeddb_sqlite_utils_test.cpp | 2 +- .../distributeddb_storage_query_sync_test.cpp | 18 ++-- ...rage_single_ver_natural_store_testcase.cpp | 94 +++++++++++++++++++ ...torage_single_ver_natural_store_testcase.h | 3 + ...e_sqlite_single_ver_natural_store_test.cpp | 46 +++++++++ ...ributeddb_storage_subscribe_query_test.cpp | 2 +- .../distributeddb_multi_ver_p2p_sync_test.cpp | 2 +- ...buteddb_single_ver_p2p_sync_check_test.cpp | 2 +- 17 files changed, 167 insertions(+), 24 deletions(-) diff --git a/frameworks/innerkitsimpl/distributeddatafwk/test/unittest/device_kvstore_test.cpp b/frameworks/innerkitsimpl/distributeddatafwk/test/unittest/device_kvstore_test.cpp index fede017944d..73d512252ee 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/test/unittest/device_kvstore_test.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/test/unittest/device_kvstore_test.cpp @@ -41,7 +41,7 @@ public: static Status status_; static std::string deviceId_; static Options options_; - static const int MAX_VALUE_SIZE = 4 * 1024 * 1024; // max value size is 4M.; + static const int MAX_VALUE_SIZE = 16 * 1024 * 1024; // max value size is 4M.; }; const std::string VALID_SCHEMA = "{\"SCHEMA_VERSION\":\"1.0\"," diff --git a/frameworks/innerkitsimpl/distributeddatafwk/test/unittest/single_kvstore_client_test.cpp b/frameworks/innerkitsimpl/distributeddatafwk/test/unittest/single_kvstore_client_test.cpp index 91379f2c9c9..cb4faf03486 100644 --- a/frameworks/innerkitsimpl/distributeddatafwk/test/unittest/single_kvstore_client_test.cpp +++ b/frameworks/innerkitsimpl/distributeddatafwk/test/unittest/single_kvstore_client_test.cpp @@ -50,7 +50,7 @@ const std::string VALID_SCHEMA_STRICT_DEFINE = "{\"SCHEMA_VERSION\":\"1.0\"," std::shared_ptr SingleKvStoreClientTest::singleKvStore = nullptr; Status SingleKvStoreClientTest::status_ = Status::ERROR; -int SingleKvStoreClientTest::MAX_VALUE_SIZE = 4 * 1024 * 1024; // max value size is 4M. +int SingleKvStoreClientTest::MAX_VALUE_SIZE = 16 * 1024 * 1024; // max value size is 4M. void SingleKvStoreClientTest::SetUpTestCase(void) { diff --git a/frameworks/innerkitsimpl/kvdb/include/single_store_impl.h b/frameworks/innerkitsimpl/kvdb/include/single_store_impl.h index cb5d44ed689..f2690b0f607 100644 --- a/frameworks/innerkitsimpl/kvdb/include/single_store_impl.h +++ b/frameworks/innerkitsimpl/kvdb/include/single_store_impl.h @@ -94,7 +94,7 @@ protected: std::shared_ptr TakeOut(uint32_t &realType, std::shared_ptr observer); private: - static constexpr size_t MAX_VALUE_LENGTH = 4 * 1024 * 1024; + static constexpr size_t MAX_VALUE_LENGTH = 16 * 1024 * 1024; static constexpr size_t MAX_OBSERVER_SIZE = 8; Status GetResultSet(const DBQuery &query, std::shared_ptr &resultSet) const; Status GetEntries(const DBQuery &query, std::vector &entries) const; diff --git a/frameworks/innerkitsimpl/kvdb/test/single_store_impl_test.cpp b/frameworks/innerkitsimpl/kvdb/test/single_store_impl_test.cpp index 4311288801c..f4c053defc4 100644 --- a/frameworks/innerkitsimpl/kvdb/test/single_store_impl_test.cpp +++ b/frameworks/innerkitsimpl/kvdb/test/single_store_impl_test.cpp @@ -842,7 +842,7 @@ HWTEST_F(SingleStoreImplTest, MaxLogSizeTest, TestSize.Level0) * @tc.expected: step1. Returns SUCCESS. */ std::string key; - std::vector value = Random(4 * 1024 * 1024); + std::vector value = Random(16 * 1024 * 1024); key = "test0"; EXPECT_EQ(kvStore_->Put(key, value), SUCCESS); key = "test1"; @@ -900,7 +900,7 @@ HWTEST_F(SingleStoreImplTest, MaxLogSizeTest002, TestSize.Level0) * @tc.expected: step1. Returns SUCCESS. */ std::string key; - std::vector value = Random(4 * 1024 * 1024); + std::vector value = Random(16 * 1024 * 1024); key = "test0"; EXPECT_EQ(kvStore_->Put(key, value), SUCCESS); key = "test1"; diff --git a/frameworks/libs/distributeddb/common/include/db_constant.h b/frameworks/libs/distributeddb/common/include/db_constant.h index 2f8bcf9d5a5..9f396fb725e 100644 --- a/frameworks/libs/distributeddb/common/include/db_constant.h +++ b/frameworks/libs/distributeddb/common/include/db_constant.h @@ -22,7 +22,7 @@ namespace DistributedDB { class DBConstant { public: static constexpr size_t MAX_KEY_SIZE = 1024; - static constexpr size_t MAX_VALUE_SIZE = 4194304; + static constexpr size_t MAX_VALUE_SIZE = 16777216; static constexpr size_t MAX_BATCH_SIZE = 128; static constexpr size_t MAX_DEV_LENGTH = 128; static constexpr size_t MAX_TRANSACTION_ENTRY_SIZE = 128; diff --git a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp index 27bef4c14ad..dc31268ad83 100644 --- a/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp +++ b/frameworks/libs/distributeddb/gaussdb_rd/src/oh_adapter/src/rd_sqlite_utils.cpp @@ -20,7 +20,7 @@ #include "rd_log_print.h" namespace DocumentDB { -const int MAX_BLOB_READ_SIZE = 5 * 1024 * 1024; // 5M limit +const int MAX_BLOB_READ_SIZE = 16 * 1024 * 1024; // 5M limit const int BUSY_TIMEOUT_MS = 3000; // 3000ms for sqlite busy timeout. const std::string BEGIN_SQL = "BEGIN TRANSACTION"; const std::string BEGIN_IMMEDIATE_SQL = "BEGIN IMMEDIATE TRANSACTION"; diff --git a/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_sqlite_ext.cpp b/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_sqlite_ext.cpp index 65769550f90..869e598ad31 100644 --- a/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_sqlite_ext.cpp +++ b/frameworks/libs/distributeddb/interfaces/src/relational/relational_store_sqlite_ext.cpp @@ -63,7 +63,7 @@ constexpr int E_OK = 0; constexpr int E_ERROR = 1; constexpr int STR_TO_LL_BY_DEVALUE = 10; constexpr int BUSY_TIMEOUT = 2000; // 2s. -constexpr int MAX_BLOB_READ_SIZE = 5 * 1024 * 1024; // 5M limit +constexpr int MAX_BLOB_READ_SIZE = 16 * 1024 * 1024; // 5M limit const std::string DEVICE_TYPE = "device"; const std::string SYNC_TABLE_TYPE = "sync_table_type_"; class ValueHashCalc { diff --git a/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp b/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp index 91ef3df8380..48d2c0dc336 100644 --- a/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp +++ b/frameworks/libs/distributeddb/storage/src/sqlite/sqlite_utils.cpp @@ -47,7 +47,7 @@ namespace { const int BIND_KEY_INDEX = 1; const int BIND_VAL_INDEX = 2; const int USING_STR_LEN = -1; - const int MAX_BLOB_READ_SIZE = 5 * 1024 * 1024; // 5M limit + const int MAX_BLOB_READ_SIZE = 16 * 1024 * 1024; // 5M limit const int MAX_TEXT_READ_SIZE = 5 * 1024 * 1024; // 5M limit const std::string WAL_MODE_SQL = "PRAGMA journal_mode=WAL;"; const std::string SYNC_MODE_FULL_SQL = "PRAGMA synchronous=FULL;"; diff --git a/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_index_unit_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_index_unit_test.cpp index 1054a2f7e8a..9f9522e03de 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_index_unit_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/interfaces/distributeddb_interfaces_index_unit_test.cpp @@ -702,7 +702,7 @@ HWTEST_F(DistributedDBInterfacesIndexUnitTest, CheckSchemaSkipsize002, TestSize. * @tc.expected: step6. return OK. */ option.schema = GenerateSchemaString(g_pathGroup1, vector(), - 4 * 1024 * 1024 - 2, false, true); // skipsize in schema, 4M - 2, 1024 is scale + 16 * 1024 * 1024 - 2, false, true); // skipsize in schema, 4M - 2, 1024 is scale g_mgr.GetKvStore(storeId, option, g_kvNbDelegateCallback); ASSERT_TRUE(g_kvNbDelegatePtr != nullptr); EXPECT_EQ(g_kvDelegateStatus, OK); @@ -714,7 +714,7 @@ HWTEST_F(DistributedDBInterfacesIndexUnitTest, CheckSchemaSkipsize002, TestSize. * @tc.expected: step6. return not OK. */ option.schema = GenerateSchemaString(g_pathGroup1, vector(), - 4 * 1024 * 1024 - 1, false, true); // skipsize in schema, 4M - 1, 1024 is scale + 16 * 1024 * 1024 - 1, false, true); // skipsize in schema, 4M - 1, 1024 is scale g_mgr.GetKvStore(storeId, option, g_kvNbDelegateCallback); EXPECT_TRUE(g_kvNbDelegatePtr == nullptr); EXPECT_TRUE(g_kvDelegateStatus != OK); diff --git a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_sqlite_utils_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_sqlite_utils_test.cpp index eec9414c1a2..20c96002a5e 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_sqlite_utils_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_sqlite_utils_test.cpp @@ -30,7 +30,7 @@ namespace { string g_dbDir; sqlite3 *g_db = nullptr; - const int MAX_BLOB_READ_SIZE = 5 * 1024 * 1024; // 5M limit + const int MAX_BLOB_READ_SIZE = 16 * 1024 * 1024; // 5M limit const int MAX_TEXT_READ_SIZE = 5 * 1024 * 1024; // 5M limit } diff --git a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_query_sync_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_query_sync_test.cpp index 3db6c1b2e35..4cc0186d0c6 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_query_sync_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_query_sync_test.cpp @@ -212,7 +212,7 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, GetQuerySyncData001, TestSize.Level1 Query query = Query::Select().PrefixKey(key); QueryObject queryObj(query); - DataSizeSpecInfo specInfo = {4 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; + DataSizeSpecInfo specInfo = {16 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; std::vector entries; ContinueToken token = nullptr; EXPECT_EQ(g_store->GetSyncData(queryObj, SyncTimeRange{}, specInfo, token, entries), E_OK); @@ -252,7 +252,7 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, GetQuerySyncData002, TestSize.Level1 */ Query query = Query::Select().PrefixKey(PREFIX_KEY); QueryObject queryObj(query); - DataSizeSpecInfo specInfo = {4 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; + DataSizeSpecInfo specInfo = {16 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; std::vector entries; ContinueToken token = nullptr; EXPECT_EQ(g_store->GetSyncData(queryObj, SyncTimeRange{}, specInfo, token, entries), E_OK); @@ -321,7 +321,7 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, GetQuerySyncData004, TestSize.Level1 */ Query query = Query::Select().PrefixKey(PREFIX_KEY); QueryObject queryObj(query); - DataSizeSpecInfo specInfo = {4 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; + DataSizeSpecInfo specInfo = {16 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; std::vector entries; ContinueToken token = new (std::nothrow) SQLiteSingleVerContinueToken{SyncTimeRange{}, queryObj}; EXPECT_EQ(g_store->GetSyncDataNext(entries, token, specInfo), E_OK); @@ -384,7 +384,7 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, GetQuerySyncData006, TestSize.Level1 */ Query query = Query::Select().PrefixKey(PREFIX_KEY); QueryObject queryObj(query); - DataSizeSpecInfo specInfo = {4 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; + DataSizeSpecInfo specInfo = {16 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; std::vector entries; ContinueToken token = nullptr; EXPECT_EQ(g_store->GetSyncData(queryObj, SyncTimeRange{}, specInfo, token, entries), E_OK); @@ -662,7 +662,7 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, GetQueryID002, TestSize.Level1) EXPECT_EQ(QuerySyncObject::DeSerializeData(readParcel, queryObj2), E_OK); LOGD("Query obj after serialize!"); - DataSizeSpecInfo specInfo = {4 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; + DataSizeSpecInfo specInfo = {16 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; std::vector entries; ContinueToken token = nullptr; EXPECT_EQ(g_store->GetSyncData(queryObj2, SyncTimeRange{}, specInfo, token, entries), E_OK); @@ -734,7 +734,7 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, Serialize001, TestSize.Level1) */ Query query = Query::Select().PrefixKey(key); QueryObject queryObj(query); - DataSizeSpecInfo specInfo = {4 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; + DataSizeSpecInfo specInfo = {16 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; std::vector entries; ContinueToken token = nullptr; LOGD("Ori query obj!"); @@ -929,7 +929,7 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, querySyncByField, TestSize.Level1) Query queryAll = Query::Select(); Query queryPrefixKeyLimit = Query::Select().PrefixKey({}).Limit(1, 0); - DataSizeSpecInfo specInfo = {4 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; + DataSizeSpecInfo specInfo = {16 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; std::vector entries; ContinueToken token = nullptr; @@ -1001,7 +1001,7 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, MultiQueryParcel, TestSize.Level1) Query queryInvalidCombine = Query::Select().EqualTo("$.field_name3", 1).BeginGroup(); Query queryPrefixKeyLimit = Query::Select().PrefixKey({}).Limit(1, 0); - DataSizeSpecInfo specInfo = {4 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; + DataSizeSpecInfo specInfo = {16 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; std::vector entries; ContinueToken token = nullptr; @@ -1082,7 +1082,7 @@ HWTEST_F(DistributedDBStorageQuerySyncTest, MultiQueryGetSyncData001, TestSize.L Query query4 = Query::Select().PrefixKey({}).OrderBy("$.field_name6"); Query query5 = Query::Select().PrefixKey({}).IsNull("field_name10"); - DataSizeSpecInfo specInfo = {4 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; + DataSizeSpecInfo specInfo = {16 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; std::vector entries; ContinueToken token = nullptr; diff --git a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp index 5d7e5381192..39aedaf568f 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.cpp @@ -554,6 +554,100 @@ void DistributedDBStorageSingleVerNaturalStoreTestCase::PutSyncData003(SQLiteSin EXPECT_EQ(DistributedDBToolsUnitTest::IsValueEqual(valueRead3, dataItem3.value), true); } +/** + * @tc.name: PutLargeSyncData001 + * @tc.desc: To test the function of synchronizing the new data of the remote device that synchronizes the database. + * @tc.type: FUNC + * @tc.require: + * @tc.author: chenchaohao + */ +void DistributedDBStorageSingleVerNaturalStoreTestCase::PutLargeSyncData001(SQLiteSingleVerNaturalStore *&store, + SQLiteSingleVerNaturalStoreConnection *&connection) +{ + IOption option; + option.dataType = IOption::SYNC_DATA; + Timestamp timeBegin; + store->GetMaxTimestamp(timeBegin); + Key key1; + Value value1; + DistributedDBToolsUnitTest::GetRandomKeyValue(key1, 13); // random size + DistributedDBToolsUnitTest::GetRandomKeyValue(value1, 15728640); // 15MB + + /** + * @tc.steps:step1/2. Set Ioption to synchronous data and insert a (key1, value1) data record by put interface. + */ + EXPECT_EQ(connection->Put(option, key1, value1), E_OK); + Timestamp timeEnd; + store->GetMaxTimestamp(timeEnd); + EXPECT_GT(timeEnd, timeBegin); + + DataItem item1; + std::vector vect; + item1.key = key1; + DistributedDBToolsUnitTest::GetRandomKeyValue(item1.value, 18); // random size + item1.timestamp = timeBegin; + item1.writeTimestamp = item1.timestamp; + item1.flag = 0; + vect.push_back(item1); + + /** + * @tc.steps:step3. Insert a (key1, value2!=value1, timestamp, false) data record + * through the PutSyncData interface. The value of timestamp is less than or equal + * to the value of timestamp. For Compare the timestamp to determine whether to synchronization data. + * @tc.expected: step3. Return OK. + */ + EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(store, vect, "deviceB"), E_OK); + + /** + * @tc.steps:step4. The Ioption is set to synchronize data + * through the Get interface to obtain the value data of the key1. + * @tc.expected: step4. Return OK.The obtained value is value1. + */ + Value valueRead; + EXPECT_EQ(connection->Get(option, key1, valueRead), E_OK); + EXPECT_EQ(DistributedDBToolsUnitTest::IsValueEqual(valueRead, value1), true); + + item1.timestamp = timeEnd + 1; + item1.writeTimestamp = item1.timestamp; + vect.clear(); + vect.push_back(item1); + + /** + * @tc.steps:step5. Insert a (key1, value3!=value1, timestamp, false) data record + * through the PutSyncData interface of the NaturalStore. The value of timestamp + * is greater than that of timestamp inserted in 2. + * @tc.expected: step5. Return OK. + */ + EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(store, vect, "deviceB"), E_OK); + + /** + * @tc.steps:step6. The Ioption is set to synchronize data through the Get interface + * to obtain the value data of the key1. + * @tc.expected: step6. Return OK. + */ + EXPECT_EQ(connection->Get(option, key1, valueRead), E_OK); + EXPECT_EQ(DistributedDBToolsUnitTest::IsValueEqual(item1.value, valueRead), true); + + DistributedDBToolsUnitTest::GetRandomKeyValue(item1.key, 35); // random size + DistributedDBToolsUnitTest::GetRandomKeyValue(item1.value, 47); // random size + vect.clear(); + vect.push_back(item1); + + /** + * @tc.steps:step7. Insert a (key2, value4) data record through the PutSyncData interface. + * @tc.expected: step7. Return OK. + */ + EXPECT_EQ(DistributedDBToolsUnitTest::PutSyncDataTest(store, vect, "deviceB"), E_OK); + + /** + * @tc.steps:step8. The Ioption is set to synchronize data + * through the Get interface to obtain the value data of the key2. + * @tc.expected: step8. Returns OK, and the obtained data is value4. + */ + EXPECT_EQ(connection->Get(option, item1.key, valueRead), E_OK); + EXPECT_EQ(DistributedDBToolsUnitTest::IsValueEqual(item1.value, valueRead), true); +} + /** * @tc.name: PutMetaData001 * @tc.desc: Test metadata insertion and modification. diff --git a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.h b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.h index 0846199cd3d..e7fd64a25bd 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.h +++ b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_single_ver_natural_store_testcase.h @@ -66,6 +66,9 @@ public: static void PutSyncData003(DistributedDB::SQLiteSingleVerNaturalStore *&store, DistributedDB::SQLiteSingleVerNaturalStoreConnection *&connection); + static void PutLargeSyncData001(DistributedDB::SQLiteSingleVerNaturalStore *&store, + DistributedDB::SQLiteSingleVerNaturalStoreConnection *&connection); + static void PutMetaData001(DistributedDB::SQLiteSingleVerNaturalStore *&store, DistributedDB::SQLiteSingleVerNaturalStoreConnection *&connection); diff --git a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_sqlite_single_ver_natural_store_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_sqlite_single_ver_natural_store_test.cpp index 075e76053d7..9975583214a 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_sqlite_single_ver_natural_store_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_sqlite_single_ver_natural_store_test.cpp @@ -1147,4 +1147,50 @@ HWTEST_F(DistributedDBStorageSQLiteSingleVerNaturalStoreTest, MigrationAndReleas store->DecObjRef(store); } } + +/** + * @tc.name: PutLargeSyncData001 + * @tc.desc: To test the function of synchronizing the new data of the remote device that synchronizes the database. + * @tc.type: FUNC + * @tc.require: + * @tc.author: chenchaohao + */ +HWTEST_F(DistributedDBStorageSQLiteSingleVerNaturalStoreTest, PutLargeSyncData001, TestSize.Level1) +{ + /** + * @tc.steps:step1/2. Set Ioption to synchronous data and insert a (key1, value1) data record by put interface. + */ + /** + * @tc.steps:step3. Insert a (key1, value2!=value1, timestamp, false) data record + * through the PutSyncData interface. The value of timestamp is less than or equal + * to the value of timestamp. For Compare the timestamp to determine whether to synchronization data. + * @tc.expected: step3. Return OK. + */ + /** + * @tc.steps:step4. The Ioption is set to synchronize data + * through the Get interface to obtain the value data of the key1. + * @tc.expected: step4. Return OK.The obtained value is value1. + */ + /** + * @tc.steps:step5. Insert a (key1, value3!=value1, timestamp, false) data record + * through the PutSyncData interface of the NaturalStore. The value of timestamp + * is greater than that of timestamp inserted in 2. + * @tc.expected: step5. Return OK. + */ + /** + * @tc.steps:step6. The Ioption is set to synchronize data through the Get interface + * to obtain the value data of the key1. + * @tc.expected: step6. Return OK. + */ + /** + * @tc.steps:step7. Insert a (key2, value4) data record through the PutSyncData interface. + * @tc.expected: step7. Return OK. + */ + /** + * @tc.steps:step8. The Ioption is set to synchronize data + * through the Get interface to obtain the value data of the key2. + * @tc.expected: step8. Returns OK, and the obtained data is value4. + */ + DistributedDBStorageSingleVerNaturalStoreTestCase::PutLargeSyncData001(g_store, g_connection); +} } \ No newline at end of file diff --git a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp index 9da40f841c0..10f66f2d8e2 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/storage/distributeddb_storage_subscribe_query_test.cpp @@ -736,7 +736,7 @@ HWTEST_F(DistributedDBStorageSubscribeQueryTest, GetSyncDataTransTest001, TestSi std::this_thread::sleep_for(std::chrono::milliseconds(5)); // wait for 5 ms Query query = Query::Select().EqualTo("field_name1", false); QueryObject queryObj(query); - DataSizeSpecInfo specInfo = {4 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; + DataSizeSpecInfo specInfo = {16 * 1024 * 1024, DBConstant::MAX_HPMODE_PACK_ITEM_SIZE}; std::vector entries; ContinueToken token = nullptr; EXPECT_EQ(store->GetSyncData(queryObj, SyncTimeRange{}, specInfo, token, entries), E_OK); diff --git a/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_multi_ver_p2p_sync_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_multi_ver_p2p_sync_test.cpp index 3b9a4067d7a..588ba3deeda 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_multi_ver_p2p_sync_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_multi_ver_p2p_sync_test.cpp @@ -52,7 +52,7 @@ namespace { const std::string DEVICE_C = "deviceC"; const int LIMIT_KEY_SIZE = 1024; constexpr int BIG_VALUE_SIZE = 1024 + 1; // > 1K - constexpr int LIMIT_VALUE_SIZE = 4 * 1024 * 1024; // 4M + constexpr int LIMIT_VALUE_SIZE = 16 * 1024 * 1024; // 4M KvStoreDelegateManager g_mgr("sync_test", "sync_test"); KvStoreConfig g_config; KvStoreDelegate::Option g_option; diff --git a/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp index b22e3dd1b74..be722387f0b 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_single_ver_p2p_sync_check_test.cpp @@ -61,7 +61,7 @@ namespace { placeholders::_1, placeholders::_2, std::ref(g_kvDelegateStatus), std::ref(g_kvDelegatePtr)); #ifndef LOW_LEVEL_MEM_DEV const int KEY_LEN = 20; // 20 Bytes - const int VALUE_LEN = 4 * 1024 * 1024; // 4MB + const int VALUE_LEN = 16 * 1024 * 1024; // 4MB const int ENTRY_NUM = 2; // 16 entries #endif -- Gitee