Skip to content

Commit

Permalink
SNOW-894815 Fix TestConcurrentReadOnParams cleaning up the connection…
Browse files Browse the repository at this point in the history
… too early
  • Loading branch information
sfc-gh-pfus committed Oct 17, 2023
1 parent c6c2afd commit 9b222b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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) {
Expand Down

0 comments on commit 9b222b2

Please sign in to comment.