use of io.crate.testing.SQLResponse in project crate by crate.
the class InformationSchemaQueryTest method testConcurrentInformationSchemaQueries.
@Test
public void testConcurrentInformationSchemaQueries() throws Exception {
final SQLResponse response = execute("select * from information_schema.columns " + "order by table_schema, table_name, column_name");
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 information_schema.columns " + "order by table_schema, table_name, column_name");
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 InsertIntoIntegrationTest method testInsertWithPrimaryKeyMultiValuesFailing.
@Test
public void testInsertWithPrimaryKeyMultiValuesFailing() throws Exception {
execute("create table locations (id integer primary key)");
ensureYellow();
SQLResponse response = execute("insert into locations (id) values (1), (2)");
assertThat(response.rowCount(), is(2L));
response = execute("insert into locations (id) values (2), (3)");
assertThat(response.rowCount(), is(1L));
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class JobLogIntegrationTest method testEmptyJobsInLog.
@Test
public void testEmptyJobsInLog() throws Exception {
// Setup data
sqlExecutor.exec("create table characters (id int primary key, name string)");
sqlExecutor.ensureYellowOrGreen();
sqlExecutor.exec("set global transient stats.enabled = true");
sqlExecutor.exec("insert into characters (id, name) values (1, 'sysjobstest')");
sqlExecutor.exec("refresh table characters");
SQLResponse response = sqlExecutor.exec("delete from characters where id = 1");
// make sure everything is deleted (nothing changed in whole class lifecycle cluster state)
assertThat(response.rowCount(), is(1L));
sqlExecutor.exec("refresh table characters");
response = sqlExecutor.exec("select * from sys.jobs_log where stmt like 'insert into%' or stmt like 'delete%'");
assertThat(response.rowCount(), is(2L));
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class FulltextAnalyzerResolverTest method useAnalyzerForIndexSettings.
@Test
public void useAnalyzerForIndexSettings() throws Exception {
execute("CREATE ANALYZER a11 (" + " TOKENIZER standard," + " TOKEN_FILTERS (" + " lowercase," + " mystop WITH (" + " type='stop'," + " stopword=['the', 'over']" + " )" + " )" + ")");
Settings settings = getPersistentClusterSettings();
assertThat(settings.getAsMap(), allOf(hasKey("crate.analysis.custom.analyzer.a11"), hasKey("crate.analysis.custom.filter.a11_mystop")));
Settings analyzerSettings = FulltextAnalyzerResolver.decodeSettings(settings.get("crate.analysis.custom.analyzer.a11"));
Settings tokenFilterSettings = FulltextAnalyzerResolver.decodeSettings(settings.get("crate" + ".analysis.custom.filter.a11_mystop"));
Settings.Builder builder = Settings.builder();
builder.put(analyzerSettings);
builder.put(tokenFilterSettings);
execute("create table test (" + " id integer primary key," + " name string," + " content string index using fulltext with (analyzer='a11')" + ")");
ensureYellow();
execute("insert into test (id, name, content) values (?, ?, ?)", new Object[] { 1, "phrase", "The quick brown fox jumps over the lazy dog." });
execute("insert into test (id, name, content) values (?, ?, ?)", new Object[] { 2, "another phrase", "Don't panic!" });
refresh();
SQLResponse response = execute("select id from test where match(content, 'brown jump')");
assertEquals(1L, response.rowCount());
assertEquals(1, response.rows()[0][0]);
}
use of io.crate.testing.SQLResponse in project crate by crate.
the class GroupByAggregateTest method testGroupByArbitrary.
@Test
public void testGroupByArbitrary() throws Exception {
this.setup.groupBySetup();
execute("select arbitrary(name), race from characters group by race order by race asc");
SQLResponse arbitrary_response = response;
assertEquals(3, arbitrary_response.rowCount());
assertEquals("Android", arbitrary_response.rows()[0][1]);
assertEquals(1, execute("select name from characters where race=? AND name=? ", new Object[] { "Android", arbitrary_response.rows()[0][0] }).rowCount());
assertEquals("Human", arbitrary_response.rows()[1][1]);
assertEquals(1, execute("select name from characters where race=? AND name=? ", new Object[] { "Human", arbitrary_response.rows()[1][0] }).rowCount());
assertEquals("Vogon", arbitrary_response.rows()[2][1]);
assertEquals(1, execute("select name from characters where race=? AND name=? ", new Object[] { "Vogon", arbitrary_response.rows()[2][0] }).rowCount());
}
Aggregations