20 #include <ripple/beast/unit_test.h>
21 #include <ripple/beast/utility/temp_dir.h>
22 #include <ripple/core/ConfigSections.h>
23 #include <ripple/nodestore/DatabaseShard.h>
24 #include <ripple/protocol/ErrorCodes.h>
25 #include <ripple/protocol/jss.h>
26 #include <test/jtx/Env.h>
42 auto const completed =
43 result[jss::error_message] ==
"Database import not running";
48 info->incomplete().size() + info->finalized().size() ==
66 sectionNode.set(
"earliest_seq",
"257");
67 sectionNode.set(
"ledgers_per_shard",
"256");
68 c->setupControl(
true,
true,
true);
70 return jtx::Env(*
this, std::move(c));
77 for (
int i = 0; i < 256 * (numberOfShards + 1); ++i)
84 if (!BEAST_EXPECT(!shardStore))
92 jvParams[jss::action] =
"status";
94 auto const result = env.
rpc(
95 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
105 jvParams[jss::action] =
"start";
107 auto const result = env.
rpc(
108 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
117 jvParams[jss::action] =
"status";
119 auto const result = env.
rpc(
120 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
136 section.set(
"path", tempDir.
path());
137 section.set(
"max_historical_shards",
"20");
138 section.set(
"ledgers_per_shard",
"256");
139 section.set(
"earliest_seq",
"257");
141 sectionNode.set(
"earliest_seq",
"257");
142 sectionNode.set(
"ledgers_per_shard",
"256");
143 c->setupControl(
true,
true,
true);
145 return jtx::Env(*
this, std::move(c));
153 (numberOfShards + 1);
160 if (!BEAST_EXPECT(shardStore))
168 jvParams[jss::action] =
"start";
170 auto const result = env.
rpc(
171 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
174 result[jss::message] ==
"Database import initiated...");
177 while (!shardStore->getDatabaseImportSequence())
188 jvParams[jss::action] =
"status";
190 auto const result = env.
rpc(
191 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
194 result[jss::status] ==
"success" ||
205 auto const completeShards =
206 shardStore->getShardInfo()->finalized();
208 if (!completeShards.empty())
210 auto const result = env.
rpc(
217 BEAST_EXPECT(result[jss::firstShardIndex] == 1);
218 BEAST_EXPECT(result[jss::lastShardIndex] == 10);
222 if (boost::icl::contains(completeShards, 1))
224 auto const result = env.
rpc(
230 result[jss::currentShardIndex] >= 1 ||
240 false,
"Import timeout: could just be a slow machine.");
246 while (!boost::icl::contains(
247 shardStore->getShardInfo()->finalized(), 10))
270 section.set(
"path", tempDir.
path());
271 section.set(
"max_historical_shards",
"20");
272 section.set(
"ledgers_per_shard",
"256");
273 section.set(
"earliest_seq",
"257");
275 sectionNode.set(
"earliest_seq",
"257");
276 sectionNode.set(
"ledgers_per_shard",
"256");
277 c->setupControl(
true,
true,
true);
279 return jtx::Env(*
this, std::move(c));
287 (numberOfShards + 1);
294 if (!BEAST_EXPECT(shardStore))
302 jvParams[jss::action] =
"start";
304 auto const result = env.
rpc(
305 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
308 result[jss::message] ==
"Database import initiated...");
316 jvParams[jss::action] =
"status";
318 auto const result = env.
rpc(
319 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
322 result[jss::status] ==
"success" ||
328 while (shardStore->getShardInfo()->finalized().empty())
336 false,
"Import timeout: could just be a slow machine.");
344 jvParams[jss::action] =
"stop";
346 auto const result = env.
rpc(
347 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
350 result[jss::message] ==
"Database import halt initiated..." ||
363 jvParams[jss::action] =
"status";
365 auto const result = env.
rpc(
366 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
370 if (result.isMember(jss::error))
372 if (BEAST_EXPECT(result.isMember(jss::error_message)))
375 result[jss::error_message] ==
376 "Database import not running");
386 false,
"Import timeout: could just be a slow machine.");