Search in sources :

Example 21 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class SqlEntityTagsTest method prepareData.

@BeforeClass
public static void prepareData() throws Exception {
    Series series = new Series(TEST_ENTITY_NAME, TEST_METRIC_NAME) {

        {
            addSamples(Sample.ofDateInteger("2016-06-19T11:00:00.000Z", 3));
        }
    };
    EntityMethod.createOrReplaceEntityCheck(new Entity(TEST_ENTITY_NAME, new HashMap<String, String>() {

        {
            put("tag1", "val1");
            put("tag2", "val2");
            put("tag3", "v3");
        }
    }));
    SeriesMethod.insertSeriesCheck(Collections.singletonList(series));
}
Also used : Series(com.axibase.tsd.api.model.series.Series) Entity(com.axibase.tsd.api.model.entity.Entity) HashMap(java.util.HashMap) BeforeClass(org.testng.annotations.BeforeClass)

Example 22 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class LastAndFirstFunctionTagsTest method prepareData.

@BeforeClass
public void prepareData() throws Exception {
    String testEntity = entity();
    Entity entity = new Entity(testEntity);
    entity.addTag("literal_tag", "value");
    entity.addTag("numeric_tag", "123");
    Series series = new Series(testEntity, TEST_METRIC);
    series.addSamples(Sample.ofDateInteger("2017-01-01T09:30:00.000Z", 1), Sample.ofDateInteger("2017-01-01T10:30:00.000Z", 1), Sample.ofDateInteger("2017-01-01T11:30:00.000Z", 2), Sample.ofDateInteger("2017-01-01T12:30:00.000Z", 2), Sample.ofDateInteger("2017-01-01T13:30:00.000Z", 2));
    EntityMethod.createOrReplaceEntityCheck(entity);
    SeriesMethod.insertSeriesCheck(series);
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) Series(com.axibase.tsd.api.model.series.Series) BeforeClass(org.testng.annotations.BeforeClass)

Example 23 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class AutoTimeZoneTest method testEntityTimeZone.

@Test
public void testEntityTimeZone() throws Exception {
    Entity entity = new Entity(entity());
    entity.setTimeZoneID(ALGIERS_TIMEZONE_ID);
    Series series = new Series(entity.getName(), metric());
    series.addSamples(DEFAULT_SAMPLE);
    EntityMethod.createOrReplaceEntityCheck(entity);
    SeriesMethod.insertSeriesCheck(Collections.singletonList(series));
    String sqlQuery = String.format("SELECT date_format(time, '%s', AUTO) FROM \"%s\"", DEFAULT_PATTERN, series.getMetric());
    String[][] expectedRows = { { formatDate(parseDate(DEFAULT_SAMPLE.getRawDate()), DEFAULT_PATTERN, getTimeZone(entity.getTimeZoneID())) } };
    assertSqlQueryRows("Failed to define entity timezone by AUTO param", expectedRows, sqlQuery);
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) Series(com.axibase.tsd.api.model.series.Series) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 24 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class InterpolateUserTimeZoneTest method testInterpolateEntityTimezone.

@Issue("4103")
@Test(description = "Check that entity.timezone can be used for interpolation")
public void testInterpolateEntityTimezone() throws Exception {
    String entityName = Mocks.entity();
    String metricName = Mocks.metric();
    Entity entity = new Entity(entityName);
    entity.setTimeZoneID("America/Los_Angeles");
    Series series = new Series(entityName, metricName);
    series.addSamples(Sample.ofDateInteger("2017-10-11T05:22:43.573Z", 1), Sample.ofDateInteger("2017-10-12T05:22:43.573Z", 2));
    EntityMethod.createOrReplaceEntityCheck(entity);
    SeriesMethod.insertSeriesCheck(series);
    String sqlQuery = String.format("SELECT date_format(datetime, 'yy-MM-dd HH:mm:ss', entity.timezone) " + "FROM \"%1$s\" " + "WHERE datetime BETWEEN '2017-10-11T05:00:00.000Z' " + "AND '2017-10-12T05:00:00.000Z' " + "WITH INTERPOLATE(1 DAY, PREVIOUS, OUTER, FALSE, CALENDAR, entity.timezone)", metricName);
    String[][] expectedRows = { { "17-10-11 00:00:00" } };
    assertSqlQueryRows("Incorrect interpolation when using entity.timezone as custom timezone", expectedRows, sqlQuery);
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) Series(com.axibase.tsd.api.model.series.Series) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) SqlTest(com.axibase.tsd.api.method.sql.SqlTest)

Example 25 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class LikeEscapeTest method prepareTest.

@BeforeClass
public void prepareTest() throws Exception {
    Map<String, String> testTags = Collections.singletonMap(prefix + "tag", prefix + "value");
    Entity entity = new Entity(TEST_ENTITY, testTags).setLabel(prefix + Mocks.LABEL);
    Metric metric = new Metric(TEST_METRIC, testTags).setLabel(prefix + Mocks.LABEL).setDescription(prefix + Mocks.DESCRIPTION).setUnits(prefix + "units");
    Series series = new Series(TEST_ENTITY, TEST_METRIC, testTags);
    series.addSamples(Sample.ofDateIntegerText(Mocks.ISO_TIME, 1, prefix + Mocks.TEXT_VALUE));
    EntityMethod.createOrReplaceEntityCheck(entity);
    MetricMethod.createOrReplaceMetricCheck(metric);
    SeriesMethod.insertSeriesCheck(series);
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) Series(com.axibase.tsd.api.model.series.Series) Metric(com.axibase.tsd.api.model.metric.Metric) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

Entity (com.axibase.tsd.api.model.entity.Entity)77 Test (org.testng.annotations.Test)60 Issue (io.qameta.allure.Issue)43 Metric (com.axibase.tsd.api.model.metric.Metric)21 Series (com.axibase.tsd.api.model.series.Series)21 BeforeClass (org.testng.annotations.BeforeClass)15 PropertyQuery (com.axibase.tsd.api.model.property.PropertyQuery)12 EntityCommand (com.axibase.tsd.api.model.command.EntityCommand)9 HashMap (java.util.HashMap)9 Property (com.axibase.tsd.api.model.property.Property)8 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)6 EntityCheck (com.axibase.tsd.api.method.checks.EntityCheck)5 Response (javax.ws.rs.core.Response)5 PlainCommand (com.axibase.tsd.api.model.command.PlainCommand)4 File (java.io.File)4 SqlTest (com.axibase.tsd.api.method.sql.SqlTest)3 SeriesSearchResultRecord (com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord)3 Sample (com.axibase.tsd.api.model.series.Sample)2 SeriesSearchQuery (com.axibase.tsd.api.model.series.search.SeriesSearchQuery)2 BigDecimal (java.math.BigDecimal)2