[#73] pool/tree: Fix index in retry loop #99
2 changed files with 11 additions and 4 deletions
|
@ -725,7 +725,7 @@ func (p *Pool) requestWithRetry(fn func(client grpcService.TreeServiceClient) er
|
|||
groupsLen := len(p.innerPools)
|
||||
for i := startI; i < startI+groupsLen; i++ {
|
||||
indexI := i % groupsLen
|
||||
clientsLen := len(p.innerPools[i].clients)
|
||||
clientsLen := len(p.innerPools[indexI].clients)
|
||||
for j := startJ; j < startJ+clientsLen; j++ {
|
||||
indexJ := j % clientsLen
|
||||
if cl, err = p.innerPools[indexI].clients[indexJ].serviceClient(); err == nil {
|
||||
|
|
|
@ -3,10 +3,10 @@ package tree
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
grpcService "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool/tree/service"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool"
|
||||
grpcService "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool/tree/service"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap/zaptest"
|
||||
)
|
||||
|
@ -148,6 +148,14 @@ func TestRetry(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
checkIndicesAndReset(t, p, 1, 0)
|
||||
})
|
||||
|
||||
t.Run("no panic group switch", func(t *testing.T) {
|
||||
setErrors(p, nodes[1]...)
|
||||
p.setStartIndices(1, 0)
|
||||
err := p.requestWithRetry(makeFn)
|
||||
require.NoError(t, err)
|
||||
checkIndicesAndReset(t, p, 0, 0)
|
||||
})
|
||||
}
|
||||
|
||||
func TestRebalance(t *testing.T) {
|
||||
|
@ -246,8 +254,7 @@ func checkIndicesAndReset(t *testing.T, p *Pool, iExp, jExp int) {
|
|||
|
||||
func checkIndices(t *testing.T, p *Pool, iExp, jExp int) {
|
||||
i, j := p.getStartIndices()
|
||||
require.Equal(t, iExp, i)
|
||||
require.Equal(t, jExp, j)
|
||||
require.Equal(t, [2]int{iExp, jExp}, [2]int{i, j})
|
||||
}
|
||||
|
||||
func resetClients(p *Pool) {
|
||||
|
|
Loading…
Reference in a new issue