From 9b222b26053e4cf9859e5dbe60d895ee89732b87 Mon Sep 17 00:00:00 2001 From: Piotr Fus Date: Thu, 12 Oct 2023 09:06:30 +0200 Subject: [PATCH] SNOW-894815 Fix TestConcurrentReadOnParams cleaning up the connection too early --- .github/workflows/build-test.yml | 1 + connection_test.go | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 291b1ee6a..b61a03c18 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -48,6 +48,7 @@ jobs: env: PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }} CLOUD_PROVIDER: ${{ matrix.cloud }} + GORACE: history_size=7 run: ./ci/test.sh - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 diff --git a/connection_test.go b/connection_test.go index a76cdb7c1..91e822203 100644 --- a/connection_test.go +++ b/connection_test.go @@ -476,19 +476,17 @@ func TestExecWithServerSideError(t *testing.T) { } func TestConcurrentReadOnParams(t *testing.T) { - t.Skip("Fails randomly") - config, err := ParseDSN(dsn) + db, err := sql.Open("snowflake", dsn) if err != nil { - t.Fatal("Failed to parse dsn") + t.Fatalf("Error while opening connection: %v", err) } - connector := NewConnector(SnowflakeDriver{}, *config) - db := sql.OpenDB(connector) + defer db.Close() wg := sync.WaitGroup{} for i := 0; i < 10; i++ { wg.Add(1) go func() { for c := 0; c < 10; c++ { - stmt, err := db.PrepareContext(context.Background(), "SELECT * FROM information_schema.columns WHERE table_schema = ?") + stmt, err := db.PrepareContext(context.Background(), "SELECT table_schema FROM information_schema.columns WHERE table_schema = ? LIMIT 1") if err != nil { t.Error(err) } @@ -499,13 +497,18 @@ func TestConcurrentReadOnParams(t *testing.T) { if rows == nil { continue } + rows.Next() + var tableName string + err = rows.Scan(&tableName) + if err != nil { + t.Error(err) + } _ = rows.Close() } wg.Done() }() } wg.Wait() - defer db.Close() } func postQueryTest(_ context.Context, _ *snowflakeRestful, _ *url.Values, headers map[string]string, _ []byte, _ time.Duration, _ UUID, _ *Config) (*execResponse, error) {