diff --git a/frameworks/libs/distributeddb/storage/src/storage_proxy.cpp b/frameworks/libs/distributeddb/storage/src/storage_proxy.cpp index a66d131b4dd623f69eac22a2fccc4bb7c8e9a077..ff7526fcf29d56837bf1cdb03641a194a57aa483 100644 --- a/frameworks/libs/distributeddb/storage/src/storage_proxy.cpp +++ b/frameworks/libs/distributeddb/storage/src/storage_proxy.cpp @@ -125,7 +125,7 @@ int StorageProxy::StartTransaction(TransactType type, bool isAsyncDownload) return -E_INVALID_DB; } int errCode = store_->StartTransaction(type, isAsyncDownload); - if (errCode == E_OK) { + if (errCode == E_OK && !isAsyncDownload) { transactionExeFlag_.store(true); isWrite_.store(type == TransactType::IMMEDIATE); } @@ -139,7 +139,7 @@ int StorageProxy::Commit(bool isAsyncDownload) return -E_INVALID_DB; } int errCode = store_->Commit(isAsyncDownload); - if (errCode == E_OK) { + if (errCode == E_OK && !isAsyncDownload) { transactionExeFlag_.store(false); } return errCode; @@ -152,7 +152,7 @@ int StorageProxy::Rollback(bool isAsyncDownload) return -E_INVALID_DB; } int errCode = store_->Rollback(isAsyncDownload); - if (errCode == E_OK) { + if (errCode == E_OK && !isAsyncDownload) { transactionExeFlag_.store(false); } return errCode; diff --git a/frameworks/libs/distributeddb/test/unittest/common/communicator/distributeddb_communicator_deep_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/communicator/distributeddb_communicator_deep_test.cpp index 39e449f42a52b7c9cd770724385dcabe0eb6373f..26cd007efbacfe92331d87f349790b1101780e4f 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/communicator/distributeddb_communicator_deep_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/communicator/distributeddb_communicator_deep_test.cpp @@ -52,18 +52,6 @@ public: void DistributedDBCommunicatorDeepTest::SetUpTestCase(void) { - /** - * @tc.setup: Create and init CommunicatorAggregator and AdapterStub - */ - LOGI("[UT][DeepTest][SetUpTestCase] Enter."); - bool errCode = SetUpEnv(g_envDeviceA, DEVICE_NAME_A); - ASSERT_EQ(errCode, true); - errCode = SetUpEnv(g_envDeviceB, DEVICE_NAME_B); - ASSERT_EQ(errCode, true); - errCode = SetUpEnv(g_envDeviceC, DEVICE_NAME_C); - ASSERT_EQ(errCode, true); - DoRegTransformFunction(); - CommunicatorAggregator::EnableCommunicatorNotFoundFeedback(false); } void DistributedDBCommunicatorDeepTest::TearDownTestCase(void) @@ -73,10 +61,6 @@ void DistributedDBCommunicatorDeepTest::TearDownTestCase(void) */ LOGI("[UT][DeepTest][TearDownTestCase] Enter."); std::this_thread::sleep_for(std::chrono::seconds(7)); // Wait 7 s to make sure all thread quiet and memory released - TearDownEnv(g_envDeviceA); - TearDownEnv(g_envDeviceB); - TearDownEnv(g_envDeviceC); - CommunicatorAggregator::EnableCommunicatorNotFoundFeedback(true); } namespace { @@ -117,6 +101,18 @@ void ReleaseAllCommunicator() void DistributedDBCommunicatorDeepTest::SetUp() { DistributedDBUnitTest::DistributedDBToolsUnitTest::PrintTestCaseInfo(); + /** + * @tc.setup: Create and init CommunicatorAggregator and AdapterStub + */ + LOGI("[UT][DeepTest][SetUpTestCase] Enter."); + bool isSuccess = SetUpEnv(g_envDeviceA, DEVICE_NAME_A); + ASSERT_EQ(isSuccess, true); + isSuccess = SetUpEnv(g_envDeviceB, DEVICE_NAME_B); + ASSERT_EQ(isSuccess, true); + isSuccess = SetUpEnv(g_envDeviceC, DEVICE_NAME_C); + ASSERT_EQ(isSuccess, true); + DoRegTransformFunction(); + CommunicatorAggregator::EnableCommunicatorNotFoundFeedback(false); /** * @tc.setup: Alloc communicator AA, AB, BB, BC, CC, CA */ @@ -129,6 +125,10 @@ void DistributedDBCommunicatorDeepTest::TearDown() * @tc.teardown: Release communicator AA, AB, BB, BC, CC, CA */ ReleaseAllCommunicator(); + TearDownEnv(g_envDeviceA); + TearDownEnv(g_envDeviceB); + TearDownEnv(g_envDeviceC); + CommunicatorAggregator::EnableCommunicatorNotFoundFeedback(true); std::this_thread::sleep_for(std::chrono::milliseconds(200)); // Wait 200 ms to make sure all thread quiet } diff --git a/frameworks/libs/distributeddb/test/unittest/common/syncer/cloud/distributeddb_cloud_async_download_assets_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/syncer/cloud/distributeddb_cloud_async_download_assets_test.cpp index 2724f3c047599fad8c3f24e9a4d01359128a714f..652137e6ffa92737a8110f8265fc4cb32c5f67da 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/syncer/cloud/distributeddb_cloud_async_download_assets_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/syncer/cloud/distributeddb_cloud_async_download_assets_test.cpp @@ -1159,7 +1159,7 @@ void DistributedDBCloudAsyncDownloadAssetsTest::UpdateLocalAndCheckUploadCount(c HWTEST_F(DistributedDBCloudAsyncDownloadAssetsTest, AsyncAbnormalDownload007, TestSize.Level1) { int cloudCount = 10; - UpdateLocalAndCheckUploadCount(true, cloudCount, cloudCount); + EXPECT_NO_FATAL_FAILURE(UpdateLocalAndCheckUploadCount(true, cloudCount, cloudCount)); } /** @@ -1271,10 +1271,10 @@ void DistributedDBCloudAsyncDownloadAssetsTest::DoSkipAssetDownload(SkipAssetTes HWTEST_F(DistributedDBCloudAsyncDownloadAssetsTest, SkipAssetDownloadTest001, TestSize.Level1) { /** - * @tc.expected: step1. sync return OK, and has 0 inconsistent records + * @tc.expected: step1. sync return OK, and has 1 inconsistent records */ SkipAssetTestParamT param = {.downloadRes = SKIP_ASSET, .useBatch = true, .useAsync = true, - .startIndex = 0, .expectInconsistentCount = 0, .expectSyncRes = OK}; + .startIndex = 0, .expectInconsistentCount = 1, .expectSyncRes = OK}; DoSkipAssetDownload(param); } diff --git a/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp index ac2257652a811032ae5be8bdc2b8759c5d3fe35f..7c2745e573790af8fd3ba7d14a038ca64f188e19 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_relational_ver_p2p_sync_test.cpp @@ -2849,6 +2849,7 @@ HWTEST_F(DistributedDBRelationalVerP2PSyncTest, AutoLaunchSyncAfterRekey_001, Te std::this_thread::sleep_for(std::chrono::minutes(1)); sqlite3_close(db); db = nullptr; + g_mgr.SetAutoLaunchRequestCallback(nullptr); } /**