Search in sources :

Example 56 with SQLResponse

use of io.crate.testing.SQLResponse in project crate by crate.

the class TransportSQLActionClassLifecycleTest method testSysNodesVersionFromMultipleNodes.

@Test
public void testSysNodesVersionFromMultipleNodes() throws Exception {
    SQLResponse response = execute("select version, version['number'], " + "version['build_hash'], version['build_snapshot'] " + "from sys.nodes");
    assertThat(response.rowCount(), is(2L));
    for (int i = 0; i <= 1; i++) {
        assertThat(response.rows()[i][0], instanceOf(Map.class));
        assertThat((Map<String, Object>) response.rows()[i][0], allOf(hasKey("number"), hasKey("build_hash"), hasKey("build_snapshot")));
        assertThat((String) response.rows()[i][1], Matchers.is(Version.CURRENT.number()));
        assertThat((String) response.rows()[i][2], is(Build.CURRENT.hash()));
        assertThat((Boolean) response.rows()[i][3], is(Version.CURRENT.snapshot()));
    }
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 57 with SQLResponse

use of io.crate.testing.SQLResponse in project crate by crate.

the class TransportSQLActionClassLifecycleTest method testCountWithGroupByOrderOnKeyDescAndLimit.

@Test
public void testCountWithGroupByOrderOnKeyDescAndLimit() throws Exception {
    SQLResponse response = execute("select count(*), race from characters group by race order by race desc limit 2");
    assertEquals(2L, response.rowCount());
    assertEquals(2L, response.rows()[0][0]);
    assertEquals("Vogon", response.rows()[0][1]);
    assertEquals(4L, response.rows()[1][0]);
    assertEquals("Human", response.rows()[1][1]);
}
Also used : SQLResponse(io.crate.testing.SQLResponse)

Example 58 with SQLResponse

use of io.crate.testing.SQLResponse in project crate by crate.

the class SysShardsTest method testSelectWithOrderByColumnNotInOutputs.

@Test
public void testSelectWithOrderByColumnNotInOutputs() throws Exception {
    // regression test... query failed with ArrayOutOfBoundsException due to inputColumn mangling in planner
    SQLResponse response = execute("select id from sys.shards order by table_name limit 1");
    assertThat(response.rowCount(), is(1L));
    assertThat(response.rows()[0][0], instanceOf(Integer.class));
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Example 59 with SQLResponse

use of io.crate.testing.SQLResponse in project crate by crate.

the class SysShardsTest method testSelectWhereBoolean.

@Test
public void testSelectWhereBoolean() throws Exception {
    SQLResponse response = execute("select * from sys.shards where \"primary\" = false");
    assertEquals(13L, response.rowCount());
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Example 60 with SQLResponse

use of io.crate.testing.SQLResponse in project crate by crate.

the class SysShardsTest method testSelectGlobalAggregates.

@Test
public void testSelectGlobalAggregates() throws Exception {
    SQLResponse response = execute("select sum(size), min(size), max(size), avg(size) from sys.shards");
    assertEquals(1L, response.rowCount());
    assertEquals(4, response.rows()[0].length);
    assertNotNull(response.rows()[0][0]);
    assertNotNull(response.rows()[0][1]);
    assertNotNull(response.rows()[0][2]);
    assertNotNull(response.rows()[0][3]);
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Aggregations

SQLResponse (io.crate.testing.SQLResponse)109 Test (org.junit.Test)78 Map (java.util.Map)13 UseJdbc (io.crate.testing.UseJdbc)10 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)8 PartitionName (io.crate.metadata.PartitionName)4 TestingHelpers.resolveCanonicalString (io.crate.testing.TestingHelpers.resolveCanonicalString)4 Path (java.nio.file.Path)4 BytesRef (org.apache.lucene.util.BytesRef)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 TreeMap (java.util.TreeMap)2 List (java.util.List)1 UUID (java.util.UUID)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ClusterRerouteRequestBuilder (org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteRequestBuilder)1 ClusterStateResponse (org.elasticsearch.action.admin.cluster.state.ClusterStateResponse)1 SearchRequest (org.elasticsearch.action.search.SearchRequest)1 SearchResponse (org.elasticsearch.action.search.SearchResponse)1