lib/protoparser/graphite: add more tests after eb45185eef

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/610
This commit is contained in:
Aliaksandr Valialkin 2020-07-08 14:10:31 +03:00
parent 1ae0334e17
commit 50ecf09042

View File

@ -86,6 +86,13 @@ func TestRowsUnmarshalSuccess(t *testing.T) {
Value: 1123, Value: 1123,
}}, }},
}) })
f("aaa 1123 -1", &Rows{
Rows: []Row{{
Metric: "aaa",
Value: 1123,
Timestamp: -1,
}},
})
// Timestamp bigger than 1<<31 // Timestamp bigger than 1<<31
f("aaa 1123 429496729600", &Rows{ f("aaa 1123 429496729600", &Rows{
@ -177,13 +184,42 @@ func Test_streamContext_Read(t *testing.T) {
} }
} }
// -1 timestamp // Full line without tags
currentTimestamp := int64(fasttime.UnixTimestamp()) 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{ f("aaa 1123", &Rows{
Rows: []Row{{ Rows: []Row{{
Metric: "aaa", Metric: "aaa",
Value: 1123, 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,
}}, }},
}) })
} }