1 /*
2 * Copyright (c) 2021 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 #ifndef OMIT_MULTI_VER
16 #include <gtest/gtest.h>
17
18 #include "distributeddb_data_generate_unit_test.h"
19 #include "distributeddb_interfaces_transaction_testcase.h"
20 #include "distributeddb_tools_unit_test.h"
21
22 using namespace testing::ext;
23 using namespace DistributedDB;
24 using namespace DistributedDBUnitTest;
25 using namespace std;
26
27 namespace {
28 string g_testDir;
29 const bool LOCAL_ONLY = true;
30 const string STORE_ID = STORE_ID_LOCAL;
31
32 KvStoreDelegateManager g_mgr(APP_ID, USER_ID);
33 KvStoreConfig g_config;
34
35 // define the g_kvDelegateCallback, used to get some information when open a kv store.
36 DBStatus g_kvDelegateStatus = INVALID_ARGS;
37 KvStoreDelegate *g_kvDelegatePtr = nullptr;
38 // the type of g_kvDelegateCallback is function<void(DBStatus, KvStoreDelegate*)>
39 auto g_kvDelegateCallback = bind(&DistributedDBToolsUnitTest::KvStoreDelegateCallback, placeholders::_1,
40 placeholders::_2, std::ref(g_kvDelegateStatus), std::ref(g_kvDelegatePtr));
41
42 // define the g_snapshotDelegateCallback, used to get some information when open a kv snapshot.
43 DBStatus g_snapshotDelegateStatus = INVALID_ARGS;
44 KvStoreSnapshotDelegate *g_snapshotDelegatePtr = nullptr;
45 // the type of g_snapshotDelegateCallback is function<void(DBStatus, KvStoreSnapshotDelegate*)>
46 auto g_snapshotDelegateCallback = bind(&DistributedDBToolsUnitTest::SnapshotDelegateCallback,
47 placeholders::_1, placeholders::_2, std::ref(g_snapshotDelegateStatus), std::ref(g_snapshotDelegatePtr));
48 }
49
50 class DistributedDBInterfacesTransactionTest : public testing::Test {
51 public:
52 static void SetUpTestCase(void);
53 static void TearDownTestCase(void);
54 void SetUp();
55 void TearDown();
56 };
57
SetUpTestCase(void)58 void DistributedDBInterfacesTransactionTest::SetUpTestCase(void)
59 {
60 DistributedDBToolsUnitTest::TestDirInit(g_testDir);
61 g_config.dataDir = g_testDir;
62 g_mgr.SetKvStoreConfig(g_config);
63 }
64
TearDownTestCase(void)65 void DistributedDBInterfacesTransactionTest::TearDownTestCase(void)
66 {
67 if (DistributedDBToolsUnitTest::RemoveTestDbFiles(g_testDir) != 0) {
68 LOGE("rm test db files error!");
69 }
70 }
71
SetUp(void)72 void DistributedDBInterfacesTransactionTest::SetUp(void)
73 {
74 DistributedDBToolsUnitTest::PrintTestCaseInfo();
75 /*
76 * Here, we create STORE_ID before test,
77 * and it will be closed in TearDown().
78 */
79 KvStoreDelegate::Option option = {true, LOCAL_ONLY};
80 g_mgr.GetKvStore(STORE_ID, option, g_kvDelegateCallback);
81 EXPECT_TRUE(g_kvDelegateStatus == OK);
82 ASSERT_TRUE(g_kvDelegatePtr != nullptr);
83 }
84
TearDown(void)85 void DistributedDBInterfacesTransactionTest::TearDown(void)
86 {
87 if (g_kvDelegatePtr != nullptr && g_snapshotDelegatePtr != nullptr) {
88 EXPECT_TRUE(g_kvDelegatePtr->ReleaseKvStoreSnapshot(g_snapshotDelegatePtr) == OK);
89 g_snapshotDelegatePtr = nullptr;
90 }
91
92 if (g_kvDelegatePtr != nullptr) {
93 EXPECT_EQ(g_mgr.CloseKvStore(g_kvDelegatePtr), OK);
94 g_kvDelegatePtr = nullptr;
95 EXPECT_EQ(g_mgr.DeleteKvStore(STORE_ID), OK);
96 }
97 }
98
99 /**
100 * @tc.name: StartTransaction001
101 * @tc.desc: Test that can't call StartTransaction interface repeatedly.
102 * @tc.type: FUNC
103 * @tc.require: AR000BVRNK AR000CQDTO
104 * @tc.author: huangnaigu
105 */
106 HWTEST_F(DistributedDBInterfacesTransactionTest, StartTransaction001, TestSize.Level1)
107 {
108 /**
109 * @tc.steps:step1. call StartTransaction interface the 1st time.
110 * @tc.expected: step1. call succeed.
111 */
112 /**
113 * @tc.steps:step2. call StartTransaction interface the 2nd time.
114 * @tc.expected: step2. call failed and return ERROR.
115 */
116 DistributedDBInterfacesTransactionTestCase::StartTransaction001(g_kvDelegatePtr);
117 }
118
119 /**
120 * @tc.name: StartTransaction002
121 * @tc.desc: Test that call StartTransaction and commit interface normally.
122 * @tc.type: FUNC
123 * @tc.require: AR000BVRNK AR000CQDTO
124 * @tc.author: huangnaigu
125 */
126 HWTEST_F(DistributedDBInterfacesTransactionTest, StartTransaction002, TestSize.Level1)
127 {
128 /**
129 * @tc.steps:step1. call StartTransaction interface.
130 * @tc.expected: step1. call succeed.
131 */
132 /**
133 * @tc.steps:step2. call commit interface.
134 * @tc.expected: step2. call succeed.
135 */
136 DistributedDBInterfacesTransactionTestCase::StartTransaction002(g_kvDelegatePtr);
137 }
138
139 /**
140 * @tc.name: StartTransaction003
141 * @tc.desc: Test that call StartTransaction and rolback interface normally.
142 * @tc.type: FUNC
143 * @tc.require: AR000BVRNK AR000CQDTO
144 * @tc.author: huangnaigu
145 */
146 HWTEST_F(DistributedDBInterfacesTransactionTest, StartTransaction003, TestSize.Level1)
147 {
148 /**
149 * @tc.steps:step1. call StartTransaction interface.
150 * @tc.expected: step1. call succeed.
151 */
152 /**
153 * @tc.steps:step2. call rollback interface.
154 * @tc.expected: step2. call succeed.
155 */
156 DistributedDBInterfacesTransactionTestCase::StartTransaction003(g_kvDelegatePtr);
157 }
158
159 /**
160 * @tc.name: StartTransaction004
161 * @tc.desc: Test that call StartTransaction and rolback interface normally.
162 * @tc.type: FUNC
163 * @tc.require: AR000BVRNK AR000CQDTO
164 * @tc.author: huangnaigu
165 */
166 HWTEST_F(DistributedDBInterfacesTransactionTest, StartTransaction004, TestSize.Level1)
167 {
168 /**
169 * @tc.steps:step1. call StartTransaction interface.
170 * @tc.expected: step1. call succeed.
171 */
172 /**
173 * @tc.steps:step2. put (k1, v1) to data base.
174 * @tc.expected: step2. put succeed.
175 */
176 /**
177 * @tc.steps:step3. close data base.
178 * @tc.expected: step3. close succeed.
179 */
180 /**
181 * @tc.steps:step4. use GetKvStore interface to open db.
182 * @tc.expected: step4. open succeed.
183 */
184 /**
185 * @tc.steps:step5. use snapshot interface to check the value of k1.
186 * @tc.expected: step5. can't get the record of k1.
187 */
188 DistributedDBInterfacesTransactionTestCase::StartTransaction004(g_kvDelegatePtr, STORE_ID, LOCAL_ONLY,
189 g_mgr, g_snapshotDelegatePtr);
190 }
191
192 /**
193 * @tc.name: StartTransaction005
194 * @tc.desc: Test that can't call StartTransaction interface repeatedly for different kv store.
195 * @tc.type: FUNC
196 * @tc.require: AR000BVRNK AR000CQDTO
197 * @tc.author: huangnaigu
198 */
199 HWTEST_F(DistributedDBInterfacesTransactionTest, StartTransaction005, TestSize.Level3)
200 {
201 /**
202 * @tc.steps:step1. call StartTransaction interface the 1st time.
203 * @tc.expected: step1. call succeed.
204 */
205 /**
206 * @tc.steps:step2. call StartTransaction interface the 2nd time using another .
207 * @tc.expected: step2. call failed.
208 */
209 /**
210 * @tc.steps:step4. call commit interface the 1st time.
211 * @tc.expected: step4. call failed.
212 */
213 /**
214 * @tc.steps:step5. call commit interface the 2nd time.
215 * @tc.expected: step5. call failed.
216 */
217 DistributedDBInterfacesTransactionTestCase::StartTransaction005(g_kvDelegatePtr, STORE_ID, LOCAL_ONLY, g_mgr);
218 }
219
220 /**
221 * @tc.name: Commit001
222 * @tc.desc: Test that can't commit Transaction before it start.
223 * @tc.type: FUNC
224 * @tc.require: AR000CQDTO AR000CQDTP
225 * @tc.author: huangnaigu
226 */
227 HWTEST_F(DistributedDBInterfacesTransactionTest, Commit001, TestSize.Level1)
228 {
229 /**
230 * @tc.steps:step1. commit Transaction without start it.
231 * @tc.expected: step1. commit failed and returned ERROR.
232 */
233 DistributedDBInterfacesTransactionTestCase::Commit001(g_kvDelegatePtr);
234 }
235
236 /**
237 * @tc.name: Commit002
238 * @tc.desc: Test that can't commit Transaction repeatedly even if it start normally.
239 * @tc.type: FUNC
240 * @tc.require: AR000CQDTO AR000CQDTP
241 * @tc.author: huangnaigu
242 */
243 HWTEST_F(DistributedDBInterfacesTransactionTest, Commit002, TestSize.Level1)
244 {
245 /**
246 * @tc.steps:step1. call StartTransaction interface.
247 * @tc.expected: step1. call succeed.
248 */
249 /**
250 * @tc.steps:step2. call commit interface the 1st time.
251 * @tc.expected: step2. call succeed.
252 */
253 /**
254 * @tc.steps:step3. call commit interface the 2nd time.
255 * @tc.expected: step3. call failed and returned ERROR.
256 */
257 DistributedDBInterfacesTransactionTestCase::Commit002(g_kvDelegatePtr);
258 }
259
260 /**
261 * @tc.name: Commit003
262 * @tc.desc: Test that can commit Transaction after put record.
263 * @tc.type: FUNC
264 * @tc.require: AR000CQDTO AR000CQDTP
265 * @tc.author: huangnaigu
266 */
267 HWTEST_F(DistributedDBInterfacesTransactionTest, Commit003, TestSize.Level1)
268 {
269 /**
270 * @tc.steps:step1. call StartTransaction interface.
271 * @tc.expected: step1. call succeed.
272 */
273 /**
274 * @tc.steps:step2. put (k1, v1) to db.
275 * @tc.expected: step2. put succeed.
276 */
277 /**
278 * @tc.steps:step3. call commit interface.
279 * @tc.expected: step3. call succeed.
280 */
281 /**
282 * @tc.steps:step4. use snapshot interface to check if (k1, v1) is put succeed.
283 * @tc.expected: step4. can find (k1, v1) from db.
284 */
285 DistributedDBInterfacesTransactionTestCase::Commit003(g_kvDelegatePtr, g_snapshotDelegatePtr);
286 }
287
288 /**
289 * @tc.name: Commit004
290 * @tc.desc: Test that can commit Transaction after update record.
291 * @tc.type: FUNC
292 * @tc.require: AR000CQDTO AR000CQDTP
293 * @tc.author: huangnaigu
294 */
295 HWTEST_F(DistributedDBInterfacesTransactionTest, Commit004, TestSize.Level1)
296 {
297 /**
298 * @tc.steps:step1. put one data.
299 * @tc.expected: step1. call succeed.
300 */
301 /**
302 * @tc.steps:step2. call StartTransaction interface.
303 * @tc.expected: step2. call succeed.
304 */
305 /**
306 * @tc.steps:step3. update the data to another value.
307 * @tc.expected: step3. call succeed.
308 */
309 /**
310 * @tc.steps:step4. call commit interface.
311 * @tc.expected: step4. call succeed.
312 */
313 /**
314 * @tc.steps:step5. use snapshot interface to check the updated data.
315 * @tc.expected: step5. the value is updated.
316 */
317 DistributedDBInterfacesTransactionTestCase::Commit004(g_kvDelegatePtr, g_snapshotDelegatePtr);
318 }
319
320 /**
321 * @tc.name: Commit005
322 * @tc.desc: Test that can commit Transaction after delete record.
323 * @tc.type: FUNC
324 * @tc.require: AR000CQDTO AR000CQDTP
325 * @tc.author: huangnaigu
326 */
327 HWTEST_F(DistributedDBInterfacesTransactionTest, Commit005, TestSize.Level1)
328 {
329 /**
330 * @tc.steps:step1. call StartTransaction interface.
331 * @tc.expected: step1. call succeed.
332 */
333 /**
334 * @tc.steps:step2. delete record from db where key = k1.
335 * @tc.expected: step2. delete succeed.
336 */
337 /**
338 * @tc.steps:step3. call commit interface.
339 * @tc.expected: step3. commit succeed.
340 */
341 /**
342 * @tc.steps:step4. use snapshot interface to check if (k1, v1) is delete succeed.
343 * @tc.expected: step4. can't find (k1, v1) in the db.
344 */
345 DistributedDBInterfacesTransactionTestCase::Commit005(g_kvDelegatePtr, g_snapshotDelegatePtr);
346 }
347
348 /**
349 * @tc.name: Commit006
350 * @tc.desc: Test that can commit Transaction after clear all the records.
351 * @tc.type: FUNC
352 * @tc.require: AR000CQDTO
353 * @tc.author: huangnaigu
354 */
355 HWTEST_F(DistributedDBInterfacesTransactionTest, Commit006, TestSize.Level1)
356 {
357 /**
358 * @tc.steps:step1. call StartTransaction interface.
359 * @tc.expected: step1. call succeed.
360 */
361 /**
362 * @tc.steps:step2. clear all the records from db.
363 * @tc.expected: step2. clear succeed.
364 */
365 /**
366 * @tc.steps:step3. call commit interface.
367 * @tc.expected: step3. commit succeed.
368 */
369 /**
370 * @tc.steps:step4. use snapshot interface to check if there are any data in db.
371 * @tc.expected: step4. can't find any data in db.
372 */
373 DistributedDBInterfacesTransactionTestCase::Commit006(g_kvDelegatePtr, g_snapshotDelegatePtr);
374 }
375
376 /**
377 * @tc.name: Commit007
378 * @tc.desc: Test that can commit Transaction after delete and update db.
379 * @tc.type: FUNC
380 * @tc.require: AR000CQDTO AR000CQDTP
381 * @tc.author: huangnaigu
382 */
383 HWTEST_F(DistributedDBInterfacesTransactionTest, Commit007, TestSize.Level1)
384 {
385 /**
386 * @tc.steps:step1. call StartTransaction interface.
387 * @tc.expected: step1. call succeed.
388 */
389 /**
390 * @tc.steps:step2. delete record from db where key = k1.
391 * @tc.expected: step2. delete succeed.
392 */
393 /**
394 * @tc.steps:step3. put (k2, v1) to db.
395 * @tc.expected: step3. put succeed.
396 */
397 /**
398 * @tc.steps:step4. call commit interface.
399 * @tc.expected: step4. commit succeed.
400 */
401 /**
402 * @tc.steps:step5. use snapshot interface to check the data in db.
403 * @tc.expected: step5. can't find (k1, v1) but can find (k2, v1) in db.
404 */
405 DistributedDBInterfacesTransactionTestCase::Commit007(g_kvDelegatePtr, g_snapshotDelegatePtr);
406 }
407
408 /**
409 * @tc.name: Commit008
410 * @tc.desc: Test that can commit Transaction after clear and new add records.
411 * @tc.type: FUNC
412 * @tc.require: AR000CQDTO AR000CQDTP
413 * @tc.author: huangnaigu
414 */
415 HWTEST_F(DistributedDBInterfacesTransactionTest, Commit008, TestSize.Level1)
416 {
417 /**
418 * @tc.steps:step1. call StartTransaction interface.
419 * @tc.expected: step1. call succeed.
420 */
421 /**
422 * @tc.steps:step2. clear all the records from db.
423 * @tc.expected: step2. clear succeed.
424 */
425 /**
426 * @tc.steps:step3. put (k3, v3) to db.
427 * @tc.expected: step3. put succeed.
428 */
429 /**
430 * @tc.steps:step4. call commit interface.
431 * @tc.expected: step4. commit succeed.
432 */
433 /**
434 * @tc.steps:step5. use snapshot interface to check the data in db.
435 * @tc.expected: step5. can only find (k3, v3) in db.
436 */
437 DistributedDBInterfacesTransactionTestCase::Commit008(g_kvDelegatePtr, g_snapshotDelegatePtr);
438 }
439
440 /**
441 * @tc.name: RollBack001
442 * @tc.desc: Test if new commit records and logs generated
443 * when a transaction rollback-ed
444 * @tc.type: FUNC
445 * @tc.require: AR000BVRNM AR000CQDTQ
446 * @tc.author: huangnaigu
447 */
448 HWTEST_F(DistributedDBInterfacesTransactionTest, Rollback001, TestSize.Level1)
449 {
450 /**
451 * @tc.steps:step1. Test g_kvDelegatePtr->Rollback
452 * @tc.expected: step1. Return ERROR.
453 */
454 DistributedDBInterfacesTransactionTestCase::RollBack001(g_kvDelegatePtr);
455 }
456
457 /**
458 * @tc.name: RollBack002
459 * @tc.desc: rollback a transaction two times
460 * @tc.type: FUNC
461 * @tc.require: AR000BVRNM AR000CQDTQ
462 * @tc.author: huangnaigu
463 */
464 HWTEST_F(DistributedDBInterfacesTransactionTest, Rollback002, TestSize.Level1)
465 {
466 /**
467 * @tc.steps:step1. start a transaction
468 * @tc.expected: step1. Return OK.
469 */
470 /**
471 * @tc.steps:step2. rollback the transaction
472 * @tc.expected: step2. Return OK.
473 */
474 /**
475 * @tc.steps:step3. rollback the transaction the second time
476 * @tc.expected: step3. Return ERROR.
477 */
478 DistributedDBInterfacesTransactionTestCase::RollBack002(g_kvDelegatePtr);
479 }
480
481 /**
482 * @tc.name: RollBack003
483 * @tc.desc: insert a data and rollback
484 * @tc.type: FUNC
485 * @tc.require: AR000BVRNM AR000CQDTQ
486 * @tc.author: huangnaigu
487 */
488 HWTEST_F(DistributedDBInterfacesTransactionTest, Rollback003, TestSize.Level1)
489 {
490 /**
491 * @tc.steps:step1. start a transaction
492 * @tc.expected: step1. Return OK.
493 */
494 /**
495 * @tc.steps:step2. Put (k1,v1)
496 * @tc.expected: step2. Return OK.
497 */
498 /**
499 * @tc.steps:step3. rollback a transaction
500 * @tc.expected: step3. Return OK.
501 */
502 /**
503 * @tc.steps:step4. check if (k1,v1) exists
504 * @tc.expected: step4. Return NOT_FOUND.
505 */
506 DistributedDBInterfacesTransactionTestCase::RollBack003(g_kvDelegatePtr, g_snapshotDelegatePtr);
507 }
508
509 /**
510 * @tc.name: RollBack004
511 * @tc.desc: update a data and rollback
512 * @tc.type: FUNC
513 * @tc.require: AR000BVRNM AR000CQDTQ
514 * @tc.author: huangnaigu
515 */
516 HWTEST_F(DistributedDBInterfacesTransactionTest, Rollback004, TestSize.Level1)
517 {
518 /**
519 * @tc.steps:step1. Put (k1,v1)
520 * @tc.expected: step1. Return OK.
521 */
522 /**
523 * @tc.steps:step2. start a transaction
524 * @tc.expected: step2. Return OK.
525 */
526 /**
527 * @tc.steps:step3. Update (k1,v1) to (k1,v2) in the transaction
528 * @tc.expected: step3. Return OK.
529 */
530 /**
531 * @tc.steps:step4. rollback the transaction
532 * @tc.expected: step4. Return OK.
533 */
534 /**
535 * @tc.steps:step5. check the value of k1 is v1
536 * @tc.expected: step5. verification is OK .
537 */
538 DistributedDBInterfacesTransactionTestCase::RollBack004(g_kvDelegatePtr, g_snapshotDelegatePtr);
539 }
540
541 /**
542 * @tc.name: RollBack005
543 * @tc.desc: delete a exist data and rollback
544 * @tc.type: FUNC
545 * @tc.require: AR000BVRNM AR000CQDTQ
546 * @tc.author: huangnaigu
547 */
548 HWTEST_F(DistributedDBInterfacesTransactionTest, Rollback005, TestSize.Level1)
549 {
550 /**
551 * @tc.steps:step1. Put (k1,v1)
552 * @tc.expected: step1. Return OK.
553 */
554 /**
555 * @tc.steps:step2. start a transaction
556 * @tc.expected: step2. Return OK.
557 */
558 /**
559 * @tc.steps:step3. Delete (k1,v1) in the transaction
560 * @tc.expected: step3. Return OK.
561 */
562 /**
563 * @tc.steps:step4. rollback the transaction
564 * @tc.expected: step4. Return OK.
565 */
566 /**
567 * @tc.steps:step5. check the value of k1 is v1
568 * @tc.expected: step5. verification is OK .
569 */
570 DistributedDBInterfacesTransactionTestCase::RollBack005(g_kvDelegatePtr, g_snapshotDelegatePtr);
571 }
572
573 /**
574 * @tc.name: RollBack006
575 * @tc.desc: clear db and rollback
576 * @tc.type: FUNC
577 * @tc.require: AR000BVRNM AR000CQDTQ
578 * @tc.author: huangnaigu
579 */
580 HWTEST_F(DistributedDBInterfacesTransactionTest, Rollback006, TestSize.Level1)
581 {
582 /**
583 * @tc.steps:step1. PutBatch records: (k1,v1), (k2,v2)
584 * @tc.expected: step1. Return OK.
585 */
586 /**
587 * @tc.steps:step2. start a transaction
588 * @tc.expected: step2. Return OK.
589 */
590 /**
591 * @tc.steps:step3. Clear all records in the transaction
592 * @tc.expected: step3. Return OK.
593 */
594 /**
595 * @tc.steps:step4. rollback the transaction
596 * @tc.expected: step4. Return OK.
597 */
598 /**
599 * @tc.steps:step5. check if there are 2 records in the db
600 * @tc.expected: step5. verification is OK .
601 */
602 DistributedDBInterfacesTransactionTestCase::RollBack006(g_kvDelegatePtr, g_snapshotDelegatePtr);
603 }
604
605 /**
606 * @tc.name: RollBack007
607 * @tc.desc: delete a exist data and update a data and rollback
608 * @tc.type: FUNC
609 * @tc.require: AR000BVRNM AR000CQDTQ
610 * @tc.author: huangnaigu
611 */
612 HWTEST_F(DistributedDBInterfacesTransactionTest, Rollback007, TestSize.Level1)
613 {
614 /**
615 * @tc.steps:step1. PutBatch records: (k1,v1), (k2,v2)
616 * @tc.expected: step1. Return OK.
617 */
618 /**
619 * @tc.steps:step2. start a transaction
620 * @tc.expected: step2. Return OK.
621 */
622 /**
623 * @tc.steps:step3. Delete (k1,v1) in the transaction
624 * @tc.expected: step3. Return OK.
625 */
626 /**
627 * @tc.steps:step4. Update (k2,v2) to (k2,v1) in the transaction
628 * @tc.expected: step4. Return OK.
629 */
630 /**
631 * @tc.steps:step5. rollback the transaction
632 * @tc.expected: step5. Return OK.
633 */
634 /**
635 * @tc.steps:step6. check if (k1,v1),(k2,v2) exist and no more records in the db
636 * @tc.expected: step6. verification is OK .
637 */
638 DistributedDBInterfacesTransactionTestCase::RollBack007(g_kvDelegatePtr, g_snapshotDelegatePtr);
639 }
640
641 /**
642 * @tc.name: RollBack008
643 * @tc.desc: clear db and insert a data and rollback
644 * @tc.type: FUNC
645 * @tc.require: AR000BVRNM AR000CQDTQ
646 * @tc.author: huangnaigu
647 */
648 HWTEST_F(DistributedDBInterfacesTransactionTest, Rollback008, TestSize.Level1)
649 {
650 /**
651 * @tc.steps:step1. PutBatch records: (k1,v1), (k2,v2)
652 * @tc.expected: step1. Return OK.
653 */
654 /**
655 * @tc.steps:step2. start a transaction
656 * @tc.expected: step2. Return OK.
657 */
658 /**
659 * @tc.steps:step3. Clear all records in the transaction
660 * @tc.expected: step3. Return OK.
661 */
662 /**
663 * @tc.steps:step4. Put (012, ABC) in the transaction
664 * @tc.expected: step4. Return OK.
665 */
666 /**
667 * @tc.steps:step5. rollback the transaction
668 * @tc.expected: step5. Return OK.
669 */
670 /**
671 * @tc.steps:step6. check if (k1,v1),(k2,v2) exist and no more records in the db
672 * @tc.expected: step6. verification is OK .
673 */
674 DistributedDBInterfacesTransactionTestCase::RollBack008(g_kvDelegatePtr, g_snapshotDelegatePtr);
675 }
676 #endif // OMIT_MULTI_VER