From 97521ef988f46f9eae5ea1040b706ce5d234229f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Farkas?= Date: Thu, 14 Mar 2024 12:37:04 +0100 Subject: [PATCH] postgres: improve snapshot-tests for long/wide situations (#84387) --- .../postgres_snapshot_test.go | 3 +- ...golden.jsonc => no_rows_long.golden.jsonc} | 0 .../{no_rows.sql => no_rows_long.sql} | 0 .../time_series/no_rows_wide.golden.jsonc | 36 +++++++++++++++++++ .../testdata/time_series/no_rows_wide.sql | 10 ++++++ 5 files changed, 48 insertions(+), 1 deletion(-) rename pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/{no_rows.golden.jsonc => no_rows_long.golden.jsonc} (100%) rename pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/{no_rows.sql => no_rows_long.sql} (100%) create mode 100644 pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows_wide.golden.jsonc create mode 100644 pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows_wide.sql diff --git a/pkg/tsdb/grafana-postgresql-datasource/postgres_snapshot_test.go b/pkg/tsdb/grafana-postgresql-datasource/postgres_snapshot_test.go index df7a226f202..a9582ec7222 100644 --- a/pkg/tsdb/grafana-postgresql-datasource/postgres_snapshot_test.go +++ b/pkg/tsdb/grafana-postgresql-datasource/postgres_snapshot_test.go @@ -98,7 +98,8 @@ func TestIntegrationPostgresSnapshots(t *testing.T) { format string }{ {format: "time_series", name: "simple"}, - {format: "time_series", name: "no_rows"}, + {format: "time_series", name: "no_rows_long"}, + {format: "time_series", name: "no_rows_wide"}, {format: "time_series", name: "7x_compat_metric_label"}, {format: "time_series", name: "convert_to_float64"}, {format: "time_series", name: "convert_to_float64_not"}, diff --git a/pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows.golden.jsonc b/pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows_long.golden.jsonc similarity index 100% rename from pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows.golden.jsonc rename to pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows_long.golden.jsonc diff --git a/pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows.sql b/pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows_long.sql similarity index 100% rename from pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows.sql rename to pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows_long.sql diff --git a/pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows_wide.golden.jsonc b/pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows_wide.golden.jsonc new file mode 100644 index 00000000000..2cc0ccc47b8 --- /dev/null +++ b/pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows_wide.golden.jsonc @@ -0,0 +1,36 @@ +// 🌟 This was machine generated. Do not edit. 🌟 +// +// Frame[0] { +// "typeVersion": [ +// 0, +// 0 +// ], +// "executedQueryString": "SELECT * FROM tbl WHERE false" +// } +// Name: +// Dimensions: 0 Fields by 0 Rows +// + +// + +// +// +// 🌟 This was machine generated. Do not edit. 🌟 +{ + "status": 200, + "frames": [ + { + "schema": { + "meta": { + "typeVersion": [ + 0, + 0 + ], + "executedQueryString": "SELECT * FROM tbl WHERE false" + }, + "fields": [] + }, + "data": { + "values": [] + } + } + ] +} \ No newline at end of file diff --git a/pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows_wide.sql b/pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows_wide.sql new file mode 100644 index 00000000000..b34df7a0650 --- /dev/null +++ b/pkg/tsdb/grafana-postgresql-datasource/testdata/time_series/no_rows_wide.sql @@ -0,0 +1,10 @@ +-- SELECT * FROM tbl WHERE false +CREATE TEMPORARY TABLE tbl ( + "time" timestamp with time zone, + v1 double precision, + v2 double precision +); + +INSERT INTO tbl ("time", v1, v2) VALUES +('2023-12-24 14:30:03 UTC', 10, 110), +('2023-12-24 14:31:03 UTC', 20, 120); \ No newline at end of file