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

services/obs: Service test failed for content mismatch #959

Closed
Xuanwo opened this issue Oct 23, 2021 · 2 comments
Closed

services/obs: Service test failed for content mismatch #959

Xuanwo opened this issue Oct 23, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@Xuanwo
Copy link
Contributor

Xuanwo commented Oct 23, 2021

     When Read a file with offset or size 
      When Read with offset 
        The error should be nil ✔✔
        The content should be match ✔✘✔
      When Read with size 
        The error should be nil ✔✔
        The content should be match ✔✘✔
      When Read with offset and size 
        The error should be nil ✔✔
        The content should be match ✔✘✔

 Failures:

  * /data/actions/beta/go-storage/go-storage/services/obs/tests/storage_test.go 
  Line 14:
  Expected: '138112'
  Actual:   '451281'
  (Should be equal)

  * /data/actions/beta/go-storage/go-storage/services/obs/tests/storage_test.go 
  Line 14:
  Expected: '1288953'
  Actual:   '2688928'
  (Should be equal)

  * /data/actions/beta/go-storage/go-storage/services/obs/tests/storage_test.go 
  Line 14:
  Expected: '49793'
  Actual:   '291284'
  (Should be equal)

Obs implementation must be buggy, let's fix it before release.

@Xuanwo
Copy link
Contributor Author

Xuanwo commented Oct 23, 2021

obs doesn't support offset and size now:

func (s *Storage) read(ctx context.Context, path string, w io.Writer, opt pairStorageRead) (n int64, err error) {
rp := s.getAbsPath(path)
input := &obs.GetObjectInput{}
input.Bucket = s.bucket
input.Key = rp
output, err := s.client.GetObject(input)
if err != nil {
return 0, err
}
rc := output.Body
if opt.HasIoCallback {
rc = iowrap.CallbackReadCloser(rc, opt.IoCallback)
}
return io.Copy(w, rc)

this can be fixed by like:

func (s *Storage) read(ctx context.Context, path string, w io.Writer, opt pairStorageRead) (n int64, err error) {
rp := s.getAbsPath(path)
output := &api.GetObjectResult{}
if opt.HasOffset && !opt.HasSize {
output, err = s.client.GetObject(s.bucket, rp, nil, opt.Offset)
} else if !opt.HasOffset && opt.HasSize {
output, err = s.client.GetObject(s.bucket, rp, nil, 0, opt.Size-1)
} else if opt.HasSize && opt.HasOffset {
output, err = s.client.GetObject(s.bucket, rp, nil, opt.Offset, opt.Offset+opt.Size-1)
} else {
output, err = s.client.GetObject(s.bucket, rp, nil)
}

@Xuanwo
Copy link
Contributor Author

Xuanwo commented Nov 10, 2021

Wait for huaweicloud/huaweicloud-sdk-go-obs#10

@Xuanwo Xuanwo closed this as completed Sep 15, 2022
@Xuanwo Xuanwo moved this to 📋 Backlog in Xuanwo's Work Sep 15, 2022
@Xuanwo Xuanwo moved this from 📋 Backlog to 📦 Done in Xuanwo's Work Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant