Search in sources :

Example 26 with SQLResponse

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

the class SysShardsTest method testSelectStarWhereTable.

@Test
public void testSelectStarWhereTable() throws Exception {
    SQLResponse response = execute("select * from sys.shards where table_name = 'characters'");
    assertEquals(8L, response.rowCount());
    assertEquals(15, response.cols().length);
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Example 27 with SQLResponse

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

the class SysShardsTest method testSelectWhereTable.

@Test
public void testSelectWhereTable() throws Exception {
    SQLResponse response = execute("select id, size from sys.shards " + "where table_name = 'characters'");
    assertEquals(8L, response.rowCount());
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Example 28 with SQLResponse

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

the class SysShardsTest method testSelectGroupByHaving.

@Test
public void testSelectGroupByHaving() throws Exception {
    SQLResponse response = execute("select count(*) " + "from sys.shards " + "group by table_name " + "having table_name = 'quotes'");
    assertThat(TestingHelpers.printedTable(response.rows()), is("8\n"));
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Example 29 with SQLResponse

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

the class SysShardsTest method testSelectRecoveryExpression.

@Test
public void testSelectRecoveryExpression() throws Exception {
    SQLResponse response = execute("select recovery, " + "recovery['files'], recovery['files']['used'], recovery['files']['reused'], recovery['files']['recovered'], " + "recovery['size'], recovery['size']['used'], recovery['size']['reused'], recovery['size']['recovered'] " + "from sys.shards");
    for (Object[] row : response.rows()) {
        Map recovery = (Map) row[0];
        Map<String, Integer> files = (Map<String, Integer>) row[1];
        assertThat(((Map<String, Integer>) recovery.get("files")).entrySet(), equalTo(files.entrySet()));
        Map<String, Long> size = (Map<String, Long>) row[5];
        assertThat(((Map<String, Long>) recovery.get("size")).entrySet(), equalTo(size.entrySet()));
    }
}
Also used : SQLResponse(io.crate.testing.SQLResponse) TestingHelpers.resolveCanonicalString(io.crate.testing.TestingHelpers.resolveCanonicalString) Map(java.util.Map) Test(org.junit.Test)

Example 30 with SQLResponse

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

the class SysShardsTest method testSelectStarLike.

@Test
public void testSelectStarLike() throws Exception {
    SQLResponse response = execute("select * from sys.shards where table_name like 'charact%'");
    assertEquals(8L, response.rowCount());
    assertEquals(15, response.cols().length);
}
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