20 #include <ripple/beast/utility/temp_dir.h>
21 #include <ripple/core/DatabaseCon.h>
22 #include <ripple/nodestore/DummyScheduler.h>
23 #include <ripple/nodestore/Manager.h>
25 #include <test/jtx/CheckMessageLogs.h>
26 #include <test/jtx/envconfig.h>
27 #include <test/nodestore/TestBase.h>
28 #include <test/unit_test/SuiteJournal.h>
51 auto const integrityWarning =
52 "reducing the data integrity guarantees from the "
53 "default [sqlite] behavior is not recommended for "
54 "nodes storing large amounts of history, because of the "
55 "difficulty inherent in rebuilding corrupted data.";
62 if (BEAST_EXPECT(s.globalPragma->size() == 3))
65 s.globalPragma->at(0) ==
"PRAGMA journal_mode=wal;");
67 s.globalPragma->at(1) ==
"PRAGMA synchronous=normal;");
69 s.globalPragma->at(2) ==
"PRAGMA temp_store=file;");
80 auto& section = p->section(
"sqlite");
81 section.set(
"safety_level",
"high");
83 p->LEDGER_HISTORY = 100
'000'000;
88 std::make_unique<CheckMessageLogs>(
89 integrityWarning, &found),
95 if (BEAST_EXPECT(s.globalPragma->size() == 3))
98 s.globalPragma->at(0) ==
"PRAGMA journal_mode=wal;");
100 s.globalPragma->at(1) ==
"PRAGMA synchronous=normal;");
102 s.globalPragma->at(2) ==
"PRAGMA temp_store=file;");
113 auto& section = p->section(
"sqlite");
114 section.set(
"safety_level",
"low");
116 p->LEDGER_HISTORY = 100
'000'000;
121 std::make_unique<CheckMessageLogs>(
122 integrityWarning, &found),
128 if (BEAST_EXPECT(s.globalPragma->size() == 3))
131 s.globalPragma->at(0) ==
"PRAGMA journal_mode=memory;");
133 s.globalPragma->at(1) ==
"PRAGMA synchronous=off;");
135 s.globalPragma->at(2) ==
"PRAGMA temp_store=memory;");
146 auto& section = p->section(
"sqlite");
147 section.set(
"journal_mode",
"off");
148 section.set(
"synchronous",
"extra");
149 section.set(
"temp_store",
"default");
155 std::make_unique<CheckMessageLogs>(
156 integrityWarning, &found),
162 BEAST_EXPECT(!found);
164 if (BEAST_EXPECT(s.globalPragma->size() == 3))
167 s.globalPragma->at(0) ==
"PRAGMA journal_mode=off;");
169 s.globalPragma->at(1) ==
"PRAGMA synchronous=extra;");
171 s.globalPragma->at(2) ==
"PRAGMA temp_store=default;");
182 auto& section = p->section(
"sqlite");
183 section.set(
"journal_mode",
"off");
184 section.set(
"synchronous",
"extra");
185 section.set(
"temp_store",
"default");
187 p->LEDGER_HISTORY = 50
'000'000;
192 std::make_unique<CheckMessageLogs>(
193 integrityWarning, &found),
201 if (BEAST_EXPECT(s.globalPragma->size() == 3))
204 s.globalPragma->at(0) ==
"PRAGMA journal_mode=off;");
206 s.globalPragma->at(1) ==
"PRAGMA synchronous=extra;");
208 s.globalPragma->at(2) ==
"PRAGMA temp_store=default;");
214 auto const expected =
215 "Failed to initialize SQL databases: "
216 "Configuration file may not define both \"safety_level\" and "
222 auto& section = p->section(
"sqlite");
223 section.set(
"safety_level",
"low");
224 section.set(
"journal_mode",
"off");
225 section.set(
"synchronous",
"extra");
226 section.set(
"temp_store",
"default");
234 std::make_unique<CheckMessageLogs>(expected, &found),
246 auto const expected =
247 "Failed to initialize SQL databases: Configuration file may "
248 "not define both \"safety_level\" and \"journal_mode\"";
253 auto& section = p->section(
"sqlite");
254 section.set(
"safety_level",
"high");
255 section.set(
"journal_mode",
"off");
263 std::make_unique<CheckMessageLogs>(expected, &found),
275 auto const expected =
276 "Failed to initialize SQL databases: Configuration file may "
277 "not define both \"safety_level\" and \"synchronous\"";
282 auto& section = p->section(
"sqlite");
283 section.set(
"safety_level",
"low");
284 section.set(
"synchronous",
"extra");
292 std::make_unique<CheckMessageLogs>(expected, &found),
304 auto const expected =
305 "Failed to initialize SQL databases: Configuration file may "
306 "not define both \"safety_level\" and \"temp_store\"";
311 auto& section = p->section(
"sqlite");
312 section.set(
"safety_level",
"high");
313 section.set(
"temp_store",
"default");
321 std::make_unique<CheckMessageLogs>(expected, &found),
333 auto const expected =
334 "Failed to initialize SQL databases: Invalid safety_level "
340 auto& section = p->section(
"sqlite");
341 section.set(
"safety_level",
"slow");
349 std::make_unique<CheckMessageLogs>(expected, &found),
361 auto const expected =
362 "Failed to initialize SQL databases: Invalid journal_mode "
368 auto& section = p->section(
"sqlite");
369 section.set(
"journal_mode",
"fast");
377 std::make_unique<CheckMessageLogs>(expected, &found),
389 auto const expected =
390 "Failed to initialize SQL databases: Invalid synchronous "
396 auto& section = p->section(
"sqlite");
397 section.set(
"synchronous",
"instant");
405 std::make_unique<CheckMessageLogs>(expected, &found),
417 auto const expected =
418 "Failed to initialize SQL databases: Invalid temp_store "
424 auto& section = p->section(
"sqlite");
425 section.set(
"temp_store",
"network");
433 std::make_unique<CheckMessageLogs>(expected, &found),
456 srcParams.
set(
"type", srcBackendType);
457 srcParams.
set(
"path", node_db.
path());
479 destParams.
set(
"type", destBackendType);
480 destParams.
set(
"path", dest_db.
path());
486 "import into '" + destBackendType +
"' from '" +
487 srcBackendType +
"'");
490 dest->importDatabase(*src);
507 bool const testPersistence,
509 int numObjsToTest = 2000)
513 std::string s =
"NodeStore backend '" + type +
"'";
519 nodeParams.
set(
"type", type);
520 nodeParams.
set(
"path", node_db.
path());
567 if (type ==
"memory")
581 nodeParams.
set(
"earliest_seq",
"0");
594 nodeParams.
set(
"earliest_seq",
"1");
600 BEAST_EXPECT(db->earliestLedgerSeq() == 1);
632 nodeParams.
set(
"ledgers_per_shard",
"100");
644 nodeParams.
set(
"ledgers_per_shard",
"256");
649 BEAST_EXPECT(db->ledgersPerShard() == 256);
668 #if RIPPLE_ROCKSDB_AVAILABLE
677 #if RIPPLE_ROCKSDB_AVAILABLE
681 #if RIPPLE_ENABLE_SQLITE_BACKEND_TESTS