(t *testing.T)
| 3849 | } |
| 3850 | |
| 3851 | func TestRing_Get_NoMemoryAllocations(t *testing.T) { |
| 3852 | // Initialise the ring. |
| 3853 | ringDesc := &Desc{Ingesters: generateRingInstances(initTokenGenerator(t), 3, 3, 128)} |
| 3854 | ring := newRingForTesting(Config{HeartbeatTimeout: time.Hour, ZoneAwarenessEnabled: true, SubringCacheDisabled: true, ReplicationFactor: 3}, true) |
| 3855 | ring.setRingStateFromDesc(ringDesc, false, false, false) |
| 3856 | |
| 3857 | buf, bufHosts, bufZones := MakeBuffersForGet() |
| 3858 | r := rand.New(rand.NewSource(time.Now().UnixNano())) |
| 3859 | |
| 3860 | numAllocs := testing.AllocsPerRun(10, func() { |
| 3861 | set, err := ring.Get(r.Uint32(), Write, buf, bufHosts, bufZones) |
| 3862 | if err != nil || len(set.Instances) != 3 { |
| 3863 | t.Fail() |
| 3864 | } |
| 3865 | }) |
| 3866 | |
| 3867 | assert.Equal(t, float64(0), numAllocs) |
| 3868 | } |
| 3869 | |
| 3870 | // generateTokensLinear returns tokens with a linear distribution. |
| 3871 | func generateTokensLinear(instanceID, numInstances, numTokens int) []uint32 { |
nothing calls this directly
no test coverage detected