Revert "Postgres: Switch the datasource plugin from lib/pq to pgx (#8… (#85509)

Revert "Postgres: Switch the datasource plugin from lib/pq to pgx (#83768)"

This reverts commit ecd6de826a315526ed5fac0ce9e70f9f50e217c8.
This commit is contained in:
Gábor Farkas
2024-04-03 11:02:22 +02:00
committed by GitHub
parent ffb5d23a13
commit 8159e1db3a
17 changed files with 943 additions and 1078 deletions

View File

@ -3,6 +3,7 @@ package postgres
import (
"context"
"encoding/json"
"fmt"
"os"
"path/filepath"
"regexp"
@ -48,6 +49,20 @@ func TestIntegrationPostgresSnapshots(t *testing.T) {
t.Skip()
}
getCnnStr := func() string {
host := os.Getenv("POSTGRES_HOST")
if host == "" {
host = "localhost"
}
port := os.Getenv("POSTGRES_PORT")
if port == "" {
port = "5432"
}
return fmt.Sprintf("user=grafanatest password=grafanatest host=%s port=%s dbname=grafanadstest sslmode=disable",
host, port)
}
sqlQueryCommentRe := regexp.MustCompile(`^-- (.+)\n`)
readSqlFile := func(path string) (string, string) {
@ -137,34 +152,18 @@ func TestIntegrationPostgresSnapshots(t *testing.T) {
ConnMaxLifetime: 14400,
Timescaledb: false,
ConfigurationMethod: "file-path",
Mode: "disable",
}
host := os.Getenv("POSTGRES_HOST")
if host == "" {
host = "localhost"
}
port := os.Getenv("POSTGRES_PORT")
if port == "" {
port = "5432"
}
dsInfo := sqleng.DataSourceInfo{
JsonData: jsonData,
DecryptedSecureJSONData: map[string]string{
"password": "grafanatest",
},
URL: host + ":" + port,
Database: "grafanadstest",
User: "grafanatest",
JsonData: jsonData,
DecryptedSecureJSONData: map[string]string{},
}
logger := log.New()
settings := backend.DataSourceInstanceSettings{}
proxyClient, err := settings.ProxyClient(context.Background())
require.NoError(t, err)
db, handler, err := newPostgres("error", 10000, dsInfo, logger, proxyClient)
cnnstr := getCnnStr()
db, handler, err := newPostgres(context.Background(), "error", 10000, dsInfo, cnnstr, logger, backend.DataSourceInstanceSettings{})
t.Cleanup((func() {
_, err := db.Exec("DROP TABLE tbl")