mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
influxdb: flux: use more precise start and end timestamps (#39415)
* influxdb: flux: use more precise start and end timestamps * added unit test
This commit is contained in:
@@ -16,8 +16,8 @@ func interpolate(query queryModel) (string, error) {
|
|||||||
matches := variableFilterExp.FindAllStringSubmatch(flux, -1)
|
matches := variableFilterExp.FindAllStringSubmatch(flux, -1)
|
||||||
if matches != nil {
|
if matches != nil {
|
||||||
timeRange := query.TimeRange
|
timeRange := query.TimeRange
|
||||||
from := timeRange.From.UTC().Format(time.RFC3339)
|
from := timeRange.From.UTC().Format(time.RFC3339Nano)
|
||||||
to := timeRange.To.UTC().Format(time.RFC3339)
|
to := timeRange.To.UTC().Format(time.RFC3339Nano)
|
||||||
for _, match := range matches {
|
for _, match := range matches {
|
||||||
switch match[2] {
|
switch match[2] {
|
||||||
case "timeRangeStart":
|
case "timeRangeStart":
|
||||||
|
|||||||
@@ -11,12 +11,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestInterpolate(t *testing.T) {
|
func TestInterpolate(t *testing.T) {
|
||||||
// Unix sec: 1500376552
|
|
||||||
// Unix ms: 1500376552001
|
|
||||||
|
|
||||||
timeRange := backend.TimeRange{
|
timeRange := backend.TimeRange{
|
||||||
From: time.Unix(0, 0),
|
From: time.Unix(1632305571, 310985041),
|
||||||
To: time.Unix(0, 0),
|
To: time.Unix(1632309171, 310985042),
|
||||||
}
|
}
|
||||||
|
|
||||||
options := queryOptions{
|
options := queryOptions{
|
||||||
@@ -33,7 +30,7 @@ func TestInterpolate(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "interpolate flux variables",
|
name: "interpolate flux variables",
|
||||||
before: `v.timeRangeStart, something.timeRangeStop, XYZ.bucket, uuUUu.defaultBucket, aBcDefG.organization, window.windowPeriod, a91{}.bucket`,
|
before: `v.timeRangeStart, something.timeRangeStop, XYZ.bucket, uuUUu.defaultBucket, aBcDefG.organization, window.windowPeriod, a91{}.bucket`,
|
||||||
after: `1970-01-01T00:00:00Z, 1970-01-01T00:00:00Z, "grafana2", "grafana3", "grafana1", 1s, a91{}.bucket`,
|
after: `2021-09-22T10:12:51.310985041Z, 2021-09-22T11:12:51.310985042Z, "grafana2", "grafana3", "grafana1", 1s, a91{}.bucket`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|||||||
Reference in New Issue
Block a user