Search in sources :

Example 21 with AeshTestConnection

use of org.infinispan.server.test.core.AeshTestConnection 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 22 with AeshTestConnection

use of org.infinispan.server.test.core.AeshTestConnection 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 23 with AeshTestConnection

use of org.infinispan.server.test.core.AeshTestConnection 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

AeshTestConnection (org.infinispan.server.test.core.AeshTestConnection)23 AeshDelegatingShell (org.infinispan.cli.impl.AeshDelegatingShell)19 Test (org.junit.Test)14 File (java.io.File)3 Path (java.nio.file.Path)3 Properties (java.util.Properties)3 ZipFile (java.util.zip.ZipFile)2 IOException (java.io.IOException)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Config (org.aesh.terminal.utils.Config)1 CLI (org.infinispan.cli.commands.CLI)1 CommonsTestingUtil (org.infinispan.commons.test.CommonsTestingUtil)1 Util (org.infinispan.commons.util.Util)1 BackupConfiguration (org.infinispan.configuration.cache.BackupConfiguration)1 CacheMode (org.infinispan.configuration.cache.CacheMode)1