Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NO-SNOW Add better logging to TestPutGetWithAutoCompressFalse #1251

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions assert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
fatalOnNonEmpty(t, validateStringContains(actual, expectedToContain, descriptions...))
}

func assertStringDoesNotContainE(t *testing.T, actual string, expectedNotToContain string, descriptions ...string) {

Check failure on line 79 in assert_test.go

View workflow job for this annotation

GitHub Actions / Check linter

func `assertStringDoesNotContainE` is unused (unused)
errorOnNonEmpty(t, validateStringDoesNotContain(actual, expectedNotToContain, descriptions...))
}

func assertEmptyStringE(t *testing.T, actual string, descriptions ...string) {
errorOnNonEmpty(t, validateEmptyString(actual, descriptions...))
}
Expand Down Expand Up @@ -184,6 +188,14 @@
return fmt.Sprintf("expected \"%s\" to contain \"%s\" but did not. %s", actual, expectedToContain, desc)
}

func validateStringDoesNotContain(actual string, expectedToNotContain string, descriptions ...string) string {

Check failure on line 191 in assert_test.go

View workflow job for this annotation

GitHub Actions / Check linter

func `validateStringDoesNotContain` is unused (unused)
if !strings.Contains(actual, expectedToNotContain) {
return ""
}
desc := joinDescriptions(descriptions...)
return fmt.Sprintf("expected \"%s\" not to contain \"%s\" but it did. %s", actual, expectedToNotContain, desc)
}

func validateEmptyString(actual string, descriptions ...string) string {
if actual == "" {
return ""
Expand Down
6 changes: 6 additions & 0 deletions azure_storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ func (util *snowflakeAzureClient) getFileHeader(meta *fileMetadata, filename str
if err != nil {
var se *azcore.ResponseError
if errors.As(err, &se) {
print("azure getFileHeader: ")
println(se.StatusCode, se.ErrorCode)
if se.ErrorCode == string(bloberror.BlobNotFound) {
meta.resStatus = notFoundFile
return nil, fmt.Errorf("could not find file")
Expand All @@ -100,6 +102,7 @@ func (util *snowflakeAzureClient) getFileHeader(meta *fileMetadata, filename str
return nil, fmt.Errorf("received 403, attempting to renew")
}
}
println("unknown azure error")
meta.resStatus = errStatus
return nil, err
}
Expand Down Expand Up @@ -233,6 +236,8 @@ func (util *snowflakeAzureClient) uploadFile(
if err != nil {
var se *azcore.ResponseError
if errors.As(err, &se) {
print("azure upload file: ")
println(se.StatusCode, se.ErrorCode)
if se.StatusCode == 403 && util.detectAzureTokenExpireError(se.RawResponse) {
meta.resStatus = renewToken
} else {
Expand All @@ -241,6 +246,7 @@ func (util *snowflakeAzureClient) uploadFile(
}
return err
}
println("Unknown azure error")
meta.resStatus = errStatus
return err
}
Expand Down
2 changes: 1 addition & 1 deletion driver_ocsp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ func TestExpiredCertificate(t *testing.T) {
// Go 1.20 throws tls CertificateVerification error
errString := urlErr.Err.Error()
// badssl sometimes times out
if !strings.Contains(errString, "certificate has expired or is not yet valid") && !strings.Contains(errString, "timeout") {
if !strings.Contains(errString, "certificate has expired or is not yet valid") && !strings.Contains(errString, "timeout") && !strings.Contains(errString, "established connection failed because connected host has failed to respond") {
t.Fatalf("failed to extract error Certificate error: %v", err)
}
}
Expand Down
4 changes: 4 additions & 0 deletions function_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ func TestGoWrapper(t *testing.T) {
GoroutineWrapper = closeGoWrapperCalledChannel

ctx := WithAsyncMode(context.Background())
println("Staring SELECT 1 query")
rows := dbt.mustQueryContext(ctx, "SELECT 1")
assertTrueE(t, rows.Next())
defer rows.Close()
var i int
assertNilF(t, rows.Scan(&i))

assertTrueF(t, getGoWrapperCalled(), "channel should be closed, indicating our wrapper worked")
})
Expand Down
5 changes: 5 additions & 0 deletions gcs_storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func (util *snowflakeGcsClient) getFileHeader(meta *fileMetadata, filename strin
if err != nil {
return nil, err
}
print("GCS getFileHeader: ")
println(resp.StatusCode)
if resp.StatusCode != http.StatusOK {
meta.lastError = fmt.Errorf("%v", resp.Status)
meta.resStatus = errStatus
Expand Down Expand Up @@ -224,6 +226,9 @@ func (util *snowflakeGcsClient) uploadFile(
if err != nil {
return err
}
print("GCS uploadFile: ")
println(err.Error())
println(resp.StatusCode)
if resp.StatusCode != http.StatusOK {
if resp.StatusCode == 403 || resp.StatusCode == 408 || resp.StatusCode == 429 || resp.StatusCode == 500 || resp.StatusCode == 503 {
meta.lastError = fmt.Errorf("%v", resp.Status)
Expand Down
7 changes: 3 additions & 4 deletions put_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,10 +716,9 @@ func TestPutGetLargeFile(t *testing.T) {
assertNilF(t, rows.Close())
}()
var file, s1, s2, s3 string
if rows.Next() {
err = rows.Scan(&file, &s1, &s2, &s3)
assertNilF(t, err)
}
assertTrueF(t, rows.Next())
err = rows.Scan(&file, &s1, &s2, &s3)
assertNilF(t, err)

if !strings.Contains(file, "largefile.txt.gz") {
t.Fatalf("should contain file. got: %v", file)
Expand Down
4 changes: 4 additions & 0 deletions s3_storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ func (util *snowflakeS3Client) getFileHeader(meta *fileMetadata, filename string
}
out, err := s3Cli.HeadObject(context.Background(), headObjInput)
if err != nil {
print("err in S3 getFileHeader: ")
println(err.Error())
var ae smithy.APIError
if errors.As(err, &ae) {
if ae.ErrorCode() == notFound {
Expand Down Expand Up @@ -217,6 +219,8 @@ func (util *snowflakeS3Client) uploadFile(
}

if err != nil {
print("err in S3 uploadFile: ")
println(err.Error())
var ae smithy.APIError
if errors.As(err, &ae) {
if ae.ErrorCode() == expiredToken {
Expand Down
5 changes: 3 additions & 2 deletions storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ func (rsu *remoteStorageUtil) uploadOneFile(meta *fileMetadata) error {
if !meta.overwrite {
header, err := utilClass.getFileHeader(meta, meta.dstFileName)
if meta.resStatus == notFoundFile {
err := utilClass.uploadFile(dataFile, meta, encryptMeta, maxConcurrency, meta.options.MultiPartThreshold)
if err != nil {
err2 := utilClass.uploadFile(dataFile, meta, encryptMeta, maxConcurrency, meta.options.MultiPartThreshold)
if err2 != nil {
logger.Warnf("Error uploading %v. err: %v", dataFile, err)
}
} else if err != nil {
println(err)
return err
}
if header != nil && meta.resStatus == uploaded {
Expand Down
Loading