Skip to content

Commit

Permalink
IGNITE-20592 Added the multiple nodes argument to the 'schedule_index…
Browse files Browse the repository at this point in the history
…es_rebuild' command (#10982)
  • Loading branch information
Vladsz83 authored Oct 19, 2023
1 parent 4a95648 commit 32f7a7e
Show file tree
Hide file tree
Showing 11 changed files with 443 additions and 115 deletions.
2 changes: 1 addition & 1 deletion docs/_docs/tools/control-script.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ The `schedule_indexes_rebuild` commands Apache Ignite to rebuild indexes for spe

[source, shell]
----
control.sh|bat --cache schedule_indexes_rebuild --node-id nodeId --cache-names cacheName[index1,...indexN],cacheName2,cacheName3[index1] --group-names groupName1,groupName2,...groupNameN
control.sh|bat --cache schedule_indexes_rebuild --node-ids nodeId1,...nodeIdN|--all-nodes --cache-names cacheName[index1,...indexN],cacheName2,cacheName3[index1] --group-names groupName1,groupName2,...groupNameN
----

Parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,52 @@ public void testIndexForceRebuildWrongArgs() {
IllegalArgumentException.class,
"Unexpected value: --some-other-arg"
);

GridTestUtils.assertThrows(
null,
() -> parseArgs(asList(
CACHE, "indexes_force_rebuild",
"--node-id", nodeId,
"--node-ids", nodeId + ',' + nodeId,
"--cache-names", "someNames"
)),
IllegalArgumentException.class,
"Only one of [--node-ids, --all-nodes, --node-id] allowed"
);

GridTestUtils.assertThrows(
null,
() -> parseArgs(asList(
CACHE, "indexes_force_rebuild",
"--node-id", nodeId,
"--all-nodes"
)),
IllegalArgumentException.class,
"Only one of [--node-ids, --all-nodes, --node-id] allowed"
);

GridTestUtils.assertThrows(
null,
() -> parseArgs(asList(
CACHE, "indexes_force_rebuild",
"--node-ids", nodeId + ',' + nodeId,
"--all-nodes"
)),
IllegalArgumentException.class,
"Only one of [--node-ids, --all-nodes, --node-id] allowed"
);

GridTestUtils.assertThrows(
null,
() -> parseArgs(asList(
CACHE, "indexes_force_rebuild",
"--node-id", nodeId,
"--node-ids", nodeId + ',' + nodeId,
"--all-nodes"
)),
IllegalArgumentException.class,
"Only one of [--node-ids, --all-nodes, --node-id] allowed"
);
}

/** */
Expand Down Expand Up @@ -1037,6 +1083,37 @@ public void testScheduleIndexRebuildWrongArgs() {
IllegalArgumentException.class,
"Square brackets must contain comma-separated indexes or not be used at all."
);

GridTestUtils.assertThrows(
null,
() -> parseArgs(asList(CACHE, "schedule_indexes_rebuild", "--node-id", nodeId, "--all-nodes", "--group-names", "a")),
IllegalArgumentException.class,
"Only one of [--node-ids, --all-nodes, --node-id]"
);

GridTestUtils.assertThrows(
null,
() -> parseArgs(asList(CACHE, "schedule_indexes_rebuild", "--node-id", nodeId, "--node-ids", nodeId + ',' + nodeId,
"--group-names", "a")),
IllegalArgumentException.class,
"Only one of [--node-ids, --all-nodes, --node-id]"
);

GridTestUtils.assertThrows(
null,
() -> parseArgs(asList(CACHE, "schedule_indexes_rebuild", "--all-nodes", "--node-ids", nodeId + ',' + nodeId,
"--group-names", "a")),
IllegalArgumentException.class,
"Only one of [--node-ids, --all-nodes, --node-id]"
);

GridTestUtils.assertThrows(
null,
() -> parseArgs(asList(CACHE, "schedule_indexes_rebuild", "--node-id", nodeId, "--all-nodes",
"--node-ids", nodeId + ',' + nodeId, "--group-names", "a")),
IllegalArgumentException.class,
"Only one of [--node-ids, --all-nodes, --node-id]"
);
}

/** */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,37 +285,6 @@ public void testComplexIndexRebuild() throws IgniteInterruptedCheckedException {
removeLogListener(grid(LAST_NODE_NUM), lsnr);
}

/**
* Checks two arguments in the group are not allowed.
*/
@Test
public void testInvalidArgumentGroups() {
injectTestSystemOut();

assertContains(log, executeCommand(EXIT_CODE_INVALID_ARGUMENTS, "--cache", "indexes_force_rebuild",
"--node-ids", grid(LAST_NODE_NUM).localNode().id().toString() + ',' + grid(0).localNode().id().toString(),
"--node-id", grid(LAST_NODE_NUM).localNode().id().toString(),
"--cache-names", CACHE_NAME_NO_GRP),
"Only one of [--node-ids, --all-nodes, --node-id] allowed");

assertContains(log, executeCommand(EXIT_CODE_INVALID_ARGUMENTS, "--cache", "indexes_force_rebuild",
"--node-ids", grid(LAST_NODE_NUM).localNode().id().toString() + ',' + grid(0).localNode().id().toString(),
"--all-nodes",
"--cache-names", CACHE_NAME_NO_GRP),
"Only one of [--node-ids, --all-nodes, --node-id] allowed");

assertContains(log, executeCommand(EXIT_CODE_INVALID_ARGUMENTS, "--cache", "indexes_force_rebuild",
"--all-nodes",
"--node-id", grid(LAST_NODE_NUM).localNode().id().toString(),
"--cache-names", CACHE_NAME_NO_GRP),
"Only one of [--node-ids, --all-nodes, --node-id] allowed");

assertContains(log, executeCommand(EXIT_CODE_INVALID_ARGUMENTS, "--cache", "indexes_force_rebuild",
"--node-id", grid(LAST_NODE_NUM).localNode().id().toString(),
"--cache-names", CACHE_NAME_NO_GRP, "--group-names", CACHE_NAME_NO_GRP),
"Only one of [--group-names, --cache-names] allowed");
}

/**
* Checks --node-id and --cache-names options,
* correctness of utility output and the fact that indexes were actually rebuilt.
Expand Down Expand Up @@ -730,7 +699,7 @@ private static void validateOutputCacheNamesNotFound(String outputStr, String...
assertContains(
log,
outputStr,
"WARNING: These caches were not found:" + U.nl() + makeStringListWithIndent(cacheNames)
CacheIndexesForceRebuildCommand.PREF_CACHES_NOT_FOUND + U.nl() + makeStringListWithIndent(cacheNames)
);
}

Expand All @@ -744,7 +713,7 @@ private void validateOutputCacheGroupsNotFound(String outputStr, String... cache
assertContains(
log,
outputStr,
"WARNING: These cache groups were not found:" + U.nl() + makeStringListWithIndent(cacheGrps)
CacheIndexesForceRebuildCommand.PREF_GROUPS_NOT_FOUND + U.nl() + makeStringListWithIndent(cacheGrps)
);
}

Expand Down Expand Up @@ -815,7 +784,7 @@ private void validateOutputIndicesRebuildWasStarted(String outputStr, Map<String
* @param prefix Prefix or header to search.
* @param targetStr Target string to search after {@code prefix}.
*/
private static void validateMultiNodeOutput(String outputStr, String prefix, String targetStr) {
static void validateMultiNodeOutput(String outputStr, String prefix, String targetStr) {
String[] lines = outputStr.split(U.nl());

for (int i = 0, heraderIdx = -1; i < lines.length; ++i) {
Expand Down
Loading

0 comments on commit 32f7a7e

Please sign in to comment.