Skip to content

Commit

Permalink
Fixes for test
Browse files Browse the repository at this point in the history
  • Loading branch information
guy-har committed Oct 9, 2023
1 parent d31ac25 commit 08eadf6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions esti/golden/lakectl_fs_upload_pre_signed.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Path: ${FILE_PATH}
Modified Time: <DATE> <TIME> <TZ>
Size: 1024 bytes
Human Size: 1.0 kB
Physical Address: <PRE_SIGN_URL>
Checksum: <CHECKSUM>
Content-Type: application/octet-stream
2 changes: 1 addition & 1 deletion esti/lakectl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestLakectlPreSignUpload(t *testing.T) {

filePath := "ro_1k.1"
vars["FILE_PATH"] = filePath
RunCmdAndVerifySuccessWithFile(t, Lakectl()+" fs upload -s files/ro_1k lakefs://"+repoName+"/"+mainBranch+"/"+filePath+" --pre-sign", false, "lakectl_fs_upload", vars)
RunCmdAndVerifySuccessWithFile(t, Lakectl()+" fs upload -s files/ro_1k lakefs://"+repoName+"/"+mainBranch+"/"+filePath+" --pre-sign", false, "lakectl_fs_upload_pre_signed", vars)

}

Expand Down
4 changes: 2 additions & 2 deletions esti/lakectl_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
reTime = regexp.MustCompile(`\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [-+]\d{4} \w{1,3}`)
reCommitID = regexp.MustCompile(`[\d|a-f]{64}`)
reShortCommitID = regexp.MustCompile(`[\d|a-f]{16}`)
reChecksum = regexp.MustCompile(`[\d|a-f]{32}`)
reChecksum = regexp.MustCompile(`([\d|a-f]{32})|(0x[0-9A-F]{15})`)
reEndpoint = regexp.MustCompile(`https?://\w+(:\d+)?/api/v\d+/`)
rePhysicalAddress = regexp.MustCompile(`/data/[0-9a-v]{20}/[0-9a-v]{20}`)
reVariable = regexp.MustCompile(`\$\{([^${}]+)}`)
Expand Down Expand Up @@ -130,12 +130,12 @@ func sanitize(output string, vars map[string]string) string {
if _, ok := vars["DATE"]; !ok {
s = normalizeProgramTimestamp(s)
}
s = normalizeRandomObjectKey(s, vars["STORAGE"])
s = normalizeCommitID(s)
s = normalizeChecksum(s)
s = normalizeShortCommitID(s)
s = normalizeEndpoint(s, vars["LAKEFS_ENDPOINT"])
s = normalizePreSignURL(s) // should be after storage and endpoint to enable non pre-sign url on azure
s = normalizeRandomObjectKey(s, vars["STORAGE"])
return s
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/api/helpers/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func clientUploadPreSignHelper(ctx context.Context, client apigen.ClientWithResp

etag := putResp.Header.Get("Etag")
etag = strings.TrimSpace(etag)
etag = strings.Trim(etag, "\"")
if etag == "" {
return nil, fmt.Errorf("etag is missing: %w", ErrRequestFailed)
}
Expand All @@ -177,7 +178,10 @@ func clientUploadPreSignHelper(ctx context.Context, client apigen.ClientWithResp
return nil, fmt.Errorf("link object to backing store: %w", err)
}
if linkResp.JSON200 != nil {
return linkResp.JSON200, nil
objStat := *linkResp.JSON200
// this is a workaround for the fact that the API does not return the full physical address
objStat.PhysicalAddress = preSignURL
return &objStat, nil
}
if linkResp.JSON409 != nil {
return nil, ErrConflict
Expand Down

0 comments on commit 08eadf6

Please sign in to comment.