Search in sources :

Example 61 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)

Example 62 with Metric

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

the class MetricGetTest method testMetricNameContainsSlash.

@Issue("1278")
@Test
public void testMetricNameContainsSlash() throws Exception {
    final Metric metric = new Metric("get/metric-2");
    createOrReplaceMetricCheck(metric);
    Response response = queryMetric(metric.getName());
    assertEquals("Fail to execute queryMetric query", OK.getStatusCode(), response.getStatus());
    assertTrue("Metrics should be equal", compareJsonString(jacksonMapper.writeValueAsString(metric), response.readEntity(String.class)));
}
Also used : Response(javax.ws.rs.core.Response) Metric(com.axibase.tsd.api.model.metric.Metric) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 63 with Metric

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

the class SeriesQueryTest method testVersionedLimitSupport.

@Issue("2970")
@Test
public void testVersionedLimitSupport() throws Exception {
    Series series = new Series("e-query-v-l-24", "m-query-v-l-24");
    final int limitValue = 2;
    Metric versionedMetric = new Metric();
    versionedMetric.setName(series.getMetric());
    versionedMetric.setVersioned(true);
    MetricMethod.createOrReplaceMetric(versionedMetric);
    series.addSamples(Sample.ofDateInteger(MIN_STORABLE_DATE, 0), Sample.ofDateInteger(addOneMS(MIN_STORABLE_DATE), 1), Sample.ofDateInteger(addOneMS(addOneMS(MIN_STORABLE_DATE)), 2));
    insertSeriesCheck(Collections.singletonList(series));
    Map<String, Object> query = new HashMap<>();
    query.put("entity", series.getEntity());
    query.put("metric", series.getMetric());
    query.put("startDate", MIN_QUERYABLE_DATE);
    query.put("endDate", MAX_QUERYABLE_DATE);
    query.put("versioned", true);
    query.put("limit", limitValue);
    final Response response = querySeries(query);
    JSONArray jsonArray = new JSONArray(response.readEntity(String.class));
    final String assertMessage = String.format("Response should contain only %d samples", limitValue);
    assertEquals(assertMessage, limitValue, calculateJsonArraySize(((JSONObject) jsonArray.get(0)).getString("data")));
}
Also used : Response(javax.ws.rs.core.Response) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Metric(com.axibase.tsd.api.model.metric.Metric) JSONObject(org.json.JSONObject) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 64 with Metric

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

the class SeriesQueryWildcardEscapeTest method testEntitySpecialCharEscapeNotFound.

@Issue("4662")
@Test(description = "Test series query for entity name that contains wildcard and nothing were found", dataProvider = "provideSpecialCharacters")
public static void testEntitySpecialCharEscapeNotFound(char c) throws Exception {
    String entityName = ENTITY_PREFIX + c + "e2";
    String metricName = Mocks.metric();
    Series series = new Series(entityName, metricName);
    EntityMethod.createOrReplaceEntityCheck(new Entity(entityName));
    MetricMethod.createOrReplaceMetricCheck(new Metric(metricName));
    SeriesQuery seriesQuery = new SeriesQuery(series);
    String actualEntityName = SeriesMethod.querySeriesAsList(seriesQuery).get(0).getEntity();
    String expectedEntityName = ENTITY_PREFIX + '\\' + c + "e2";
    assertEquals("Wrong result when performing series query with entity that contains wildcard character " + c + " and no series were found", expectedEntityName, actualEntityName);
}
Also used : Series(com.axibase.tsd.api.model.series.Series) Entity(com.axibase.tsd.api.model.entity.Entity) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Metric(com.axibase.tsd.api.model.metric.Metric) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 65 with Metric

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

the class SeriesSearchTest method testAllFields.

@Issue("4404")
@Test(description = "Test all fields returned")
public void testAllFields() {
    Entity expectedEntity = EntityMethod.getEntity(resultRecord4.getEntity().getName());
    Metric expectedMetric = MetricMethod.getMetric(resultRecord4.getMetric().getName());
    SeriesSearchQuery query = new SeriesSearchQuery("sst_22*");
    query.addEntityFields("*");
    query.addEntityTags("*");
    query.addMetricFields("*");
    query.addMetricTags("*");
    SeriesSearchResult result = SeriesMethod.searchSeries(query);
    SeriesSearchResultRecord[] resultRecords = result.getData();
    assertTrue(resultRecords != null && resultRecords.length == 1, "Incorrect series count");
    SeriesSearchResultRecord resultRecord = resultRecords[0];
    Entity resultEntity = resultRecord.getEntity();
    Metric resultMetric = resultRecord.getMetric();
    assertEquals(resultEntity, expectedEntity);
    assertEquals(resultMetric, expectedMetric);
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) SeriesSearchResultRecord(com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord) SeriesSearchQuery(com.axibase.tsd.api.model.series.search.SeriesSearchQuery) Metric(com.axibase.tsd.api.model.metric.Metric) SeriesSearchResult(com.axibase.tsd.api.model.series.search.SeriesSearchResult) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

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