Skip to content

Commit

Permalink
debug: run TestUploadDownloadSpending in loop on dev
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Oct 30, 2024
1 parent e528e95 commit 2fc01a2
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 26 deletions.
50 changes: 25 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,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;-tags=netgo"
- 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;-tags=netgo"
# - name: Test Stores
# uses: n8maninger/action-golang-test@v1
# with:
# args: "-race;-short;-tags=netgo"
# - 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;-tags=netgo"
- name: Test Integration
uses: n8maninger/action-golang-test@v1
with:
package: "./internal/test/e2e/..."
args: "-failfast;-race;-timeout=60m;-tags=netgo"
- 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;-timeout=60m;-tags=netgo"
args: "-failfast;-race;-timeout=60m;-tags=netgo;-count=50;-run=^TestUploadDownloadExtended$"
# - 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;-timeout=60m;-tags=netgo"
- name: Build
run: go build -o bin/ -tags='netgo timetzdata' ./cmd/renterd
10 changes: 10 additions & 0 deletions internal/test/e2e/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,11 @@ func announceHosts(hosts []*Host) error {
// MineToRenewWindow is a helper which mines enough blocks for the autopilot to
// reach its renew window.
func (c *TestCluster) MineToRenewWindow() {
start := time.Now()
defer func() {
fmt.Printf("DEBUG %v | CLUSTER: MineToRenewWindow took %v\n", time.Now().Format(time.TimeOnly), time.Since(start))
}()

c.tt.Helper()
cs, err := c.Bus.ConsensusState(context.Background())
c.tt.OK(err)
Expand All @@ -692,6 +697,11 @@ func (c *TestCluster) MineBlocks(n uint64) {
}

func (c *TestCluster) sync() {
start := time.Now()
defer func() {
fmt.Printf("DEBUG %v | CLUSTER: sync took %v\n", time.Now().Format(time.TimeOnly), time.Since(start))
}()

tip := c.cm.Tip()
c.tt.Retry(3000, time.Millisecond, func() error {
cs, err := c.Bus.ConsensusState(context.Background())
Expand Down
10 changes: 10 additions & 0 deletions worker/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"errors"
"fmt"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -127,6 +128,15 @@ func (d *downloader) estimate() float64 {
}

func (d *downloader) execute(req *sectorDownloadReq) (err error) {
start := time.Now()
defer func() {
if err == nil {
fmt.Printf("DEBUG %v | HOST: read sector took %v\n", time.Now().Format(time.TimeOnly), time.Since(start))
} else {
fmt.Printf("DEBUG %v | HOST: read sector took %v, failed with %v\n", time.Now().Format(time.TimeOnly), time.Since(start), err)
}
}()

// download the sector
buf := bytes.NewBuffer(make([]byte, 0, req.length))
err = d.host.DownloadSector(req.ctx, buf, req.root, req.offset, req.length, req.overpay)
Expand Down
11 changes: 10 additions & 1 deletion worker/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ func (u *uploader) estimate() float64 {
// execute executes the sector upload request, if the upload was successful it
// returns the time it took to upload the sector to the host
func (u *uploader) execute(req *sectorUploadReq) (_ time.Duration, err error) {
start := time.Now()
defer func() {
if err == nil {
fmt.Printf("DEBUG %v | HOST: write sector took %v\n", time.Now().Format(time.TimeOnly), time.Since(start))
} else {
fmt.Printf("DEBUG %v | HOST: write sector took %v, failed with %v\n", time.Now().Format(time.TimeOnly), time.Since(start), err)
}
}()

// grab fields
u.mu.Lock()
host := u.host
Expand Down Expand Up @@ -298,7 +307,7 @@ func (u *uploader) execute(req *sectorUploadReq) (_ time.Duration, err error) {
}

// upload the sector
start := time.Now()
start = time.Now()
err = host.UploadSector(ctx, req.sector.root, req.sector.sectorData(), rev)
if err != nil {
return 0, fmt.Errorf("failed to upload sector to contract %v; %w", fcid, err)
Expand Down

0 comments on commit 2fc01a2

Please sign in to comment.