use of com.cinchapi.concourse.Concourse in project concourse by cinchapi.
the class Upgrade0_11_0_1Test method preUpgradeActions.
@Override
protected void preUpgradeActions() {
envs = new String[] { "foo", "bar" };
ClientServerTests.insertRandomData(server, envs);
for (String env : envs) {
Concourse concourse = server.connect("admin", "admin", env);
try {
Set<Long> inventory = concourse.inventory();
Map<Long, Map<String, Set<Object>>> records = Maps.newHashMap();
for (long record : inventory) {
if (TestData.getScaleCount() % 3 == 0) {
records.put(record, concourse.select(record));
}
}
Map<String, Map<Object, Set<Long>>> indexes = Maps.newLinkedHashMap();
Set<String> keys = concourse.describe();
for (String key : concourse.describe()) {
if (TestData.getScaleCount() % 3 == 0) {
indexes.put(key, concourse.browse(key));
}
}
tests.put(env, con -> {
System.out.println("Checking inventory...");
Assert.assertEquals(inventory, con.inventory());
System.out.println("Checking random records...");
for (Entry<Long, Map<String, Set<Object>>> entry : records.entrySet()) {
Map<String, Set<Object>> expected = entry.getValue();
long record = entry.getKey();
Assert.assertEquals(expected, con.select(record));
}
System.out.println("Checking dictionary...");
Assert.assertEquals(keys, con.describe());
System.out.println("Checking random indexes...");
for (Entry<String, Map<Object, Set<Long>>> entry : indexes.entrySet()) {
Map<Object, Set<Long>> expected = entry.getValue();
String key = entry.getKey();
Assert.assertEquals(expected, con.browse(key));
}
});
} finally {
concourse.close();
}
}
}
use of com.cinchapi.concourse.Concourse in project concourse by cinchapi.
the class CON171 method repro2.
@Test(expected = TransactionException.class)
public void repro2() {
Concourse client2 = Concourse.connect(SERVER_HOST, SERVER_PORT, "admin", "admin");
client.stage();
client.find("foo", Operator.EQUALS, "bar");
client2.add("foo", "bar", 1);
Assert.assertTrue(client.find("foo", Operator.EQUALS, "bar").isEmpty());
}
use of com.cinchapi.concourse.Concourse in project concourse by cinchapi.
the class CON75 method repro.
@Test
public void repro() {
final AtomicBoolean running = new AtomicBoolean(true);
final AtomicBoolean caughtException = new AtomicBoolean(false);
int count = 0;
for (int i = 0; i < 247; i++) {
client.add("__table__", "youtube", i);
client.add("count", i, i);
count = i;
}
final int value = count;
final Concourse client2 = Concourse.connect(SERVER_HOST, SERVER_PORT, "admin", "admin");
final Concourse client3 = Concourse.connect(SERVER_HOST, SERVER_PORT, "admin", "admin");
Thread a = new Thread(new Runnable() {
@Override
public void run() {
int count = value;
while (running.get()) {
try {
client2.add("__table__", "youtube", count);
client2.add("count", count, count);
count++;
} catch (RuntimeException e) {
caughtException.set(true);
running.set(false);
}
}
}
});
Thread b = new Thread(new Runnable() {
@Override
public void run() {
while (running.get()) {
try {
client3.clear("count", client.search("__table__", "youtube"));
} catch (RuntimeException e) {
caughtException.set(true);
running.set(false);
}
}
}
});
a.start();
b.start();
StandardActions.wait(1500, TimeUnit.MILLISECONDS);
running.set(false);
Assert.assertFalse(caughtException.get());
}
use of com.cinchapi.concourse.Concourse in project concourse by cinchapi.
the class ClientServerTests method insertRandomData.
/**
* A utility method to populate the test server with random data.
*
* @param server the {@link ManagedConcourseServer} used in the test
* @param environments the environments in which random data should be
* inserted
*/
public static void insertRandomData(ManagedConcourseServer server, String... environments) {
for (String environment : environments) {
Path directory = server.getDatabaseDirectory().resolve(environment).resolve("cpb");
Concourse client = server.connect("admin", "admin", environment);
try {
int count = Random.getScaleCount();
Stream<Path> stream = null;
try {
while (stream == null || stream.count() < count) {
client.add(Random.getSimpleString(), Random.getObject());
if (stream != null) {
stream.close();
}
stream = java.nio.file.Files.list(directory);
}
} finally {
stream.close();
}
} catch (IOException e) {
throw CheckedExceptions.throwAsRuntimeException(e);
}
}
}
use of com.cinchapi.concourse.Concourse in project concourse by cinchapi.
the class ManagedConcourseServerTest method testTranslateOrderBetweenClientAndServer.
@Test
public void testTranslateOrderBetweenClientAndServer() {
server.start();
Concourse concourse = server.connect();
concourse.select(ImmutableList.of(1L, 2L), Order.by("name"));
// lack of Exception means the test passes
Assert.assertTrue(true);
}
Aggregations