Search in sources :

Example 6 with AeshTestConnection

use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.

the class CliIT method testCliAuthorization.

@Test
public void testCliAuthorization() {
    try (AeshTestConnection terminal = new AeshTestConnection()) {
        CLI.main(new AeshDelegatingShell(terminal), new String[] {}, properties);
        connect(terminal);
        terminal.send("user roles ls");
        terminal.assertContains("\"admin\"");
        terminal.send("user roles create --permissions=ALL_WRITE wizard");
        terminal.send("user roles create --permissions=ALL_READ cleric");
        terminal.clear();
        terminal.send("user roles ls");
        terminal.assertContains("\"wizard\"");
        terminal.assertContains("\"cleric\"");
        terminal.send("user roles grant --roles=wizard,cleric,admin admin");
        terminal.clear();
        terminal.send("user roles ls admin");
        terminal.assertContains("\"wizard\"");
        terminal.assertContains("\"cleric\"");
        terminal.send("user roles deny --roles=cleric admin");
        terminal.clear();
        terminal.send("user roles ls admin");
        terminal.assertContains("\"wizard\"");
        terminal.assertNotContains("\"cleric\"");
        terminal.send("user roles remove wizard");
        terminal.clear();
        terminal.send("user roles ls");
        terminal.assertContains("\"cleric\"");
        terminal.assertNotContains("\"wizard\"");
    }
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) Test(org.junit.Test)

Example 7 with AeshTestConnection

use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.

the class CliIT method testCliCacheAvailability.

@Test
public void testCliCacheAvailability() {
    try (AeshTestConnection terminal = new AeshTestConnection()) {
        CLI.main(new AeshDelegatingShell(terminal), new String[] {}, properties);
        connect(terminal);
        terminal.send("availability " + CLUSTERED_LOCK_CACHE_NAME);
        terminal.assertContains("AVAILABLE");
        terminal.send("availability --mode=DEGRADED_MODE " + CLUSTERED_LOCK_CACHE_NAME);
        terminal.send("availability " + CLUSTERED_LOCK_CACHE_NAME);
        terminal.assertContains("DEGRADED_MODE");
        terminal.send("availability --mode=AVAILABILITY " + CLUSTERED_LOCK_CACHE_NAME);
        terminal.send("availability " + CLUSTERED_LOCK_CACHE_NAME);
        terminal.assertContains("AVAILABLE");
    }
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) Test(org.junit.Test)

Example 8 with AeshTestConnection

use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.

the class CliIT method testCliTasks.

@Test
public void testCliTasks() {
    try (AeshTestConnection terminal = new AeshTestConnection()) {
        CLI.main(new AeshDelegatingShell(terminal), new String[] { "-c", connectionUrl() }, properties);
        connect(terminal);
        terminal.send("cd tasks");
        terminal.send("ls");
        terminal.assertContains("@@cache@names");
        terminal.clear();
        terminal.send("task exec @@cache@names");
        terminal.assertContains("\"___script_cache\"");
        terminal.clear();
        File resource = getCliResource("hello.js");
        terminal.send("task upload --file=" + resource.getPath() + " hello");
        terminal.send("task exec hello -Pgreetee=world");
        terminal.assertContains("\"Hello world\"");
    }
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) File(java.io.File) Test(org.junit.Test)

Example 9 with AeshTestConnection

use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.

the class CliIT method testCliUploadProtobufSchemas.

@Test
public void testCliUploadProtobufSchemas() {
    try (AeshTestConnection terminal = new AeshTestConnection()) {
        CLI.main(new AeshDelegatingShell(terminal), new String[] {}, properties);
        // connect
        connect(terminal);
        // upload
        terminal.send("schema upload --file=" + getCliResource("person.proto").getPath() + " person.proto");
        terminal.assertContains("\"error\" : null");
        terminal.clear();
        terminal.send("cd /containers/default/schemas");
        terminal.send("ls");
        terminal.assertContains("person.proto");
        terminal.clear();
        terminal.send("schema ls");
        terminal.assertContains("person.proto");
        terminal.send("schema get person.proto");
        terminal.assertContains("PhoneNumber");
        terminal.send("schema remove person.proto");
        terminal.clear();
        terminal.send("schema ls");
        terminal.assertContains("[]");
    }
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) Test(org.junit.Test)

Example 10 with AeshTestConnection

use of org.infinispan.server.test.core.AeshTestConnection in project infinispan by infinispan.

the class XSiteCliOperations method extractView.

private static List<String> extractView(AeshTestConnection terminal) {
    terminal.send("describe");
    // make sure the command succeed
    terminal.assertContains("//containers/default");
    String allOutput = terminal.getOutputBuffer();
    Pattern pattern = Pattern.compile("^\\s*\"cluster_members\"\\s*:\\s*\\[\\s+(.*)\\s+],\\s*$");
    for (String line : allOutput.split(Config.getLineSeparator())) {
        line = line.trim();
        Matcher matcher = pattern.matcher(line);
        if (matcher.matches()) {
            terminal.clear();
            return Stream.of(matcher.group(1).split(",")).map(s -> s.replaceAll("[\\[\\]\"]", "")).collect(Collectors.toList());
        }
    }
    terminal.clear();
    throw new IllegalStateException("Unable to find 'cluster_members' in:\n" + allOutput);
}
Also used : AeshDelegatingShell(org.infinispan.cli.impl.AeshDelegatingShell) BeforeClass(org.junit.BeforeClass) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) BackupConfiguration(org.infinispan.configuration.cache.BackupConfiguration) Matcher(java.util.regex.Matcher) InfinispanXSiteServerRule(org.infinispan.server.test.junit4.InfinispanXSiteServerRule) XSiteStateTransferMode(org.infinispan.configuration.cache.XSiteStateTransferMode) Config(org.aesh.terminal.utils.Config) ClassRule(org.junit.ClassRule) AfterClass(org.junit.AfterClass) Properties(java.util.Properties) Util(org.infinispan.commons.util.Util) Test(org.junit.Test) Collectors(java.util.stream.Collectors) File(java.io.File) Consumer(java.util.function.Consumer) List(java.util.List) CacheMode(org.infinispan.configuration.cache.CacheMode) Stream(java.util.stream.Stream) CLI(org.infinispan.cli.commands.CLI) Rule(org.junit.Rule) CommonsTestingUtil(org.infinispan.commons.test.CommonsTestingUtil) XSiteIT(org.infinispan.server.functional.XSiteIT) AeshTestConnection(org.infinispan.server.test.core.AeshTestConnection) Pattern(java.util.regex.Pattern) TestServer(org.infinispan.server.test.core.TestServer) InfinispanXSiteServerTestMethodRule(org.infinispan.server.test.junit4.InfinispanXSiteServerTestMethodRule) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

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