Skip to content

Commit 3034d1b

Browse files
authored
fix issues executing CI on localhost (#2816)
* local coverage check * remove the change on sov helpers for icm * fix macos docker install * fix * nit * try out macos 15 * nit * nit
1 parent b7989c5 commit 3034d1b

File tree

5 files changed

+84
-35
lines changed

5 files changed

+84
-35
lines changed

.github/workflows/e2e-test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
"\\[Error handling\\]",
2020
"\\[Key\\]",
2121
"\\[ICM\\]",
22+
"\\[Local Network\\]",
2223
"\\[Network\\]",
2324
"\\[Blockchain Configure\\]",
2425
"\\[Package Management\\]",
@@ -31,8 +32,8 @@ jobs:
3132
"\\[Etna AddRemove Validator SOV PoS\\]",
3233
"\\[Etna Add Validator SOV Local\\]",
3334
"\\[Subnet\\]",
34-
"\\[Upgrade expect network failure\\]",
35-
"\\[Upgrade public network\\]",
35+
"\\[Upgrade expect network failure",
36+
"\\[Upgrade public network",
3637
"\\[Upgrade local network\\]",
3738
"\\[Node create\\]",
3839
"\\[Node devnet\\]",
@@ -82,7 +83,7 @@ jobs:
8283
npm install -g tsx
8384
8485
- name: Install Docker on MacOS
85-
if: ${{ (matrix.os == 'macos-14') && (matrix.suite == '\\[Public Subnet non SOV\\]') }}
86+
if: ${{ (matrix.os == 'macos-14') && (matrix.suite == '\[Public Subnet non SOV\]') }}
8687
run: |
8788
brew install docker
8889
brew install colima

pkg/application/downloader.go

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"net/http"
1111
"os"
1212
"strings"
13+
"time"
1314

1415
"github.com/ava-labs/avalanche-cli/pkg/constants"
1516
"github.com/ava-labs/avalanche-cli/pkg/utils"
@@ -46,17 +47,14 @@ func NewDownloader() Downloader {
4647
return &downloader{}
4748
}
4849

49-
func (downloader) Download(url string) ([]byte, error) {
50-
resp, err := http.Get(url)
50+
func (d downloader) Download(url string) ([]byte, error) {
51+
token := os.Getenv(constants.GithubAPITokenEnvVarName)
52+
body, err := d.doAPIRequest(url, token)
5153
if err != nil {
5254
return nil, err
5355
}
54-
defer resp.Body.Close()
55-
if resp.StatusCode != http.StatusOK {
56-
return nil, fmt.Errorf("unexpected http status code: %d", resp.StatusCode)
57-
}
58-
59-
return io.ReadAll(resp.Body)
56+
defer body.Close()
57+
return io.ReadAll(body)
6058
}
6159

6260
// GetLatestPreReleaseVersion returns the latest available pre release or release version from github
@@ -148,22 +146,33 @@ func (d downloader) GetAllReleasesForRepo(org, repo, component string, kind Rele
148146
}
149147

150148
func (downloader) doAPIRequest(url, token string) (io.ReadCloser, error) {
151-
request, err := http.NewRequest("GET", url, nil)
152-
if err != nil {
153-
return nil, fmt.Errorf("failed to create request for %s: %w", url, err)
154-
}
155-
if token != "" {
156-
// avoid rate limitation issues at CI
157-
request.Header.Set("authorization", fmt.Sprintf("Bearer %s", token))
158-
}
159-
resp, err := http.DefaultClient.Do(request)
160-
if err != nil {
161-
return nil, fmt.Errorf("failed doing request to %s: %w", url, err)
162-
}
163-
if resp.StatusCode != http.StatusOK {
164-
return nil, fmt.Errorf("failed doing request %s: unexpected http status code: %d", url, resp.StatusCode)
149+
retries := 0
150+
for {
151+
request, err := http.NewRequest("GET", url, nil)
152+
if err != nil {
153+
return nil, fmt.Errorf("failed to create request for %s: %w", url, err)
154+
}
155+
if token != "" {
156+
// avoid rate limitation issues at CI
157+
request.Header.Set("authorization", fmt.Sprintf("Bearer %s", token))
158+
}
159+
resp, err := http.DefaultClient.Do(request)
160+
if err != nil {
161+
return nil, fmt.Errorf("failed doing request to %s: %w", url, err)
162+
}
163+
if resp.StatusCode != http.StatusOK {
164+
if resp.StatusCode == http.StatusTooManyRequests {
165+
if retries <= 5 {
166+
retries++
167+
toSleep := time.Duration(retries) * 10 * time.Second
168+
time.Sleep(toSleep)
169+
continue
170+
}
171+
}
172+
return nil, fmt.Errorf("failed doing request %s: unexpected http status code: %d", url, resp.StatusCode)
173+
}
174+
return resp.Body, nil
165175
}
166-
return resp.Body, nil
167176
}
168177

169178
func (d downloader) getLatestReleaseVersion(org, repo string) (string, error) {

pkg/localnet/helpers.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,8 @@ func TrackSubnet(
164164
return err
165165
}
166166
ux.Logger.GreenCheckmarkToUser("%s successfully tracking %s", networkModel.Name(), blockchainName)
167-
network, err := GetTmpNetNetwork(networkDir)
168-
if err != nil {
169-
return err
170-
}
171167
if networkModel.Kind == models.Local {
172-
if err := TmpNetSetAlias(network.Nodes, blockchainID.String(), blockchainName, subnetID); err != nil {
168+
if err := TmpNetSetDefaultAliases(ctx, networkDir); err != nil {
173169
return err
174170
}
175171
}

tests/e2e/testcases/packageman/suite.go

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,51 @@ var _ = ginkgo.Describe("[Package Management]", ginkgo.Ordered, func() {
144144
commands.DeleteSubnetConfig(secondSubnetName)
145145
})
146146

147+
ginkgo.It("can deploy multiple subnet-evm versions SOV", func() {
148+
// check subnet-evm install precondition
149+
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey1])).Should(gomega.BeFalse())
150+
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey2])).Should(gomega.BeFalse())
151+
152+
commands.CreateSubnetEvmConfigWithVersionSOV(subnetName, utils.SubnetEvmGenesisPoaPath, binaryToVersion[utils.SoloSubnetEVMKey1])
153+
commands.CreateSubnetEvmConfigWithVersionSOV(secondSubnetName, utils.SubnetEvmGenesisPoaPath, binaryToVersion[utils.SoloSubnetEVMKey2])
154+
155+
deployOutput := commands.DeploySubnetLocallySOV(subnetName)
156+
rpcs1, err := utils.ParseRPCsFromOutput(deployOutput)
157+
if err != nil {
158+
fmt.Println(deployOutput)
159+
}
160+
gomega.Expect(err).Should(gomega.BeNil())
161+
gomega.Expect(rpcs1).Should(gomega.HaveLen(1))
162+
163+
deployOutput = commands.DeploySubnetLocallySOV(secondSubnetName)
164+
rpcs2, err := utils.ParseRPCsFromOutput(deployOutput)
165+
if err != nil {
166+
fmt.Println(deployOutput)
167+
}
168+
gomega.Expect(err).Should(gomega.BeNil())
169+
gomega.Expect(rpcs2).Should(gomega.HaveLen(1))
170+
171+
err = utils.SetHardhatRPC(rpcs1[0])
172+
gomega.Expect(err).Should(gomega.BeNil())
173+
174+
err = utils.RunHardhatTests(utils.BaseTest)
175+
gomega.Expect(err).Should(gomega.BeNil())
176+
177+
err = utils.SetHardhatRPC(rpcs2[0])
178+
gomega.Expect(err).Should(gomega.BeNil())
179+
180+
err = utils.RunHardhatTests(utils.BaseTest)
181+
gomega.Expect(err).Should(gomega.BeNil())
182+
183+
// check subnet-evm install
184+
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey1])).Should(gomega.BeTrue())
185+
gomega.Expect(utils.CheckSubnetEVMExists(binaryToVersion[utils.SoloSubnetEVMKey2])).Should(gomega.BeTrue())
186+
187+
commands.DeleteSubnetConfig(subnetName)
188+
commands.DeleteSubnetConfig(secondSubnetName)
189+
})
190+
147191
ginkgo.It("can deploy with multiple avalanchego versions non SOV", func() {
148-
ginkgo.Skip("skipped until two consecutive avago version with dynamic fees are available")
149192
// check avago install precondition
150193
gomega.Expect(utils.CheckAvalancheGoExists(binaryToVersion[utils.MultiAvago1Key])).Should(gomega.BeFalse())
151194
gomega.Expect(utils.CheckAvalancheGoExists(binaryToVersion[utils.MultiAvago2Key])).Should(gomega.BeFalse())
@@ -205,7 +248,7 @@ var _ = ginkgo.Describe("[Package Management]", ginkgo.Ordered, func() {
205248
})
206249

207250
ginkgo.It("can deploy with multiple avalanchego versions SOV", func() {
208-
ginkgo.Skip("skipped until two consecutive avago version with fortuna support are available")
251+
ginkgo.Skip("this needs two avalanchego compatible at signature aggregation level, which currently is prone to issues")
209252
evmVersion := binaryToVersion[utils.MultiAvagoSubnetEVMKey]
210253
avagoVersion1 := binaryToVersion[utils.MultiAvago1Key]
211254
avagoVersion2 := binaryToVersion[utils.MultiAvago2Key]

tests/e2e/utils/versions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
"strconv"
1111
"sync"
1212

13-
"github.com/ava-labs/avalanche-cli/pkg/dependencies"
14-
1513
"github.com/ava-labs/avalanche-cli/pkg/application"
1614
"github.com/ava-labs/avalanche-cli/pkg/binutils"
1715
"github.com/ava-labs/avalanche-cli/pkg/constants"
16+
"github.com/ava-labs/avalanche-cli/pkg/dependencies"
1817
"github.com/ava-labs/avalanche-cli/pkg/models"
1918
"github.com/ava-labs/avalanchego/utils/logging"
19+
2020
"golang.org/x/mod/semver"
2121
)
2222

0 commit comments

Comments
 (0)