From 50ecf090424f34d245c15249ab542cb1d9553d3a Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 8 Jul 2020 14:10:31 +0300 Subject: [PATCH] lib/protoparser/graphite: add more tests after eb45185eef619d187286a65942b09979fd0921fc Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/610 --- lib/protoparser/graphite/parser_test.go | 42 +++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/lib/protoparser/graphite/parser_test.go b/lib/protoparser/graphite/parser_test.go index 3eefef35ae..965da55f83 100644 --- a/lib/protoparser/graphite/parser_test.go +++ b/lib/protoparser/graphite/parser_test.go @@ -86,6 +86,13 @@ func TestRowsUnmarshalSuccess(t *testing.T) { Value: 1123, }}, }) + f("aaa 1123 -1", &Rows{ + Rows: []Row{{ + Metric: "aaa", + Value: 1123, + Timestamp: -1, + }}, + }) // Timestamp bigger than 1<<31 f("aaa 1123 429496729600", &Rows{ @@ -177,13 +184,42 @@ func Test_streamContext_Read(t *testing.T) { } } - // -1 timestamp - currentTimestamp := int64(fasttime.UnixTimestamp()) + // Full line without tags + f("aaa 1123 345", &Rows{ + Rows: []Row{{ + Metric: "aaa", + Value: 1123, + Timestamp: 345*1000, + }}, + }) + // Full line with tags + f("aaa;x=y 1123 345", &Rows{ + Rows: []Row{{ + Metric: "aaa", + Tags: []Tag{{ + Key: "x", + Value: "y", + }}, + Value: 1123, + Timestamp: 345*1000, + }}, + }) + // missing timestamp. + // Note that this test may be flaky due to timing issues. TODO: fix it f("aaa 1123", &Rows{ Rows: []Row{{ Metric: "aaa", Value: 1123, - Timestamp: currentTimestamp * 1000, + Timestamp: int64(fasttime.UnixTimestamp()) * 1000, + }}, + }) + // -1 timestamp. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/610 + // Note that this test may be flaky due to timing issues. TODO: fix it. + f("aaa 1123 -1", &Rows{ + Rows: []Row{{ + Metric: "aaa", + Value: 1123, + Timestamp: int64(fasttime.UnixTimestamp()) * 1000, }}, }) }