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));
}
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));
}
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"));
}
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"));
}
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"));
}
Aggregations