Skip to content

Commit 4f298ca

Browse files
committed
Merge remote-tracking branch 'origin/main' into CBG-4267
2 parents 7a0fd69 + 45b3bbf commit 4f298ca

File tree

5 files changed

+12
-71
lines changed

5 files changed

+12
-71
lines changed

db/active_replicator.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,14 @@ func connect(arc *activeReplicatorCommon, idSuffix string) (blipSender *blip.Sen
222222
cancelCtx, cancelFunc := context.WithCancel(context.WithoutCancel(ctx)) // separate cancel context from parent cancel context
223223

224224
var originPatterns []string // no origin headers for ISGR
225+
var blipContext *blip.Context
226+
225227
// NewSGBlipContext doesn't set cancellation context - active replication cancellation on db close is handled independently
226-
// TODO: CBG-3661 ActiveReplicator subprotocol versions
227-
// - make this configurable for testing mixed-version replications
228-
// - if unspecified, default to v2 and v3 until VV is supported with ISGR, then also include v4
229-
protocols := []string{CBMobileReplicationV3.SubprotocolString(), CBMobileReplicationV2.SubprotocolString()}
230-
ctx, blipContext, err := NewSGBlipContextWithProtocols(ctx, arc.config.ID+idSuffix, originPatterns, protocols, cancelCtx)
228+
if len(arc.config.SupportedBLIPProtocols) > 0 {
229+
ctx, blipContext, err = NewSGBlipContextWithProtocols(ctx, arc.config.ID+idSuffix, originPatterns, arc.config.SupportedBLIPProtocols, cancelCtx)
230+
} else {
231+
ctx, blipContext, err = NewSGBlipContext(ctx, arc.config.ID+idSuffix, originPatterns, cancelCtx)
232+
}
231233
if err != nil {
232234
cancelFunc()
233235
return nil, nil, err

db/active_replicator_common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ func newActiveReplicatorCommon(ctx context.Context, config *ActiveReplicatorConf
123123
statusKey: metakeys.ReplicationStatusKey(checkpointID),
124124
direction: direction,
125125
}
126+
// CBG-4780: WIll hard code to use < 4 protocols for now, as the ISGR doesn't support 4+ protocols.
127+
arc.config.SupportedBLIPProtocols = []string{CBMobileReplicationV3.SubprotocolString(), CBMobileReplicationV2.SubprotocolString()}
126128

127129
if config.CollectionsEnabled {
128130
arc.namedCollections = make(map[base.ScopeAndCollectionName]*activeReplicatorCollection)

db/active_replicator_config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ type ActiveReplicatorConfig struct {
114114
// Returns an error from ActiveReplicator.Stop() if the replicator encountered any recovered panics inside handlers.
115115
// Intended for test usage only, enabled by default but disabled for the prod-ISGR codepath.
116116
reportHandlerPanicsOnStop *bool
117+
118+
// SupportedBLIPProtocols is a list of BLIP protocols supported by the active replicator.
119+
SupportedBLIPProtocols []string
117120
}
118121

119122
// SetCheckpointPrefix is a cross-package way of defining a checkpoint prefix for an ActiveReplicatorConfig intended for test usage.

rest/attachment_test.go

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,66 +2390,6 @@ func TestPushUnknownAttachmentAsStub(t *testing.T) {
23902390
})
23912391
}
23922392

2393-
func TestMinRevPosWorkToAvoidUnnecessaryProveAttachment(t *testing.T) {
2394-
rtConfig := &RestTesterConfig{
2395-
GuestEnabled: true,
2396-
DatabaseConfig: &DatabaseConfig{
2397-
DbConfig: DbConfig{
2398-
AllowConflicts: base.Ptr(true),
2399-
},
2400-
},
2401-
}
2402-
2403-
btcRunner := NewBlipTesterClientRunner(t)
2404-
const docID = "doc"
2405-
2406-
btcRunner.Run(func(t *testing.T, SupportedBLIPProtocols []string) {
2407-
rt := NewRestTester(t, rtConfig)
2408-
defer rt.Close()
2409-
2410-
opts := BlipTesterClientOpts{SupportedBLIPProtocols: SupportedBLIPProtocols}
2411-
btc := btcRunner.NewBlipTesterClientOptsWithRT(rt, &opts)
2412-
defer btc.Close()
2413-
2414-
btcRunner.StartPull(btc.id)
2415-
2416-
// Push an initial rev with attachment data
2417-
initialVersion := rt.PutDocWithAttachment(docID, "{}", "hello.txt", "aGVsbG8gd29ybGQ=")
2418-
rt.WaitForPendingChanges()
2419-
2420-
// Replicate data to client and ensure doc arrives
2421-
rt.WaitForPendingChanges()
2422-
btcRunner.WaitForVersion(btc.id, docID, initialVersion)
2423-
2424-
// Create a set of revisions before we start the replicator to ensure there's a significant amount of history to push
2425-
version := initialVersion
2426-
for i := 0; i < 25; i++ {
2427-
version = btcRunner.AddRev(btc.id, docID, &version, []byte(`{"update_count":`+strconv.Itoa(i)+`,"_attachments": {"hello.txt": {"revpos":1,"stub":true,"digest":"sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0="}}}`))
2428-
}
2429-
2430-
// Note this references revpos 1 and therefore SGW has it - Shouldn't need proveAttachment, even when we replicate it
2431-
proveAttachmentBefore := btc.pushReplication.replicationStats.ProveAttachment.Value()
2432-
btcRunner.StartPushWithOpts(btc.id, BlipTesterPushOptions{Continuous: false})
2433-
rt.WaitForVersion(docID, version)
2434-
2435-
proveAttachmentAfter := btc.pushReplication.replicationStats.ProveAttachment.Value()
2436-
assert.Equal(t, proveAttachmentBefore, proveAttachmentAfter)
2437-
2438-
// start another push to run in the background from where we last left off
2439-
latestSeq := btcRunner.SingleCollection(btc.id).lastSeq()
2440-
btcRunner.StartPushWithOpts(btc.id, BlipTesterPushOptions{Continuous: true, Since: strconv.Itoa(int(latestSeq))})
2441-
2442-
// Push another bunch of history, this time whilst a replicator is actively pushing them
2443-
for i := 25; i < 50; i++ {
2444-
version = btcRunner.AddRev(btc.id, docID, &version, []byte(`{"update_count":`+strconv.Itoa(i)+`,"_attachments": {"hello.txt": {"revpos":1,"stub":true,"digest":"sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0="}}}`))
2445-
}
2446-
2447-
rt.WaitForVersion(docID, version)
2448-
proveAttachmentAfter = btc.pushReplication.replicationStats.ProveAttachment.Value()
2449-
assert.Equal(t, proveAttachmentBefore, proveAttachmentAfter)
2450-
})
2451-
}
2452-
24532393
func TestAttachmentWithErroneousRevPos(t *testing.T) {
24542394
rtConfig := &RestTesterConfig{
24552395
GuestEnabled: true,

rest/utilities_testing_blip_client.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -956,12 +956,6 @@ func (btcc *BlipTesterCollectionClient) updateLastReplicatedRev(docID string, ve
956956
rev.message = msg
957957
}
958958

959-
func (c *BlipTesterCollectionClient) lastSeq() clientSeq {
960-
c.seqLock.RLock()
961-
defer c.seqLock.RUnlock()
962-
return c._seqLast
963-
}
964-
965959
func newBlipTesterReplication(tb testing.TB, id string, btc *BlipTesterClient, skipCollectionsInitialization bool) *BlipTesterReplicator {
966960
bt, err := NewBlipTesterFromSpecWithRT(tb, &BlipTesterSpec{
967961
connectingPassword: RestTesterDefaultUserPassword,

0 commit comments

Comments
 (0)