func TestRangeStatsInit(t *testing.T) {
	tc := testContext{}
	tc.Start(t)
	defer tc.Stop()
	ms := engine.MVCCStats{
		LiveBytes:       1,
		KeyBytes:        2,
		ValBytes:        3,
		IntentBytes:     4,
		LiveCount:       5,
		KeyCount:        6,
		ValCount:        7,
		IntentCount:     8,
		IntentAge:       9,
		GCBytesAge:      10,
		LastUpdateNanos: 11,
	}
	ms.SetStats(tc.engine, 1)

	s, err := newRangeStats(1, tc.engine)
	if err != nil {
		t.Fatal(err)
	}
	if !reflect.DeepEqual(ms, s.MVCCStats) {
		t.Errorf("mvcc stats mismatch %+v != %+v", ms, s.MVCCStats)
	}
}
Exemple #2
0
// SetStats sets stats wholesale.
func (rs *rangeStats) SetMVCCStats(e engine.Engine, ms engine.MVCCStats) {
	rs.Lock()
	defer rs.Unlock()
	rs.MVCCStats = ms
	ms.SetStats(e, rs.raftID)
}