Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

Implement GSP-134 Write Behavior Consistency #32

Merged
merged 3 commits into from
Jul 12, 2021
Merged

Implement GSP-134 Write Behavior Consistency #32

merged 3 commits into from
Jul 12, 2021

Conversation

JinnyYi
Copy link
Contributor

@JinnyYi JinnyYi commented Jul 9, 2021

No description provided.

appender.go Show resolved Hide resolved
copier.go Outdated Show resolved Hide resolved
mover.go Outdated Show resolved Hide resolved
storager.go Outdated Show resolved Hide resolved
@Xuanwo Xuanwo requested review from a team July 9, 2021 11:48
_, err = ap.WriteAppend(o, r, size)
if err != nil {
t.Fatal(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to CommitAppend now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. We need CommitAppend here as for dropbox path will be assigned when CommitAppend. If we miss CommitAppend here, there will be no association between the two append operations and the first append object will not be deleted.

appender.go Outdated
}
}()

Convey("The first returning error should be nil", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be "returned error", or simply "the first error"

appender.go Outdated

o, err = ap.CreateAppend(path)

Convey("The second returning error also should be nil", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

})

Convey("The object append offset should be 0", func() {
So(o.MustGetAppendOffset(), ShouldBeZeroValue)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is append offset the same as size?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the next append offset should match the current object length.
Maybe I need to add the size(content-length) check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that append offset is redundant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean we can retain the offset check and add the size check when CreateAppend with an existing appendable object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know what you mean here. Of course yes.

But I was wondering whether we can remove the field if it's not needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some services require CommitAppend to finish an append process, and until it was committed, the object will not have valid content-length. That's why we introduced GSP-44: Add CommitAppend in Appender.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it

copier.go Outdated
Comment on lines 92 to 96
defer func() {
err = store.Delete(src)
if err != nil {
t.Error(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part should be moved ahead, otherwise src won't be deleted when dst has an error.

copier.go Outdated
Comment on lines 141 to 145
defer func() {
err = store.Delete(src)
if err != nil {
t.Error(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

mover.go Outdated
Comment on lines 100 to 104
defer func() {
err = store.Delete(src)
if err != nil {
t.Error(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

mover.go Outdated
Comment on lines 158 to 162
defer func() {
err = store.Delete(src)
if err != nil {
t.Error(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

multiparter.go Outdated
@@ -22,17 +22,30 @@ func TestMultiparter(t *testing.T, store types.Storager) {
path := uuid.New().String()
o, err := m.CreateMultipart(path)

defer func() {
err := store.Delete(path, pairs.WithMultipartID(o.MustGetMultipartID()))
Convey("The first returning error should be nil", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

multiparter.go Outdated
Convey("The error should be nil", func() {
o, err = m.CreateMultipart(path)

Convey("The second returning error also should be nil", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

storager.go Outdated
@@ -88,7 +88,16 @@ func TestStorager(t *testing.T, store types.Storager) {
}
}()

Convey("The error should be nil", func() {
Convey("The first returning error should be nil", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

storager.go Outdated

_, err = store.Write(path, bytes.NewReader(content), secondSize)

Convey("The second returning error also should be nil", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants