From 9662e3bdecf0170c5681996eb48a4986ee9fa9bc Mon Sep 17 00:00:00 2001 From: PJ Date: Fri, 16 Aug 2024 10:28:08 +0200 Subject: [PATCH 1/6] testing: evaluate err of RHPForm --- .github/workflows/test.yml | 50 +++++++++++++++---------------- internal/test/e2e/cluster_test.go | 3 +- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99a409029..5b89e43e4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,34 +49,34 @@ jobs: host port: 3800 mysql version: '8' mysql root password: test - - name: Test Stores - uses: n8maninger/action-golang-test@v1 - with: - args: "-race;-short" - - name: Test Stores - MySQL - if: matrix.os == 'ubuntu-latest' - uses: n8maninger/action-golang-test@v1 - env: - RENTERD_DB_URI: 127.0.0.1:3800 - RENTERD_DB_USER: root - RENTERD_DB_PASSWORD: test - with: - package: "./stores" - args: "-race;-short" + # - name: Test Stores + # uses: n8maninger/action-golang-test@v1 + # with: + # args: "-race;-short" + # - name: Test Stores - MySQL + # if: matrix.os == 'ubuntu-latest' + # uses: n8maninger/action-golang-test@v1 + # env: + # RENTERD_DB_URI: 127.0.0.1:3800 + # RENTERD_DB_USER: root + # RENTERD_DB_PASSWORD: test + # with: + # package: "./stores" + # args: "-race;-short" - name: Test Integration uses: n8maninger/action-golang-test@v1 with: package: "./internal/test/e2e/..." - args: "-failfast;-race;-tags=testing;-timeout=60m" - - name: Test Integration - MySQL - if: matrix.os == 'ubuntu-latest' - uses: n8maninger/action-golang-test@v1 - env: - RENTERD_DB_URI: 127.0.0.1:3800 - RENTERD_DB_USER: root - RENTERD_DB_PASSWORD: test - with: - package: "./internal/test/e2e/..." - args: "-failfast;-race;-tags=testing;-timeout=60m" + args: "-failfast;-race;-tags=testing;-timeout=60m;-count=100;-run=TestContractApplyChainUpdates" + # - name: Test Integration - MySQL + # if: matrix.os == 'ubuntu-latest' + # uses: n8maninger/action-golang-test@v1 + # env: + # RENTERD_DB_URI: 127.0.0.1:3800 + # RENTERD_DB_USER: root + # RENTERD_DB_PASSWORD: test + # with: + # package: "./internal/test/e2e/..." + # args: "-failfast;-race;-tags=testing;-timeout=60m" - name: Build run: go build -o bin/ ./cmd/renterd diff --git a/internal/test/e2e/cluster_test.go b/internal/test/e2e/cluster_test.go index a410c892c..a92f8a36b 100644 --- a/internal/test/e2e/cluster_test.go +++ b/internal/test/e2e/cluster_test.go @@ -1090,7 +1090,8 @@ func TestContractApplyChainUpdates(t *testing.T) { // manually form a contract with the host cs, _ := b.ConsensusState(context.Background()) wallet, _ := b.Wallet(context.Background()) - rev, _, _ := w.RHPForm(context.Background(), cs.BlockHeight+test.AutopilotConfig.Contracts.Period+test.AutopilotConfig.Contracts.RenewWindow, h.PublicKey, h.NetAddress, wallet.Address, types.Siacoins(1), types.Siacoins(1)) + rev, _, err := w.RHPForm(context.Background(), cs.BlockHeight+test.AutopilotConfig.Contracts.Period+test.AutopilotConfig.Contracts.RenewWindow, h.PublicKey, h.NetAddress, wallet.Address, types.Siacoins(1), types.Siacoins(1)) + tt.OK(err) contract, err := b.AddContract(context.Background(), rev, rev.Revision.MissedHostPayout().Sub(types.Siacoins(1)), types.Siacoins(1), cs.BlockHeight, api.ContractStatePending) tt.OK(err) From 724b188c93a897ef3e2a7722348ba01dec4af157 Mon Sep 17 00:00:00 2001 From: PJ Date: Fri, 16 Aug 2024 14:21:17 +0200 Subject: [PATCH 2/6] testing: use buffered error channel --- internal/test/e2e/host.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/test/e2e/host.go b/internal/test/e2e/host.go index c6dd44381..e6867fa2c 100644 --- a/internal/test/e2e/host.go +++ b/internal/test/e2e/host.go @@ -174,7 +174,7 @@ func (h *Host) RHPv3Addr() string { // AddVolume adds a new volume to the host func (h *Host) AddVolume(ctx context.Context, path string, size uint64) error { - result := make(chan error) + result := make(chan error, 1) _, err := h.storage.AddVolume(ctx, path, size, result) if err != nil { return err From 594e43f97d202c20b998b64a14adaa3003bb10a1 Mon Sep 17 00:00:00 2001 From: PJ Date: Fri, 16 Aug 2024 14:59:24 +0200 Subject: [PATCH 3/6] testing: update retry interval --- internal/test/e2e/cluster.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/test/e2e/cluster.go b/internal/test/e2e/cluster.go index 2ac6e5a76..bf88f5eef 100644 --- a/internal/test/e2e/cluster.go +++ b/internal/test/e2e/cluster.go @@ -834,8 +834,8 @@ func (c *TestCluster) AddHost(h *Host) { c.tt.OK(addStorageFolderToHost(ctx, []*Host{h})) c.tt.OK(announceHosts([]*Host{h})) - // Mine a few blocks. The host should show up eventually. - c.tt.Retry(10, time.Second, func() error { + // Mine until the host shows up. + c.tt.Retry(100, 100*time.Millisecond, func() error { c.tt.Helper() _, err := c.Bus.Host(context.Background(), h.PublicKey()) From e621756ce12016852f875675343b1453d330cf7d Mon Sep 17 00:00:00 2001 From: PJ Date: Fri, 16 Aug 2024 15:25:22 +0200 Subject: [PATCH 4/6] debug: add logging --- internal/test/e2e/cluster_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/test/e2e/cluster_test.go b/internal/test/e2e/cluster_test.go index a92f8a36b..7c5a8543a 100644 --- a/internal/test/e2e/cluster_test.go +++ b/internal/test/e2e/cluster_test.go @@ -1091,6 +1091,22 @@ func TestContractApplyChainUpdates(t *testing.T) { cs, _ := b.ConsensusState(context.Background()) wallet, _ := b.Wallet(context.Background()) rev, _, err := w.RHPForm(context.Background(), cs.BlockHeight+test.AutopilotConfig.Contracts.Period+test.AutopilotConfig.Contracts.RenewWindow, h.PublicKey, h.NetAddress, wallet.Address, types.Siacoins(1), types.Siacoins(1)) + if err != nil { + sce, err := hosts[0].wallet.SpendableOutputs() + if err != nil { + panic(err) + } + t.Log("spendable outputs:") + for _, so := range sce { + t.Log(so) + } + bal, err := hosts[0].wallet.Balance() + if err != nil { + panic(err) + } + t.Log("balance:", bal) + t.Fatal(err) + } tt.OK(err) contract, err := b.AddContract(context.Background(), rev, rev.Revision.MissedHostPayout().Sub(types.Siacoins(1)), types.Siacoins(1), cs.BlockHeight, api.ContractStatePending) tt.OK(err) From e24629080165caab9639ce7e7314283a2552c060 Mon Sep 17 00:00:00 2001 From: PJ Date: Fri, 16 Aug 2024 15:40:54 +0200 Subject: [PATCH 5/6] testing: make sure host has multiple spendable outputs --- internal/test/e2e/cluster.go | 6 ++++-- internal/test/e2e/cluster_test.go | 16 ---------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/internal/test/e2e/cluster.go b/internal/test/e2e/cluster.go index bf88f5eef..3e01e8ae7 100644 --- a/internal/test/e2e/cluster.go +++ b/internal/test/e2e/cluster.go @@ -812,8 +812,10 @@ func (c *TestCluster) AddHost(h *Host) { c.hosts = append(c.hosts, h) // Fund host from bus. - fundAmt := types.Siacoins(25e3) - c.tt.OKAll(c.Bus.SendSiacoins(context.Background(), h.WalletAddress(), fundAmt, true)) + fundAmt := types.Siacoins(5e3) + for i := 0; i < 5; i++ { + c.tt.OKAll(c.Bus.SendSiacoins(context.Background(), h.WalletAddress(), fundAmt, true)) + } // Mine transaction. c.MineBlocks(1) diff --git a/internal/test/e2e/cluster_test.go b/internal/test/e2e/cluster_test.go index 7c5a8543a..a92f8a36b 100644 --- a/internal/test/e2e/cluster_test.go +++ b/internal/test/e2e/cluster_test.go @@ -1091,22 +1091,6 @@ func TestContractApplyChainUpdates(t *testing.T) { cs, _ := b.ConsensusState(context.Background()) wallet, _ := b.Wallet(context.Background()) rev, _, err := w.RHPForm(context.Background(), cs.BlockHeight+test.AutopilotConfig.Contracts.Period+test.AutopilotConfig.Contracts.RenewWindow, h.PublicKey, h.NetAddress, wallet.Address, types.Siacoins(1), types.Siacoins(1)) - if err != nil { - sce, err := hosts[0].wallet.SpendableOutputs() - if err != nil { - panic(err) - } - t.Log("spendable outputs:") - for _, so := range sce { - t.Log(so) - } - bal, err := hosts[0].wallet.Balance() - if err != nil { - panic(err) - } - t.Log("balance:", bal) - t.Fatal(err) - } tt.OK(err) contract, err := b.AddContract(context.Background(), rev, rev.Revision.MissedHostPayout().Sub(types.Siacoins(1)), types.Siacoins(1), cs.BlockHeight, api.ContractStatePending) tt.OK(err) From 5ec92d0b38a776d9459fc744128f224fc4013fee Mon Sep 17 00:00:00 2001 From: PJ Date: Fri, 16 Aug 2024 15:56:39 +0200 Subject: [PATCH 6/6] testing: undo loop --- .github/workflows/test.yml | 50 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b89e43e4..99a409029 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,34 +49,34 @@ jobs: host port: 3800 mysql version: '8' mysql root password: test - # - name: Test Stores - # uses: n8maninger/action-golang-test@v1 - # with: - # args: "-race;-short" - # - name: Test Stores - MySQL - # if: matrix.os == 'ubuntu-latest' - # uses: n8maninger/action-golang-test@v1 - # env: - # RENTERD_DB_URI: 127.0.0.1:3800 - # RENTERD_DB_USER: root - # RENTERD_DB_PASSWORD: test - # with: - # package: "./stores" - # args: "-race;-short" + - name: Test Stores + uses: n8maninger/action-golang-test@v1 + with: + args: "-race;-short" + - name: Test Stores - MySQL + if: matrix.os == 'ubuntu-latest' + uses: n8maninger/action-golang-test@v1 + env: + RENTERD_DB_URI: 127.0.0.1:3800 + RENTERD_DB_USER: root + RENTERD_DB_PASSWORD: test + with: + package: "./stores" + args: "-race;-short" - name: Test Integration uses: n8maninger/action-golang-test@v1 with: package: "./internal/test/e2e/..." - args: "-failfast;-race;-tags=testing;-timeout=60m;-count=100;-run=TestContractApplyChainUpdates" - # - name: Test Integration - MySQL - # if: matrix.os == 'ubuntu-latest' - # uses: n8maninger/action-golang-test@v1 - # env: - # RENTERD_DB_URI: 127.0.0.1:3800 - # RENTERD_DB_USER: root - # RENTERD_DB_PASSWORD: test - # with: - # package: "./internal/test/e2e/..." - # args: "-failfast;-race;-tags=testing;-timeout=60m" + args: "-failfast;-race;-tags=testing;-timeout=60m" + - name: Test Integration - MySQL + if: matrix.os == 'ubuntu-latest' + uses: n8maninger/action-golang-test@v1 + env: + RENTERD_DB_URI: 127.0.0.1:3800 + RENTERD_DB_USER: root + RENTERD_DB_PASSWORD: test + with: + package: "./internal/test/e2e/..." + args: "-failfast;-race;-tags=testing;-timeout=60m" - name: Build run: go build -o bin/ ./cmd/renterd