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);
}
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);
}
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);
}
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));
}
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);
}
Aggregations