Skip to content

Commit

Permalink
Merge pull request #476 from bonitoo-io/tag_key_sorted
Browse files Browse the repository at this point in the history
issue #468 tags should be sorted by key in line protocol to reduce db server overheads
  • Loading branch information
majst01 authored Jul 25, 2018
2 parents 0aac8f0 + 2d1c9bc commit a59e4e6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/test/java/org/influxdb/dto/PointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,4 +450,31 @@ public void testLineProtocolHourPrecision() throws Exception {
String expectedHourTimeStamp = String.valueOf(Math.round(pDate.getTime() / 3600000)); // 1000ms * 60s * 60m
assertThat(hourTime).isEqualTo(expectedHourTimeStamp);
}

/*
* Test if representation of tags in line protocol format should be sorted by tag key
*/
@Test
public void testTagKeyIsSortedInLineProtocol() {
Point p = Point
.measurement("cpu")
.time(1000000000L, TimeUnit.MILLISECONDS)
.addField("value", 1)
.tag("region", "us-west")
.tag("host", "serverA")
.tag("env", "prod")
.tag("target", "servers")
.tag("zone", "1c")
.tag("tag5", "value5")
.tag("tag1", "value1")
.tag("tag2", "value2")
.tag("tag3", "value3")
.tag("tag4", "value4")
.build();

String lineProtocol = p.lineProtocol();
String correctOrder = "env=prod,host=serverA,region=us-west,tag1=value1,tag2=value2,tag3=value3,tag4=value4,tag5=value5,target=servers,zone=1c";
String tags = lineProtocol.substring(lineProtocol.indexOf(',') + 1, lineProtocol.indexOf(' '));
assertThat(tags).isEqualTo(correctOrder);
}
}

0 comments on commit a59e4e6

Please sign in to comment.