Package io.crate.action.sql

Examples of io.crate.action.sql.SQLResponse.rowCount()


    @Test
    public void testSysNodesOs() throws Exception {
        SQLResponse response = executor.exec("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"), greaterThan(0L));

        assertThat((Short) ((Map) results.get("cpu")).get("system"), greaterThanOrEqualTo((short) 0));
View Full Code Here


    }

    @Test
    public void testFs() throws Exception {
        SQLResponse response = executor.exec("select fs from sys.nodes limit 1");
        assertThat(response.rowCount(), is(1L));
        assertThat(response.rows()[0][0], instanceOf(Map.class));
        Map<String, Object> fs = (Map<String, Object>)response.rows()[0][0];
        assertThat(fs.keySet().size(), is(3));
        assertThat(fs.keySet(), hasItems("total", "disks", "data"));
View Full Code Here

    }

    @Test
    public void testFsNoRootFS() throws Exception {
        SQLResponse response = executor.exec("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")));
            }
View Full Code Here

    }

    @Test
    public void testSysNodesObjectArrayStringChildColumn() throws Exception {
        SQLResponse response = executor.exec("select fs['data']['path'] from sys.nodes");
        assertThat(response.rowCount(), Matchers.is(2L));
        for (Object path : (Object[])response.rows()[0][0]) {
            assertThat(path, instanceOf(String.class));
        }
    }
View Full Code Here

    @Test
    public void testVersion() throws Exception {
        SQLResponse response = executor.exec("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()));
View Full Code Here

    }

    @Test
    public void testRegexpMatchOnNode() throws Exception {
        SQLResponse response = executor.exec("select name from sys.nodes where name ~ 'node_[0-9]{1,2}' order by name");
        assertThat(response.rowCount(), is(2L));
        assertThat((String)response.rows()[0][0], is("node_0"));
        assertThat((String)response.rows()[1][0], is("node_1"));
    }
}
View Full Code Here

    @Test
    public void testSelectOrderByGlobalExpression() throws Exception {
        SQLResponse response = executor.exec(
            "select count(*), sys.cluster.name from characters group by sys.cluster.name order by sys.cluster.name");
        assertEquals(1, response.rowCount());
        assertEquals(7L, response.rows()[0][0]);

        assertEquals(GLOBAL_CLUSTER.clusterName(), response.rows()[0][1]);
    }

View Full Code Here

    @Test
    public void testSelectGlobalExpressionGroupBy() throws Exception {
        SQLResponse response = executor.exec(
            "select count(distinct race), sys.cluster.name from characters group by sys.cluster.name");
        assertEquals(1, response.rowCount());
        for (int i=0; i<response.rowCount();i++) {
            assertEquals(3L, response.rows()[i][0]);
            assertEquals(GLOBAL_CLUSTER.clusterName(), response.rows()[i][1]);
        }
    }
View Full Code Here

    @Test
    public void testSelectGlobalExpressionGroupBy() throws Exception {
        SQLResponse response = executor.exec(
            "select count(distinct race), sys.cluster.name from characters group by sys.cluster.name");
        assertEquals(1, response.rowCount());
        for (int i=0; i<response.rowCount();i++) {
            assertEquals(3L, response.rows()[i][0]);
            assertEquals(GLOBAL_CLUSTER.clusterName(), response.rows()[i][1]);
        }
    }
View Full Code Here

    @Test
    public void testSelectGlobalExpressionGroupByWith2GroupByKeys() throws Exception {
        SQLResponse response = executor.exec(
            "select count(name), sys.cluster.name from characters " +
                "group by race, sys.cluster.name order by count(name) desc");
        assertEquals(3, response.rowCount());
        assertEquals(4L, response.rows()[0][0]);
        assertEquals(GLOBAL_CLUSTER.clusterName(), response.rows()[0][1]);
        assertEquals(response.rows()[0][1], response.rows()[1][1]);
        assertEquals(response.rows()[0][1], response.rows()[2][1]);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.