@@ -11,7 +11,9 @@ import (
1111 "path/filepath"
1212 "regexp"
1313 "strings"
14+ "time"
1415
16+ "github.com/avast/retry-go/v4"
1517 "github.com/google/go-github/v72/github"
1618 "github.com/pkg/errors"
1719 "github.com/smartcontractkit/chainlink-testing-framework/framework"
@@ -510,23 +512,26 @@ func registerSingleProto(
510512 }
511513
512514 url := fmt .Sprintf ("%s/subjects/%s/versions" , registryURL , subject )
513- // Force IPv4 to avoid Docker IPv6 port forwarding issues
514- url = strings .Replace (url , "localhost" , "127.0.0.1" , 1 )
515- framework .L .Debug ().Msgf ("Registering schema to URL: %s" , url )
516515
517- resp , respErr := http .Post (url , "application/vnd.schemaregistry.v1+json" , bytes .NewReader (payload ))
518- if respErr != nil {
519- return 0 , errors .Wrap (respErr , "failed to post to schema registry" )
520- }
521- defer resp .Body .Close ()
516+ var resp * http.Response
517+ retry .Do (func () error {
518+ var respErr error
519+ resp , respErr = http .Post (url , "application/vnd.schemaregistry.v1+json" , bytes .NewReader (payload ))
520+ if respErr != nil {
521+ return errors .Wrap (respErr , "failed to post to schema registry" )
522+ }
523+ defer resp .Body .Close ()
522524
523- if resp .StatusCode >= 300 {
524- data , dataErr := io .ReadAll (resp .Body )
525- if dataErr != nil {
526- return 0 , errors .Wrap (dataErr , "failed to read response body" )
525+ if resp .StatusCode >= 300 {
526+ data , dataErr := io .ReadAll (resp .Body )
527+ if dataErr != nil {
528+ return errors .Wrap (dataErr , "failed to read response body" )
529+ }
530+ return fmt .Errorf ("schema registry error (%d): %s" , resp .StatusCode , data )
527531 }
528- return 0 , fmt .Errorf ("schema registry error (%d): %s" , resp .StatusCode , data )
529- }
532+
533+ return nil
534+ }, retry .Attempts (10 ), retry .Delay (100 * time .Millisecond ), retry .DelayType (retry .BackOffDelay ))
530535
531536 var result struct {
532537 ID int `json:"id"`
0 commit comments