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>
50 auto const integrityWarning =
51 "reducing the data integrity guarantees from the "
52 "default [sqlite] behavior is not recommended for "
53 "nodes storing large amounts of history, because of the "
54 "difficulty inherent in rebuilding corrupted data.";
61 if (BEAST_EXPECT(s.globalPragma->size() == 3))
64 s.globalPragma->at(0) ==
"PRAGMA journal_mode=wal;");
66 s.globalPragma->at(1) ==
"PRAGMA synchronous=normal;");
68 s.globalPragma->at(2) ==
"PRAGMA temp_store=file;");
79 auto& section = p->section(
"sqlite");
80 section.set(
"safety_level",
"high");
82 p->LEDGER_HISTORY = 100
'000'000;
87 std::make_unique<CheckMessageLogs>(
88 integrityWarning, &found),
94 if (BEAST_EXPECT(s.globalPragma->size() == 3))
97 s.globalPragma->at(0) ==
"PRAGMA journal_mode=wal;");
99 s.globalPragma->at(1) ==
"PRAGMA synchronous=normal;");
101 s.globalPragma->at(2) ==
"PRAGMA temp_store=file;");
112 auto& section = p->section(
"sqlite");
113 section.set(
"safety_level",
"low");
115 p->LEDGER_HISTORY = 100
'000'000;
120 std::make_unique<CheckMessageLogs>(
121 integrityWarning, &found),
127 if (BEAST_EXPECT(s.globalPragma->size() == 3))
130 s.globalPragma->at(0) ==
"PRAGMA journal_mode=memory;");
132 s.globalPragma->at(1) ==
"PRAGMA synchronous=off;");
134 s.globalPragma->at(2) ==
"PRAGMA temp_store=memory;");
145 auto& section = p->section(
"sqlite");
146 section.set(
"journal_mode",
"off");
147 section.set(
"synchronous",
"extra");
148 section.set(
"temp_store",
"default");
154 std::make_unique<CheckMessageLogs>(
155 integrityWarning, &found),
161 BEAST_EXPECT(!found);
163 if (BEAST_EXPECT(s.globalPragma->size() == 3))
166 s.globalPragma->at(0) ==
"PRAGMA journal_mode=off;");
168 s.globalPragma->at(1) ==
"PRAGMA synchronous=extra;");
170 s.globalPragma->at(2) ==
"PRAGMA temp_store=default;");
181 auto& section = p->section(
"sqlite");
182 section.set(
"journal_mode",
"off");
183 section.set(
"synchronous",
"extra");
184 section.set(
"temp_store",
"default");
186 p->LEDGER_HISTORY = 50
'000'000;
191 std::make_unique<CheckMessageLogs>(
192 integrityWarning, &found),
200 if (BEAST_EXPECT(s.globalPragma->size() == 3))
203 s.globalPragma->at(0) ==
"PRAGMA journal_mode=off;");
205 s.globalPragma->at(1) ==
"PRAGMA synchronous=extra;");
207 s.globalPragma->at(2) ==
"PRAGMA temp_store=default;");
213 auto const expected =
214 "Failed to initialize SQLite databases: "
215 "Configuration file may not define both \"safety_level\" and "
221 auto& section = p->section(
"sqlite");
222 section.set(
"safety_level",
"low");
223 section.set(
"journal_mode",
"off");
224 section.set(
"synchronous",
"extra");
225 section.set(
"temp_store",
"default");
233 std::make_unique<CheckMessageLogs>(expected, &found),
245 auto const expected =
246 "Failed to initialize SQLite databases: Configuration file may "
247 "not define both \"safety_level\" and \"journal_mode\"";
252 auto& section = p->section(
"sqlite");
253 section.set(
"safety_level",
"high");
254 section.set(
"journal_mode",
"off");
262 std::make_unique<CheckMessageLogs>(expected, &found),
274 auto const expected =
275 "Failed to initialize SQLite databases: Configuration file may "
276 "not define both \"safety_level\" and \"synchronous\"";
281 auto& section = p->section(
"sqlite");
282 section.set(
"safety_level",
"low");
283 section.set(
"synchronous",
"extra");
291 std::make_unique<CheckMessageLogs>(expected, &found),
303 auto const expected =
304 "Failed to initialize SQLite databases: Configuration file may "
305 "not define both \"safety_level\" and \"temp_store\"";
310 auto& section = p->section(
"sqlite");
311 section.set(
"safety_level",
"high");
312 section.set(
"temp_store",
"default");
320 std::make_unique<CheckMessageLogs>(expected, &found),
332 auto const expected =
333 "Failed to initialize SQLite databases: Invalid safety_level "
339 auto& section = p->section(
"sqlite");
340 section.set(
"safety_level",
"slow");
348 std::make_unique<CheckMessageLogs>(expected, &found),
360 auto const expected =
361 "Failed to initialize SQLite databases: Invalid journal_mode "
367 auto& section = p->section(
"sqlite");
368 section.set(
"journal_mode",
"fast");
376 std::make_unique<CheckMessageLogs>(expected, &found),
388 auto const expected =
389 "Failed to initialize SQLite databases: Invalid synchronous "
395 auto& section = p->section(
"sqlite");
396 section.set(
"synchronous",
"instant");
404 std::make_unique<CheckMessageLogs>(expected, &found),
416 auto const expected =
417 "Failed to initialize SQLite databases: Invalid temp_store "
423 auto& section = p->section(
"sqlite");
424 section.set(
"temp_store",
"network");
432 std::make_unique<CheckMessageLogs>(expected, &found),
456 srcParams.
set(
"type", srcBackendType);
457 srcParams.
set(
"path", node_db.
path());
491 destParams.
set(
"type", destBackendType);
492 destParams.
set(
"path", dest_db.
path());
504 "import into '" + destBackendType +
"' from '" +
505 srcBackendType +
"'");
525 bool const testPersistence,
527 int numObjsToTest = 2000)
532 std::string s =
"NodeStore backend '" + type +
"'";
538 nodeParams.
set(
"type", type);
539 nodeParams.
set(
"path", node_db.
path());
598 if (type ==
"memory")
619 nodeParams.
set(
"earliest_seq",
"0");
638 nodeParams.
set(
"earliest_seq",
"1");
650 BEAST_EXPECT(db->earliestLedgerSeq() == 1);
693 #if RIPPLE_ROCKSDB_AVAILABLE
702 #if RIPPLE_ROCKSDB_AVAILABLE
706 #if RIPPLE_ENABLE_SQLITE_BACKEND_TESTS