Search in sources :

Example 6 with Interval

use of com.axibase.tsd.api.model.series.query.Interval in project atsd-api-test by axibase.

the class SeriesQueryDateFilterTest method testIntervalOnly.

@Issue("3030")
@Test
public void testIntervalOnly() throws Exception {
    Series series = new Series("datefilter-e-1", "datefilter-m-1");
    series.addSamples(DATE_FILTER_DEFAULT_SAMPLE);
    insertSeriesCheck(Collections.singletonList(series));
    SeriesQuery query = new SeriesQuery(series.getEntity(), series.getMetric());
    query.setInterval(new Interval(40, TimeUnit.YEAR));
    Response response = querySeries(query);
    assertSame("Response code mismatch", Response.Status.Family.SUCCESSFUL, Util.responseFamily(response));
    final String expected = jacksonMapper.writeValueAsString(Collections.singletonList(series));
    final String given = response.readEntity(String.class);
    assertTrue("Stored series mismatch", compareJsonString(expected, given));
}
Also used : Response(javax.ws.rs.core.Response) Series(com.axibase.tsd.api.model.series.Series) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Interval(com.axibase.tsd.api.model.series.query.Interval) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 7 with Interval

use of com.axibase.tsd.api.model.series.query.Interval in project atsd-api-test by axibase.

the class TokenSeriesTest method testQueryMethod.

@Test(description = "Tests series query endpoint with tokens.")
@Issue("6052")
public void testQueryMethod() throws Exception {
    String queryURL = "/series/query";
    SeriesQuery query = new SeriesQuery(entity, metric).setStartDate(SAMPLE_TIME).setInterval(new Interval(1, TimeUnit.DAY));
    String queryToken = TokenRepository.getToken(username, HttpMethod.POST, queryURL);
    Response response = querySeries(Collections.singletonList(query), queryToken);
    assertTrue(compareJsonString(Util.prettyPrint(Collections.singletonList(series)), response.readEntity(String.class), false));
}
Also used : Response(javax.ws.rs.core.Response) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Interval(com.axibase.tsd.api.model.series.query.Interval) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SeriesTest(com.axibase.tsd.api.method.series.SeriesTest)

Example 8 with Interval

use of com.axibase.tsd.api.model.series.query.Interval in project atsd-api-test by axibase.

the class SeriesQueryForecastTimeFilterTest method testData.

@DataProvider(parallel = false)
public Object[][] testData() {
    Interval days_2 = new Interval(2, TimeUnit.DAY);
    Interval days_3 = new Interval(3, TimeUnit.DAY);
    return new Object[][] { { new Horizon().setLength(111), false, false, 10 * 24 * 60, 111 }, // - 24*60: first period (= 1 day) of Holt-Winters reconstructed series is always zero, and not included in response
    { new Horizon().setLength(111), true, false, 11 * 8 * 60 - 24 * 60, 111 }, { new Horizon().setLength(111), true, true, 9 * 8 * 60 - 24 * 60, 111 }, { new Horizon().setLength(2 * 24 * 60), true, true, 9 * 8 * 60 - 24 * 60, 2 * 24 * 60 }, { new Horizon().setInterval(days_2), false, false, 10 * 24 * 60, 2 * 24 * 60 }, // -1: latest timestamp 17:59 is not included because it equals to end time of 2 day interval
    { new Horizon().setInterval(days_2), true, false, 11 * 8 * 60 - 24 * 60, 2 * 8 * 60 - 1 }, { new Horizon().setInterval(days_2), true, true, 9 * 8 * 60 - 24 * 60, 1 * 8 * 60 }, // +1: forecastEndTime implemented "inclusive"
    { new Horizon().setEndDate("2021-04-18T00:00:00Z"), false, false, 10 * 24 * 60, 2 * 24 * 60 + 1 }, { new Horizon().setEndDate("2021-04-18T00:00:00Z"), true, false, 11 * 8 * 60 - 24 * 60, 2 * 8 * 60 }, { new Horizon().setEndDate("2021-04-18T00:00:00Z"), true, true, 9 * 8 * 60 - 24 * 60, 1 * 8 * 60 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setLength(111), false, false, 9 * 24 * 60, 111 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setLength(111), true, false, 10 * 8 * 60 - 24 * 60, 111 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setLength(111), true, true, 8 * 8 * 60 - 24 * 60, 111 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setLength(3 * 24 * 60), true, true, 8 * 8 * 60 - 24 * 60, 3 * 24 * 60 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setInterval(days_3), false, false, 9 * 24 * 60, 3 * 24 * 60 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setInterval(days_3), true, false, 10 * 8 * 60 - 24 * 60, 3 * 8 * 60 - 1 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setInterval(days_3), true, true, 8 * 8 * 60 - 24 * 60, 2 * 8 * 60 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setEndDate("2021-04-18T00:00:00Z"), false, false, 9 * 24 * 60, 3 * 24 * 60 + 1 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setEndDate("2021-04-18T00:00:00Z"), true, false, 10 * 8 * 60 - 24 * 60, 3 * 8 * 60 }, { new Horizon().setStartDate("2021-04-15T00:00:00Z").setEndDate("2021-04-18T00:00:00Z"), true, true, 8 * 8 * 60 - 24 * 60, 2 * 8 * 60 } };
}
Also used : Horizon(com.axibase.tsd.api.model.series.query.transformation.forecast.Horizon) Interval(com.axibase.tsd.api.model.series.query.Interval) DataProvider(org.testng.annotations.DataProvider)

Example 9 with Interval

use of com.axibase.tsd.api.model.series.query.Interval in project atsd-api-test by axibase.

the class SeriesQueryForecastTimeFilterTest method buildForecastSettings.

private Forecast buildForecastSettings() {
    HoltWintersSettings hwSettings = new HoltWintersSettings().setAlpha(0.5).setBeta(0.5).setGamma(0.5).setAuto(false).setPeriod(new Period(1, TimeUnit.DAY));
    List<SeriesType> include = Arrays.asList(SeriesType.RECONSTRUCTED, SeriesType.FORECAST);
    return new Forecast().setHw(hwSettings).setInclude(include).setScoreInterval(new Interval(1, TimeUnit.DAY));
}
Also used : Forecast(com.axibase.tsd.api.model.series.query.transformation.forecast.Forecast) SeriesType(com.axibase.tsd.api.model.series.SeriesType) Period(com.axibase.tsd.api.model.Period) HoltWintersSettings(com.axibase.tsd.api.model.series.query.transformation.forecast.HoltWintersSettings) Interval(com.axibase.tsd.api.model.series.query.Interval)

Example 10 with Interval

use of com.axibase.tsd.api.model.series.query.Interval in project atsd-api-test by axibase.

the class SeriesQueryTest method testDateIntervalFieldEnoughToGroup.

@Issue("3030")
@Test
public void testDateIntervalFieldEnoughToGroup() throws Exception {
    Series series = new Series("entity-query-25", "metric-query-25");
    series.addSamples(Sample.ofDateInteger(MIN_STORABLE_DATE, 1));
    insertSeriesCheck(Collections.singletonList(series));
    SeriesQuery query = new SeriesQuery();
    query.setEntity(series.getEntity());
    query.setMetric(series.getMetric());
    query.setInterval(new Interval(99999, TimeUnit.QUARTER));
    query.setGroup(new Group(GroupType.SUM));
    List<Series> storedSeries = querySeriesAsList(query);
    final String expected = jacksonMapper.writeValueAsString(Collections.singletonList(series));
    final String given = jacksonMapper.writeValueAsString(storedSeries);
    assertTrue("Stored series does not match to inserted", compareJsonString(expected, given));
}
Also used : Series(com.axibase.tsd.api.model.series.Series) Group(com.axibase.tsd.api.model.series.query.transformation.group.Group) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Interval(com.axibase.tsd.api.model.series.query.Interval) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

Interval (com.axibase.tsd.api.model.series.query.Interval)12 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)10 Issue (io.qameta.allure.Issue)9 Test (org.testng.annotations.Test)9 Series (com.axibase.tsd.api.model.series.Series)6 Response (javax.ws.rs.core.Response)6 Period (com.axibase.tsd.api.model.Period)2 SeriesTest (com.axibase.tsd.api.method.series.SeriesTest)1 Sample (com.axibase.tsd.api.model.series.Sample)1 SeriesType (com.axibase.tsd.api.model.series.SeriesType)1 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)1 Forecast (com.axibase.tsd.api.model.series.query.transformation.forecast.Forecast)1 HoltWintersSettings (com.axibase.tsd.api.model.series.query.transformation.forecast.HoltWintersSettings)1 Horizon (com.axibase.tsd.api.model.series.query.transformation.forecast.Horizon)1 Group (com.axibase.tsd.api.model.series.query.transformation.group.Group)1 BigDecimal (java.math.BigDecimal)1 DataProvider (org.testng.annotations.DataProvider)1