use of org.apache.ignite.internal.commandline.CommandHandler in project ignite by apache.
the class GridCommandHandlerIndexListTest method checkCacheNameFilter.
/**
*/
private void checkCacheNameFilter(String cacheRegEx, Predicate<String> predicate, int expectedResNum) {
final CommandHandler handler = new CommandHandler(createTestLogger());
assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_list", "--cache-name", cacheRegEx));
Set<IndexListInfoContainer> cmdResult = handler.getLastOperationResult();
assertNotNull(cmdResult);
boolean isResCorrect = cmdResult.stream().map(IndexListInfoContainer::cacheName).allMatch(predicate);
assertTrue("Unexpected command result", isResCorrect);
int indexesNum = cmdResult.size();
assertEquals("Unexpected number of indexes: " + indexesNum, indexesNum, expectedResNum);
}
use of org.apache.ignite.internal.commandline.CommandHandler in project ignite by apache.
the class BaselineEventsTest method testEventsDisabledByDefault.
/**
*/
@Test
public void testEventsDisabledByDefault() throws Exception {
// noinspection ZeroLengthArrayAllocation
includedEvtTypes = new int[0];
IgniteClusterEx cluster = startGrid(0).cluster();
cluster.active(true);
AtomicInteger evtsTriggered = new AtomicInteger();
listen(grid(0), event -> {
evtsTriggered.incrementAndGet();
return true;
}, EventType.EVT_BASELINE_AUTO_ADJUST_ENABLED_CHANGED, EventType.EVT_BASELINE_AUTO_ADJUST_AWAITING_TIME_CHANGED);
startGrid(1);
String consistentIds = grid(0).localNode().consistentId() + "," + grid(1).localNode().consistentId();
assertEquals(CommandHandler.EXIT_CODE_OK, new CommandHandler().execute(Arrays.asList("--baseline", "set", consistentIds, "--yes")));
awaitPartitionMapExchange();
startGrid(2);
cluster.setBaselineTopology(cluster.topologyVersion());
awaitPartitionMapExchange();
assertEquals(CommandHandler.EXIT_CODE_OK, new CommandHandler().execute(Arrays.asList("--baseline", "auto_adjust", "enable", "timeout", "10", "--yes")));
cluster.baselineAutoAdjustEnabled(false);
cluster.baselineAutoAdjustTimeout(50);
assertFalse(GridTestUtils.waitForCondition(() -> evtsTriggered.get() > 0, 3_000L));
}
use of org.apache.ignite.internal.commandline.CommandHandler in project ignite by apache.
the class BaselineEventsTest method testChangeAutoAdjustEnabled.
/**
*/
@Test
public void testChangeAutoAdjustEnabled() throws Exception {
IgniteClusterEx cluster = startGrids(2).cluster();
cluster.active(true);
assertFalse(cluster.isBaselineAutoAdjustEnabled());
AtomicBoolean autoAdjustEnabled = new AtomicBoolean();
listen(grid(0), event -> {
BaselineConfigurationChangedEvent bltCfgChangedEvt = (BaselineConfigurationChangedEvent) event;
autoAdjustEnabled.set(bltCfgChangedEvt.isAutoAdjustEnabled());
return true;
}, EventType.EVT_BASELINE_AUTO_ADJUST_ENABLED_CHANGED);
assertEquals(CommandHandler.EXIT_CODE_OK, new CommandHandler().execute(Arrays.asList("--baseline", "auto_adjust", "enable", "timeout", "10", "--yes")));
assertTrue(GridTestUtils.waitForCondition(autoAdjustEnabled::get, 3_000));
assertEquals(CommandHandler.EXIT_CODE_OK, new CommandHandler().execute(Arrays.asList("--baseline", "auto_adjust", "disable", "--yes")));
assertFalse(autoAdjustEnabled.get());
cluster.baselineAutoAdjustEnabled(true);
assertTrue(GridTestUtils.waitForCondition(autoAdjustEnabled::get, 3_000));
cluster.baselineAutoAdjustEnabled(false);
assertTrue(GridTestUtils.waitForCondition(() -> !autoAdjustEnabled.get(), 3_000));
}
use of org.apache.ignite.internal.commandline.CommandHandler in project ignite by apache.
the class GridCommandHandlerSslWithSecurityTest method testConnector.
/**
* Checks that control.sh script can connect to the cluster, that has SSL enabled.
*/
@Test
public void testConnector() throws Exception {
IgniteEx crd = startGrid();
crd.cluster().state(ACTIVE);
injectTestSystemOut();
CommandHandler hnd = new CommandHandler();
int exitCode = hnd.execute(Arrays.asList("--state", "--user", login, "--password", pwd, "--keystore", keyStorePath("connectorClient"), "--keystore-password", keyStorePassword(), "--truststore", keyStorePath("trustthree"), "--truststore-password", keyStorePassword()));
assertEquals(EXIT_CODE_OK, exitCode);
flushCommandOutput(hnd);
// Make sure all sensitive information is masked.
String testOutput = testOut.toString();
assertContains(log, testOutput, "--password *****");
assertContains(log, testOutput, "--keystore-password *****");
assertContains(log, testOutput, "--truststore-password *****");
}
use of org.apache.ignite.internal.commandline.CommandHandler in project ignite by apache.
the class GridCommandHandlerSslWithSecurityTest method testInputKeyTrustStorePwdOnlyOnce.
/**
* Verify that the command work correctly when entering passwords for
* keystore and truststore, and that these passwords are requested only
* once.
*
* @throws Exception If failed.
*/
@Test
public void testInputKeyTrustStorePwdOnlyOnce() throws Exception {
IgniteEx crd = startGrid();
crd.cluster().state(ACTIVE);
CommandHandler cmd = new CommandHandler();
AtomicInteger keyStorePwdCnt = new AtomicInteger();
AtomicInteger trustStorePwdCnt = new AtomicInteger();
cmd.console = new NoopConsole() {
/**
* {@inheritDoc}
*/
@Override
public char[] readPassword(String fmt, Object... args) {
if (fmt.contains("keystore")) {
keyStorePwdCnt.incrementAndGet();
return keyStorePassword().toCharArray();
} else if (fmt.contains("truststore")) {
trustStorePwdCnt.incrementAndGet();
return keyStorePassword().toCharArray();
}
return pwd.toCharArray();
}
};
List<String> args = new ArrayList<>();
args.add(DEACTIVATE.text());
args.add("--force");
args.add("--yes");
args.add("--user");
args.add(login);
args.add("--keystore");
args.add(keyStorePath("connectorServer"));
args.add("--truststore");
args.add(keyStorePath("trustthree"));
assertEquals(EXIT_CODE_OK, cmd.execute(args));
assertEquals(1, keyStorePwdCnt.get());
assertEquals(1, trustStorePwdCnt.get());
}
Aggregations