From 2f6757c828acf9235577175a4cbc8aa08fb36e98 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Thu, 4 May 2023 14:13:25 +0300 Subject: [PATCH] [#311] ir: Fix data race in unit tests Signed-off-by: Dmitrii Stepanov --- pkg/innerring/processors/alphabet/handlers_test.go | 5 ++--- pkg/innerring/processors/frostfs/handlers_test.go | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/innerring/processors/alphabet/handlers_test.go b/pkg/innerring/processors/alphabet/handlers_test.go index 5e71cbc90..c098ca27d 100644 --- a/pkg/innerring/processors/alphabet/handlers_test.go +++ b/pkg/innerring/processors/alphabet/handlers_test.go @@ -2,7 +2,6 @@ package alphabet_test import ( "testing" - "time" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/alphabet" @@ -140,7 +139,7 @@ func TestProcessorEmitsGasToNetmapIfNoParsedWallets(t *testing.T) { processor.HandleGasEmission(timers.NewAlphabetEmitTick{}) - time.Sleep(time.Second) + processor.WaitPoolRunning() require.EqualValues(t, []invokedMethod{ { @@ -201,7 +200,7 @@ func TestProcessorDoesntEmitGasIfNoNetmapOrParsedWallets(t *testing.T) { processor.HandleGasEmission(timers.NewAlphabetEmitTick{}) - time.Sleep(time.Second) + processor.WaitPoolRunning() require.EqualValues(t, []invokedMethod{ { diff --git a/pkg/innerring/processors/frostfs/handlers_test.go b/pkg/innerring/processors/frostfs/handlers_test.go index ee2a00427..db7835811 100644 --- a/pkg/innerring/processors/frostfs/handlers_test.go +++ b/pkg/innerring/processors/frostfs/handlers_test.go @@ -254,7 +254,9 @@ func TestHandleUnbind(t *testing.T) { proc.handleBind(evBind) - time.Sleep(time.Second) + for proc.pool.Running() > 0 { + time.Sleep(10 * time.Millisecond) + } require.EqualValues(t, []frostfsid.CommonBindPrm{expBind}, id.remove, "invalid remove keys value") require.EqualValues(t, []frostfsid.CommonBindPrm{expBind}, id.add, "invalid add keys value") -- 2.45.2