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" ||
206 auto const completeShards =
207 shardStore->getShardInfo()->finalized();
209 if (!completeShards.empty())
211 auto const result = env.
rpc(
217 shardStore, numberOfShards, result))
219 BEAST_EXPECT(result[jss::firstShardIndex] == 1);
220 BEAST_EXPECT(result[jss::lastShardIndex] == 10);
224 if (boost::icl::contains(completeShards, 1))
226 auto const result = env.
rpc(
232 result[jss::currentShardIndex] >= 1 ||
234 shardStore, numberOfShards, result));
245 "Import timeout: could just be a slow machine.");
254 while (!boost::icl::contains(
255 shardStore->getShardInfo()->finalized(), 10))
262 shardStore, numberOfShards, result));
280 section.set(
"path", tempDir.
path());
281 section.set(
"max_historical_shards",
"20");
282 section.set(
"ledgers_per_shard",
"256");
283 section.set(
"earliest_seq",
"257");
285 sectionNode.set(
"earliest_seq",
"257");
286 sectionNode.set(
"ledgers_per_shard",
"256");
287 c->setupControl(
true,
true,
true);
298 (numberOfShards + 1);
305 if (!BEAST_EXPECT(shardStore))
313 jvParams[jss::action] =
"start";
315 auto const result = env.
rpc(
316 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
319 result[jss::message] ==
"Database import initiated...");
327 jvParams[jss::action] =
"status";
329 auto const result = env.
rpc(
330 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
333 result[jss::status] ==
"success" ||
339 while (shardStore->getShardInfo()->finalized().empty())
347 false,
"Import timeout: could just be a slow machine.");
355 jvParams[jss::action] =
"stop";
357 auto const result = env.
rpc(
358 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
361 result[jss::message] ==
"Database import halt initiated..." ||
374 jvParams[jss::action] =
"status";
376 auto const result = env.
rpc(
377 "json",
"node_to_shard",
to_string(jvParams))[jss::result];
381 if (result.isMember(jss::error))
383 if (BEAST_EXPECT(result.isMember(jss::error_message)))
386 result[jss::error_message] ==
387 "Database import not running");
397 false,
"Import timeout: could just be a slow machine.");