mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/swarm/swarm-smoke: fix fail condition
This commit is contained in:
parent
c481bcc75d
commit
c6cd410760
1 changed files with 9 additions and 7 deletions
|
|
@ -86,24 +86,26 @@ outer:
|
||||||
hashes = append(hashes, uploadResult{hash: hash, digest: fhash})
|
hashes = append(hashes, uploadResult{hash: hash, digest: fhash})
|
||||||
time.Sleep(time.Duration(syncDelay) * time.Second)
|
time.Sleep(time.Duration(syncDelay) * time.Second)
|
||||||
uploadedBytes += filesize * 1000
|
uploadedBytes += filesize * 1000
|
||||||
c := make(chan struct{}, 1)
|
q := make(chan struct{}, 1)
|
||||||
d := make(chan struct{})
|
d := make(chan struct{})
|
||||||
defer close(c)
|
defer close(q)
|
||||||
defer close(d)
|
defer close(d)
|
||||||
for i, v := range hashes {
|
for i, v := range hashes {
|
||||||
timeout := time.After(time.Duration(timeout) * time.Second)
|
timeoutC := time.After(time.Duration(timeout) * time.Second)
|
||||||
errored = false
|
errored = false
|
||||||
|
|
||||||
task:
|
task:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case c <- struct{}{}:
|
case q <- struct{}{}:
|
||||||
go func() {
|
go func() {
|
||||||
|
var start time.Time
|
||||||
inner:
|
inner:
|
||||||
for {
|
for {
|
||||||
log.Info("trying to retrieve hash", "hash", v.hash)
|
log.Info("trying to retrieve hash", "hash", v.hash)
|
||||||
idx := 1 + rand.Intn(len(hosts)-1)
|
idx := 1 + rand.Intn(len(hosts)-1)
|
||||||
ruid := uuid.New()[:8]
|
ruid := uuid.New()[:8]
|
||||||
|
start = time.Now()
|
||||||
// fetch hangs when swarm dies out, so we have to jump through a bit more hoops to actually
|
// fetch hangs when swarm dies out, so we have to jump through a bit more hoops to actually
|
||||||
// catch the timeout, but also allow this retry logic
|
// catch the timeout, but also allow this retry logic
|
||||||
err := fetch(v.hash, httpEndpoint(hosts[idx]), v.digest, ruid, "")
|
err := fetch(v.hash, httpEndpoint(hosts[idx]), v.digest, ruid, "")
|
||||||
|
|
@ -116,13 +118,13 @@ outer:
|
||||||
d <- struct{}{}
|
d <- struct{}{}
|
||||||
}()
|
}()
|
||||||
case <-d:
|
case <-d:
|
||||||
<-c
|
<-q
|
||||||
break task
|
break task
|
||||||
case <-timeout:
|
case <-timeoutC:
|
||||||
errored = true
|
errored = true
|
||||||
log.Error("error retrieving hash. timeout", "hash idx", i, "err", err)
|
log.Error("error retrieving hash. timeout", "hash idx", i, "err", err)
|
||||||
metrics.GetOrRegisterCounter("sliding-window.single.error", nil).Inc(1)
|
metrics.GetOrRegisterCounter("sliding-window.single.error", nil).Inc(1)
|
||||||
break task
|
break outer
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue