Search in sources :

Example 41 with Metric

use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.

the class CSVUploadTest method testFileWithCRLineBreakAndDST.

@Issue("3591")
@Test
public void testFileWithCRLineBreakAndDST(Method method) throws Exception {
    Entity entity = new Entity("e-cr-dst-parser-ms-2");
    Metric metric = new Metric("m-cr-dst-parser-ms-2");
    File csvPath = resolvePath(Paths.get(RESOURCE_DIR, "test-cr-dst-parser.csv").toString());
    Response response = binaryCsvUpload(csvPath, CRLF_PARSER, entity.getName());
    assertEquals("Failed to upload file", OK.getStatusCode(), response.getStatus());
    SeriesQuery seriesQuery = new SeriesQuery(entity.getName(), metric.getName(), MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
    assertSeriesQueryDataSize(seriesQuery, 3);
    Sample sample = SeriesMethod.querySeriesAsList(seriesQuery).get(0).getData().get(0);
    Calendar serverCalendar = new GregorianCalendar(TimeZone.getTimeZone(timezone));
    serverCalendar.clear();
    serverCalendar.set(2015, Calendar.NOVEMBER, 24, 6, 17);
    assertEquals("Date failed to save", serverCalendar.getTime(), parseDate(sample.getRawDate()));
}
Also used : Response(javax.ws.rs.core.Response) Entity(com.axibase.tsd.api.model.entity.Entity) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Sample(com.axibase.tsd.api.model.series.Sample) Metric(com.axibase.tsd.api.model.metric.Metric) File(java.io.File) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 42 with Metric

use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.

the class CSVUploadTest method testTimeRangeInISO.

@Issue("2957")
@Test
public void testTimeRangeInISO(Method method) throws Exception {
    Entity entity = new Entity("e-csv-simple-parser-iso-0");
    Metric metric = new Metric("m-csv-simple-parser-iso-0");
    File csvPath = resolvePath(Paths.get(RESOURCE_DIR, "test-time-range-iso.csv").toString());
    Response response = binaryCsvUpload(csvPath, SIMPLE_PARSER_ISO);
    assertEquals("Failed to upload file", OK.getStatusCode(), response.getStatus());
    SeriesQuery seriesQuery = new SeriesQuery(entity.getName(), metric.getName(), MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
    assertSeriesQueryDataSize(seriesQuery, 2);
    List<Series> seriesList = SeriesMethod.querySeriesAsList(seriesQuery);
    Series series = seriesList.get(0);
    assertEquals("Min storable date failed to save", MIN_STORABLE_DATE, series.getData().get(0).getRawDate());
    assertEquals("Incorrect stored value", "12.45", series.getData().get(0).getValue().toString());
    assertEquals("Max storable date failed to save", MAX_STORABLE_DATE, series.getData().get(1).getRawDate());
    assertEquals("Incorrect stored value", "10.8", series.getData().get(1).getValue().toString());
}
Also used : Response(javax.ws.rs.core.Response) Entity(com.axibase.tsd.api.model.entity.Entity) Series(com.axibase.tsd.api.model.series.Series) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Metric(com.axibase.tsd.api.model.metric.Metric) File(java.io.File) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 43 with Metric

use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.

the class MetricCreateOrReplaceTest method testMetricTagNameIsLowerCased.

@Issue("3141")
@Test
public void testMetricTagNameIsLowerCased() throws Exception {
    final String TAG_NAME = "SoMeTaG";
    final String TAG_VALUE = "value";
    Map<String, String> tags = new HashMap<>();
    tags.put(TAG_NAME, TAG_VALUE);
    Metric metric = new Metric("create-metric-with-tag", tags);
    Response response1 = createOrReplaceMetric(metric);
    assertEquals("Failed to create metric", OK.getStatusCode(), response1.getStatus());
    Response response2 = queryMetric(metric.getName());
    Metric createdMetric = response2.readEntity(Metric.class);
    assertEquals("Wrong metric name", metric.getName(), createdMetric.getName());
    Map<String, String> expectedTags = new HashMap<>();
    expectedTags.put(TAG_NAME.toLowerCase(), TAG_VALUE);
    assertEquals("Wrong metric tags", expectedTags, createdMetric.getTags());
}
Also used : Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) Metric(com.axibase.tsd.api.model.metric.Metric) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 44 with Metric

use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.

the class MetricCreateOrReplaceTest method testTimeZone.

@Test
public void testTimeZone() throws Exception {
    Metric metric = new Metric(metric());
    metric.setTimeZoneID("GMT0");
    createOrReplaceMetricCheck(metric);
    Metric actualMetric = queryMetric(metric.getName()).readEntity(Metric.class);
    assertEquals(String.format("Failed to create metric with the %s timezone", metric.getTimeZoneID()), actualMetric.getTimeZoneID(), metric.getTimeZoneID());
}
Also used : Metric(com.axibase.tsd.api.model.metric.Metric) Test(org.testng.annotations.Test)

Example 45 with Metric

use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.

the class MetricCreateOrReplaceTest method testCreateOrReplace.

@Test
public void testCreateOrReplace() throws Exception {
    final Metric metric = new Metric("m-create-or-replace");
    metric.setDataType(DataType.DECIMAL);
    Response response = createOrReplaceMetric(metric.getName(), metric);
    assertEquals("Fail to execute createOrReplaceEntityGroup method", OK.getStatusCode(), response.getStatus());
    assertTrue("Fail to check metric inserted", metricExist(metric));
}
Also used : Response(javax.ws.rs.core.Response) Metric(com.axibase.tsd.api.model.metric.Metric) Test(org.testng.annotations.Test)

Aggregations

Metric (com.axibase.tsd.api.model.metric.Metric)76 Test (org.testng.annotations.Test)58 Issue (io.qameta.allure.Issue)50 Series (com.axibase.tsd.api.model.series.Series)25 Entity (com.axibase.tsd.api.model.entity.Entity)21 Response (javax.ws.rs.core.Response)16 BeforeClass (org.testng.annotations.BeforeClass)15 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)13 MetricCommand (com.axibase.tsd.api.model.command.MetricCommand)10 SqlTest (com.axibase.tsd.api.method.sql.SqlTest)7 BigDecimal (java.math.BigDecimal)7 MetricCheck (com.axibase.tsd.api.method.checks.MetricCheck)5 HashMap (java.util.HashMap)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 SeriesSearchResultRecord (com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord)3 Period (com.axibase.tsd.api.model.Period)2 Sample (com.axibase.tsd.api.model.series.Sample)2 Aggregate (com.axibase.tsd.api.model.series.query.transformation.aggregate.Aggregate)2 SeriesSearchQuery (com.axibase.tsd.api.model.series.search.SeriesSearchQuery)2