use of com.cinchapi.concourse.Concourse in project concourse by cinchapi.
the class CON649 method repro.
@Test
public void repro() throws IOException, TTransportException, InterruptedException {
List<Thread> clients = Lists.newArrayList();
Table<Long, String, String> expected = HashBasedTable.create();
for (int i = 0; i < Runtime.getRuntime().availableProcessors(); ++i) {
clients.add(new Thread(() -> {
Concourse $client = server.connect();
while (!Thread.currentThread().isInterrupted()) {
try {
long id = Random.getLong();
String key = Random.getSimpleString();
String value = Random.getSimpleString();
$client.add(key, value, id);
expected.put(id, key, value);
// allow some transports to go
Random.tinySleep();
// through...
} catch (Exception e) {
Thread.currentThread().interrupt();
}
}
}));
}
clients.forEach(Thread::start);
Thread.sleep(10000);
Random.microSleep();
server.stop();
Path db = server.getDatabaseDirectory().resolve("default");
List<Path> directories = ImmutableList.of(db.resolve("cpb"), db.resolve("csb"), db.resolve("ctb"));
Map<String, AtomicInteger> counts = Maps.newLinkedHashMap();
directories.forEach(directory -> {
try {
Files.list(directory).forEach(file -> {
System.out.println(file);
String name = file.getFileName().toString().split("\\.")[0];
counts.computeIfAbsent(name, key -> new AtomicInteger(0)).incrementAndGet();
});
} catch (IOException e) {
e.printStackTrace();
}
});
Set<Integer> distinct = Sets.newHashSet();
counts.forEach((path, count) -> {
System.out.println(path + " = " + count);
distinct.add(count.get());
});
System.out.println(counts.size());
server.start();
client = server.connect();
for (Cell<Long, String, String> cell : expected.cellSet()) {
long record = cell.getRowKey();
String key = cell.getColumnKey();
Object value = cell.getValue();
Assert.assertEquals(value, client.get(key, record));
}
}
use of com.cinchapi.concourse.Concourse in project concourse by cinchapi.
the class PluginSecurityTest method testPluginMethodsInheritsUserPermission.
@Test
public void testPluginMethodsInheritsUserPermission() {
server.executeCli("users", "create jeff --set-password jeff --set-role user --password admin");
Concourse client2 = server.connect("jeff", "jeff");
try {
client2.invokePlugin(TestPlugin.class.getName(), "inventory");
Assert.fail();
} catch (Exception e) {
server.executeCli("users", "grant jeff --permission read --password admin");
Assert.assertEquals(ImmutableSet.of(), client2.invokePlugin(TestPlugin.class.getName(), "inventory"));
}
}
use of com.cinchapi.concourse.Concourse in project concourse by cinchapi.
the class PermissionTest method testDriverIsUsableAfterPermissionException.
@Test
public void testDriverIsUsableAfterPermissionException() {
createUser("jeff", "jeff", "user");
Concourse client2 = Concourse.connect(SERVER_HOST, SERVER_PORT, "jeff", "jeff");
grant("jeff", "read", "");
long record = client.add("foo", "foo");
try {
client2.set("foo", "bar", record);
Assert.fail();
} catch (PermissionException e) {
Assert.assertEquals("foo", client2.get("foo", record));
}
}
Aggregations