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());
}
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());
}
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());
}
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;
}
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);
}
Aggregations