[#1475] Remove container estimation code
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m38s
Vulncheck / Vulncheck (pull_request) Successful in 5m20s
Build / Build Components (pull_request) Successful in 6m9s
Tests and linters / gopls check (pull_request) Successful in 6m1s
Tests and linters / Lint (pull_request) Successful in 6m46s
Tests and linters / Tests with -race (pull_request) Successful in 9m35s
Tests and linters / Tests (pull_request) Successful in 2m6s
Tests and linters / Staticcheck (pull_request) Successful in 2m27s
DCO action / DCO (pull_request) Successful in 1m1s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m45s
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m38s
Vulncheck / Vulncheck (pull_request) Successful in 5m20s
Build / Build Components (pull_request) Successful in 6m9s
Tests and linters / gopls check (pull_request) Successful in 6m1s
Tests and linters / Lint (pull_request) Successful in 6m46s
Tests and linters / Tests with -race (pull_request) Successful in 9m35s
Tests and linters / Tests (pull_request) Successful in 2m6s
Tests and linters / Staticcheck (pull_request) Successful in 2m27s
DCO action / DCO (pull_request) Successful in 1m1s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m45s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
7edec9193c
commit
c8fb154151
13 changed files with 9 additions and 499 deletions
|
@ -3,29 +3,20 @@ package innerring
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/container"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestEpochTimer(t *testing.T) {
|
||||
t.Parallel()
|
||||
alphaState := &testAlphabetState{isAlphabet: true}
|
||||
neh := &testNewEpochHandler{}
|
||||
cnrStopper := &testContainerEstStopper{}
|
||||
epochState := &testEpochState{
|
||||
counter: 99,
|
||||
duration: 10,
|
||||
}
|
||||
|
||||
args := &epochTimerArgs{
|
||||
l: test.NewLogger(t),
|
||||
alphabetState: alphaState,
|
||||
newEpochHandlers: []newEpochHandler{neh.Handle},
|
||||
cnrWrapper: cnrStopper,
|
||||
epoch: epochState,
|
||||
stopEstimationDMul: 2,
|
||||
stopEstimationDDiv: 10,
|
||||
newEpochHandlers: []newEpochHandler{neh.Handle},
|
||||
epoch: epochState,
|
||||
}
|
||||
et := newEpochTimer(args)
|
||||
err := et.Reset()
|
||||
|
@ -33,63 +24,43 @@ func TestEpochTimer(t *testing.T) {
|
|||
|
||||
et.Tick(100)
|
||||
require.Equal(t, 0, neh.called, "invalid new epoch handler calls")
|
||||
require.Equal(t, 0, cnrStopper.called, "invalid container stop handler calls")
|
||||
|
||||
et.Tick(101)
|
||||
require.Equal(t, 0, neh.called, "invalid new epoch handler calls")
|
||||
require.Equal(t, 1, cnrStopper.called, "invalid container stop handler calls")
|
||||
|
||||
et.Tick(102)
|
||||
require.Equal(t, 0, neh.called, "invalid new epoch handler calls")
|
||||
require.Equal(t, 1, cnrStopper.called, "invalid container stop handler calls")
|
||||
|
||||
et.Tick(103)
|
||||
require.Equal(t, 0, neh.called, "invalid new epoch handler calls")
|
||||
require.Equal(t, 1, cnrStopper.called, "invalid container stop handler calls")
|
||||
|
||||
var h uint32
|
||||
for h = 104; h < 109; h++ {
|
||||
et.Tick(h)
|
||||
require.Equal(t, 0, neh.called, "invalid new epoch handler calls")
|
||||
require.Equal(t, 1, cnrStopper.called, "invalid container stop handler calls")
|
||||
}
|
||||
|
||||
et.Tick(109)
|
||||
require.Equal(t, 1, neh.called, "invalid new epoch handler calls")
|
||||
require.Equal(t, 1, cnrStopper.called, "invalid container stop handler calls")
|
||||
|
||||
et.Tick(110)
|
||||
require.Equal(t, 1, neh.called, "invalid new epoch handler calls")
|
||||
require.Equal(t, 1, cnrStopper.called, "invalid container stop handler calls")
|
||||
|
||||
et.Tick(111)
|
||||
require.Equal(t, 1, neh.called, "invalid new epoch handler calls")
|
||||
require.Equal(t, 2, cnrStopper.called, "invalid container stop handler calls")
|
||||
|
||||
et.Tick(112)
|
||||
require.Equal(t, 1, neh.called, "invalid new epoch handler calls")
|
||||
require.Equal(t, 2, cnrStopper.called, "invalid container stop handler calls")
|
||||
|
||||
et.Tick(113)
|
||||
require.Equal(t, 1, neh.called, "invalid new epoch handler calls")
|
||||
require.Equal(t, 2, cnrStopper.called, "invalid container stop handler calls")
|
||||
|
||||
for h = 114; h < 119; h++ {
|
||||
et.Tick(h)
|
||||
require.Equal(t, 1, neh.called, "invalid new epoch handler calls")
|
||||
require.Equal(t, 2, cnrStopper.called, "invalid container stop handler calls")
|
||||
}
|
||||
et.Tick(120)
|
||||
require.Equal(t, 2, neh.called, "invalid new epoch handler calls")
|
||||
require.Equal(t, 2, cnrStopper.called, "invalid container stop handler calls")
|
||||
}
|
||||
|
||||
type testAlphabetState struct {
|
||||
isAlphabet bool
|
||||
}
|
||||
|
||||
func (s *testAlphabetState) IsAlphabet() bool {
|
||||
return s.isAlphabet
|
||||
}
|
||||
|
||||
type testNewEpochHandler struct {
|
||||
|
@ -100,15 +71,6 @@ func (h *testNewEpochHandler) Handle() {
|
|||
h.called++
|
||||
}
|
||||
|
||||
type testContainerEstStopper struct {
|
||||
called int
|
||||
}
|
||||
|
||||
func (s *testContainerEstStopper) StopEstimation(_ container.StopEstimationPrm) error {
|
||||
s.called++
|
||||
return nil
|
||||
}
|
||||
|
||||
type testEpochState struct {
|
||||
counter uint64
|
||||
duration uint64
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue