• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "rdb_general_ut.h"
17 
18 namespace DistributedDB {
19 using namespace testing::ext;
20 using namespace DistributedDB;
21 using namespace DistributedDBUnitTest;
22 
23 class DistributedDBRDBDataStatusTest : public RDBGeneralUt {
24 public:
25     void SetUp() override;
26 protected:
27     void PrepareTableBasicEnv(bool createWithTracker = false);
28     void PrepareBasicTableByType(TableSyncType type);
29     void PrepareBasicTableByType(const std::vector<std::string> &tables, TableSyncType type);
30     void DataStatusComplexTest(bool testWithTracker);
31     static UtDateBaseSchemaInfo GetDefaultSchema();
32     static UtTableSchemaInfo GetTableSchema(const std::string &table, bool noPk = false);
33     void InitCollaborationDelegate();
34     static constexpr const char *DEVICE_SYNC_TABLE = "DEVICE_SYNC_TABLE";
35     static constexpr const char *DEVICE_A = "DEVICE_A";
36     static constexpr const char *DEVICE_B = "DEVICE_B";
37     static constexpr const char *DEVICE_C = "DEVICE_C";
38     StoreInfo info1_ = {USER_ID, APP_ID, STORE_ID_1};
39     StoreInfo info2_ = {USER_ID, APP_ID, STORE_ID_2};
40 };
41 
SetUp()42 void DistributedDBRDBDataStatusTest::SetUp()
43 {
44     RDBGeneralUt::SetUp();
45     SetSchemaInfo(info1_, GetDefaultSchema());
46     SetSchemaInfo(info2_, GetDefaultSchema());
47 }
48 
GetDefaultSchema()49 UtDateBaseSchemaInfo DistributedDBRDBDataStatusTest::GetDefaultSchema()
50 {
51     UtDateBaseSchemaInfo info;
52     info.tablesInfo.push_back(GetTableSchema(DEVICE_SYNC_TABLE));
53     return info;
54 }
55 
GetTableSchema(const std::string & table,bool noPk)56 UtTableSchemaInfo DistributedDBRDBDataStatusTest::GetTableSchema(const std::string &table, bool noPk)
57 {
58     UtTableSchemaInfo tableSchema;
59     tableSchema.name = table;
60     UtFieldInfo field;
61     field.field.colName = "id";
62     field.field.type = TYPE_INDEX<int64_t>;
63     if (!noPk) {
64         field.field.primary = true;
65     }
66     tableSchema.fieldInfo.push_back(field);
67     return tableSchema;
68 }
69 
PrepareTableBasicEnv(bool createWithTracker)70 void DistributedDBRDBDataStatusTest::PrepareTableBasicEnv(bool createWithTracker)
71 {
72     /**
73      * @tc.steps: step1. Call InitDelegate interface with default split table mode.
74      * @tc.expected: step1. Ok
75      */
76     ASSERT_EQ(BasicUnitTest::InitDelegate(info1_, DEVICE_A), E_OK);
77     ASSERT_EQ(BasicUnitTest::InitDelegate(info2_, DEVICE_B), E_OK);
78     /**
79      * @tc.steps: step2. Set distributed tables.
80      * @tc.expected: step2. Ok
81      */
82     ASSERT_EQ(SetDistributedTables(info1_, {DEVICE_SYNC_TABLE}), E_OK);
83     ASSERT_EQ(SetDistributedTables(info2_, {DEVICE_SYNC_TABLE}), E_OK);
84     if (createWithTracker) {
85         ASSERT_EQ(SetTrackerTables(info1_, {DEVICE_SYNC_TABLE}), E_OK);
86         ASSERT_EQ(SetTrackerTables(info2_, {DEVICE_SYNC_TABLE}), E_OK);
87     }
88     /**
89      * @tc.steps: step3. Insert local data.
90      * @tc.expected: step3. Ok
91      */
92     InsertLocalDBData(0, 1, info1_);
93     /**
94      * @tc.steps: step4. DEV_A sync to DEV_B.
95      * @tc.expected: step4. Ok
96      */
97     BlockPush(info1_, info2_, DEVICE_SYNC_TABLE);
98     /**
99      * @tc.steps: step5. DEV_A update time
100      * @tc.expected: step5. Ok
101      */
102     auto store = GetDelegate(info1_);
103     ASSERT_NE(store, nullptr);
104     EXPECT_EQ(store->OperateDataStatus(static_cast<uint32_t>(DataOperator::UPDATE_TIME)), OK);
105 }
106 
PrepareBasicTableByType(TableSyncType type)107 void DistributedDBRDBDataStatusTest::PrepareBasicTableByType(TableSyncType type)
108 {
109     ASSERT_NO_FATAL_FAILURE(PrepareBasicTableByType({DEVICE_SYNC_TABLE}, type));
110 }
111 
PrepareBasicTableByType(const std::vector<std::string> & tables,TableSyncType type)112 void DistributedDBRDBDataStatusTest::PrepareBasicTableByType(const std::vector<std::string> &tables,
113     TableSyncType type)
114 {
115     /**
116      * @tc.steps: step1. Call InitDelegate interface with default split table mode.
117      * @tc.expected: step1. Ok
118      */
119     ASSERT_EQ(BasicUnitTest::InitDelegate(info1_, DEVICE_A), E_OK);
120     ASSERT_EQ(BasicUnitTest::InitDelegate(info2_, DEVICE_B), E_OK);
121     /**
122      * @tc.steps: step2. Set distributed tables.
123      * @tc.expected: step2. Ok
124      */
125     ASSERT_EQ(SetDistributedTables(info1_, tables, type), E_OK);
126     ASSERT_EQ(SetDistributedTables(info2_, tables, type), E_OK);
127     ASSERT_EQ(SetTrackerTables(info1_, tables), E_OK);
128     /**
129      * @tc.steps: step3. Insert local data.
130      * @tc.expected: step3. Ok
131      */
132     InsertLocalDBData(0, 1, info1_);
133 }
134 
DataStatusComplexTest(bool testWithTracker)135 void DistributedDBRDBDataStatusTest::DataStatusComplexTest(bool testWithTracker)
136 {
137     RelationalStoreDelegate::Option option;
138     option.tableMode = DistributedTableMode::COLLABORATION;
139     SetOption(option);
140     ASSERT_NO_FATAL_FAILURE(PrepareTableBasicEnv(testWithTracker));
141     /**
142      * @tc.steps: step6. Reopen store with DEV_C.
143      * @tc.expected: step6. Ok
144      */
145     ASSERT_EQ(RDBGeneralUt::CloseDelegate(info1_), OK);
146     ASSERT_EQ(BasicUnitTest::InitDelegate(info1_, DEVICE_C), E_OK);
147     /**
148      * @tc.steps: step7. DEV_C sync to DEV_B.
149      * @tc.expected: step7. Ok
150      */
151     BlockPush(info1_, info2_, DEVICE_SYNC_TABLE);
152     /**
153      * @tc.steps: step8. Check 1 record with device_c.
154      * @tc.expected: step8. Ok
155      */
156     EXPECT_EQ(CountTableDataByDev(info2_, DBCommon::GetLogTableName(DEVICE_SYNC_TABLE), DEVICE_C), 1);
157 }
158 
InitCollaborationDelegate()159 void DistributedDBRDBDataStatusTest::InitCollaborationDelegate()
160 {
161     RelationalStoreDelegate::Option option;
162     option.tableMode = DistributedTableMode::COLLABORATION;
163     SetOption(option);
164     ASSERT_EQ(BasicUnitTest::InitDelegate(info1_, DEVICE_A), E_OK);
165     ASSERT_EQ(BasicUnitTest::InitDelegate(info2_, DEVICE_B), E_OK);
166 }
167 
168 /**
169  * @tc.name: SplitTable001
170  * @tc.desc: Test split table sync after update time.
171  * @tc.type: FUNC
172  * @tc.require:
173  * @tc.author: zqq
174  */
175 HWTEST_F(DistributedDBRDBDataStatusTest, SplitTable001, TestSize.Level0)
176 {
177     ASSERT_NO_FATAL_FAILURE(PrepareTableBasicEnv());
178     /**
179      * @tc.steps: step6. DEV_A sync to DEV_B.
180      * @tc.expected: step6. Ok
181      */
182     BlockPush(info1_, info2_, DEVICE_SYNC_TABLE);
183 }
184 
185 
186 /**
187  * @tc.name: SplitTable002
188  * @tc.desc: Test split table sync with diff dev after update time.
189  * @tc.type: FUNC
190  * @tc.require:
191  * @tc.author: zqq
192  */
193 HWTEST_F(DistributedDBRDBDataStatusTest, SplitTable002, TestSize.Level0)
194 {
195     ASSERT_NO_FATAL_FAILURE(PrepareTableBasicEnv());
196     /**
197      * @tc.steps: step6. Reopen store with DEV_C.
198      * @tc.expected: step6. Ok
199      */
200     ASSERT_EQ(RDBGeneralUt::CloseDelegate(info1_), OK);
201     ASSERT_EQ(BasicUnitTest::InitDelegate(info1_, DEVICE_C), E_OK);
202     /**
203      * @tc.steps: step7. DEV_C sync to DEV_B.
204      * @tc.expected: step7. Ok
205      */
206     BlockPush(info1_, info2_, DEVICE_SYNC_TABLE);
207     /**
208      * @tc.steps: step8. Check 1 record in device_c table.
209      * @tc.expected: step8. Ok
210      */
211     EXPECT_EQ(CountTableData(info2_, DBCommon::GetDistributedTableName(DEVICE_C, DEVICE_SYNC_TABLE)), 1);
212 }
213 
214 /**
215  * @tc.name: CollaborationTable001
216  * @tc.desc: Test collaboration table sync after update time.
217  * @tc.type: FUNC
218  * @tc.require:
219  * @tc.author: zqq
220  */
221 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable001, TestSize.Level0)
222 {
223     RelationalStoreDelegate::Option option;
224     option.tableMode = DistributedTableMode::COLLABORATION;
225     SetOption(option);
226     ASSERT_NO_FATAL_FAILURE(PrepareTableBasicEnv());
227     /**
228      * @tc.steps: step6. DEV_A sync to DEV_B.
229      * @tc.expected: step6. Ok
230      */
231     BlockPush(info1_, info2_, DEVICE_SYNC_TABLE);
232 }
233 
234 /**
235  * @tc.name: CollaborationTable002
236  * @tc.desc: Test collaboration table sync after update time.
237  * @tc.type: FUNC
238  * @tc.require:
239  * @tc.author: zqq
240  */
241 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable002, TestSize.Level0)
242 {
243     DataStatusComplexTest(false);
244 }
245 
246 /**
247  * @tc.name: CollaborationTable003
248  * @tc.desc: Test collaboration search table sync after update time.
249  * @tc.type: FUNC
250  * @tc.require:
251  * @tc.author: zqq
252  */
253 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable003, TestSize.Level0)
254 {
255     DataStatusComplexTest(true);
256 }
257 
258 /**
259  * @tc.name: CollaborationTable004
260  * @tc.desc: Test collaboration search table sync after update time.
261  * @tc.type: FUNC
262  * @tc.require:
263  * @tc.author: tankaisheng
264  */
265 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable004, TestSize.Level0)
266 {
267     RelationalStoreDelegate::Option option;
268     option.tableMode = DistributedTableMode::COLLABORATION;
269     SetOption(option);
270     ASSERT_NO_FATAL_FAILURE(PrepareBasicTableByType(DEVICE_COOPERATION));
271     /**
272      * @tc.steps: step1. DEV_A sync to DEV_B.
273      * @tc.expected: step1. Ok
274      */
275     BlockPush(info1_, info2_, DEVICE_SYNC_TABLE);
276 }
277 
278 /**
279  * @tc.name: CollaborationTable005
280  * @tc.desc: Test collaboration no pk table set schema twice.
281  * @tc.type: FUNC
282  * @tc.require:
283  * @tc.author: zqq
284  */
285 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable005, TestSize.Level0)
286 {
287     /**
288      * @tc.steps: step1. Create no pk table and set as distributed table.
289      * @tc.expected: step1. Ok
290      */
291     UtDateBaseSchemaInfo info;
292     info.tablesInfo.push_back(GetTableSchema("new_table", true));
293     SetSchemaInfo(info1_, info);
294     SetSchemaInfo(info2_, info);
295     RelationalStoreDelegate::Option option;
296     option.tableMode = DistributedTableMode::COLLABORATION;
297     SetOption(option);
298     ASSERT_NO_FATAL_FAILURE(PrepareBasicTableByType({"new_table"}, DEVICE_COOPERATION));
299     /**
300      * @tc.steps: step2. Update distributed table by create more table.
301      * @tc.expected: step2. Ok
302      */
303     info.tablesInfo.push_back(GetTableSchema(DEVICE_SYNC_TABLE));
304     SetSchemaInfo(info1_, info);
305     SetSchemaInfo(info2_, info);
306     ASSERT_NO_FATAL_FAILURE(PrepareBasicTableByType({"new_table", DEVICE_SYNC_TABLE}, DEVICE_COOPERATION));
307 }
308 
309 /**
310  * @tc.name: CollaborationTable006
311  * @tc.desc: Test device collaboration and search table sync.
312  * @tc.type: FUNC
313  * @tc.require:
314  * @tc.author: suyue
315  */
316 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable006, TestSize.Level1)
317 {
318     ASSERT_NO_FATAL_FAILURE(InitCollaborationDelegate());
319     /**
320      * @tc.steps: step1. Set distributed tables and Tracker tables.
321      * @tc.expected: step1. Ok
322      */
323     ASSERT_EQ(SetDistributedTables(info1_, {DEVICE_SYNC_TABLE}, DEVICE_COOPERATION), E_OK);
324     ASSERT_EQ(SetTrackerTables(info2_, {DEVICE_SYNC_TABLE}), E_OK);
325     /**
326      * @tc.steps: step2. Insert data and sync.
327      * @tc.expected: step2. SCHEMA_MISMATCH
328      */
329     InsertLocalDBData(0, 1, info1_);
330     BlockPush(info1_, info2_, DEVICE_SYNC_TABLE, SCHEMA_MISMATCH);
331 }
332 
333 /**
334  * @tc.name: CollaborationTable007
335  * @tc.desc: Test device collaboration search table and search table sync.
336  * @tc.type: FUNC
337  * @tc.require:
338  * @tc.author: suyue
339  */
340 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable007, TestSize.Level1)
341 {
342     ASSERT_NO_FATAL_FAILURE(InitCollaborationDelegate());
343     /**
344      * @tc.steps: step1. Set distributed tables and Tracker tables.
345      * @tc.expected: step1. Ok
346      */
347     ASSERT_EQ(SetDistributedTables(info1_, {DEVICE_SYNC_TABLE}, DEVICE_COOPERATION), E_OK);
348     ASSERT_EQ(SetTrackerTables(info1_, {DEVICE_SYNC_TABLE}), E_OK);
349     ASSERT_EQ(SetTrackerTables(info2_, {DEVICE_SYNC_TABLE}), E_OK);
350     /**
351      * @tc.steps: step2. Insert data and sync.
352      * @tc.expected: step2. SCHEMA_MISMATCH
353      */
354     InsertLocalDBData(0, 1, info1_);
355     BlockPush(info1_, info2_, DEVICE_SYNC_TABLE, SCHEMA_MISMATCH);
356 }
357 
358 /**
359  * @tc.name: CollaborationTable008
360  * @tc.desc: Test device collaboration and cloud collaboration search table sync.
361  * @tc.type: FUNC
362  * @tc.require:
363  * @tc.author: suyue
364  */
365 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable008, TestSize.Level1)
366 {
367     ASSERT_NO_FATAL_FAILURE(InitCollaborationDelegate());
368     /**
369      * @tc.steps: step1. Set distributed tables and Tracker tables.
370      * @tc.expected: step1. Ok
371      */
372     ASSERT_EQ(SetDistributedTables(info1_, {DEVICE_SYNC_TABLE}, DEVICE_COOPERATION), E_OK);
373     ASSERT_EQ(SetDistributedTables(info2_, {DEVICE_SYNC_TABLE}, CLOUD_COOPERATION), E_OK);
374     ASSERT_EQ(SetTrackerTables(info2_, {DEVICE_SYNC_TABLE}), E_OK);
375     /**
376      * @tc.steps: step2. Insert data and sync.
377      * @tc.expected: step2. NOT_SUPPORT
378      */
379     InsertLocalDBData(0, 1, info1_);
380     BlockPush(info1_, info2_, DEVICE_SYNC_TABLE, NOT_SUPPORT);
381 }
382 
383 /**
384  * @tc.name: CollaborationTable009
385  * @tc.desc: Test device collaboration search table and cloud collaboration search table sync.
386  * @tc.type: FUNC
387  * @tc.require:
388  * @tc.author: suyue
389  */
390 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable009, TestSize.Level1)
391 {
392     ASSERT_NO_FATAL_FAILURE(InitCollaborationDelegate());
393     /**
394      * @tc.steps: step1. Set distributed tables and Tracker tables.
395      * @tc.expected: step1. Ok
396      */
397     ASSERT_EQ(SetDistributedTables(info1_, {DEVICE_SYNC_TABLE}, DEVICE_COOPERATION), E_OK);
398     ASSERT_EQ(SetTrackerTables(info1_, {DEVICE_SYNC_TABLE}), E_OK);
399     ASSERT_EQ(SetDistributedTables(info2_, {DEVICE_SYNC_TABLE}, CLOUD_COOPERATION), E_OK);
400     ASSERT_EQ(SetTrackerTables(info2_, {DEVICE_SYNC_TABLE}), E_OK);
401     /**
402      * @tc.steps: step2. Insert data and sync.
403      * @tc.expected: step2. NOT_SUPPORT
404      */
405     InsertLocalDBData(0, 1, info1_);
406     BlockPush(info1_, info2_, DEVICE_SYNC_TABLE, NOT_SUPPORT);
407 }
408 
409 /**
410  * @tc.name: CollaborationTable010
411  * @tc.desc: Test device collaboration and cloud collaboration able sync.
412  * @tc.type: FUNC
413  * @tc.require:
414  * @tc.author: suyue
415  */
416 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable010, TestSize.Level1)
417 {
418     ASSERT_NO_FATAL_FAILURE(InitCollaborationDelegate());
419     /**
420      * @tc.steps: step1. Set distributed tables and Tracker tables.
421      * @tc.expected: step1. Ok
422      */
423     ASSERT_EQ(SetDistributedTables(info1_, {DEVICE_SYNC_TABLE}, CLOUD_COOPERATION), E_OK);
424     ASSERT_EQ(SetDistributedTables(info2_, {DEVICE_SYNC_TABLE}, DEVICE_COOPERATION), E_OK);
425     /**
426      * @tc.steps: step2. Insert data and sync.
427      * @tc.expected: step2. NOT_SUPPORT
428      */
429     InsertLocalDBData(0, 1, info1_);
430     auto store = GetDelegate(info1_);
431     ASSERT_NE(store, nullptr);
432     auto toDevice  = GetDevice(info2_);
433     ASSERT_FALSE(toDevice.empty());
434     Query query = Query::Select(DEVICE_SYNC_TABLE);
435     DBStatus callStatus = store->Sync({toDevice}, SYNC_MODE_PUSH_ONLY, query, nullptr, true);
436     EXPECT_EQ(callStatus, NOT_SUPPORT);
437 }
438 
439 /**
440  * @tc.name: CollaborationTable011
441  * @tc.desc: Test cloud collaboration table and device collaboration search table sync.
442  * @tc.type: FUNC
443  * @tc.require:
444  * @tc.author: suyue
445  */
446 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable011, TestSize.Level1)
447 {
448     ASSERT_NO_FATAL_FAILURE(InitCollaborationDelegate());
449     /**
450      * @tc.steps: step1. Set distributed tables and Tracker tables.
451      * @tc.expected: step1. Ok
452      */
453     ASSERT_EQ(SetDistributedTables(info1_, {DEVICE_SYNC_TABLE}, CLOUD_COOPERATION), E_OK);
454     ASSERT_EQ(SetDistributedTables(info2_, {DEVICE_SYNC_TABLE}, DEVICE_COOPERATION), E_OK);
455     ASSERT_EQ(SetTrackerTables(info2_, {DEVICE_SYNC_TABLE}), E_OK);
456     /**
457      * @tc.steps: step2. Insert data and sync.
458      * @tc.expected: step2. NOT_SUPPORT
459      */
460     InsertLocalDBData(0, 1, info1_);
461     auto store = GetDelegate(info1_);
462     ASSERT_NE(store, nullptr);
463     auto toDevice  = GetDevice(info2_);
464     ASSERT_FALSE(toDevice.empty());
465     Query query = Query::Select(DEVICE_SYNC_TABLE);
466     DBStatus callStatus = store->Sync({toDevice}, SYNC_MODE_PUSH_ONLY, query, nullptr, true);
467     EXPECT_EQ(callStatus, NOT_SUPPORT);
468 }
469 
470 /**
471  * @tc.name: CollaborationTable012
472  * @tc.desc: Test cloud collaboration and search table sync.
473  * @tc.type: FUNC
474  * @tc.require:
475  * @tc.author: suyue
476  */
477 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable012, TestSize.Level1)
478 {
479     ASSERT_NO_FATAL_FAILURE(InitCollaborationDelegate());
480     /**
481      * @tc.steps: step1. Set distributed tables and Tracker tables.
482      * @tc.expected: step1. Ok
483      */
484     ASSERT_EQ(SetDistributedTables(info1_, {DEVICE_SYNC_TABLE}, CLOUD_COOPERATION), E_OK);
485     ASSERT_EQ(SetTrackerTables(info2_, {DEVICE_SYNC_TABLE}), E_OK);
486     /**
487      * @tc.steps: step2. Insert data and sync.
488      * @tc.expected: step2. NOT_SUPPORT
489      */
490     InsertLocalDBData(0, 1, info1_);
491     auto store = GetDelegate(info1_);
492     ASSERT_NE(store, nullptr);
493     auto toDevice  = GetDevice(info2_);
494     ASSERT_FALSE(toDevice.empty());
495     Query query = Query::Select(DEVICE_SYNC_TABLE);
496     DBStatus callStatus = store->Sync({toDevice}, SYNC_MODE_PUSH_ONLY, query, nullptr, true);
497     EXPECT_EQ(callStatus, NOT_SUPPORT);
498 }
499 
500 /**
501  * @tc.name: CollaborationTable013
502  * @tc.desc: Test cloud collaboration search table and search table sync.
503  * @tc.type: FUNC
504  * @tc.require:
505  * @tc.author: suyue
506  */
507 HWTEST_F(DistributedDBRDBDataStatusTest, CollaborationTable013, TestSize.Level1)
508 {
509     ASSERT_NO_FATAL_FAILURE(InitCollaborationDelegate());
510     /**
511      * @tc.steps: step1. Set distributed tables and Tracker tables.
512      * @tc.expected: step1. Ok
513      */
514     ASSERT_EQ(SetDistributedTables(info1_, {DEVICE_SYNC_TABLE}, CLOUD_COOPERATION), E_OK);
515     ASSERT_EQ(SetTrackerTables(info1_, {DEVICE_SYNC_TABLE}), E_OK);
516     ASSERT_EQ(SetTrackerTables(info2_, {DEVICE_SYNC_TABLE}), E_OK);
517     /**
518      * @tc.steps: step2. Insert data and sync.
519      * @tc.expected: step2. NOT_SUPPORT
520      */
521     InsertLocalDBData(0, 1, info1_);
522     auto store = GetDelegate(info1_);
523     ASSERT_NE(store, nullptr);
524     auto toDevice  = GetDevice(info2_);
525     ASSERT_FALSE(toDevice.empty());
526     Query query = Query::Select(DEVICE_SYNC_TABLE);
527     DBStatus callStatus = store->Sync({toDevice}, SYNC_MODE_PUSH_ONLY, query, nullptr, true);
528     EXPECT_EQ(callStatus, NOT_SUPPORT);
529 }
530 
531 /**
532  * @tc.name: CreateDistributedTableTest001
533  * @tc.desc: Test CreateDistributedTable interface after re-create table.
534  * @tc.type: FUNC
535  * @tc.require:
536  * @tc.author: suyue
537  */
538 HWTEST_F(DistributedDBRDBDataStatusTest, CreateDistributedTableTest001, TestSize.Level0)
539 {
540     RelationalStoreDelegate::Option option;
541     option.tableMode = DistributedTableMode::COLLABORATION;
542     SetOption(option);
543     ASSERT_NO_FATAL_FAILURE(PrepareTableBasicEnv());
544     EXPECT_EQ(RDBGeneralUt::CreateDistributedTable(info1_, {DEVICE_SYNC_TABLE}), E_OK);
545 
546     /**
547      * @tc.steps: step1. Drop table, and create same table that unique field are added.
548      * @tc.expected: step1. Ok
549      */
550     sqlite3 *db = GetSqliteHandle(info1_);
551     ASSERT_NE(db, nullptr);
552     std::string newSql = "DROP TABLE DEVICE_SYNC_TABLE;";
553     EXPECT_EQ(RelationalTestUtils::ExecSql(db, newSql), SQLITE_OK);
554     newSql = "CREATE TABLE IF NOT EXISTS DEVICE_SYNC_TABLE('id' INTEGER PRIMARY KEY, new_field INTEGER UNIQUE);";
555     EXPECT_EQ(RelationalTestUtils::ExecSql(db, newSql), SQLITE_OK);
556 
557     /**
558      * @tc.steps: step2. Create distributed table.
559      * @tc.expected: step2. OK
560      */
561     EXPECT_EQ(RDBGeneralUt::CreateDistributedTable(info1_, {DEVICE_SYNC_TABLE}), E_OK);
562 }
563 
564 /**
565  * @tc.name: TimeCheck001
566  * @tc.desc: Test operate data status after modify time.
567  * @tc.type: FUNC
568  * @tc.require:
569  * @tc.author: zqq
570  */
571 HWTEST_F(DistributedDBRDBDataStatusTest, TimeCheck001, TestSize.Level0)
572 {
573     /**
574      * @tc.steps: step1. Create distributed table and insert local data.
575      */
576     ASSERT_NO_FATAL_FAILURE(InitCollaborationDelegate());
577     EXPECT_EQ(RDBGeneralUt::CreateDistributedTable(info1_, {DEVICE_SYNC_TABLE}), E_OK);
578     InsertLocalDBData(0, 1, info1_);
579     /**
580      * @tc.steps: step2. Get last max timestamp.
581      * @tc.expected: step2. Ok
582      */
583     sqlite3 *db = GetSqliteHandle(info1_);
584     ASSERT_NE(db, nullptr);
585     auto [errCode, t1] = RelationalTestUtils::GetMaxTimestamp(db, DEVICE_SYNC_TABLE);
586     EXPECT_EQ(errCode, E_OK);
587     /**
588      * @tc.steps: step3. Modify time offset and operator data status.
589      * @tc.expected: step3. Ok
590      */
591     std::string sql = "INSERT OR REPLACE INTO " + std::string(DBConstant::RELATIONAL_PREFIX) +
592         "metadata VALUES('localTimeOffset', '100000')";
593     ASSERT_EQ(RelationalTestUtils::ExecSql(db, sql), E_OK);
594     auto store = GetDelegate(info1_);
595     ASSERT_NE(store, nullptr);
596     EXPECT_EQ(store->OperateDataStatus(static_cast<uint32_t>(DataOperator::UPDATE_TIME)), OK);
597     /**
598      * @tc.steps: step4. Check timestamp should not decrease.
599      * @tc.expected: step4. Ok
600      */
601     auto [ret, t2] = RelationalTestUtils::GetMaxTimestamp(db, DEVICE_SYNC_TABLE);
602     EXPECT_EQ(ret, E_OK);
603     EXPECT_GE(t2, t1);
604 }
605 }