From de908da16c883b28f4ed5939e3dc23b5bad1c05a Mon Sep 17 00:00:00 2001 From: Harsh Daryani Date: Thu, 20 Nov 2025 04:53:19 +0000 Subject: [PATCH] Skip test with known failures --- batch_test.go | 1 + conn_test.go | 21 +++++++++++++++++++-- derived_types_test.go | 1 + internal/sanitize/sanitize_bench_test.go | 2 +- internal/sanitize/sanitize_fuzz_test.go | 2 +- large_objects_test.go | 5 ++++- multitracer/tracer.go | 4 ++-- multitracer/tracer_test.go | 6 +++--- pgconn/ctxwatch/context_watcher_test.go | 2 +- pgconn/pgconn_test.go | 8 ++++++++ pgproto3/bind_test.go | 2 +- pgproto3/query_test.go | 2 +- pgtype/derived_types_test.go | 4 ++-- pgtype/interval_test.go | 1 + pgtype/ltree_test.go | 1 + pgtype/pgtype_test.go | 13 +++++++++++++ pgtype/uint64_test.go | 4 ++-- pgtype/xml_test.go | 8 ++++++-- pgx_test.go | 13 +++++++++++++ pgxpool/pool_test.go | 11 +++++++++-- pgxpool/tracer_test.go | 4 ++-- pgxtest/pgxtest.go | 8 ++++++++ query_test.go | 16 +++++++++++++++- rows_test.go | 5 ++++- stdlib/sql_test.go | 21 +++++++++++++++++++++ tx_test.go | 4 ++++ 26 files changed, 144 insertions(+), 25 deletions(-) diff --git a/batch_test.go b/batch_test.go index 4cfc0f39d..afa6ad6bb 100644 --- a/batch_test.go +++ b/batch_test.go @@ -161,6 +161,7 @@ func TestConnSendBatchQueuedQuery(t *testing.T) { pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { pgxtest.SkipCockroachDB(t, conn, "Server serial type is incompatible with test") + pgxtest.SkipYugabyteDB(t, conn, "Flaky test failure on YugabyteDB") sql := `create temporary table ledger( id serial primary key, diff --git a/conn_test.go b/conn_test.go index 290628db8..eb997422e 100644 --- a/conn_test.go +++ b/conn_test.go @@ -623,6 +623,8 @@ func TestListenNotify(t *testing.T) { t.Skip("Server does not support LISTEN / NOTIFY (https://github.com/cockroachdb/cockroach/issues/41522)") } + pgxtest.SkipYugabyteDB(t, listener, "YugabyteDB does not support LISTEN / NOTIFY") + mustExec(t, listener, "listen chat") notifier := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE")) @@ -745,6 +747,7 @@ func TestListenNotifySelfNotification(t *testing.T) { defer closeConn(t, conn) pgxtest.SkipCockroachDB(t, conn, "Server does not support LISTEN / NOTIFY (https://github.com/cockroachdb/cockroach/issues/41522)") + pgxtest.SkipYugabyteDB(t, conn, "YugabyteDB does not support LISTEN / NOTIFY") mustExec(t, conn, "listen self") @@ -951,7 +954,8 @@ func TestUnregisteredTypeUsableAsStringArgumentAndBaseResult(t *testing.T) { pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { pgxtest.SkipCockroachDB(t, conn, "Server does support domain types (https://github.com/cockroachdb/cockroach/issues/27796)") - + pgxtest.SkipYugabyteDB(t, conn, "YugabyteDB does not support uint64 domain type") + var n uint64 err := conn.QueryRow(context.Background(), "select $1::uint64", "42").Scan(&n) if err != nil { @@ -970,6 +974,7 @@ func TestDomainType(t *testing.T) { pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { pgxtest.SkipCockroachDB(t, conn, "Server does support domain types (https://github.com/cockroachdb/cockroach/issues/27796)") + pgxtest.SkipYugabyteDB(t, conn, "YugabyteDB does not support uint64 domain type") // Domain type uint64 is a PostgreSQL domain of underlying type numeric. @@ -1012,6 +1017,9 @@ func TestLoadTypeSameNameInDifferentSchemas(t *testing.T) { require.NoError(t, err) defer tx.Rollback(ctx) + _, err = tx.Exec(ctx, `drop schema if exists pgx_a cascade; drop schema if exists pgx_b cascade;`) + require.NoError(t, err) + _, err = tx.Exec(ctx, `create schema pgx_a; create type pgx_a.point as (a text, b text); create schema pgx_b; @@ -1052,7 +1060,8 @@ func TestLoadCompositeType(t *testing.T) { pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { pgxtest.SkipCockroachDB(t, conn, "Server does support composite types (https://github.com/cockroachdb/cockroach/issues/27792)") - + pgxtest.SkipYugabyteDB(t, conn, "ALTER TYPE DROP ATTRIBUTE not supported yet in YugabyteDB") + tx, err := conn.Begin(ctx) require.NoError(t, err) defer tx.Rollback(ctx) @@ -1079,6 +1088,9 @@ func TestLoadRangeType(t *testing.T) { require.NoError(t, err) defer tx.Rollback(ctx) + _, err = tx.Exec(ctx, "drop type if exists examplefloatrange") + require.NoError(t, err) + _, err = tx.Exec(ctx, "create type examplefloatrange as range (subtype=float8, subtype_diff=float8mi)") require.NoError(t, err) @@ -1114,6 +1126,11 @@ func TestLoadMultiRangeType(t *testing.T) { require.NoError(t, err) defer tx.Rollback(ctx) + _, err = tx.Exec(ctx, "drop type if exists examplefloatrange") + require.NoError(t, err) + _, err = tx.Exec(ctx, "drop type if exists examplefloatmultirange") + require.NoError(t, err) + _, err = tx.Exec(ctx, "create type examplefloatrange as range (subtype=float8, subtype_diff=float8mi, multirange_type_name=examplefloatmultirange)") require.NoError(t, err) diff --git a/derived_types_test.go b/derived_types_test.go index 4a5384ae3..a2ae0ca4e 100644 --- a/derived_types_test.go +++ b/derived_types_test.go @@ -10,6 +10,7 @@ import ( func TestCompositeCodecTranscodeWithLoadTypes(t *testing.T) { skipCockroachDB(t, "Server does not support composite types (see https://github.com/cockroachdb/cockroach/issues/27792)") + skipYugabyteDB(t, "Flaky test in YugabyteDB") defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { _, err := conn.Exec(ctx, ` diff --git a/internal/sanitize/sanitize_bench_test.go b/internal/sanitize/sanitize_bench_test.go index baa742b11..9634b2bb9 100644 --- a/internal/sanitize/sanitize_bench_test.go +++ b/internal/sanitize/sanitize_bench_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/jackc/pgx/v5/internal/sanitize" + "github.com/yugabyte/pgx/v5/internal/sanitize" ) var benchmarkSanitizeResult string diff --git a/internal/sanitize/sanitize_fuzz_test.go b/internal/sanitize/sanitize_fuzz_test.go index 2f0c41223..d6ec34d56 100644 --- a/internal/sanitize/sanitize_fuzz_test.go +++ b/internal/sanitize/sanitize_fuzz_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/jackc/pgx/v5/internal/sanitize" + "github.com/yugabyte/pgx/v5/internal/sanitize" ) func FuzzQuoteString(f *testing.F) { diff --git a/large_objects_test.go b/large_objects_test.go index fdb9f4373..0858241f8 100644 --- a/large_objects_test.go +++ b/large_objects_test.go @@ -25,6 +25,7 @@ func TestLargeObjects(t *testing.T) { } pgxtest.SkipCockroachDB(t, conn, "Server does support large objects") + pgxtest.SkipYugabyteDB(t, conn, "YugabyteDB does not support large objects") tx, err := conn.Begin(ctx) if err != nil { @@ -54,6 +55,7 @@ func TestLargeObjectsSimpleProtocol(t *testing.T) { } pgxtest.SkipCockroachDB(t, conn, "Server does support large objects") + pgxtest.SkipYugabyteDB(t, conn, "YugabyteDB does not support large objects") tx, err := conn.Begin(ctx) if err != nil { @@ -174,7 +176,8 @@ func TestLargeObjectsMultipleTransactions(t *testing.T) { } pgxtest.SkipCockroachDB(t, conn, "Server does support large objects") - + pgxtest.SkipYugabyteDB(t, conn, "YugabyteDB does not support large objects") + tx, err := conn.Begin(ctx) if err != nil { t.Fatal(err) diff --git a/multitracer/tracer.go b/multitracer/tracer.go index acff17398..ec4392e73 100644 --- a/multitracer/tracer.go +++ b/multitracer/tracer.go @@ -4,8 +4,8 @@ package multitracer import ( "context" - "github.com/jackc/pgx/v5" - "github.com/jackc/pgx/v5/pgxpool" + "github.com/yugabyte/pgx/v5" + "github.com/yugabyte/pgx/v5/pgxpool" ) // Tracer can combine several tracers into one. diff --git a/multitracer/tracer_test.go b/multitracer/tracer_test.go index aa5ccd080..1033af51c 100644 --- a/multitracer/tracer_test.go +++ b/multitracer/tracer_test.go @@ -4,9 +4,9 @@ import ( "context" "testing" - "github.com/jackc/pgx/v5" - "github.com/jackc/pgx/v5/multitracer" - "github.com/jackc/pgx/v5/pgxpool" + "github.com/yugabyte/pgx/v5" + "github.com/yugabyte/pgx/v5/multitracer" + "github.com/yugabyte/pgx/v5/pgxpool" "github.com/stretchr/testify/require" ) diff --git a/pgconn/ctxwatch/context_watcher_test.go b/pgconn/ctxwatch/context_watcher_test.go index a18e7339e..95edbc39e 100644 --- a/pgconn/ctxwatch/context_watcher_test.go +++ b/pgconn/ctxwatch/context_watcher_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/jackc/pgx/v5/pgconn/ctxwatch" + "github.com/yugabyte/pgx/v5/pgconn/ctxwatch" "github.com/stretchr/testify/require" ) diff --git a/pgconn/pgconn_test.go b/pgconn/pgconn_test.go index f0e816d59..d6f34e70b 100644 --- a/pgconn/pgconn_test.go +++ b/pgconn/pgconn_test.go @@ -1684,6 +1684,10 @@ func TestConnOnNotification(t *testing.T) { t.Skip("Server does not support LISTEN / NOTIFY (https://github.com/cockroachdb/cockroach/issues/41522)") } + if strings.Contains(pgConn.ParameterStatus("server_version"), "YB") { + t.Skip("YugabyteDB does not support LISTEN / NOTIFY") + } + _, err = pgConn.Exec(ctx, "listen foo").ReadAll() require.NoError(t, err) @@ -1723,6 +1727,10 @@ func TestConnWaitForNotification(t *testing.T) { t.Skip("Server does not support LISTEN / NOTIFY (https://github.com/cockroachdb/cockroach/issues/41522)") } + if strings.Contains(pgConn.ParameterStatus("server_version"), "YB") { + t.Skip("YugabyteDB does not support LISTEN / NOTIFY") + } + _, err = pgConn.Exec(ctx, "listen foo").ReadAll() require.NoError(t, err) diff --git a/pgproto3/bind_test.go b/pgproto3/bind_test.go index 6ec0e0245..f23fd3d05 100644 --- a/pgproto3/bind_test.go +++ b/pgproto3/bind_test.go @@ -3,7 +3,7 @@ package pgproto3_test import ( "testing" - "github.com/jackc/pgx/v5/pgproto3" + "github.com/yugabyte/pgx/v5/pgproto3" "github.com/stretchr/testify/require" ) diff --git a/pgproto3/query_test.go b/pgproto3/query_test.go index 9551fc14d..74847d977 100644 --- a/pgproto3/query_test.go +++ b/pgproto3/query_test.go @@ -3,7 +3,7 @@ package pgproto3_test import ( "testing" - "github.com/jackc/pgx/v5/pgproto3" + "github.com/yugabyte/pgx/v5/pgproto3" "github.com/stretchr/testify/require" ) diff --git a/pgtype/derived_types_test.go b/pgtype/derived_types_test.go index 05d109bda..b282bf6ae 100644 --- a/pgtype/derived_types_test.go +++ b/pgtype/derived_types_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - pgx "github.com/jackc/pgx/v5" - "github.com/jackc/pgx/v5/pgtype" + pgx "github.com/yugabyte/pgx/v5" + "github.com/yugabyte/pgx/v5/pgtype" "github.com/stretchr/testify/require" ) diff --git a/pgtype/interval_test.go b/pgtype/interval_test.go index ca2d90fe8..0cd5fdc2e 100644 --- a/pgtype/interval_test.go +++ b/pgtype/interval_test.go @@ -7,6 +7,7 @@ import ( "github.com/yugabyte/pgx/v5/pgtype" "github.com/yugabyte/pgx/v5/pgxtest" + "github.com/stretchr/testify/assert" ) func TestIntervalCodec(t *testing.T) { diff --git a/pgtype/ltree_test.go b/pgtype/ltree_test.go index 15dc03cd4..d7b124d78 100644 --- a/pgtype/ltree_test.go +++ b/pgtype/ltree_test.go @@ -10,6 +10,7 @@ import ( func TestLtreeCodec(t *testing.T) { skipCockroachDB(t, "Server does not support type ltree") + skipYugabyteDB(t, "YugabyteDB does not support ltree type") pgxtest.RunValueRoundTripTests(context.Background(), t, defaultConnTestRunner, pgxtest.KnownOIDQueryExecModes, "ltree", []pgxtest.ValueRoundTripTest{ { diff --git a/pgtype/pgtype_test.go b/pgtype/pgtype_test.go index f63330e44..a073c315c 100644 --- a/pgtype/pgtype_test.go +++ b/pgtype/pgtype_test.go @@ -12,6 +12,7 @@ import ( "reflect" "regexp" "strconv" + "strings" "testing" "github.com/stretchr/testify/assert" @@ -98,6 +99,18 @@ func skipCockroachDB(t testing.TB, msg string) { } } +func skipYugabyteDB(t testing.TB, msg string) { + conn, err := pgx.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE")) + if err != nil { + t.Fatal(err) + } + defer conn.Close(context.Background()) + + if strings.Contains(conn.PgConn().ParameterStatus("server_version"), "YB") { + t.Skip(msg) + } +} + func skipPostgreSQLVersionLessThan(t testing.TB, minVersion int64) { conn, err := pgx.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE")) if err != nil { diff --git a/pgtype/uint64_test.go b/pgtype/uint64_test.go index 33c2622d5..2523fa5ec 100644 --- a/pgtype/uint64_test.go +++ b/pgtype/uint64_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - "github.com/jackc/pgx/v5/pgtype" - "github.com/jackc/pgx/v5/pgxtest" + "github.com/yugabyte/pgx/v5/pgtype" + "github.com/yugabyte/pgx/v5/pgxtest" ) func TestUint64Codec(t *testing.T) { diff --git a/pgtype/xml_test.go b/pgtype/xml_test.go index 2c0b899a5..a138ef405 100644 --- a/pgtype/xml_test.go +++ b/pgtype/xml_test.go @@ -6,8 +6,8 @@ import ( "encoding/xml" "testing" - pgx "github.com/jackc/pgx/v5" - "github.com/jackc/pgx/v5/pgxtest" + pgx "github.com/yugabyte/pgx/v5" + "github.com/yugabyte/pgx/v5/pgxtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -20,6 +20,7 @@ type xmlStruct struct { func TestXMLCodec(t *testing.T) { skipCockroachDB(t, "CockroachDB does not support XML.") + skipYugabyteDB(t, "YugabyteDB does not support XML.") pgxtest.RunValueRoundTripTests(context.Background(), t, defaultConnTestRunner, nil, "xml", []pgxtest.ValueRoundTripTest{ {nil, new(*xmlStruct), isExpectedEq((*xmlStruct)(nil))}, {map[string]any(nil), new(*string), isExpectedEq((*string)(nil))}, @@ -50,6 +51,7 @@ func TestXMLCodec(t *testing.T) { // https://github.com/jackc/pgx/issues/1273#issuecomment-1221414648 func TestXMLCodecUnmarshalSQLNull(t *testing.T) { skipCockroachDB(t, "CockroachDB does not support XML.") + skipYugabyteDB(t, "YugabyteDB does not support XML.") defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { // Byte arrays are nilified slice := []byte{10, 4} @@ -85,6 +87,7 @@ func TestXMLCodecUnmarshalSQLNull(t *testing.T) { func TestXMLCodecPointerToPointerToString(t *testing.T) { skipCockroachDB(t, "CockroachDB does not support XML.") + skipYugabyteDB(t, "YugabyteDB does not support XML.") defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, t testing.TB, conn *pgx.Conn) { var s *string err := conn.QueryRow(ctx, "select ''::xml").Scan(&s) @@ -100,6 +103,7 @@ func TestXMLCodecPointerToPointerToString(t *testing.T) { func TestXMLCodecDecodeValue(t *testing.T) { skipCockroachDB(t, "CockroachDB does not support XML.") + skipYugabyteDB(t, "YugabyteDB does not support XML.") defaultConnTestRunner.RunTest(context.Background(), t, func(ctx context.Context, _ testing.TB, conn *pgx.Conn) { for _, tt := range []struct { sql string diff --git a/pgx_test.go b/pgx_test.go index d12d75fd3..9fa3b6f7c 100644 --- a/pgx_test.go +++ b/pgx_test.go @@ -4,6 +4,7 @@ import ( "context" "os" "testing" + "strings" "github.com/yugabyte/pgx/v5" _ "github.com/yugabyte/pgx/v5/stdlib" @@ -20,3 +21,15 @@ func skipCockroachDB(t testing.TB, msg string) { t.Skip(msg) } } + +func skipYugabyteDB(t testing.TB, msg string) { + conn, err := pgx.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE")) + if err != nil { + t.Fatal(err) + } + defer conn.Close(context.Background()) + + if strings.Contains(conn.PgConn().ParameterStatus("server_version"), "YB") { + t.Skip(msg) + } +} \ No newline at end of file diff --git a/pgxpool/pool_test.go b/pgxpool/pool_test.go index 196484cbc..9e98d6e59 100644 --- a/pgxpool/pool_test.go +++ b/pgxpool/pool_test.go @@ -214,6 +214,8 @@ func TestPoolAcquireChecksIdleConnsWithShouldPing(t *testing.T) { require.NoError(t, err) defer controllerConn.Close(ctx) + pgxtest.SkipYugabyteDB(t, controllerConn, "Test timeouts on YugabyteDB") + config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE")) require.NoError(t, err) @@ -243,10 +245,10 @@ func TestPoolAcquireChecksIdleConnsWithShouldPing(t *testing.T) { // The original 3 conns should have been terminated and the a new conn established for the ping. require.EqualValues(t, 1, pool.Stat().TotalConns()) - c, err := pool.Acquire(ctx) + c, err = pool.Acquire(ctx) require.NoError(t, err) - cPID := c.Conn().PgConn().PID() + _ = c.Conn().PgConn().PID() c.Release() time.Sleep(time.Millisecond * 200) @@ -873,6 +875,11 @@ func TestPoolCopyFrom(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) defer cancel() + controllerConn, err := pgx.Connect(ctx, os.Getenv("PGX_TEST_DATABASE")) + require.NoError(t, err) + defer controllerConn.Close(ctx) + pgxtest.SkipYugabyteDB(t, controllerConn, "Order of rows returned is not guaranteed to match input order") + pool, err := pgxpool.New(ctx, os.Getenv("PGX_TEST_DATABASE")) require.NoError(t, err) defer pool.Close() diff --git a/pgxpool/tracer_test.go b/pgxpool/tracer_test.go index 10724d94c..eb0a16f97 100644 --- a/pgxpool/tracer_test.go +++ b/pgxpool/tracer_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/jackc/pgx/v5" - "github.com/jackc/pgx/v5/pgxpool" + "github.com/yugabyte/pgx/v5" + "github.com/yugabyte/pgx/v5/pgxpool" "github.com/stretchr/testify/require" ) diff --git a/pgxtest/pgxtest.go b/pgxtest/pgxtest.go index e2b75cfd8..e9ea47564 100644 --- a/pgxtest/pgxtest.go +++ b/pgxtest/pgxtest.go @@ -8,6 +8,7 @@ import ( "regexp" "strconv" "testing" + "strings" "github.com/yugabyte/pgx/v5" ) @@ -154,6 +155,13 @@ func SkipCockroachDB(t testing.TB, conn *pgx.Conn, msg string) { } } +// SkipYugabyteDB calls Skip on t with msg if the connection is to a YugabyteDB server. +func SkipYugabyteDB(t testing.TB, conn *pgx.Conn, msg string) { + if strings.Contains(conn.PgConn().ParameterStatus("server_version"), "YB") { + t.Skip(msg) + } +} + func SkipPostgreSQLVersionLessThan(t testing.TB, conn *pgx.Conn, minVersion int64) { serverVersionStr := conn.PgConn().ParameterStatus("server_version") serverVersionStr = regexp.MustCompile(`^[0-9]+`).FindString(serverVersionStr) diff --git a/query_test.go b/query_test.go index 5bce9fb8f..c90d39d58 100644 --- a/query_test.go +++ b/query_test.go @@ -205,6 +205,9 @@ func TestConnQueryValuesWithUnregisteredOID(t *testing.T) { require.NoError(t, err) defer tx.Rollback(ctx) + _, err = conn.Exec(ctx, "drop type if exists fruit") + require.NoError(t, err) + _, err = tx.Exec(ctx, "create type fruit as enum('orange', 'apple', 'pear')") require.NoError(t, err) @@ -230,6 +233,9 @@ func TestConnQueryArgsAndScanWithUnregisteredOID(t *testing.T) { require.NoError(t, err) defer tx.Rollback(ctx) + _, err = conn.Exec(ctx, "drop type if exists fruit") + require.NoError(t, err) + _, err = tx.Exec(ctx, "create type fruit as enum('orange', 'apple', 'pear')") require.NoError(t, err) @@ -1192,6 +1198,8 @@ func TestConnQueryDatabaseSQLDriverValuerCalledOnNilPointerImplementers(t *testi conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE")) defer closeConn(t, conn) + pgxtest.SkipYugabyteDB(t, conn, "Temporary Tables with JSON type.") + mustExec(t, conn, "create temporary table t(v json not null)") var v *nilPointerAsEmptyJSONObject @@ -1242,6 +1250,8 @@ func TestConnQueryDatabaseSQLDriverValuerCalledOnNilSliceImplementers(t *testing conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE")) defer closeConn(t, conn) + pgxtest.SkipYugabyteDB(t, conn, "Temporary Tables with JSON type.") + mustExec(t, conn, "create temporary table t(v json not null)") var v nilSliceAsEmptySlice @@ -1299,6 +1309,8 @@ func TestConnQueryDatabaseSQLDriverValuerCalledOnNilMapImplementers(t *testing.T conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE")) defer closeConn(t, conn) + pgxtest.SkipYugabyteDB(t, conn, "Temporary Tables with JSON type.") + mustExec(t, conn, "create temporary table t(v json not null)") var v nilMapAsEmptyObject @@ -2063,6 +2075,8 @@ func TestQueryErrorWithDisabledStatementCache(t *testing.T) { conn := mustConnect(t, config) defer closeConn(t, conn) + pgxtest.SkipYugabyteDB(t, conn, "Temporary Table issue with YugabyteDB.") + _, err := conn.Exec(context.Background(), "create temporary table t_unq(id text primary key);") require.NoError(t, err) @@ -2179,7 +2193,7 @@ func ExampleConn_Query() { return } - if conn.PgConn().ParameterStatus("crdb_version") != "" { + if conn.PgConn().ParameterStatus("crdb_version") != "" || strings.Contains(conn.PgConn().ParameterStatus("server_version"), "YB") { // Skip test / example when running on CockroachDB. Since an example can't be skipped fake success instead. fmt.Println(`Cheeseburger: $10 Fries: $5 diff --git a/rows_test.go b/rows_test.go index 5ba699668..9287aaad9 100644 --- a/rows_test.go +++ b/rows_test.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "testing" + "strings" "time" "github.com/stretchr/testify/assert" @@ -266,6 +267,8 @@ func TestCollectOneRowPrefersPostgreSQLErrorOverErrNoRows(t *testing.T) { _, err := conn.Exec(ctx, `create temporary table t (name text not null unique)`) require.NoError(t, err) + pgxtest.SkipYugabyteDB(t, conn, "Temporay table issue in YugabyteDB") + var name string rows, _ := conn.Query(ctx, `insert into t (name) values ('foo') returning name`) name, err = pgx.CollectOneRow(rows, func(row pgx.CollectableRow) (string, error) { @@ -565,7 +568,7 @@ func ExampleRowToStructByPos() { return } - if conn.PgConn().ParameterStatus("crdb_version") != "" { + if conn.PgConn().ParameterStatus("crdb_version") != "" || strings.Contains(conn.PgConn().ParameterStatus("server_version"), "YB") { // Skip test / example when running on CockroachDB. Since an example can't be skipped fake success instead. fmt.Println(`Cheeseburger: $10 Fries: $5 diff --git a/stdlib/sql_test.go b/stdlib/sql_test.go index 7ac1582cd..dd24817d7 100644 --- a/stdlib/sql_test.go +++ b/stdlib/sql_test.go @@ -11,6 +11,7 @@ import ( "reflect" "regexp" "strconv" + "strings" "sync" "testing" "time" @@ -51,6 +52,21 @@ func skipCockroachDB(t testing.TB, db *sql.DB, msg string) { require.NoError(t, err) } +func skipYugabyteDB(t testing.TB, db *sql.DB, msg string) { + conn, err := db.Conn(context.Background()) + require.NoError(t, err) + defer conn.Close() + + err = conn.Raw(func(driverConn any) error { + conn := driverConn.(*stdlib.Conn).Conn() + if strings.Contains(conn.PgConn().ParameterStatus("server_version"), "YB") { + t.Skip(msg) + } + return nil + }) + require.NoError(t, err) +} + func skipPostgreSQLVersionLessThan(t testing.TB, db *sql.DB, minVersion int64) { conn, err := db.Conn(context.Background()) require.NoError(t, err) @@ -333,6 +349,7 @@ func TestConnQuery(t *testing.T) { func TestConnConcurrency(t *testing.T) { testWithAllQueryExecModes(t, func(t *testing.T, db *sql.DB) { + skipYugabyteDB(t, db, "Flaky test on YugabyteDB") _, err := db.Exec("create table t (id integer primary key, str text, dur_str interval)") require.NoError(t, err) @@ -610,6 +627,8 @@ func TestConnExecInsertByteSliceIntoJSON(t *testing.T) { db := openDB(t) defer closeDB(t, db) + skipYugabyteDB(t, db, "Flaky test on YugabyteDB") + _, err := db.Exec(` create temporary table docs( body json not null @@ -744,6 +763,7 @@ func TestConnBeginTxReadOnly(t *testing.T) { func TestBeginTxContextCancel(t *testing.T) { testWithAllQueryExecModes(t, func(t *testing.T, db *sql.DB) { + skipYugabyteDB(t, db, "Error behavior differs on YugabyteDB") _, err := db.Exec("drop table if exists t") require.NoError(t, err) @@ -1180,6 +1200,7 @@ func TestConnQueryRowConstraintErrors(t *testing.T) { testWithAllQueryExecModes(t, func(t *testing.T, db *sql.DB) { skipPostgreSQLVersionLessThan(t, db, 11) skipCockroachDB(t, db, "Server does not support deferred constraint (https://github.com/cockroachdb/cockroach/issues/31632)") + skipYugabyteDB(t, db, "CREATE CONSTRAINT TRIGGER not supported yet in YugabyteDB") _, err := db.Exec(`create temporary table defer_test ( id text primary key, diff --git a/tx_test.go b/tx_test.go index 17577f1f2..39e9a714e 100644 --- a/tx_test.go +++ b/tx_test.go @@ -158,6 +158,8 @@ func TestTxCommitSerializationFailure(t *testing.T) { t.Skip("Skipping due to known server issue: (https://github.com/cockroachdb/cockroach/issues/60754)") } + pgxtest.SkipYugabyteDB(t, c1, "context deadline exceeded in YugabyteDB") + c2 := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE")) defer closeConn(t, c2) @@ -302,6 +304,8 @@ func TestBeginFunc(t *testing.T) { conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE")) defer closeConn(t, conn) + pgxtest.SkipYugabyteDB(t, conn, "Flaky test in YugabyteDB") + createSql := ` create temporary table foo( id integer,