Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion rest/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ func TestAllDocsCV(t *testing.T) {
defer rt.Close()

const docID = "foo"
docVersion := rt.PutDocDirectly(docID, db.Body{"foo": "bar"})
docVersion := rt.PutDoc(docID, `{"foo": "bar"}`)

testCases := []struct {
name string
Expand Down
2 changes: 1 addition & 1 deletion rest/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2870,7 +2870,7 @@ func TestPvDeltaReadAndWrite(t *testing.T) {
version1, _ := rt.GetDoc(docID)

// update the above doc, this should push CV to PV and adds a new CV
version2 := rt.UpdateDocDirectly(docID, version1, db.Body{"new": "update!"})
version2 := rt.UpdateDoc(docID, version1, `{"new": "update!"}`)
newDoc, _, err := collection.GetDocWithXattrs(ctx, existingHLVKey, db.DocUnmarshalAll)
require.NoError(t, err)
casV2 := newDoc.Cas
Expand Down
12 changes: 6 additions & 6 deletions rest/attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2314,8 +2314,8 @@ func TestUpdateExistingAttachment(t *testing.T) {
btcRunner.StartPull(btc.id)
btcRunner.StartPush(btc.id)

doc1Version := rt.PutDocDirectly(doc1ID, db.Body{})
doc2Version := rt.PutDocDirectly(doc2ID, db.Body{})
doc1Version := rt.PutDoc(doc1ID, "{}")
doc2Version := rt.PutDoc(doc2ID, "{}")

btcRunner.WaitForVersion(btc.id, doc1ID, doc1Version)
btcRunner.WaitForVersion(btc.id, doc2ID, doc2Version)
Expand Down Expand Up @@ -2370,7 +2370,7 @@ func TestPushUnknownAttachmentAsStub(t *testing.T) {
btcRunner.StartPush(btc.id)

// Add doc1
doc1Version := rt.PutDocDirectly(doc1ID, db.Body{})
doc1Version := rt.PutDoc(doc1ID, "{}")

btcRunner.WaitForVersion(btc.id, doc1ID, doc1Version)

Expand Down Expand Up @@ -2588,9 +2588,9 @@ func TestCBLRevposHandling(t *testing.T) {
btc := btcRunner.NewBlipTesterClientOptsWithRT(rt, &opts)
defer btc.Close()

startingBody := db.Body{"foo": "bar"}
doc1Version1 := rt.PutDocDirectly(doc1ID, startingBody)
doc2Version1 := rt.PutDocDirectly(doc2ID, startingBody)
startingBody := `{"foo": "bar"}`
doc1Version1 := rt.PutDoc(doc1ID, startingBody)
doc2Version1 := rt.PutDoc(doc2ID, startingBody)

rt.WaitForPendingChanges()
btcRunner.StartOneshotPull(btc.id)
Expand Down
10 changes: 5 additions & 5 deletions rest/blip_api_collections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func TestCollectionsReplication(t *testing.T) {
btc := btcRunner.NewBlipTesterClientOptsWithRT(rt, opts)
defer btc.Close()

version := btc.rt.PutDocDirectly(docID, db.Body{})
version := btc.rt.PutDoc(docID, "{}")

btc.rt.WaitForPendingChanges()
btcRunner.StartOneshotPull(btc.id)
Expand All @@ -283,8 +283,8 @@ func TestBlipReplicationMultipleCollections(t *testing.T) {
docName := "doc1"
body := `{"foo":"bar"}`
versions := make([]DocVersion, 0, len(btc.rt.GetKeyspaces()))
for _, collection := range btc.rt.GetDbCollections() {
docVersion := rt.PutDocDirectlyInCollection(collection, docName, db.Body{"foo": "bar"})
for _, ks := range btc.rt.GetKeyspaces() {
docVersion := rt.PutDocWithKeyspace(ks, docName, `{"foo": "bar"}`)
versions = append(versions, docVersion)
}
btc.rt.WaitForPendingChanges()
Expand Down Expand Up @@ -323,7 +323,7 @@ func TestBlipReplicationMultipleCollectionsMismatchedDocSizes(t *testing.T) {
collectionDocIDs := make(map[string][]string)
collectionVersions := make(map[string][]DocVersion)
require.Len(t, btc.rt.GetKeyspaces(), 2)
for i, collection := range btc.rt.GetDbCollections() {
for i, ks := range btc.rt.GetKeyspaces() {
// intentionally create collections with different size replications to ensure one collection finishing won't cancel another one
docCount := 10
if i == 0 {
Expand All @@ -332,7 +332,7 @@ func TestBlipReplicationMultipleCollectionsMismatchedDocSizes(t *testing.T) {
blipName := btc.rt.getCollectionsForBLIP()[i]
for j := 0; j < docCount; j++ {
docName := fmt.Sprintf("doc%d", j)
version := rt.PutDocDirectlyInCollection(collection, docName, db.Body{"foo": "bar"})
version := rt.PutDocWithKeyspace(ks, docName, `{"foo": "bar"}`)

collectionVersions[blipName] = append(collectionVersions[blipName], version)
collectionDocIDs[blipName] = append(collectionDocIDs[blipName], docName)
Expand Down
42 changes: 21 additions & 21 deletions rest/blip_api_crud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@ func TestBlipSendAndGetLargeNumberRev(t *testing.T) {
// Get non-deleted rev
response := bt.restTester.SendAdminRequest("GET", "/{{.keyspace}}/largeNumberRev?rev=1-abc", "")
RequireStatus(t, response, 200) // Check the raw bytes, because unmarshalling the response would be another opportunity for the number to get modified
responseString := string(response.Body.Bytes())
responseString := response.BodyString()
if !strings.Contains(responseString, `9223372036854775807`) {
t.Errorf("Response does not contain the expected number format. Response: %s", responseString)
}
Expand Down Expand Up @@ -2027,7 +2027,7 @@ func TestSendReplacementRevision(t *testing.T) {
defer rt.Close()

docID := test.name
version1 := rt.PutDocDirectly(docID, JsonToMap(t, fmt.Sprintf(`{"foo":"bar","channels":["%s"]}`, rev1Channel)))
version1 := rt.PutDoc(docID, fmt.Sprintf(`{"foo":"bar","channels":["%s"]}`, rev1Channel))
updatedVersion := make(chan DocVersion)
collection, ctx := rt.GetSingleTestDatabaseCollection()

Expand Down Expand Up @@ -2130,13 +2130,13 @@ func TestBlipPullRevMessageHistory(t *testing.T) {

const docID = "doc1"
// create doc1 rev 1-0335a345b6ffed05707ccc4cbc1b67f4
version1 := rt.PutDocDirectly(docID, db.Body{"hello": "world!"})
version1 := rt.PutDoc(docID, `{"hello": "world!"}`)

data := btcRunner.WaitForVersion(client.id, docID, version1)
assert.Equal(t, `{"hello":"world!"}`, string(data))

// create doc1 rev 2-959f0e9ad32d84ff652fb91d8d0caa7e
version2 := rt.UpdateDocDirectly(docID, version1, db.Body{"hello": "alice"})
version2 := rt.UpdateDoc(docID, version1, `{"hello": "alice"}`)

data = btcRunner.WaitForVersion(client.id, docID, version2)
assert.Equal(t, `{"hello":"alice"}`, string(data))
Expand Down Expand Up @@ -2192,7 +2192,7 @@ func TestPullReplicationUpdateOnOtherHLVAwarePeer(t *testing.T) {
_ = btcRunner.WaitForVersion(client.id, docID, version1)

// update the above doc
version2 := rt.UpdateDocDirectly(docID, version1, db.Body{"hello": "world!"})
version2 := rt.UpdateDoc(docID, version1, `{"hello": "world!"}`)

data := btcRunner.WaitForVersion(client.id, docID, version2)
assert.Equal(t, `{"hello":"world!"}`, string(data))
Expand Down Expand Up @@ -2247,15 +2247,15 @@ func TestActiveOnlyContinuous(t *testing.T) {
btc := btcRunner.NewBlipTesterClientOptsWithRT(rt, opts)
defer btc.Close()

version := rt.PutDocDirectly(docID, db.Body{"test": true})
version := rt.PutDoc(docID, `{"test": true}`)

// start an initial pull
btcRunner.StartPullSince(btc.id, BlipTesterPullOptions{Continuous: true, Since: "0", ActiveOnly: true})
rev := btcRunner.WaitForVersion(btc.id, docID, version)
assert.Equal(t, `{"test":true}`, string(rev))

// delete the doc and make sure the client still gets the tombstone replicated
deletedVersion := rt.DeleteDocDirectly(docID, version)
deletedVersion := rt.DeleteDoc(docID, version)

rev = btcRunner.WaitForVersion(btc.id, docID, deletedVersion)
assert.Equal(t, `{}`, string(rev))
Expand Down Expand Up @@ -2338,7 +2338,7 @@ func TestRemovedMessageWithAlternateAccess(t *testing.T) {
defer btc.Close()

const docID = "doc"
version := rt.PutDocDirectly(docID, db.Body{"channels": []string{"A", "B"}})
version := rt.PutDoc(docID, `{"channels": ["A", "B"]}`)

changes := rt.WaitForChanges(1, "/{{.keyspace}}/_changes?since=0&revocations=true", "user", true)
assert.Equal(t, "doc", changes.Results[0].ID)
Expand All @@ -2347,7 +2347,7 @@ func TestRemovedMessageWithAlternateAccess(t *testing.T) {
btcRunner.StartOneshotPull(btc.id)
_ = btcRunner.WaitForVersion(btc.id, docID, version)

version = rt.UpdateDocDirectly(docID, version, db.Body{"channels": []string{"B"}})
version = rt.UpdateDoc(docID, version, `{"channels": ["B"]}`)

changes = rt.WaitForChanges(1, fmt.Sprintf("/{{.keyspace}}/_changes?since=%s&revocations=true", changes.Last_Seq), "user", true)
assert.Equal(t, docID, changes.Results[0].ID)
Expand All @@ -2356,9 +2356,9 @@ func TestRemovedMessageWithAlternateAccess(t *testing.T) {
btcRunner.StartOneshotPull(btc.id)
_ = btcRunner.WaitForVersion(btc.id, docID, version)

version = rt.UpdateDocDirectly(docID, version, db.Body{"channels": []string{}})
version = rt.UpdateDoc(docID, version, `{"channels": []}`)
const docMarker = "docmarker"
docMarkerVersion := rt.PutDocDirectly(docMarker, db.Body{"channels": []string{"!"}})
docMarkerVersion := rt.PutDoc(docMarker, `{"channels": ["!"]}`)

changes = rt.WaitForChanges(2, fmt.Sprintf("/{{.keyspace}}/_changes?since=%s&revocations=true", changes.Last_Seq), "user", true)
assert.Equal(t, "doc", changes.Results[0].ID)
Expand Down Expand Up @@ -2423,7 +2423,7 @@ func TestRemovedMessageWithAlternateAccessAndChannelFilteredReplication(t *testi
const (
docID = "doc"
)
version := rt.PutDocDirectly(docID, db.Body{"channels": []string{"A", "B"}})
version := rt.PutDoc(docID, `{"channels": ["A", "B"]}`)

changes := rt.WaitForChanges(1, "/{{.keyspace}}/_changes?since=0&revocations=true", "user", true)
assert.Equal(t, docID, changes.Results[0].ID)
Expand All @@ -2432,7 +2432,7 @@ func TestRemovedMessageWithAlternateAccessAndChannelFilteredReplication(t *testi
btcRunner.StartOneshotPull(btc.id)
_ = btcRunner.WaitForVersion(btc.id, docID, version)

version = rt.UpdateDocDirectly(docID, version, db.Body{"channels": []string{"C"}})
version = rt.UpdateDoc(docID, version, `{"channels": ["C"]}`)
rt.WaitForPendingChanges()

// At this point changes should send revocation, as document isn't in any of the user's channels
Expand All @@ -2445,7 +2445,7 @@ func TestRemovedMessageWithAlternateAccessAndChannelFilteredReplication(t *testi

_ = rt.UpdateDoc(docID, version, `{"channels": ["B"]}`)
markerID := "docmarker"
markerVersion := rt.PutDocDirectly(markerID, db.Body{"channels": []string{"A"}})
markerVersion := rt.PutDoc(markerID, `{"channels": ["A"]}`)
rt.WaitForPendingChanges()

// Revocation should not be sent over blip, as document is now in user's channels - only marker document should be received
Expand Down Expand Up @@ -2792,7 +2792,7 @@ func TestProcessRevIncrementsStat(t *testing.T) {
defer func() { require.NoError(t, ar.Stop()) }()

activeRT.WaitForPendingChanges()
activeRT.WaitForVersion(docID, version)
activeRT.WaitForRevTreeVersion(docID, version)

base.RequireWaitForStat(t, pullStats.HandleRevCount.Value, 1)
assert.NotEqualValues(t, 0, pullStats.HandleRevBytes.Value())
Expand Down Expand Up @@ -2904,7 +2904,7 @@ func TestSendRevisionNoRevHandling(t *testing.T) {
recievedNoRevs <- msg
}

version := rt.PutDocDirectly(docName, db.Body{"foo": "bar"})
version := rt.PutDoc(docName, `{"foo": "bar"}`)

// Make the LeakyBucket return an error
leakyDataStore.SetGetRawCallback(func(key string) error {
Expand Down Expand Up @@ -2964,7 +2964,7 @@ func TestUnsubChanges(t *testing.T) {
// Sub changes
btcRunner.StartPull(btc.id)

doc1Version := rt.PutDocDirectly(doc1ID, db.Body{"key": "val1"})
doc1Version := rt.PutDoc(doc1ID, `{"key": "val1"}`)
_ = btcRunner.WaitForVersion(btc.id, doc1ID, doc1Version)

activeReplStat := rt.GetDatabase().DbStats.CBLReplicationPull().NumPullReplActiveContinuous
Expand All @@ -2975,7 +2975,7 @@ func TestUnsubChanges(t *testing.T) {
base.RequireWaitForStat(t, activeReplStat.Value, 0)

// Confirm no more changes are being sent
doc2Version := rt.PutDocDirectly(doc2ID, db.Body{"key": "val1"})
doc2Version := rt.PutDoc(doc2ID, `{"key": "val1"}`)
err := rt.WaitForConditionWithOptions(func() bool {
_, found := btcRunner.GetVersion(btc.id, "doc2", doc2Version)
return found
Expand Down Expand Up @@ -3148,7 +3148,7 @@ func TestBlipRefreshUser(t *testing.T) {
// add chan1 explicitly
rt.CreateUser(username, []string{"chan1"})

version := rt.PutDocDirectly(docID, db.Body{"channels": []string{"chan1"}})
version := rt.PutDoc(docID, `{"channels": []string{"chan1"}}`)

// Start a regular one-shot pull
btcRunner.StartPullSince(btc.id, BlipTesterPullOptions{Continuous: true, Since: "0"})
Expand Down Expand Up @@ -3202,8 +3202,8 @@ func TestImportInvalidSyncGetsNoRev(t *testing.T) {
Channels: []string{"ABC"},
})
defer btc.Close()
version := rt.PutDocDirectly(docID, JsonToMap(t, `{"some":"data", "channels":["ABC"]}`))
version2 := rt.PutDocDirectly(docID2, JsonToMap(t, `{"some":"data", "channels":["ABC"]}`))
version := rt.PutDoc(docID, `{"some":"data", "channels":["ABC"]}`)
version2 := rt.PutDoc(docID2, `{"some":"data", "channels":["ABC"]}`)
rt.WaitForPendingChanges()

// get changes resident in channel cache
Expand Down
Loading
Loading