Search in sources :

Example 76 with StringTable

use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.

the class SqlClauseWithLastTimeTest method testLessLastTime.

@Issue("3291")
@Test
public void testLessLastTime() {
    String sqlQuery = String.format("SELECT entity, value FROM \"%s\" %nWITH time < last_time - 1*minute", TEST_METRIC_NAME);
    Response response = queryResponse(sqlQuery);
    String[][] expectedRows = { { TEST_ENTITY1_NAME, "0" }, { TEST_ENTITY2_NAME, "3" } };
    StringTable resultTable = response.readEntity(StringTable.class);
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : Response(javax.ws.rs.core.Response) StringTable(com.axibase.tsd.api.model.sql.StringTable) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 77 with StringTable

use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.

the class SqlExampleAvgValueTest method testExample1.

@Issue("3047")
@Test(description = "Test for query all tags documentation example. " + "https://github.com/axibase/atsd-docs/blob/master/api/sql/examples/average-value.md")
public void testExample1() {
    String sqlQuery = String.format("SELECT avg(value) %n" + "FROM \"%s\"  %n" + "WHERE entity = '%s'" + "AND datetime >= '2016-06-19T11:00:00.000Z' AND datetime < '2016-06-19T11:16:00.000Z'", TEST_METRIC_NAME, TEST_ENTITY_NAME);
    StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
    List<List<String>> expectedRows = Collections.singletonList(Collections.singletonList("11.3"));
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) List(java.util.List) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 78 with StringTable

use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.

the class SqlExampleAvgValueTest method testExample2.

@Issue("3047")
@Test
public void testExample2() {
    String sqlQuery = String.format("SELECT avg(value), max(value), last(value), count(*) %n" + "FROM \"%s\"  %n" + "WHERE entity = '%s'" + "AND datetime >= '2016-06-19T11:00:00.000Z' AND datetime < '2016-06-19T11:16:00.000Z'", TEST_METRIC_NAME, TEST_ENTITY_NAME);
    StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
    List<List<String>> expectedRows = Collections.singletonList(Arrays.asList("11.3", "11.5", "11.5", "2"));
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) List(java.util.List) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 79 with StringTable

use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.

the class SqlExamplePerPeriodTest method testExample.

@Issue("3047")
@Test(description = "Test for alias documentation example. " + "https://github.com/axibase/atsd-docs/blob/master/api/sql/examples/aggregate-period.md")
public void testExample() {
    String sqlQuery = String.format("SELECT datetime, avg(value), max(value), last(value), count(*) %n" + "FROM \"%s\" %n" + "WHERE datetime >= '2015-09-30T09:00:05Z' AND datetime < '2015-09-30T09:00:07Z'  %n" + "GROUP BY period(1 second)", TEST_METRIC_NAME);
    StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
    List<List<String>> expectedRows = Arrays.asList(Arrays.asList("2015-09-30T09:00:05.000Z", "2.0", "3.0", "2.0", "3"), Arrays.asList("2015-09-30T09:00:06.000Z", "3.0", "3.0", "3.0", "5"));
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) List(java.util.List) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 80 with StringTable

use of com.axibase.tsd.api.model.sql.StringTable in project atsd-api-test by axibase.

the class SqlExampleSlidingWindowsTest method testExample1.

@Issue("3047")
@Test(description = "Test for query all tags documentation example. " + "https://github.com/axibase/atsd-docs/blob/master/api/sql/examples/aggregate-sliding-window.md")
public void testExample1() {
    String sqlQuery = String.format("SELECT entity, avg(value), max(value), last(value), count(*) %n" + "FROM \"%s\" %n" + "WHERE datetime >= '2016-06-19T11:00:00.000Z' AND datetime < '2016-06-19T11:00:06.000Z'  %n" + "GROUP BY entity", TEST_METRIC_NAME);
    StringTable resultTable = queryResponse(sqlQuery).readEntity(StringTable.class);
    List<List<String>> expectedRows = Arrays.asList(Arrays.asList(TEST_ENTITY1_NAME, "2.0", "3.0", "3.0", "3"), Arrays.asList(TEST_ENTITY2_NAME, "4.5", "5.0", "5.0", "2"));
    assertTableRowsExist(expectedRows, resultTable);
}
Also used : StringTable(com.axibase.tsd.api.model.sql.StringTable) List(java.util.List) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Aggregations

StringTable (com.axibase.tsd.api.model.sql.StringTable)277 Test (org.testng.annotations.Test)276 SqlTest (com.axibase.tsd.api.method.sql.SqlTest)275 Issue (io.qameta.allure.Issue)270 List (java.util.List)147 Response (javax.ws.rs.core.Response)49 ArrayList (java.util.ArrayList)23 Series (com.axibase.tsd.api.model.series.Series)4 BigDecimal (java.math.BigDecimal)1 Date (java.util.Date)1 BeforeTest (org.testng.annotations.BeforeTest)1