CBG-2053: Test that the handleRev stats still increment correctly when going through the processRev function with the stat mapping (processRevStats)
(t *testing.T)
| 2736 | // CBG-2053: Test that the handleRev stats still increment correctly when going through the processRev function with |
| 2737 | // the stat mapping (processRevStats) |
| 2738 | func 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 |
| 2792 | func TestSendRevAsReadOnlyGuest(t *testing.T) { |
nothing calls this directly
no test coverage detected