From 3232565c7d3863034c13b96b1a91d1fe6193baa3 Mon Sep 17 00:00:00 2001 From: Piotr Fus Date: Wed, 27 Nov 2024 09:00:48 +0100 Subject: [PATCH] NO-SNOW Fix tests failing on Jenkins --- ci/scripts/execute_tests.sh | 4 ++-- ci/test.bat | 2 +- put_get_test.go | 7 ++++--- put_get_with_aws_test.go | 15 ++++++++------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ci/scripts/execute_tests.sh b/ci/scripts/execute_tests.sh index 960a0871f..205f141db 100755 --- a/ci/scripts/execute_tests.sh +++ b/ci/scripts/execute_tests.sh @@ -15,7 +15,7 @@ cd $TOPDIR if [[ -n "$JENKINS_HOME" ]]; then export WORKSPACE=${WORKSPACE:-/mnt/workspace} go install github.com/jstemmer/go-junit-report/v2@latest - go test $GO_TEST_PARAMS -timeout 90m -race -v . | go-junit-report -iocopy -out $WORKSPACE/junit-go.xml + go test $GO_TEST_PARAMS -timeout 120m -race -v . | go-junit-report -iocopy -out $WORKSPACE/junit-go.xml else - go test $GO_TEST_PARAMS -timeout 90m -race -coverprofile=coverage.txt -covermode=atomic -v . + go test $GO_TEST_PARAMS -timeout 120m -race -coverprofile=coverage.txt -covermode=atomic -v . fi diff --git a/ci/test.bat b/ci/test.bat index c8343b75a..6fccb3bad 100644 --- a/ci/test.bat +++ b/ci/test.bat @@ -42,4 +42,4 @@ echo [INFO] Database: %SNOWFLAKE_TEST_DATABASE% echo [INFO] Warehouse: %SNOWFLAKE_TEST_WAREHOUSE% echo [INFO] Role: %SNOWFLAKE_TEST_ROLE% -go test %GO_TEST_PARAMS% --timeout 90m --tags=sfdebug -race -coverprofile=coverage.txt -covermode=atomic -v . +go test %GO_TEST_PARAMS% --timeout 120m --tags=sfdebug -race -coverprofile=coverage.txt -covermode=atomic -v . diff --git a/put_get_test.go b/put_get_test.go index 1308e7419..68ca087d4 100644 --- a/put_get_test.go +++ b/put_get_test.go @@ -6,6 +6,7 @@ import ( "bytes" "compress/gzip" "context" + "database/sql" "fmt" "io" "math/rand" @@ -214,14 +215,14 @@ func TestPutLocalFile(t *testing.T) { dbt.mustExec(execQuery) dbt.mustQueryAssertCount("ls @%gotest_putget_t1", 2) - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9 string + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9 sql.NullString rows := dbt.mustQuery("copy into gotest_putget_t1") defer func() { assertNilF(t, rows.Close()) }() for rows.Next() { assertNilF(t, rows.Scan(&s0, &s1, &s2, &s3, &s4, &s5, &s6, &s7, &s8, &s9)) - if s1 != "LOADED" { + if !s1.Valid || s1.String != "LOADED" { t.Fatal("not loaded") } } @@ -244,7 +245,7 @@ func TestPutLocalFile(t *testing.T) { }() if rows3.Next() { assertNilF(t, rows3.Scan(&s0, &s1, &s2, &s3, &s4, &s5, &s6, &s7, &s8, &s9)) - if s1 != "LOADED" { + if !s1.Valid || s1.String != "LOADED" { t.Fatal("not loaded") } } diff --git a/put_get_with_aws_test.go b/put_get_with_aws_test.go index 226f37a5a..0b46d9bc0 100644 --- a/put_get_with_aws_test.go +++ b/put_get_with_aws_test.go @@ -6,6 +6,7 @@ import ( "bytes" "compress/gzip" "context" + "database/sql" "encoding/json" "fmt" "io" @@ -71,9 +72,9 @@ func TestLoadS3(t *testing.T) { field_optionally_enclosed_by='\"')`, data.awsAccessKeyID, data.awsSecretAccessKey)) defer func() { - assertNilF(t, rows.Close()) + assertNilF(t, rows.Close()) }() - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9 string + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9 sql.NullString cnt := 0 for rows.Next() { assertNilF(t, rows.Scan(&s0, &s1, &s2, &s3, &s4, &s5, &s6, &s7, &s8, &s9)) @@ -82,7 +83,7 @@ func TestLoadS3(t *testing.T) { if cnt != 1 { t.Fatal("copy into tweets did not set row count to 1") } - if s0 != "s3://sfc-eng-data/twitter/O1k/tweets/1.csv.gz" { + if !s0.Valid || s0.String != "s3://sfc-eng-data/twitter/O1k/tweets/1.csv.gz" { t.Fatalf("got %v as file", s0) } }) @@ -143,7 +144,7 @@ func TestPutWithInvalidToken(t *testing.T) { t.Error(err) } defer func() { - assertNilF(t, f.Close()) + assertNilF(t, f.Close()) }() uploader := manager.NewUploader(client) if _, err = uploader.Upload(context.Background(), &s3.PutObjectInput{ @@ -275,7 +276,7 @@ func TestPutGetAWSStage(t *testing.T) { sqlText := fmt.Sprintf(sql, strings.ReplaceAll(fname, "\\", "\\\\"), stageName) rows := dbt.mustQuery(sqlText) defer func() { - assertNilF(t, rows.Close()) + assertNilF(t, rows.Close()) }() var s0, s1, s2, s3, s4, s5, s6, s7 string @@ -292,7 +293,7 @@ func TestPutGetAWSStage(t *testing.T) { sqlText = strings.ReplaceAll(sql, "\\", "\\\\") rows = dbt.mustQuery(sqlText) defer func() { - assertNilF(t, rows.Close()) + assertNilF(t, rows.Close()) }() for rows.Next() { if err = rows.Scan(&s0, &s1, &s2, &s3); err != nil { @@ -323,7 +324,7 @@ func TestPutGetAWSStage(t *testing.T) { t.Error(err) } defer func() { - assertNilF(t, f.Close()) + assertNilF(t, f.Close()) }() gz, err := gzip.NewReader(f) if err != nil {