Search in sources :

Example 91 with SQLResponse

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

the class NodeStatsTest method testRegexpMatchOnNode.

@Test
public void testRegexpMatchOnNode() throws Exception {
    SQLResponse response = execute("select name from sys.nodes where name ~ 'node_s[0-1]{1,2}' order by name");
    assertThat(response.rowCount(), is(2L));
    assertThat((String) response.rows()[0][0], is("node_s0"));
    assertThat((String) response.rows()[1][0], is("node_s1"));
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Example 92 with SQLResponse

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

the class NodeStatsTest method testFsNoRootFS.

@Test
public void testFsNoRootFS() throws Exception {
    SQLResponse response = execute("select fs['data']['dev'], fs['disks'] from sys.nodes");
    assertThat(response.rowCount(), is(2L));
    for (Object[] row : response.rows()) {
        // data device name
        for (Object diskDevName : (Object[]) row[0]) {
            assertThat((String) diskDevName, is(not("rootfs")));
        }
        Object[] disks = (Object[]) row[1];
        // disks device name
        for (Object disk : disks) {
            String diskDevName = (String) ((Map<String, Object>) disk).get("dev");
            assertThat(diskDevName, is(notNullValue()));
            assertThat(diskDevName, is(not("rootfs")));
        }
    }
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Example 93 with SQLResponse

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

the class NodeStatsTest method testVersion.

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

Example 94 with SQLResponse

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

the class NodeStatsTest method testThreadPools.

@SuppressWarnings("ConstantConditions")
@Test
// because of json some values are transfered as integer instead of long
@UseJdbc(0)
public void testThreadPools() throws Exception {
    SQLResponse response = execute("select thread_pools from sys.nodes limit 1");
    Object[] threadPools = (Object[]) response.rows()[0][0];
    assertThat(threadPools.length, greaterThanOrEqualTo(1));
    Map<String, Object> threadPool = null;
    for (Object t : threadPools) {
        Map<String, Object> map = (Map<String, Object>) t;
        if (map.get("name").equals("generic")) {
            threadPool = map;
            break;
        }
    }
    assertThat((String) threadPool.get("name"), is("generic"));
    assertThat((Integer) threadPool.get("active"), greaterThanOrEqualTo(0));
    assertThat((Long) threadPool.get("rejected"), greaterThanOrEqualTo(0L));
    assertThat((Integer) threadPool.get("largest"), greaterThanOrEqualTo(0));
    assertThat((Long) threadPool.get("completed"), greaterThanOrEqualTo(0L));
    assertThat((Integer) threadPool.get("threads"), greaterThanOrEqualTo(0));
    assertThat((Integer) threadPool.get("queue"), greaterThanOrEqualTo(0));
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Map(java.util.Map) HashMap(java.util.HashMap) UseJdbc(io.crate.testing.UseJdbc) Test(org.junit.Test)

Example 95 with SQLResponse

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

the class NodeStatsTest method testThreadPoolValue.

@Test
public void testThreadPoolValue() throws Exception {
    SQLResponse response = execute("select thread_pools['name'], thread_pools['queue'] from sys.nodes limit 1");
    assertThat(response.rowCount(), is(1L));
    Object[] objects = (Object[]) response.rows()[0][0];
    String[] names = Arrays.copyOf(objects, objects.length, String[].class);
    assertThat(names.length, greaterThanOrEqualTo(1));
    assertThat(names, Matchers.hasItemInArray("generic"));
    Object[] queues = (Object[]) response.rows()[0][1];
    assertThat(queues.length, greaterThanOrEqualTo(1));
    assertThat((Integer) queues[0], greaterThanOrEqualTo(0));
}
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