Search in sources :

Example 16 with AeshDelegatingShell

use of org.infinispan.cli.impl.AeshDelegatingShell in project infinispan by infinispan.

the class CliIT method testCliCredentials.

@Test
public void testCliCredentials() {
    try (AeshTestConnection terminal = new AeshTestConnection()) {
        CLI.main(new AeshDelegatingShell(terminal), new String[] {}, properties);
        String keyStore = Paths.get(System.getProperty("build.directory", ""), "key.store").toAbsolutePath().toString();
        terminal.send("credentials add --path=" + keyStore + " --password=secret --credential=credential password");
        terminal.send("credentials add --path=" + keyStore + " --password=secret --credential=credential another");
        terminal.clear();
        terminal.send("credentials ls --path=" + keyStore + " --password=secret");
        terminal.assertContains("password");
        terminal.assertContains("another");
    }
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) Test(org.junit.Test)

Example 17 with AeshDelegatingShell

use of org.infinispan.cli.impl.AeshDelegatingShell in project infinispan by infinispan.

the class CliIT method testCliHttpBenchmark.

@Test
public void testCliHttpBenchmark() {
    try (AeshTestConnection terminal = new AeshTestConnection()) {
        CLI.main(new AeshDelegatingShell(terminal), new String[] {}, properties);
        // no cache
        terminal.send("benchmark " + connectionUrl());
        terminal.assertContains("java.lang.IllegalArgumentException: Could not find cache");
    }
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) Test(org.junit.Test)

Example 18 with AeshDelegatingShell

use of org.infinispan.cli.impl.AeshDelegatingShell in project infinispan by infinispan.

the class CliIT method testCliInteractive.

@Test
public void testCliInteractive() {
    try (AeshTestConnection terminal = new AeshTestConnection()) {
        CLI.main(new AeshDelegatingShell(terminal), new String[] {}, properties);
        terminal.send("echo Hi");
        terminal.assertEquals("[disconnected]> echo Hi" + Config.getLineSeparator() + "Hi" + Config.getLineSeparator() + "[disconnected]> ");
        terminal.clear();
        connect(terminal);
        terminal.send("stats");
        terminal.assertContains("required_minimum_number_of_nodes");
        terminal.clear();
        terminal.send("create cache --template=org.infinispan.DIST_SYNC dcache");
        terminal.send("cd caches/dcache");
        terminal.assertContains("//containers/default/caches/dcache]>");
        terminal.send("put k1 v1");
        terminal.clear();
        terminal.send("ls");
        terminal.assertContains("k1");
        terminal.send("get k1");
        terminal.assertContains("v1");
        terminal.send("put --ttl=10 k2 v2");
        terminal.clear();
        terminal.send("describe k2");
        terminal.assertContains("\"timetoliveseconds\" : [ \"10\" ]");
        terminal.send("create cache --file=" + getCliResource("qcache.xml").getPath() + " qcache");
        terminal.send("schema upload -f=" + getCliResource("person.proto").getPath() + " person.proto");
        terminal.clear();
        terminal.send("cd /containers/default/schemas");
        terminal.send("ls");
        terminal.assertContains("person.proto");
        terminal.send("cache qcache");
        terminal.assertContains("//containers/default/caches/qcache]>");
        for (String person : Arrays.asList("jessicajones", "dannyrandy", "lukecage", "matthewmurdock")) {
            terminal.send("put --encoding=application/json --file=" + getCliResource(person + ".json").getPath() + " " + person);
        }
        terminal.clear();
        terminal.send("ls");
        for (String person : Arrays.asList("jessicajones", "dannyrandy", "lukecage", "matthewmurdock")) {
            terminal.assertContains(person);
        }
        terminal.clear();
        terminal.send("query \"from org.infinispan.rest.search.entity.Person p where p.gender = 'MALE'\"");
        terminal.assertContains("\"total_results\":3,");
        terminal.clear();
        terminal.send("stats");
        terminal.assertContains("required_minimum_number_of_nodes");
        // COUNTERS
        terminal.send("create counter --type=strong --storage=PERSISTENT --upper-bound=100 cnt1");
        terminal.send("cd /containers/default/counters/cnt1");
        terminal.send("describe");
        terminal.assertContains("\"upper-bound\" : \"100\"");
        terminal.clear();
        terminal.send("add");
        terminal.assertContains("1");
        terminal.clear();
        terminal.send("reset");
        terminal.send("ls");
        terminal.assertContains("0");
        terminal.clear();
        terminal.send("add --delta=100");
        terminal.assertContains("100");
        // ALTER CACHE
        terminal.send("create cache --file=" + getCliResource("xcache.xml").getPath() + " xcache");
        terminal.send("describe /containers/default/caches/xcache");
        terminal.assertContains("\"lifespan\" : \"60000\"");
        terminal.assertContains("\"max-count\" : \"1000\"");
        terminal.clear();
        terminal.send("alter cache --file=" + getCliResource("xcache-alter.xml").getPath() + " xcache");
        terminal.send("describe /containers/default/caches/xcache");
        terminal.assertContains("\"lifespan\" : \"30000\"");
        terminal.assertContains("\"max-count\" : \"2000\"");
        terminal.clear();
        terminal.send("alter cache xcache --attribute=memory.max-count --value=5000");
        terminal.send("describe /containers/default/caches/xcache");
        terminal.assertContains("\"lifespan\" : \"30000\"");
        terminal.assertContains("\"max-count\" : \"5000\"");
        terminal.clear();
    }
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) Test(org.junit.Test)

Example 19 with AeshDelegatingShell

use of org.infinispan.cli.impl.AeshDelegatingShell in project infinispan by infinispan.

the class CliIT method testCliConfigPersistence.

@Test
public void testCliConfigPersistence() {
    try (AeshTestConnection terminal = new AeshTestConnection()) {
        CLI.main(new AeshDelegatingShell(terminal), new String[] {}, properties);
        terminal.send("config set autoconnect-url " + connectionUrl());
        terminal.clear();
        terminal.send("config get autoconnect-url");
        terminal.assertContains(connectionUrl());
    }
    // Close and recreate the CLI so that auto-connection kicks in
    try (AeshTestConnection terminal = new AeshTestConnection()) {
        CLI.main(new AeshDelegatingShell(terminal), new String[] {}, properties);
        terminal.assertContains("//containers/default]>");
        terminal.send("config set autoconnect-url");
    }
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) Test(org.junit.Test)

Aggregations

AeshDelegatingShell (org.infinispan.cli.impl.AeshDelegatingShell)19 AeshTestConnection (org.infinispan.server.test.core.AeshTestConnection)18 Test (org.junit.Test)9 IOException (java.io.IOException)2 Properties (java.util.Properties)2 File (java.io.File)1 CommandRegistry (org.aesh.command.registry.CommandRegistry)1 SettingsBuilder (org.aesh.command.settings.SettingsBuilder)1 ReadlineConsole (org.aesh.readline.ReadlineConsole)1 ContextAwareCommandActivatorProvider (org.infinispan.cli.activators.ContextAwareCommandActivatorProvider)1 ContextAwareCompleterInvocationProvider (org.infinispan.cli.completers.ContextAwareCompleterInvocationProvider)1 CliAliasManager (org.infinispan.cli.impl.CliAliasManager)1 CliCommandNotFoundHandler (org.infinispan.cli.impl.CliCommandNotFoundHandler)1 ContextAwareCommandInvocationProvider (org.infinispan.cli.impl.ContextAwareCommandInvocationProvider)1 ContextAwareQuitHandler (org.infinispan.cli.impl.ContextAwareQuitHandler)1