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

Revert "CBG-3576: BlipTestClient support for HLV and rev tree modes" #6573

Merged
merged 1 commit into from
Nov 13, 2023
Merged
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
8 changes: 4 additions & 4 deletions db/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestDynamicChannelGrant(t *testing.T) {

// Create a document in channel chan1
doc1Body := Body{"channel": "chan1", "greeting": "hello"}
_, _, err = dbCollection.PutExistingRevWithBody(ctx, "doc1", doc1Body, []string{"1-a"}, false, ExistingVersionWithUpdateToHLV)
_, _, err = dbCollection.PutExistingRevWithBody(ctx, "doc1", doc1Body, []string{"1-a"}, false)
require.NoError(t, err)

// Verify user cannot access document
Expand All @@ -54,7 +54,7 @@ func TestDynamicChannelGrant(t *testing.T) {

// Write access granting document
grantingBody := Body{"type": "setaccess", "owner": "user1", "channel": "chan1"}
_, _, err = dbCollection.PutExistingRevWithBody(ctx, "grant1", grantingBody, []string{"1-a"}, false, ExistingVersionWithUpdateToHLV)
_, _, err = dbCollection.PutExistingRevWithBody(ctx, "grant1", grantingBody, []string{"1-a"}, false)
require.NoError(t, err)

// Verify reloaded user can access document
Expand All @@ -66,12 +66,12 @@ func TestDynamicChannelGrant(t *testing.T) {

// Create a document in channel chan2
doc2Body := Body{"channel": "chan2", "greeting": "hello"}
_, _, err = dbCollection.PutExistingRevWithBody(ctx, "doc2", doc2Body, []string{"1-a"}, false, ExistingVersionWithUpdateToHLV)
_, _, err = dbCollection.PutExistingRevWithBody(ctx, "doc2", doc2Body, []string{"1-a"}, false)
require.NoError(t, err)

// Write access granting document for chan2 (tests invalidation when channels/inval_seq exists)
grantingBody = Body{"type": "setaccess", "owner": "user1", "channel": "chan2"}
_, _, err = dbCollection.PutExistingRevWithBody(ctx, "grant2", grantingBody, []string{"1-a"}, false, ExistingVersionWithUpdateToHLV)
_, _, err = dbCollection.PutExistingRevWithBody(ctx, "grant2", grantingBody, []string{"1-a"}, false)
require.NoError(t, err)

// Verify user can now access both documents
Expand Down
28 changes: 14 additions & 14 deletions db/attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestBackupOldRevisionWithAttachments(t *testing.T) {
var rev2Body Body
rev2Data := `{"test": true, "updated": true, "_attachments": {"hello.txt": {"stub": true, "revpos": 1}}}`
require.NoError(t, base.JSONUnmarshal([]byte(rev2Data), &rev2Body))
_, _, err = collection.PutExistingRevWithBody(ctx, docID, rev2Body, []string{"2-abc", rev1ID}, true, ExistingVersionWithUpdateToHLV)
_, _, err = collection.PutExistingRevWithBody(ctx, docID, rev2Body, []string{"2-abc", rev1ID}, true)
require.NoError(t, err)
rev2ID := "2-abc"

Expand Down Expand Up @@ -200,7 +200,7 @@ func TestAttachments(t *testing.T) {
rev2Bstr := `{"_attachments": {"bye.txt": {"stub":true,"revpos":1,"digest":"sha1-gwwPApfQR9bzBKpqoEYwFmKp98A="}}, "_rev": "2-f000"}`
var body2B Body
assert.NoError(t, base.JSONUnmarshal([]byte(rev2Bstr), &body2B))
_, _, err = collection.PutExistingRevWithBody(ctx, "doc1", body2B, []string{"2-f000", rev1id}, false, ExistingVersionWithUpdateToHLV)
_, _, err = collection.PutExistingRevWithBody(ctx, "doc1", body2B, []string{"2-f000", rev1id}, false)
assert.NoError(t, err, "Couldn't update document")
}

Expand Down Expand Up @@ -284,7 +284,7 @@ func TestAttachmentCASRetryAfterNewAttachment(t *testing.T) {
rev2Data := `{"prop1":"value2", "_attachments": {"hello.txt": {"data":"aGVsbG8gd29ybGQ="}}}`
require.NoError(t, base.JSONUnmarshal([]byte(rev2Data), &rev2Body))
collection := GetSingleDatabaseCollectionWithUser(t, db)
_, _, err := collection.PutExistingRevWithBody(ctx, "doc1", rev2Body, []string{"2-abc", rev1ID}, true, ExistingVersionWithUpdateToHLV)
_, _, err := collection.PutExistingRevWithBody(ctx, "doc1", rev2Body, []string{"2-abc", rev1ID}, true)
require.NoError(t, err)

log.Printf("Done creating rev 2 for key %s", key)
Expand Down Expand Up @@ -315,7 +315,7 @@ func TestAttachmentCASRetryAfterNewAttachment(t *testing.T) {
var rev3Body Body
rev3Data := `{"prop1":"value3", "_attachments": {"hello.txt": {"revpos":2,"stub":true,"digest":"sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0="}}}`
require.NoError(t, base.JSONUnmarshal([]byte(rev3Data), &rev3Body))
_, _, err = collection.PutExistingRevWithBody(ctx, "doc1", rev3Body, []string{"3-abc", "2-abc", rev1ID}, true, ExistingVersionWithUpdateToHLV)
_, _, err = collection.PutExistingRevWithBody(ctx, "doc1", rev3Body, []string{"3-abc", "2-abc", rev1ID}, true)
require.NoError(t, err)

log.Printf("rev 3 done")
Expand Down Expand Up @@ -347,7 +347,7 @@ func TestAttachmentCASRetryDuringNewAttachment(t *testing.T) {
rev2Data := `{"prop1":"value2"}`
require.NoError(t, base.JSONUnmarshal([]byte(rev2Data), &rev2Body))
collection := GetSingleDatabaseCollectionWithUser(t, db)
_, _, err := collection.PutExistingRevWithBody(ctx, "doc1", rev2Body, []string{"2-abc", rev1ID}, true, ExistingVersionWithUpdateToHLV)
_, _, err := collection.PutExistingRevWithBody(ctx, "doc1", rev2Body, []string{"2-abc", rev1ID}, true)
require.NoError(t, err)

log.Printf("Done creating rev 2 for key %s", key)
Expand Down Expand Up @@ -378,7 +378,7 @@ func TestAttachmentCASRetryDuringNewAttachment(t *testing.T) {
var rev3Body Body
rev3Data := `{"prop1":"value3", "_attachments": {"hello.txt": {"data":"aGVsbG8gd29ybGQ="}}}`
require.NoError(t, base.JSONUnmarshal([]byte(rev3Data), &rev3Body))
_, _, err = collection.PutExistingRevWithBody(ctx, "doc1", rev3Body, []string{"3-abc", "2-abc", rev1ID}, true, ExistingVersionWithUpdateToHLV)
_, _, err = collection.PutExistingRevWithBody(ctx, "doc1", rev3Body, []string{"3-abc", "2-abc", rev1ID}, true)
require.NoError(t, err)

log.Printf("rev 3 done")
Expand Down Expand Up @@ -567,57 +567,57 @@ func TestRetrieveAncestorAttachments(t *testing.T) {
// Create document (rev 1)
text := `{"key": "value", "version": "1a"}`
assert.NoError(t, base.JSONUnmarshal([]byte(text), &body))
doc, revID, err := collection.PutExistingRevWithBody(ctx, "doc", body, []string{"1-a"}, false, ExistingVersionWithUpdateToHLV)
doc, revID, err := collection.PutExistingRevWithBody(ctx, "doc", body, []string{"1-a"}, false)
assert.NoError(t, err, "Couldn't create document")
log.Printf("doc: %v", doc)

// Add an attachment to a document (rev 2)
text = `{"key": "value", "version": "2a", "_attachments": {"att1.txt": {"data": "YXR0MS50eHQ="}}}`
assert.NoError(t, base.JSONUnmarshal([]byte(text), &body))
body[BodyRev] = revID
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"2-a", "1-a"}, false, ExistingVersionWithUpdateToHLV)
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"2-a", "1-a"}, false)
assert.NoError(t, err, "Couldn't create document")
log.Printf("doc: %v", doc)

text = `{"key": "value", "version": "3a", "_attachments": {"att1.txt": {"stub":true,"revpos":2,"digest":"sha1-gwwPApfQR9bzBKpqoEYwFmKp98A="}}}`
assert.NoError(t, base.JSONUnmarshal([]byte(text), &body))
body[BodyRev] = revID
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"3-a", "2-a"}, false, ExistingVersionWithUpdateToHLV)
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"3-a", "2-a"}, false)
assert.NoError(t, err, "Couldn't create document")
log.Printf("doc: %v", doc)

text = `{"key": "value", "version": "4a", "_attachments": {"att1.txt": {"stub":true,"revpos":2,"digest":"sha1-gwwPApfQR9bzBKpqoEYwFmKp98A="}}}`
assert.NoError(t, base.JSONUnmarshal([]byte(text), &body))
body[BodyRev] = revID
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"4-a", "3-a"}, false, ExistingVersionWithUpdateToHLV)
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"4-a", "3-a"}, false)
assert.NoError(t, err, "Couldn't create document")
log.Printf("doc: %v", doc)

text = `{"key": "value", "version": "5a", "_attachments": {"att1.txt": {"stub":true,"revpos":2,"digest":"sha1-gwwPApfQR9bzBKpqoEYwFmKp98A="}}}`
assert.NoError(t, base.JSONUnmarshal([]byte(text), &body))
body[BodyRev] = revID
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"5-a", "4-a"}, false, ExistingVersionWithUpdateToHLV)
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"5-a", "4-a"}, false)
assert.NoError(t, err, "Couldn't create document")
log.Printf("doc: %v", doc)

text = `{"key": "value", "version": "6a", "_attachments": {"att1.txt": {"stub":true,"revpos":2,"digest":"sha1-gwwPApfQR9bzBKpqoEYwFmKp98A="}}}`
assert.NoError(t, base.JSONUnmarshal([]byte(text), &body))
body[BodyRev] = revID
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"6-a", "5-a"}, false, ExistingVersionWithUpdateToHLV)
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"6-a", "5-a"}, false)
assert.NoError(t, err, "Couldn't create document")
log.Printf("doc: %v", doc)

text = `{"key": "value", "version": "3b", "type": "pruned"}`
assert.NoError(t, base.JSONUnmarshal([]byte(text), &body))
body[BodyRev] = revID
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"3-b", "2-a"}, false, ExistingVersionWithUpdateToHLV)
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"3-b", "2-a"}, false)
assert.NoError(t, err, "Couldn't create document")
log.Printf("doc: %v", doc)

text = `{"key": "value", "version": "3b", "_attachments": {"att1.txt": {"stub":true,"revpos":2,"digest":"sha1-gwwPApfQR9bzBKpqoEYwFmKp98A="}}}`
assert.NoError(t, base.JSONUnmarshal([]byte(text), &body))
body[BodyRev] = revID
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"3-b", "2-a"}, false, ExistingVersionWithUpdateToHLV)
doc, _, err = collection.PutExistingRevWithBody(ctx, "doc", body, []string{"3-b", "2-a"}, false)
assert.NoError(t, err, "Couldn't create document")
log.Printf("doc: %v", doc)
}
Expand Down
4 changes: 2 additions & 2 deletions db/blip_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1183,9 +1183,9 @@ func (bh *blipHandler) processRev(rq *blip.Message, stats *processRevStats) (err
// bh.conflictResolver != nil represents an active SGR2 and BLIPClientTypeSGR2 represents a passive SGR2
forceAllowConflictingTombstone := newDoc.Deleted && (bh.conflictResolver != nil || bh.clientType == BLIPClientTypeSGR2)
if bh.conflictResolver != nil {
_, _, err = bh.collection.PutExistingRevWithConflictResolution(bh.loggingCtx, newDoc, history, true, bh.conflictResolver, forceAllowConflictingTombstone, rawBucketDoc, ExistingVersionWithUpdateToHLV)
_, _, err = bh.collection.PutExistingRevWithConflictResolution(bh.loggingCtx, newDoc, history, true, bh.conflictResolver, forceAllowConflictingTombstone, rawBucketDoc)
} else {
_, _, err = bh.collection.PutExistingRev(bh.loggingCtx, newDoc, history, revNoConflicts, forceAllowConflictingTombstone, rawBucketDoc, ExistingVersionWithUpdateToHLV)
_, _, err = bh.collection.PutExistingRev(bh.loggingCtx, newDoc, history, revNoConflicts, forceAllowConflictingTombstone, rawBucketDoc)
}
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion db/change_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ func (c *changeCache) DocChanged(event sgbucket.FeedEvent) {

// Now add the entry for the new doc revision:
if len(rawUserXattr) > 0 {
collection.revisionCache.RemoveWithRev(docID, syncData.CurrentRev)
collection.revisionCache.Remove(docID, syncData.CurrentRev)
}
change := &LogEntry{
Sequence: syncData.Sequence,
Expand Down
4 changes: 2 additions & 2 deletions db/changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,14 @@ func BenchmarkChangesFeedDocUnmarshalling(b *testing.B) {

// Create child rev 1
docBody["child"] = "A"
_, _, err = collection.PutExistingRevWithBody(ctx, docid, docBody, []string{"2-A", revId}, false, ExistingVersionWithUpdateToHLV)
_, _, err = collection.PutExistingRevWithBody(ctx, docid, docBody, []string{"2-A", revId}, false)
if err != nil {
b.Fatalf("Error creating child1 rev: %v", err)
}

// Create child rev 2
docBody["child"] = "B"
_, _, err = collection.PutExistingRevWithBody(ctx, docid, docBody, []string{"2-B", revId}, false, ExistingVersionWithUpdateToHLV)
_, _, err = collection.PutExistingRevWithBody(ctx, docid, docBody, []string{"2-B", revId}, false)
if err != nil {
b.Fatalf("Error creating child2 rev: %v", err)
}
Expand Down
Loading