Search in sources :

Example 11 with SQLResponse

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

the class NodeStatsTest method testSysNodesOs.

@Test
// because of json some values are transfered as integer instead of long
@UseJdbc(0)
public void testSysNodesOs() throws Exception {
    SQLResponse response = execute("select os from sys.nodes limit 1");
    Map results = (Map) response.rows()[0][0];
    assertThat(response.rowCount(), is(1L));
    assertThat((Long) results.get("timestamp"), greaterThan(0L));
    assertThat((Long) results.get("uptime"), greaterThanOrEqualTo(-1L));
    assertThat((Short) ((Map) results.get("cpu")).get("system"), greaterThanOrEqualTo((short) -1));
    assertThat((Short) ((Map) results.get("cpu")).get("system"), lessThanOrEqualTo((short) 100));
    assertThat((Short) ((Map) results.get("cpu")).get("user"), greaterThanOrEqualTo((short) -1));
    assertThat((Short) ((Map) results.get("cpu")).get("user"), lessThanOrEqualTo((short) 100));
    assertThat((Short) ((Map) results.get("cpu")).get("used"), greaterThanOrEqualTo((short) -1));
    assertThat((Short) ((Map) results.get("cpu")).get("used"), lessThanOrEqualTo((short) 100));
    assertThat((Short) ((Map) results.get("cpu")).get("idle"), greaterThanOrEqualTo((short) -1));
    assertThat((Short) ((Map) results.get("cpu")).get("idle"), lessThanOrEqualTo((short) 100));
    assertThat((Short) ((Map) results.get("cpu")).get("stolen"), greaterThanOrEqualTo((short) -1));
    assertThat((Short) ((Map) results.get("cpu")).get("stolen"), lessThanOrEqualTo((short) 100));
}
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 12 with SQLResponse

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

the class SysJobsTest method testQueryAllColumns.

@Test
public void testQueryAllColumns() throws Exception {
    execute("set global stats.enabled = true");
    String stmt = "select * from sys.jobs";
    // the response contains all current jobs, if the tests are executed in parallel
    // this might be more then only the "select * from sys.jobs" statement.
    SQLResponse response = execute(stmt);
    List<String> statements = new ArrayList<>();
    for (Object[] objects : response.rows()) {
        assertNotNull(objects[0]);
        statements.add((String) objects[2]);
    }
    assertTrue(statements.contains(stmt));
}
Also used : ArrayList(java.util.ArrayList) SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Example 13 with SQLResponse

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

the class SysNodeCheckerIntegrationTest method testChecksPresenceAndSeverityLevels.

@Test
public void testChecksPresenceAndSeverityLevels() throws Exception {
    SQLResponse response = execute("select id, severity, passed from sys.node_checks order by id, node_id asc");
    assertThat(response.rowCount(), equalTo(10L));
    assertThat(TestingHelpers.printedTable(response.rows()), is(// 1 = recoveryExpectedNodesCheck
    "1| 3| false\n" + "1| 3| false\n" + // 2 = RecoveryAfterNodes
    "2| 3| false\n" + "2| 3| false\n" + // 3 = RecoveryAfterTime
    "3| 2| true\n" + "3| 2| true\n" + // 5 = HighDiskWatermark
    "5| 3| true\n" + "5| 3| true\n" + // 6 = LowDiskWatermark
    "6| 3| true\n" + "6| 3| true\n"));
}
Also used : SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Example 14 with SQLResponse

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

the class SysOperationsTest method testQueryNameFromSysOperations.

@Test
public void testQueryNameFromSysOperations() throws Exception {
    SQLResponse resp = execute("select name, job_id from sys.operations order by name asc");
    // usually this should return collect per node and an optional merge on handler
    // but it could be that the collect is finished before the localMerge task is started in which
    // case it is missing.
    assertThat(resp.rowCount(), Matchers.greaterThanOrEqualTo((long) internalCluster().numDataNodes()));
    List<String> names = new ArrayList<>();
    for (Object[] objects : resp.rows()) {
        names.add((String) objects[0]);
    }
    Collections.sort(names);
    assertTrue(names.contains("collect"));
}
Also used : ArrayList(java.util.ArrayList) SQLResponse(io.crate.testing.SQLResponse) Test(org.junit.Test)

Example 15 with SQLResponse

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

the class SysOperationsTest method testNodeExpressionOnSysOperations.

@Test
public void testNodeExpressionOnSysOperations() throws Exception {
    execute("select * from sys.nodes");
    SQLResponse response = execute("select _node['name'], id from sys.operations limit 1");
    assertThat(response.rowCount(), is(1L));
    assertThat(response.rows()[0][0].toString(), startsWith("node_s"));
}
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