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