Skip to content

Commit

Permalink
NO-SNOW Fix tests failing on Jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pfus committed Nov 27, 2024
1 parent 4e87066 commit 3232565
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions ci/scripts/execute_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion ci/test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
7 changes: 4 additions & 3 deletions put_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bytes"
"compress/gzip"
"context"
"database/sql"
"fmt"
"io"
"math/rand"
Expand Down Expand Up @@ -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")
}
}
Expand All @@ -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")
}
}
Expand Down
15 changes: 8 additions & 7 deletions put_get_with_aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bytes"
"compress/gzip"
"context"
"database/sql"
"encoding/json"
"fmt"
"io"
Expand Down Expand Up @@ -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))
Expand All @@ -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)
}
})
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3232565

Please sign in to comment.