-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctests.cpp
More file actions
817 lines (601 loc) · 21.7 KB
/
functests.cpp
File metadata and controls
817 lines (601 loc) · 21.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
#include "nplex-cpp/client.hpp"
#include "logger.hpp"
#include <cstdlib>
#include <cstring>
#include <getopt.h>
#include <initializer_list>
#include <iostream>
#include <stop_token>
#include <string>
#include <thread>
using namespace nplex;
// ---------------------------------------------------------------------------
// Types
// ---------------------------------------------------------------------------
struct config_t
{
std::string user;
std::string password;
std::string servers;
};
// ---------------------------------------------------------------------------
// Functions
// ---------------------------------------------------------------------------
static void print_help(const char *prog)
{
std::cout
<< "Description:\n"
<< " Functional tests for nplex isolation levels.\n"
<< "\n"
<< "Usage: " << prog << " [options]\n"
<< "\n"
<< "Options:\n"
<< " -h, --help Show this help and exit\n"
<< " -u, --user USER User identifier (mandatory)\n"
<< " -p, --password PWD User password (mandatory)\n"
<< " -s, --servers LIST Comma-separated server list (mandatory)\n";
}
static bool parse_args(int argc, char *argv[], config_t &cfg)
{
static struct option long_opts[] = {
{"help", no_argument, nullptr, 'h'},
{"user", required_argument, nullptr, 'u'},
{"password", required_argument, nullptr, 'p'},
{"servers", required_argument, nullptr, 's'},
{nullptr, 0, nullptr, 0}
};
int opt = 0;
while ((opt = getopt_long(argc, argv, "hu:p:s:", long_opts, nullptr)) != -1)
{
switch (opt)
{
case 'h': print_help(argv[0]); return false;
case 'u': cfg.user = optarg; break;
case 'p': cfg.password = optarg; break;
case 's': cfg.servers = optarg; break;
default: print_help(argv[0]); return false;
}
}
if (cfg.user.empty() || cfg.password.empty() || cfg.servers.empty()) {
std::cerr << "Error: --user, --password, and --servers are mandatory.\n\n";
print_help(argv[0]);
return false;
}
return true;
}
static void clean_db(const client_ptr &cli)
{
auto tx = cli->create_tx(transaction::isolation_e::READ_COMMITTED, false);
tx->remove("**");
auto rc = tx->submit(true).get();
if (rc != transaction::submit_e::COMMITTED && rc != transaction::submit_e::NO_MODIFICATIONS)
throw std::runtime_error("clean_db: submit failed");
}
struct external_upsert_change_t
{
const char *key;
std::string_view value;
};
static void external_upsert(const client_ptr &cli, std::initializer_list<external_upsert_change_t> changes)
{
if (changes.size() == 0)
return;
auto tx = cli->create_tx(transaction::isolation_e::READ_COMMITTED, false);
for (const auto &change : changes)
tx->upsert(change.key, change.value);
auto rc = tx->submit(true).get();
if (rc != transaction::submit_e::COMMITTED)
throw std::runtime_error("external_upsert(batch): submit failed");
}
static void external_upsert(const client_ptr &cli, const char *key, const std::string_view &value)
{
external_upsert(cli, {{key, value}});
}
static void external_remove(const client_ptr &cli, std::initializer_list<const char *> keys)
{
if (keys.size() == 0)
return;
auto tx = cli->create_tx(transaction::isolation_e::READ_COMMITTED, false);
for (const auto *key : keys)
tx->remove(key);
auto rc = tx->submit(true).get();
if (rc != transaction::submit_e::COMMITTED && rc != transaction::submit_e::NO_MODIFICATIONS)
throw std::runtime_error("external_remove(batch): submit failed");
}
static void external_remove(const client_ptr &cli, const char *key)
{
external_remove(cli, {key});
}
// ---------------------------------------------------------------------------
// Test infrastructure
// ---------------------------------------------------------------------------
static int g_tests_passed = 0;
static int g_tests_failed = 0;
static int g_tests_aux = 0;
#define CHECK(expr) \
do { \
if (expr) { \
g_tests_passed++; \
} else { \
g_tests_failed++; \
std::cerr << " FAIL[" << __LINE__ << "]" << std::endl; \
} \
} while (false)
#define TEST_STARTS(name) \
std::cout << " " << (name) << "..." << std::flush; \
g_tests_aux = g_tests_failed
#define TEST_FINISH() \
if (g_tests_aux == g_tests_failed) \
std::cout << " OK" << std::endl
// ---------------------------------------------------------------------------
// READ_COMMITTED tests
// ---------------------------------------------------------------------------
static void test_rc_read_sees_commits(const client_ptr &cli)
{
TEST_STARTS("rc_read_sees_commits");
clean_db(cli);
auto tx1 = cli->create_tx(transaction::isolation_e::READ_COMMITTED, true);
// key does not exist yet
auto val = tx1->read("test/x");
CHECK(val == nullptr);
// external commit: insert test/x=1
external_upsert(cli, "test/x", "1");
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "1");
// external commit: update test/x=2
external_upsert(cli, "test/x", "2");
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "2");
tx1->discard();
TEST_FINISH();
}
static void test_rc_own_writes_visible(const client_ptr &cli)
{
TEST_STARTS("rc_own_writes_visible");
clean_db(cli);
auto tx1 = cli->create_tx(transaction::isolation_e::READ_COMMITTED, false);
tx1->upsert("test/x", "99");
// external commit inserting a different value
external_upsert(cli, "test/x", "3");
auto val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "99");
tx1->discard();
TEST_FINISH();
}
static void test_rc_read_after_external_delete(const client_ptr &cli)
{
TEST_STARTS("rc_read_after_external_delete");
clean_db(cli);
external_upsert(cli, "test/x", "10");
auto tx1 = cli->create_tx(transaction::isolation_e::READ_COMMITTED, true);
auto val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "10");
external_remove(cli, "test/x");
val = tx1->read("test/x");
CHECK(val == nullptr);
tx1->discard();
TEST_FINISH();
}
static void test_rc_read_or_default(const client_ptr &cli)
{
TEST_STARTS("rc_read_or_default");
clean_db(cli);
auto tx1 = cli->create_tx(transaction::isolation_e::READ_COMMITTED, true);
auto val = tx1->read_or("test/missing", "default_val");
CHECK(val != nullptr && val->data() == "default_val");
tx1->discard();
TEST_FINISH();
}
static void test_rc_full_scenario(const client_ptr &cli)
{
TEST_STARTS("rc_full_scenario");
clean_db(cli);
auto tx1 = cli->create_tx(transaction::isolation_e::READ_COMMITTED, false);
// verify test/x is null
auto val = tx1->read("test/x");
CHECK(val == nullptr);
// tx0 inserts test/x=1
external_upsert(cli, "test/x", "1");
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "1");
// tx0 updates test/x=2
external_upsert(cli, "test/x", "2");
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "2");
// tx1 upserts test/x=99
tx1->upsert("test/x", "99");
// tx0 updates test/x=3
external_upsert(cli, "test/x", "3");
// tx1 reads test/x -> should see own write (99)
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "99");
// tx1 delete test/x
tx1->remove("test/x");
val = tx1->read("test/x");
CHECK(val == nullptr);
// tx0 updates test/x=4
external_upsert(cli, "test/x", "4");
val = tx1->read("test/x");
CHECK(val == nullptr);
tx1->discard();
TEST_FINISH();
}
// ---------------------------------------------------------------------------
// REPEATABLE_READ tests
// ---------------------------------------------------------------------------
static void test_rr_repeatable_reads(const client_ptr &cli)
{
TEST_STARTS("rr_repeatable_reads");
clean_db(cli);
external_upsert(cli, "test/x", "1");
auto tx1 = cli->create_tx(transaction::isolation_e::REPEATABLE_READ, true);
auto val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "1");
// external commit: update test/x=2
external_upsert(cli, "test/x", "2");
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "1");
tx1->discard();
TEST_FINISH();
}
static void test_rr_new_key_reads_latest(const client_ptr &cli)
{
TEST_STARTS("rr_new_key_reads_latest");
clean_db(cli);
auto tx1 = cli->create_tx(transaction::isolation_e::REPEATABLE_READ, true);
// external commit before first read of test/y
external_upsert(cli, "test/y", "10");
auto val = tx1->read("test/y");
CHECK(val != nullptr && val->data() == "10");
// external update of test/y
external_upsert(cli, "test/y", "20");
val = tx1->read("test/y");
CHECK(val != nullptr && val->data() == "10");
tx1->discard();
TEST_FINISH();
}
static void test_rr_read_after_external_delete(const client_ptr &cli)
{
TEST_STARTS("rr_read_after_external_delete");
clean_db(cli);
external_upsert(cli, "test/x", "5");
auto tx1 = cli->create_tx(transaction::isolation_e::REPEATABLE_READ, true);
auto val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "5");
external_remove(cli, "test/x");
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "5");
tx1->discard();
TEST_FINISH();
}
static void test_rr_own_writes(const client_ptr &cli)
{
TEST_STARTS("rr_own_writes");
clean_db(cli);
external_upsert(cli, "test/x", "1");
auto tx1 = cli->create_tx(transaction::isolation_e::REPEATABLE_READ, false);
auto val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "1");
tx1->upsert("test/x", "50");
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "50");
external_upsert(cli, "test/x", "2");
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "50");
tx1->discard();
TEST_FINISH();
}
static void test_rr_full_scenario(const client_ptr &cli)
{
TEST_STARTS("rr_full_scenario");
clean_db(cli);
auto tx1 = cli->create_tx(transaction::isolation_e::REPEATABLE_READ, false);
// test/x doesn't exist
auto val = tx1->read("test/x");
CHECK(val == nullptr);
// tx0 inserts test/x=1
external_upsert(cli, "test/x", "1");
// test/x was already read (as null) -> repeatable read keeps null
val = tx1->read("test/x");
CHECK(val == nullptr);
tx1->discard();
// New tx1 to read test/x=1
tx1 = cli->create_tx(transaction::isolation_e::REPEATABLE_READ, false);
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "1");
// tx0 updates test/x=2
external_upsert(cli, "test/x", "2");
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "1");
// tx1 upserts test/x=99
tx1->upsert("test/x", "99");
// tx0 updates test/x=3
external_upsert(cli, "test/x", "3");
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "99");
tx1->discard();
TEST_FINISH();
}
// ---------------------------------------------------------------------------
// SERIALIZABLE tests
// ---------------------------------------------------------------------------
static void test_ser_snapshot_read(const client_ptr &cli)
{
TEST_STARTS("ser_snapshot_read");
clean_db(cli);
external_upsert(cli, {
{"test/x", "1"},
{"test/y", "2"}
});
auto tx1 = cli->create_tx(transaction::isolation_e::SERIALIZABLE, true);
// external commit: update both keys
external_upsert(cli, {
{"test/x", "10"},
{"test/y", "20"},
{"test/z", "30"}
});
CHECK(tx1->is_dirty() == false); // we haven't read them yet
auto val_x = tx1->read("test/x");
auto val_y = tx1->read("test/y");
auto val_z = tx1->read("test/z");
CHECK(val_x != nullptr && val_x->data() == "1");
CHECK(val_y != nullptr && val_y->data() == "2");
CHECK(val_z == nullptr);
CHECK(tx1->is_dirty() == true); // they have been read
auto rc = tx1->submit(false).get();
CHECK(rc == transaction::submit_e::NO_MODIFICATIONS);
tx1->discard();
TEST_FINISH();
}
static void test_ser_phantom_prevention(const client_ptr &cli)
{
TEST_STARTS("ser_phantom_prevention");
clean_db(cli);
auto tx1 = cli->create_tx(transaction::isolation_e::SERIALIZABLE, true);
// external insert after tx creation
external_upsert(cli, "test/phantom", "ghost");
auto val = tx1->read("test/phantom");
CHECK(val == nullptr);
tx1->discard();
TEST_FINISH();
}
static void test_ser_delete_not_visible(const client_ptr &cli)
{
TEST_STARTS("ser_delete_not_visible");
clean_db(cli);
external_upsert(cli, {
{"test/x", "alive1"},
{"test/y", "alive2"}
});
auto tx1 = cli->create_tx(transaction::isolation_e::SERIALIZABLE, true);
external_remove(cli, {
"test/x",
"test/y"
});
auto val_x = tx1->read("test/x");
auto val_y = tx1->read("test/y");
CHECK(val_x != nullptr && val_x->data() == "alive1");
CHECK(val_y != nullptr && val_y->data() == "alive2");
tx1->discard();
TEST_FINISH();
}
static void test_ser_own_writes(const client_ptr &cli)
{
TEST_STARTS("ser_own_writes");
clean_db(cli);
external_upsert(cli, "test/x", "1");
auto tx1 = cli->create_tx(transaction::isolation_e::SERIALIZABLE, false);
auto val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "1");
tx1->upsert("test/x", "42");
external_upsert(cli, "test/x", "999");
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "42");
tx1->discard();
TEST_FINISH();
}
static void test_ser_full_scenario(const client_ptr &cli)
{
TEST_STARTS("ser_full_scenario");
clean_db(cli);
auto tx1 = cli->create_tx(transaction::isolation_e::SERIALIZABLE, false);
// test/x doesn't exist at tx creation
auto val = tx1->read("test/x");
CHECK(val == nullptr);
// tx0 inserts test/x=1 (after tx1 creation -> not visible)
external_upsert(cli, "test/x", "1");
val = tx1->read("test/x");
CHECK(val == nullptr);
// tx1 upserts test/x=99
tx1->upsert("test/x", "99");
// tx0 updates test/x=3
external_upsert(cli, "test/x", "3");
val = tx1->read("test/x");
CHECK(val != nullptr && val->data() == "99");
tx1->discard();
TEST_FINISH();
}
static void test_ser_rev_consistent(const client_ptr &cli)
{
TEST_STARTS("ser_rev_consistent");
clean_db(cli);
auto tx0 = cli->create_tx(transaction::isolation_e::READ_COMMITTED, true);
auto tx1 = cli->create_tx(transaction::isolation_e::SERIALIZABLE, true);
CHECK(tx0->rev() == tx1->rev());
external_upsert(cli, "test/x", "1");
// After an external commit, READ_COMMITTED rev advances but SERIALIZABLE does not
auto rev0_after = tx0->rev();
auto rev1_after = tx1->rev();
CHECK(rev0_after > rev1_after);
tx0->discard();
tx1->discard();
TEST_FINISH();
}
// ---------------------------------------------------------------------------
// DIRTY flag tests
// ---------------------------------------------------------------------------
static void test_rc_not_dirty_on_read_key(const client_ptr &cli)
{
TEST_STARTS("rc_not_dirty_on_read_key");
clean_db(cli);
external_upsert(cli, "test/x", "1");
auto tx1 = cli->create_tx(transaction::isolation_e::READ_COMMITTED, false);
tx1->read("test/x");
CHECK(!tx1->is_dirty());
external_upsert(cli, "test/x", "2");
CHECK(!tx1->is_dirty());
auto rc = tx1->submit(false).get();
CHECK(rc == transaction::submit_e::NO_MODIFICATIONS);
TEST_FINISH();
}
static void test_rc_not_dirty_unrelated_key(const client_ptr &cli)
{
TEST_STARTS("rc_not_dirty_unrelated_key");
clean_db(cli);
external_upsert(cli, "test/x", "1");
auto tx1 = cli->create_tx(transaction::isolation_e::READ_COMMITTED, false);
tx1->read("test/x");
external_upsert(cli, "test/other", "99");
CHECK(!tx1->is_dirty());
tx1->discard();
TEST_FINISH();
}
static void test_rr_dirty_on_read_key(const client_ptr &cli)
{
TEST_STARTS("rr_dirty_on_read_key");
clean_db(cli);
external_upsert(cli, "test/x", "1");
auto tx1 = cli->create_tx(transaction::isolation_e::REPEATABLE_READ, false);
tx1->read("test/x");
CHECK(!tx1->is_dirty());
external_upsert(cli, "test/x", "2");
CHECK(tx1->is_dirty());
auto rc = tx1->submit(false).get();
CHECK(rc == transaction::submit_e::NO_MODIFICATIONS);
TEST_FINISH();
}
static void test_rr_not_dirty_unrelated_key(const client_ptr &cli)
{
TEST_STARTS("rr_not_dirty_unrelated_key");
clean_db(cli);
external_upsert(cli, "test/x", "1");
auto tx1 = cli->create_tx(transaction::isolation_e::REPEATABLE_READ, false);
tx1->read("test/x");
external_upsert(cli, "test/other", "99");
CHECK(!tx1->is_dirty());
tx1->discard();
TEST_FINISH();
}
static void test_ser_dirty_on_updated_key(const client_ptr &cli)
{
TEST_STARTS("ser_dirty_on_updated_key");
clean_db(cli);
external_upsert(cli, "test/x", "1");
auto tx1 = cli->create_tx(transaction::isolation_e::SERIALIZABLE, false);
tx1->read("test/x");
CHECK(!tx1->is_dirty());
external_upsert(cli, "test/x", "2");
CHECK(tx1->is_dirty());
auto rc = tx1->submit(false).get();
CHECK(rc == transaction::submit_e::NO_MODIFICATIONS);
TEST_FINISH();
}
static void test_ser_dirty_phantom_key(const client_ptr &cli)
{
TEST_STARTS("ser_dirty_phantom_key");
clean_db(cli);
auto tx1 = cli->create_tx(transaction::isolation_e::SERIALIZABLE, false);
// External creates a new key -> adds phantom entry to tx snapshot
external_upsert(cli, "test/new", "ghost");
// Phantom was tracked but tx is not dirty yet (first occurrence)
auto val = tx1->read("test/new");
CHECK(val == nullptr);
CHECK(!tx1->is_dirty());
// Second external commit on same key -> now it IS dirty
external_upsert(cli, "test/new", "ghost2");
CHECK(tx1->is_dirty());
tx1->discard();
TEST_FINISH();
}
static void test_dirty_forced_submit(const client_ptr &cli)
{
TEST_STARTS("dirty_forced_submit");
clean_db(cli);
external_upsert(cli, "test/x", "1");
auto tx1 = cli->create_tx(transaction::isolation_e::READ_COMMITTED, false);
tx1->read("test/x");
tx1->upsert("test/x", "forced");
external_upsert(cli, "test/x", "2");
CHECK(tx1->is_dirty());
auto rc = tx1->submit(true).get(); // force=true
CHECK(rc == transaction::submit_e::COMMITTED);
TEST_FINISH();
}
// ---------------------------------------------------------------------------
// Main
// ---------------------------------------------------------------------------
int main(int argc, char *argv[])
{
config_t cfg;
if (!parse_args(argc, argv, cfg))
return EXIT_FAILURE;
try {
// Configure connection
nplex::params_t params = {
.servers = cfg.servers,
.user = cfg.user,
.password = cfg.password
};
auto cli = nplex::client::create(params);
// Attach logger
//auto log = std::make_shared<::logger>(nplex::logger::log_level_e::WARN);
//cli->set_logger(log);
// Start event loop
std::jthread worker([cli](std::stop_token st) {
cli->run(std::move(st));
});
cli->wait_for_synced();
// Run tests
std::cout << "READ_COMMITTED tests" << std::endl;
test_rc_read_sees_commits(cli);
test_rc_own_writes_visible(cli);
test_rc_read_after_external_delete(cli);
test_rc_read_or_default(cli);
test_rc_full_scenario(cli);
std::cout << "REPEATABLE_READ tests" << std::endl;
test_rr_repeatable_reads(cli);
test_rr_new_key_reads_latest(cli);
test_rr_read_after_external_delete(cli);
test_rr_own_writes(cli);
test_rr_full_scenario(cli);
std::cout << "SERIALIZABLE tests" << std::endl;
test_ser_snapshot_read(cli);
test_ser_phantom_prevention(cli);
test_ser_delete_not_visible(cli);
test_ser_own_writes(cli);
test_ser_full_scenario(cli);
test_ser_rev_consistent(cli);
std::cout << "DIRTY flag tests" << std::endl;
test_rc_not_dirty_on_read_key(cli);
test_rc_not_dirty_unrelated_key(cli);
test_rr_dirty_on_read_key(cli);
test_rr_not_dirty_unrelated_key(cli);
test_ser_dirty_on_updated_key(cli);
test_ser_dirty_phantom_key(cli);
test_dirty_forced_submit(cli);
// Clean up
clean_db(cli);
// Summary
std::cout << "\n"
<< "Results: " << g_tests_passed << " passed, "
<< g_tests_failed << " failed, "
<< (g_tests_passed + g_tests_failed) << " total"
<< std::endl;
worker.request_stop();
return (g_tests_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
catch (const std::exception &e) {
std::cerr << "Error: " << e.what() << '\n';
return EXIT_FAILURE;
}
}