use of io.crate.testing.SQLResponse in project crate by crate.
the class InformationSchemaQueryTest method testConcurrentUnassignedShardsReferenceResolver.
@Test
public void testConcurrentUnassignedShardsReferenceResolver() throws Exception {
internalCluster().ensureAtMostNumDataNodes(1);
execute("create table t1 (col1 integer) " + "clustered into 1 shards " + "with (number_of_replicas=8)");
execute("create table t2 (col1 integer) " + "clustered into 1 shards " + "with (number_of_replicas=8)");
ensureYellow();
final SQLResponse response = execute("select * from sys.shards where table_name in ('t1', 't2') and state='UNASSIGNED' order by schema_name, table_name, id");
final CountDownLatch latch = new CountDownLatch(40);
final AtomicReference<AssertionError> lastAssertionError = new AtomicReference<>();
for (int i = 0; i < 40; i++) {
final Thread t = new Thread(new Runnable() {
@Override
public void run() {
SQLResponse resp = execute("select * from sys.shards where table_name in ('t1', 't2') and state='UNASSIGNED' order by schema_name, table_name, id");
try {
assertThat(resp.rows(), Matchers.equalTo(response.rows()));
} catch (AssertionError e) {
lastAssertionError.set(e);
}
latch.countDown();
}
});
t.start();
}
latch.await();
AssertionError assertionError = lastAssertionError.get();
if (assertionError != null) {
throw assertionError;
}
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testCountWithGroupByWithWhereClause.
@Test
public void testCountWithGroupByWithWhereClause() throws Exception {
SQLResponse response = execute("select count(*), race from characters where race = 'Human' group by race");
assertEquals(1, response.rowCount());
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testSysOperationsLog.
@Test
public void testSysOperationsLog() throws Exception {
execute("select count(*), race from characters group by race order by count(*) desc limit 2");
SQLResponse resp = execute("select count(*) from sys.operations_log");
assertThat((Long) resp.rows()[0][0], is(0L));
execute("set global transient stats.enabled = true, stats.operations_log_size=10");
waitNoPendingTasksOnAll();
execute("select count(*), race from characters group by race order by count(*) desc limit 2");
assertBusy(new Runnable() {
@Override
public void run() {
SQLResponse resp = execute("select * from sys.operations_log order by ended limit 3");
List<String> names = new ArrayList<>();
for (Object[] objects : resp.rows()) {
names.add((String) objects[4]);
}
assertThat(names, Matchers.anyOf(Matchers.hasItems("distributing collect", "distributing collect"), Matchers.hasItems("collect", "localMerge"), // the select * from sys.operations_log has 2 collect operations (1 per node)
Matchers.hasItems("collect", "collect"), Matchers.hasItems("distributed merge", "localMerge")));
}
}, 10L, TimeUnit.SECONDS);
execute("reset global stats.enabled, stats.operations_log_size");
waitNoPendingTasksOnAll();
resp = execute("select count(*) from sys.operations_log");
assertThat((Long) resp.rows()[0][0], is(0L));
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testCountWithGroupByOrderOnAggAscFuncAndSecondColumnAndLimitAndTooLargeOffset.
@Test
public void testCountWithGroupByOrderOnAggAscFuncAndSecondColumnAndLimitAndTooLargeOffset() throws Exception {
SQLResponse response = execute("select count(*), gender, race from characters " + "group by race, gender order by count(*) desc, race asc limit 2 offset 20");
assertEquals(0, response.rows().length);
assertEquals(0, response.rowCount());
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class TransportSQLActionClassLifecycleTest method testSelectRaw.
@Test
public void testSelectRaw() throws Exception {
SQLResponse response = execute("select _raw from characters order by name desc limit 1");
assertEquals("{\"race\":\"Human\",\"gender\":\"female\",\"age\":32,\"birthdate\":276912000000," + "\"name\":\"Trillian\",\"details\":{\"job\":\"Mathematician\"}}\n", TestingHelpers.printedTable(response.rows()));
}
Aggregations