MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestProcessRevIncrementsStat

Function TestProcessRevIncrementsStat

rest/blip_api_crud_test.go:2738–2789  ·  view source on GitHub ↗

CBG-2053: Test that the handleRev stats still increment correctly when going through the processRev function with the stat mapping (processRevStats)

(t *testing.T)

Source from the content-addressed store, hash-verified

2736// CBG-2053: Test that the handleRev stats still increment correctly when going through the processRev function with
2737// the stat mapping (processRevStats)
2738func TestProcessRevIncrementsStat(t *testing.T) {
2739 base.RequireNumTestBuckets(t, 2)
2740
2741 sgrRunner := NewSGRTestRunner(t)
2742
2743 sgrRunner.Run(func(t *testing.T) {
2744 activeRT, remoteRT, remoteURLString := sgrRunner.SetupSGRPeers(t)
2745 activeCtx := activeRT.Context()
2746 remoteURL, err := url.Parse(remoteURLString)
2747 require.NoError(t, err)
2748
2749 replicationID := SafeDocumentName(t, t.Name())
2750
2751 stats, err := base.SyncGatewayStats.NewDBStats("test", false, false, false, nil, nil)
2752 require.NoError(t, err)
2753 dbstats, err := stats.DBReplicatorStats(replicationID)
2754 require.NoError(t, err)
2755
2756 ar, err := db.NewActiveReplicator(activeCtx, &db.ActiveReplicatorConfig{
2757 ID: replicationID,
2758 Direction: db.ActiveReplicatorTypePull,
2759 ActiveDB: &db.Database{DatabaseContext: activeRT.GetDatabase()},
2760 RemoteDBURL: remoteURL,
2761 Continuous: true,
2762 ReplicationStatsMap: dbstats,
2763 CollectionsEnabled: !activeRT.GetDatabase().OnlyDefaultCollection(),
2764 SupportedBLIPProtocols: sgrRunner.SupportedSubprotocols,
2765 })
2766 require.NoError(t, err)
2767
2768 // Confirm all stats starting on 0
2769 require.NotNil(t, ar.Pull)
2770 pullStats := ar.Pull.GetStats()
2771 require.EqualValues(t, 0, pullStats.HandleRevCount.Value())
2772 require.EqualValues(t, 0, pullStats.HandleRevBytes.Value())
2773 require.EqualValues(t, 0, pullStats.HandlePutRevCount.Value())
2774
2775 const docID = "doc"
2776 version := remoteRT.CreateTestDoc(docID)
2777
2778 assert.NoError(t, ar.Start(activeCtx))
2779 defer func() { require.NoError(t, ar.Stop()) }()
2780
2781 activeRT.WaitForPendingChanges()
2782 sgrRunner.WaitForVersion(docID, activeRT, version)
2783
2784 base.RequireWaitForStat(t, pullStats.HandleRevCount.Value, 1)
2785 assert.NotEqualValues(t, 0, pullStats.HandleRevBytes.Value())
2786 // Confirm connected client count has not increased, which uses same processRev code
2787 assert.EqualValues(t, 0, pullStats.HandlePutRevCount.Value())
2788 })
2789}
2790
2791// Attempt to send rev as GUEST when read-only guest is enabled
2792func TestSendRevAsReadOnlyGuest(t *testing.T) {

Callers

nothing calls this directly

Calls 15

RunMethod · 0.95
SetupSGRPeersMethod · 0.95
StartMethod · 0.95
StopMethod · 0.95
WaitForVersionMethod · 0.95
RequireNumTestBucketsFunction · 0.92
NewActiveReplicatorFunction · 0.92
RequireWaitForStatFunction · 0.92
NewSGRTestRunnerFunction · 0.85
NewDBStatsMethod · 0.80
DBReplicatorStatsMethod · 0.80
OnlyDefaultCollectionMethod · 0.80

Tested by

no test coverage detected