Search in sources :

Example 11 with SeriesCommand

use of com.axibase.tsd.api.model.command.SeriesCommand in project atsd-api-test by axibase.

the class BackslashCharEscapeTest method testEntity.

@Issue("2854")
@Test
public void testEntity() throws Exception {
    Series series = new Series("series-command-test\\-e5", "series-command-test-m5");
    Sample sample = Sample.ofDateInteger(Mocks.ISO_TIME, 1);
    series.addSamples(sample);
    SeriesCommand seriesCommand = new SeriesCommand();
    seriesCommand.setTimeISO(sample.getRawDate());
    seriesCommand.setEntityName(series.getEntity());
    seriesCommand.setValues(Collections.singletonMap(series.getMetric(), sample.getValue().toString()));
    CommandMethod.send(seriesCommand);
    assertSeriesExisting(series);
}
Also used : Series(com.axibase.tsd.api.model.series.Series) Sample(com.axibase.tsd.api.model.series.Sample) SeriesCommand(com.axibase.tsd.api.model.command.SeriesCommand) Issue(io.qameta.allure.Issue) SeriesTest(com.axibase.tsd.api.method.series.SeriesTest) Test(org.testng.annotations.Test)

Example 12 with SeriesCommand

use of com.axibase.tsd.api.model.command.SeriesCommand in project atsd-api-test by axibase.

the class BackslashCharEscapeTest method testMetric.

@Issue("2854")
@Test
public void testMetric() throws Exception {
    Series series = new Series("series-command-test-e6", "series-command-test\\-m6");
    Sample sample = Sample.ofDateInteger(Mocks.ISO_TIME, 1);
    series.addSamples(sample);
    SeriesCommand seriesCommand = new SeriesCommand();
    seriesCommand.setTimeISO(sample.getRawDate());
    seriesCommand.setEntityName(series.getEntity());
    seriesCommand.setValues(Collections.singletonMap(series.getMetric(), sample.getValue().toString()));
    CommandMethod.send(seriesCommand);
    assertSeriesExisting(series);
}
Also used : Series(com.axibase.tsd.api.model.series.Series) Sample(com.axibase.tsd.api.model.series.Sample) SeriesCommand(com.axibase.tsd.api.model.command.SeriesCommand) Issue(io.qameta.allure.Issue) SeriesTest(com.axibase.tsd.api.method.series.SeriesTest) Test(org.testng.annotations.Test)

Example 13 with SeriesCommand

use of com.axibase.tsd.api.model.command.SeriesCommand in project atsd-api-test by axibase.

the class DoubleBackslashCharEscapeTest method testEntity.

@Issue("2854")
@Test
public void testEntity() throws Exception {
    Series series = new Series("series-command-test\\\\-e7", "series-command-test-m7");
    Sample sample = Sample.ofJavaDateInteger(TestUtil.getCurrentDate(), 1);
    series.addSamples(sample);
    SeriesCommand seriesCommand = new SeriesCommand();
    seriesCommand.setTimeISO(sample.getRawDate());
    seriesCommand.setEntityName(series.getEntity());
    seriesCommand.setValues(Collections.singletonMap(series.getMetric(), sample.getValue().toString()));
    CommandMethod.send(seriesCommand);
    assertSeriesExisting(series);
}
Also used : Series(com.axibase.tsd.api.model.series.Series) Sample(com.axibase.tsd.api.model.series.Sample) SeriesCommand(com.axibase.tsd.api.model.command.SeriesCommand) Issue(io.qameta.allure.Issue) SeriesTest(com.axibase.tsd.api.method.series.SeriesTest) Test(org.testng.annotations.Test)

Example 14 with SeriesCommand

use of com.axibase.tsd.api.model.command.SeriesCommand in project atsd-api-test by axibase.

the class LengthTest method testMaxLengthOverflow.

@Issue("2412")
@Test
public void testMaxLengthOverflow() throws Exception {
    SeriesCommand seriesCommand = new SeriesCommand();
    seriesCommand.setTimeISO(ISO_TIME);
    seriesCommand.setEntityName(entity());
    Integer currentLength = seriesCommand.compose().length();
    Map<String, String> values = new HashMap<>();
    while (currentLength <= MAX_LENGTH) {
        Series series = new Series(seriesCommand.getEntityName(), metric());
        series.addSamples(Sample.ofDateInteger(ISO_TIME, 1));
        String appendix = FieldFormat.keyValue("m", series.getMetric(), "1");
        currentLength += appendix.length();
        values.put(series.getMetric(), "1");
    }
    seriesCommand.setValues(values);
    assertTrue("SeriesCommand length is not overflow", seriesCommand.compose().length() > MAX_LENGTH);
    CommandSendingResult expectedResult = new CommandSendingResult(1, 0);
    assertEquals("Sending result must contain one failed command", expectedResult, CommandMethod.send(seriesCommand));
}
Also used : Series(com.axibase.tsd.api.model.series.Series) CommandSendingResult(com.axibase.tsd.api.model.extended.CommandSendingResult) SeriesCommand(com.axibase.tsd.api.model.command.SeriesCommand) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 15 with SeriesCommand

use of com.axibase.tsd.api.model.command.SeriesCommand in project atsd-api-test by axibase.

the class LengthTest method testMaxLength.

@Issue("2412")
@Test
public void testMaxLength() throws Exception {
    SeriesCommand seriesCommand = new SeriesCommand();
    seriesCommand.setTimeISO(ISO_TIME);
    seriesCommand.setEntityName(entity());
    Integer currentLength = seriesCommand.compose().length();
    List<Series> seriesList = new ArrayList<>();
    Map<String, String> values = new HashMap<>();
    while (currentLength <= MAX_LENGTH) {
        Series series = new Series(seriesCommand.getEntityName(), metric());
        series.addSamples(Sample.ofDateInteger(ISO_TIME, 1));
        String appendix = FieldFormat.keyValue("m", series.getMetric(), "1");
        currentLength += appendix.length();
        if (currentLength < MAX_LENGTH) {
            values.put(series.getMetric(), "1");
            seriesList.add(series);
        } else {
            currentLength -= appendix.length();
            Integer leftCount = MAX_LENGTH - currentLength;
            String repeated = new String(new char[leftCount + 1]).replace("\0", "1");
            Integer lastIndex = seriesList.size() - 1;
            Series lastSeries = seriesList.get(lastIndex);
            seriesList.remove(lastSeries);
            lastSeries.setSamples(Collections.singletonList(Sample.ofDateDecimal(ISO_TIME, new BigDecimal(repeated))));
            values.put(lastSeries.getMetric(), repeated);
            seriesList.add(lastSeries);
            break;
        }
    }
    seriesCommand.setValues(values);
    assertEquals("Command length is not maximal", seriesCommand.compose().length(), MAX_LENGTH);
    CommandMethod.send(seriesCommand);
    assertSeriesExisting(seriesList);
}
Also used : Series(com.axibase.tsd.api.model.series.Series) SeriesCommand(com.axibase.tsd.api.model.command.SeriesCommand) BigDecimal(java.math.BigDecimal) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

SeriesCommand (com.axibase.tsd.api.model.command.SeriesCommand)18 Series (com.axibase.tsd.api.model.series.Series)16 Issue (io.qameta.allure.Issue)16 Test (org.testng.annotations.Test)16 Sample (com.axibase.tsd.api.model.series.Sample)8 SeriesTest (com.axibase.tsd.api.method.series.SeriesTest)6 CommandMethodTest (com.axibase.tsd.api.extended.CommandMethodTest)5 PlainCommand (com.axibase.tsd.api.model.command.PlainCommand)5 ArrayList (java.util.ArrayList)4 BigDecimal (java.math.BigDecimal)2 SqlTest (com.axibase.tsd.api.method.sql.SqlTest)1 CommandSendingResult (com.axibase.tsd.api.model.extended.CommandSendingResult)1 BeforeClass (org.testng.annotations.BeforeClass)1