Skip to content

Commit 7e4a950

Browse files
authored
[CRE-739] retry proto registration (#2080)
1 parent a8cb085 commit 7e4a950

File tree

7 files changed

+117
-14
lines changed

7 files changed

+117
-14
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Framework Docker Compose Tests
2+
on:
3+
push:
4+
5+
jobs:
6+
test:
7+
defaults:
8+
run:
9+
working-directory: framework/examples/myproject
10+
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write
13+
contents: read
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
test:
18+
- name: TestChipIngressSmoke
19+
config: smoke_chip.toml
20+
count: 1
21+
timeout: 3m
22+
name: ${{ matrix.test.name }}
23+
steps:
24+
- name: Checkout repo
25+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
26+
27+
- name: Configure AWS credentials using OIDC
28+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
29+
with:
30+
role-to-assume: ${{ secrets.AWS_CTF_READ_ACCESS_ROLE_ARN }}
31+
aws-region: us-west-2
32+
33+
- name: Login to Amazon ECR
34+
id: login-ecr-private
35+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
36+
with:
37+
registries: ${{ format('{0},{1}', secrets.AWS_ACCOUNT_ID_SDLC, secrets.AWS_ACCOUNT_ID_PROD) }}
38+
env:
39+
AWS_REGION: us-west-2
40+
41+
- name: Check for changes in Docker Components
42+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
43+
id: changes
44+
with:
45+
filters: |
46+
src:
47+
- 'framework/components/dockercompose/**'
48+
- '.github/workflows/framework-components-tests.yml'
49+
50+
- name: Set up Go
51+
uses: actions/setup-go@v5
52+
with:
53+
go-version: '1.24.0'
54+
55+
- name: Cache Go modules
56+
uses: actions/cache@v4
57+
with:
58+
path: |
59+
~/.cache/go-build
60+
~/go/pkg/mod
61+
key: go-modules-${{ hashFiles('framework/examples/myproject/go.sum') }}-${{ runner.os }}-framework-golden-examples
62+
restore-keys: |
63+
go-modules-${{ runner.os }}-framework-golden-examples
64+
go-modules-${{ runner.os }}
65+
66+
- name: Install dependencies
67+
run: go mod download
68+
69+
- name: Run System Tests
70+
if: steps.changes.outputs.src == 'true'
71+
env:
72+
CTF_CONFIGS: ${{ matrix.test.config }}
73+
CHIP_INGRESS_IMAGE: ${{ secrets.AWS_ACCOUNT_ID_PROD }}.dkr.ecr.us-west-2.amazonaws.com/atlas-chip-ingress:qa-latest
74+
CTF_LOG_LEVEL: debug
75+
run: |
76+
go test -timeout ${{ matrix.test.timeout }} -v -count ${{ matrix.test.count }} -run ${{ matrix.test.name }}
77+
78+
- name: Upload Logs
79+
if: always()
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: container-logs-${{ matrix.test.name }}
83+
path: framework/examples/myproject/logs
84+
retention-days: 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Revert topological sorting of proto dependencies for the local-cre
2+
- Revert support for exclude files to proto registration config
3+
- Add retry on proto registration

framework/components/dockercompose/chip_ingress_set/chip_ingress.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ func New(in *Input) (*Output, error) {
128128
wait.NewHostPortStrategy(DEFAULT_RED_PANDA_SCHEMA_REGISTRY_PORT).WithPollInterval(100*time.Millisecond),
129129
wait.NewHostPortStrategy(DEFAULT_RED_PANDA_KAFKA_PORT).WithPollInterval(100*time.Millisecond),
130130
wait.ForHTTP("/v1/status/ready").WithPort("9644"), // admin API port
131+
wait.ForHTTP("/status/ready").WithPort(DEFAULT_RED_PANDA_SCHEMA_REGISTRY_PORT).WithPollInterval(100*time.Millisecond),
131132
).WithDeadline(2*time.Minute),
132133
).WaitForService(DEFAULT_RED_PANDA_CONSOLE_SERVICE_NAME,
133134
wait.ForAll(

framework/components/dockercompose/chip_ingress_set/protos.go

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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,20 +512,33 @@ func registerSingleProto(
510512
}
511513

512514
url := fmt.Sprintf("%s/subjects/%s/versions", registryURL, subject)
515+
maxAttempts := uint(10)
513516

514-
resp, respErr := http.Post(url, "application/vnd.schemaregistry.v1+json", bytes.NewReader(payload))
515-
if respErr != nil {
516-
return 0, errors.Wrap(respErr, "failed to post to schema registry")
517-
}
518-
defer resp.Body.Close()
517+
var resp *http.Response
518+
retry.Do(func() error {
519+
var respErr error
520+
resp, respErr = http.Post(url, "application/vnd.schemaregistry.v1+json", bytes.NewReader(payload))
521+
if respErr != nil {
522+
return errors.Wrap(respErr, "failed to post to schema registry")
523+
}
519524

520-
if resp.StatusCode >= 300 {
521-
data, dataErr := io.ReadAll(resp.Body)
522-
if dataErr != nil {
523-
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)
524531
}
525-
return 0, fmt.Errorf("schema registry error (%d): %s", resp.StatusCode, data)
526-
}
532+
533+
return nil
534+
}, retry.Attempts(maxAttempts), retry.Delay(100*time.Millisecond), retry.DelayType(retry.BackOffDelay), retry.OnRetry(func(n uint, err error) {
535+
framework.L.Debug().Str("attempt/max", fmt.Sprintf("%d/%d", n, maxAttempts)).Msgf("Retrying to register schema %s: %v", subject, err)
536+
}), retry.RetryIf(func(err error) bool {
537+
// we don't want to retry all errors, because some of them are are expected (e.g. missing dependencies)
538+
// and will be handled by higher-level code
539+
return strings.Contains(err.Error(), "connection reset by peer")
540+
}))
541+
defer resp.Body.Close()
527542

528543
var result struct {
529544
ID int `json:"id"`

framework/components/dockercompose/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.24.2
55
replace github.com/smartcontractkit/chainlink-testing-framework/framework => ../../../framework
66

77
require (
8+
github.com/avast/retry-go/v4 v4.6.1
89
github.com/confluentinc/confluent-kafka-go v1.9.2
910
github.com/docker/docker v28.0.4+incompatible
1011
github.com/google/go-github/v72 v72.0.0

framework/components/dockercompose/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew
4040
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
4141
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
4242
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
43+
github.com/avast/retry-go/v4 v4.6.1 h1:VkOLRubHdisGrHnTu89g08aQEWEgRU7LVEop3GbIcMk=
44+
github.com/avast/retry-go/v4 v4.6.1/go.mod h1:V6oF8njAwxJ5gRo1Q7Cxab24xs5NCWZBeaHHBklR8mA=
4345
github.com/aws/aws-sdk-go-v2 v1.31.0 h1:3V05LbxTSItI5kUqNwhJrrrY1BAXxXt0sN0l72QmG5U=
4446
github.com/aws/aws-sdk-go-v2 v1.31.0/go.mod h1:ztolYtaEUtdpf9Wftr31CJfLVjOnD/CVRkKOOYgF8hA=
4547
github.com/aws/aws-sdk-go-v2/config v1.27.39 h1:FCylu78eTGzW1ynHcongXK9YHtoXD5AiiUqq3YfJYjU=

framework/examples/myproject/smoke_chip_ingress_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package examples
22

33
import (
44
"context"
5-
"os"
65
"testing"
76
"time"
87

@@ -17,8 +16,6 @@ type ChipConfig struct {
1716

1817
// use config file: smoke_chip.toml
1918
func TestChipIngressSmoke(t *testing.T) {
20-
t.Skip("skipping smoke test until we have a way to fetch Chip Ingress image")
21-
os.Setenv("CTF_CONFIGS", "smoke_chip.toml")
2219
in, err := framework.Load[ChipConfig](t)
2320
require.NoError(t, err, "failed to load config")
2421

0 commit comments

Comments
 (0)