From ed84757300e04c0b9d121f4f0cc0716d69e9cb33 Mon Sep 17 00:00:00 2001 From: davidcauchi Date: Wed, 6 Nov 2024 10:50:21 +0100 Subject: [PATCH] Improve logging --- integration-tests/actions/ocr2_helpers.go | 22 ++++++++++++++++++---- integration-tests/testsetups/ocr.go | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/integration-tests/actions/ocr2_helpers.go b/integration-tests/actions/ocr2_helpers.go index 87243b637e5..799b1f29236 100644 --- a/integration-tests/actions/ocr2_helpers.go +++ b/integration-tests/actions/ocr2_helpers.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/google/uuid" "github.com/lib/pq" + "github.com/rs/zerolog" "github.com/rs/zerolog/log" "golang.org/x/sync/errgroup" "gopkg.in/guregu/null.v4" @@ -193,6 +194,7 @@ func CreateOCRv2Jobs( mockServerValue int, // Value to get from the mock server when querying the path chainId int64, // EVM chain ID forwardingAllowed bool, + l zerolog.Logger, ) error { // Collect P2P ID bootstrapP2PIds, err := bootstrapNode.MustReadP2PKeys() @@ -296,20 +298,32 @@ func CreateOCRv2Jobs( jobIDs[chainlinkNode] = append(jobIDs[chainlinkNode], ocrJob.Data.ID) // Store each job ID per node } } - // Verify all jobs have been created for each chainlink node before moving on + l.Info().Msg("Verify OCRv2 jobs have been created") for chainlinkNode, ids := range jobIDs { for _, jobID := range ids { - var retries = 5 - var delay = time.Second * 2 - + var retries = 4 + var baseDelay = time.Second * 2 for i := 0; i < retries; i++ { _, resp, err := chainlinkNode.ReadJob(jobID) if err == nil && resp.StatusCode == http.StatusOK { + l.Info(). + Str("Node", chainlinkNode.PodName). + Str("Job ID", jobID). + Msg("OCRv2 job successfully created") break } if i == retries-1 { return fmt.Errorf("failed to verify job creation for node %s, jobID %s after %d retries", chainlinkNode.PodName, jobID, retries) } + + delay := baseDelay << i // Exponential delay: baseDelay * 2^i + l.Debug(). + Str("Node", chainlinkNode.PodName). + Str("Job ID", jobID). + Int("Attempt", i+1). + Dur("Delay", delay). + Msg("Exponential backoff: Waiting for next retry") + time.Sleep(delay) } } diff --git a/integration-tests/testsetups/ocr.go b/integration-tests/testsetups/ocr.go index 8e6c15c9ff3..bb98edb4f77 100644 --- a/integration-tests/testsetups/ocr.go +++ b/integration-tests/testsetups/ocr.go @@ -462,7 +462,7 @@ func (o *OCRSoakTest) createOCRv1Jobs() error { // createOCRv2Jobs creates OCRv2 jobs. func (o *OCRSoakTest) createOCRv2Jobs() error { - err := actions.CreateOCRv2Jobs(o.ocrV2Instances, o.bootstrapNode, o.workerNodes, o.mockServer, o.startingValue, o.seth.ChainID, o.OperatorForwarderFlow) + err := actions.CreateOCRv2Jobs(o.ocrV2Instances, o.bootstrapNode, o.workerNodes, o.mockServer, o.startingValue, o.seth.ChainID, o.OperatorForwarderFlow, o.log) if err != nil { return fmt.Errorf("error creating OCRv2 jobs: %w", err) }