diff --git a/pool/tree/pool.go b/pool/tree/pool.go index 171a627..ff155dc 100644 --- a/pool/tree/pool.go +++ b/pool/tree/pool.go @@ -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 { diff --git a/pool/tree/pool_test.go b/pool/tree/pool_test.go index 8c8a0cf..1c73205 100644 --- a/pool/tree/pool_test.go +++ b/pool/tree/pool_test.go @@ -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) {