From 8bf346d37bae826a617a9e7306d4e94973d06afc Mon Sep 17 00:00:00 2001 From: Kaloyan Tanev Date: Mon, 22 Jul 2024 18:10:06 +0300 Subject: [PATCH] Refactor log and move function to test.go --- cmd/test.go | 11 +++++++++++ cmd/testpeers.go | 11 ----------- cmd/testvalidator.go | 3 ++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cmd/test.go b/cmd/test.go index cb360258a..5a425908e 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -323,3 +323,14 @@ func blockAndWait(ctx context.Context, awaitTime time.Duration) { log.Info(ctx, "Forcefully stopped") } } + +func sleepWithContext(ctx context.Context, d time.Duration) { + timer := time.NewTimer(d) + select { + case <-ctx.Done(): + if !timer.Stop() { + <-timer.C + } + case <-timer.C: + } +} diff --git a/cmd/testpeers.go b/cmd/testpeers.go index ffce1da49..701bda55c 100644 --- a/cmd/testpeers.go +++ b/cmd/testpeers.go @@ -225,17 +225,6 @@ func pingPeerContinuously(ctx context.Context, tcpNode host.Host, peer p2p.Peer, } } -func sleepWithContext(ctx context.Context, d time.Duration) { - timer := time.NewTimer(d) - select { - case <-ctx.Done(): - if !timer.Stop() { - <-timer.C - } - case <-timer.C: - } -} - func runTestPeers(ctx context.Context, w io.Writer, conf testPeersConfig) error { peerTestCases := supportedPeerTestCases() queuedTestsPeer := filterTests(maps.Keys(peerTestCases), conf.testConfig) diff --git a/cmd/testvalidator.go b/cmd/testvalidator.go index 2a93ba2fd..6dd6b7dae 100644 --- a/cmd/testvalidator.go +++ b/cmd/testvalidator.go @@ -230,7 +230,7 @@ func pingValidatorContinuously(ctx context.Context, address string, resCh chan<- } func validatorPingLoadTest(ctx context.Context, conf *testValidatorConfig) testResult { - log.Info(ctx, "Running validator load tests...", + log.Info(ctx, "Running ping load tests...", z.Any("duration", conf.LoadTestDuration), z.Any("target", conf.APIAddress), ) @@ -256,6 +256,7 @@ func validatorPingLoadTest(ctx context.Context, conf *testValidatorConfig) testR } wg.Wait() close(testResCh) + log.Info(ctx, "Ping load tests finished", z.Any("target", conf.APIAddress)) highestRTT := time.Duration(0) for rtt := range testResCh {