use of org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_INVALID_ARGUMENTS in project ignite by apache.
the class GridCommandHandlerTest method testPersistenceCleanSpecifiedCachesCommand.
/**
* Test verifies persistence clean command with explicit list of caches to be cleaned.
*
* @throws Exception If failed.
*/
@Test
public void testPersistenceCleanSpecifiedCachesCommand() throws Exception {
String cacheName0 = DEFAULT_CACHE_NAME + "0";
String cacheName1 = DEFAULT_CACHE_NAME + "1";
String cacheName2 = DEFAULT_CACHE_NAME + "2";
String cacheName3 = DEFAULT_CACHE_NAME + "3";
String nonExistingCacheName = DEFAULT_CACHE_NAME + "4";
File mntcNodeWorkDir = startGridAndPutNodeToMaintenance(new CacheConfiguration[] { cacheConfiguration(cacheName0), cacheConfiguration(cacheName1), cacheConfiguration(cacheName2), cacheConfiguration(cacheName3) }, s -> !s.equals(cacheName3));
IgniteEx ig1 = startGrid(1);
String port = ig1.localNode().attribute(IgniteNodeAttributes.ATTR_REST_TCP_PORT).toString();
assertEquals(EXIT_CODE_INVALID_ARGUMENTS, execute("--persistence", "clean", "caches", nonExistingCacheName, "--host", "localhost", "--port", port));
assertEquals(EXIT_CODE_OK, execute("--persistence", "clean", "caches", cacheName0 + "," + cacheName1, "--host", "localhost", "--port", port));
boolean cleanedEmpty = Arrays.stream(mntcNodeWorkDir.listFiles()).filter(f -> f.getName().contains(cacheName0) || f.getName().contains(cacheName1)).map(f -> f.listFiles().length == 1).reduce(true, (t, u) -> t && u);
assertTrue(cleanedEmpty);
boolean nonCleanedNonEmpty = Arrays.stream(mntcNodeWorkDir.listFiles()).filter(f -> f.getName().contains(cacheName2) || f.getName().contains(cacheName3)).map(f -> f.listFiles().length > 1).reduce(true, (t, u) -> t && u);
assertTrue(nonCleanedNonEmpty);
stopGrid(1);
ig1 = startGrid(1);
assertTrue(ig1.context().maintenanceRegistry().isMaintenanceMode());
assertEquals(EXIT_CODE_OK, execute("--persistence", "clean", "caches", cacheName2, "--host", "localhost", "--port", port));
stopGrid(1);
ig1 = startGrid(1);
assertFalse(ig1.context().maintenanceRegistry().isMaintenanceMode());
}
use of org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_INVALID_ARGUMENTS in project ignite by apache.
the class GridCommandHandlerTest method testBaselineAddOnNotActiveCluster.
/**
* Test baseline add items works via control.sh
*
* @throws Exception If failed.
*/
@Test
public void testBaselineAddOnNotActiveCluster() throws Exception {
Ignite ignite = startGrid(1);
assertFalse(ignite.cluster().active());
String consistentIDs = getTestIgniteInstanceName(1);
injectTestSystemOut();
assertEquals(EXIT_CODE_UNEXPECTED_ERROR, execute("--baseline", "add", consistentIDs));
assertContains(log, testOut.toString(), "Changing BaselineTopology on inactive cluster is not allowed.");
consistentIDs = getTestIgniteInstanceName(1) + ", " + getTestIgniteInstanceName(2) + "," + getTestIgniteInstanceName(3);
assertEquals(EXIT_CODE_INVALID_ARGUMENTS, execute("--baseline", "add", consistentIDs));
String testOutStr = testOut.toString();
// Ignite instase 1 can be logged only in arguments list.
boolean isInstanse1Found = Arrays.stream(testOutStr.split("\n")).filter(s -> s.contains("Arguments:")).noneMatch(s -> s.contains(getTestIgniteInstanceName() + "1"));
assertTrue(testOutStr, testOutStr.contains("Node not found for consistent ID:"));
assertFalse(testOutStr, isInstanse1Found);
}
use of org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_INVALID_ARGUMENTS in project ignite by apache.
the class GridCommandHandlerTest method testPersistenceBackupSpecifiedCachesCommand.
/**
* Test verifies that persistence backup command with specified caches copied only content of that caches and
* doesn't touch other directories.
*
* @throws Exception If failed.
*/
@Test
public void testPersistenceBackupSpecifiedCachesCommand() throws Exception {
String cacheName0 = DEFAULT_CACHE_NAME + "0";
String cacheName1 = DEFAULT_CACHE_NAME + "1";
String cacheName2 = DEFAULT_CACHE_NAME + "2";
String nonExistingCacheName = "nonExistingCache";
File mntcNodeWorkDir = startGridAndPutNodeToMaintenance(new CacheConfiguration[] { cacheConfiguration(cacheName0), cacheConfiguration(cacheName1), cacheConfiguration(cacheName2) }, s -> s.equals(cacheName0) || s.equals(cacheName2));
IgniteEx ig1 = startGrid(1);
String port = ig1.localNode().attribute(IgniteNodeAttributes.ATTR_REST_TCP_PORT).toString();
assertEquals(EXIT_CODE_INVALID_ARGUMENTS, execute("--persistence", "backup", "caches", nonExistingCacheName, "--host", "localhost", "--port", port));
assertEquals(EXIT_CODE_OK, execute("--persistence", "backup", "caches", cacheName0 + "," + cacheName2, "--host", "localhost", "--port", port));
long backedUpCachesCnt = Arrays.stream(mntcNodeWorkDir.listFiles()).filter(File::isDirectory).filter(f -> f.getName().startsWith("backup_")).count();
assertEquals(2, backedUpCachesCnt);
checkCacheAndBackupDirsContent(mntcNodeWorkDir);
}
Aggregations