Search in sources :

Example 6 with MiniAccumuloCluster

use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project incubator-rya by apache.

the class AccumuloRyaConnectionCommandsIT method connectAccumulo.

@Test
public void connectAccumulo() throws IOException {
    final MiniAccumuloCluster cluster = getCluster();
    final Bootstrap bootstrap = getTestBootstrap();
    final JLineShellComponent shell = getTestShell();
    // Mock the user entering the correct password.
    final ApplicationContext context = bootstrap.getApplicationContext();
    final PasswordPrompt mockPrompt = context.getBean(PasswordPrompt.class);
    when(mockPrompt.getPassword()).thenReturn("password".toCharArray());
    // Execute the connect command.
    final String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " " + "--zookeepers " + cluster.getZooKeepers();
    final CommandResult connectResult = shell.executeCommand(cmd);
    // Ensure the connection was successful.
    assertTrue(connectResult.isSuccess());
}
Also used : JLineShellComponent(org.springframework.shell.core.JLineShellComponent) ApplicationContext(org.springframework.context.ApplicationContext) MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) Bootstrap(org.springframework.shell.Bootstrap) PasswordPrompt(org.apache.rya.shell.util.PasswordPrompt) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 7 with MiniAccumuloCluster

use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project incubator-rya by apache.

the class AccumuloRyaConnectionCommandsIT method connectAccumulo_wrongCredentials.

@Test
public void connectAccumulo_wrongCredentials() throws IOException {
    final MiniAccumuloCluster cluster = getCluster();
    final Bootstrap bootstrap = getTestBootstrap();
    final JLineShellComponent shell = getTestShell();
    // Mock the user entering the wrong password.
    final ApplicationContext context = bootstrap.getApplicationContext();
    final PasswordPrompt mockPrompt = context.getBean(PasswordPrompt.class);
    when(mockPrompt.getPassword()).thenReturn("asjifo[ijwa".toCharArray());
    // Execute the command
    final String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " " + "--zookeepers " + cluster.getZooKeepers();
    final CommandResult connectResult = shell.executeCommand(cmd);
    // Ensure the command failed.
    assertFalse(connectResult.isSuccess());
}
Also used : JLineShellComponent(org.springframework.shell.core.JLineShellComponent) ApplicationContext(org.springframework.context.ApplicationContext) MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) Bootstrap(org.springframework.shell.Bootstrap) PasswordPrompt(org.apache.rya.shell.util.PasswordPrompt) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 8 with MiniAccumuloCluster

use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project incubator-rya by apache.

the class AccumuloRyaConnectionCommandsIT method connectToInstance_instanceDoesNotExist.

@Test
public void connectToInstance_instanceDoesNotExist() throws IOException {
    final MiniAccumuloCluster cluster = getCluster();
    final Bootstrap bootstrap = getTestBootstrap();
    final JLineShellComponent shell = getTestShell();
    // Mock the user entering the correct password.
    final ApplicationContext context = bootstrap.getApplicationContext();
    final PasswordPrompt mockPrompt = context.getBean(PasswordPrompt.class);
    when(mockPrompt.getPassword()).thenReturn("password".toCharArray());
    // Connect to the mini accumulo instance.
    String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " " + "--zookeepers " + cluster.getZooKeepers();
    shell.executeCommand(cmd);
    // Try to connect to a non-existing instance.
    cmd = RyaConnectionCommands.CONNECT_INSTANCE_CMD + " --instance doesNotExist";
    final CommandResult result = shell.executeCommand(cmd);
    assertFalse(result.isSuccess());
}
Also used : JLineShellComponent(org.springframework.shell.core.JLineShellComponent) ApplicationContext(org.springframework.context.ApplicationContext) MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) Bootstrap(org.springframework.shell.Bootstrap) PasswordPrompt(org.apache.rya.shell.util.PasswordPrompt) CommandResult(org.springframework.shell.core.CommandResult) Test(org.junit.Test)

Example 9 with MiniAccumuloCluster

use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project incubator-rya by apache.

the class ConformanceTest method run.

@Override
public int run(final String[] args) throws Exception {
    // Validate command
    if (args.length < 1 || args.length > 2) {
        System.out.println("Usage:\n");
        System.out.println("\tConformanceTest [configuration options] " + "<test-file> <temp-dir>\n");
        System.out.println("to load test data from an RDF file " + "(configuration property " + MRUtils.FORMAT_PROP + " specifies the format, default RDF/XML); or\n");
        System.out.println("\tConformanceTest [configuration options] <temp-dir>\n");
        System.out.println("to load test data from a Rya instance (specified " + "using standard configuration properties).\n");
        System.out.println("For each test given, run the reasoner over the " + "premise ontology using a temporary Mini Accumulo instance " + "at <temp-dir>, then report conformance results.");
        System.exit(1);
    }
    final Set<Value> conformanceTestURIs = new HashSet<>();
    Collection<OwlTest> conformanceTests = new LinkedList<>();
    final List<OwlTest> successes = new LinkedList<>();
    final List<OwlTest> failures = new LinkedList<>();
    final Configuration conf = getConf();
    Repository repo;
    File workingDir;
    // If tests are in a file, stick them in a repository for querying
    if (args.length == 2) {
        workingDir = new File(PathUtils.clean(args[1]));
        RDFFormat inputFormat = RDFFormat.RDFXML;
        final String formatString = conf.get(MRUtils.FORMAT_PROP);
        if (formatString != null) {
            inputFormat = RDFFormat.valueOf(formatString);
        }
        repo = new SailRepository(new MemoryStore());
        repo.initialize();
        final RepositoryConnection conn = repo.getConnection();
        FileInputStream fileInput = new FileInputStream(PathUtils.clean(args[0]));
        conn.add(fileInput, "", inputFormat);
        fileInput.close();
        conn.close();
    } else // Otherwise, get a Rya repository
    {
        workingDir = new File(PathUtils.clean(args[0]));
        repo = MRReasoningUtils.getRepository(conf);
        repo.initialize();
    }
    // Query for the tests we're interested in
    final RepositoryConnection conn = repo.getConnection();
    conformanceTestURIs.addAll(getTestURIs(conn, TEST_INCONSISTENCY));
    conformanceTestURIs.addAll(getTestURIs(conn, TEST_CONSISTENCY));
    conformanceTestURIs.addAll(getTestURIs(conn, TEST_ENTAILMENT));
    conformanceTestURIs.addAll(getTestURIs(conn, TEST_NONENTAILMENT));
    conformanceTests = getTests(conn, conformanceTestURIs);
    conn.close();
    repo.shutDown();
    // Set up a MiniAccumulo cluster and set up conf to connect to it
    final String username = "root";
    final String password = "root";
    final MiniAccumuloCluster mini = new MiniAccumuloCluster(workingDir, password);
    mini.start();
    conf.set(MRUtils.AC_INSTANCE_PROP, mini.getInstanceName());
    conf.set(MRUtils.AC_ZK_PROP, mini.getZooKeepers());
    conf.set(MRUtils.AC_USERNAME_PROP, username);
    conf.set(MRUtils.AC_PWD_PROP, password);
    conf.setBoolean(MRUtils.AC_MOCK_PROP, false);
    conf.set(MRUtils.TABLE_PREFIX_PROPERTY, "temp_");
    // Run the conformance tests
    int result;
    for (final OwlTest test : conformanceTests) {
        System.out.println(test.uri);
        result = runTest(conf, args, test);
        if (result != 0) {
            return result;
        }
        if (test.success) {
            successes.add(test);
            System.out.println("(SUCCESS)");
        } else {
            failures.add(test);
            System.out.println("(FAIL)");
        }
    }
    mini.stop();
    System.out.println("\n" + successes.size() + " successful tests:");
    for (final OwlTest test : successes) {
        System.out.println("\t[SUCCESS] " + test.type() + " " + test.name);
    }
    System.out.println("\n" + failures.size() + " failed tests:");
    for (final OwlTest test : failures) {
        System.out.println("\t[FAIL] " + test.type() + " " + test.name);
        System.out.println("\t\t(" + test.description + ")");
        for (final Statement triple : test.error) {
            if (test.types.contains(TEST_ENTAILMENT)) {
                System.out.println("\t\tExpected: " + triple);
            } else if (test.types.contains(TEST_NONENTAILMENT)) {
                System.out.println("\t\tUnexpected: " + triple);
            }
        }
    }
    return 0;
}
Also used : RepositoryConnection(org.openrdf.repository.RepositoryConnection) Configuration(org.apache.hadoop.conf.Configuration) SailRepository(org.openrdf.repository.sail.SailRepository) Statement(org.openrdf.model.Statement) MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) LinkedList(java.util.LinkedList) FileInputStream(java.io.FileInputStream) MemoryStore(org.openrdf.sail.memory.MemoryStore) SailRepository(org.openrdf.repository.sail.SailRepository) Repository(org.openrdf.repository.Repository) Value(org.openrdf.model.Value) File(java.io.File) HashSet(java.util.HashSet) RDFFormat(org.openrdf.rio.RDFFormat)

Example 10 with MiniAccumuloCluster

use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project incubator-rya by apache.

the class KafkaExportITBase method installRyaInstance.

private void installRyaInstance() throws Exception {
    final MiniAccumuloCluster cluster = super.getMiniAccumuloCluster();
    final String instanceName = cluster.getInstanceName();
    final String zookeepers = cluster.getZooKeepers();
    // Install the Rya instance to the mini accumulo cluster.
    final RyaClient ryaClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(ACCUMULO_USER, ACCUMULO_PASSWORD.toCharArray(), instanceName, zookeepers), super.getAccumuloConnector());
    ryaClient.getInstall().install(RYA_INSTANCE_NAME, InstallConfiguration.builder().setEnableTableHashPrefix(false).setEnableFreeTextIndex(false).setEnableEntityCentricIndex(false).setEnableGeoIndex(false).setEnableTemporalIndex(false).setEnablePcjIndex(true).setFluoPcjAppName(super.getFluoConfiguration().getApplicationName()).build());
    // Connect to the Rya instance that was just installed.
    final AccumuloRdfConfiguration conf = makeConfig(instanceName, zookeepers);
    final Sail sail = RyaSailFactory.getInstance(conf);
    dao = RyaSailFactory.getAccumuloDAOWithUpdatedConfig(conf);
    ryaSailRepo = new RyaSailRepository(sail);
}
Also used : AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) Sail(org.openrdf.sail.Sail) MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) RyaClient(org.apache.rya.api.client.RyaClient) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration)

Aggregations

MiniAccumuloCluster (org.apache.accumulo.minicluster.MiniAccumuloCluster)37 File (java.io.File)11 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)8 MiniAccumuloConfig (org.apache.accumulo.minicluster.MiniAccumuloConfig)8 Test (org.junit.Test)7 IOException (java.io.IOException)6 Connector (org.apache.accumulo.core.client.Connector)6 PasswordPrompt (org.apache.rya.shell.util.PasswordPrompt)6 RFileReaderRDD (uk.gov.gchq.gaffer.sparkaccumulo.operation.rfilereaderrdd.RFileReaderRDD)6 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)5 Test (org.junit.jupiter.api.Test)5 ApplicationContext (org.springframework.context.ApplicationContext)5 Bootstrap (org.springframework.shell.Bootstrap)5 CommandResult (org.springframework.shell.core.CommandResult)5 JLineShellComponent (org.springframework.shell.core.JLineShellComponent)5 Properties (java.util.Properties)4 BeforeClass (org.junit.BeforeClass)4 AccumuloException (org.apache.accumulo.core.client.AccumuloException)3 Instance (org.apache.accumulo.core.client.Instance)3 RyaClient (org.apache.rya.api.client.RyaClient)3