@@ -39,6 +39,11 @@ import (
3939)
4040
4141func uploadAndSyncCmd (ctx * cli.Context , tuid string ) error {
42+ // use input seed if it has been set
43+ if inputSeed != 0 {
44+ seed = inputSeed
45+ }
46+
4247 randomBytes := testutil .RandomBytes (seed , filesize * 1000 )
4348
4449 errc := make (chan error )
@@ -47,37 +52,28 @@ func uploadAndSyncCmd(ctx *cli.Context, tuid string) error {
4752 errc <- uploadAndSync (ctx , randomBytes , tuid )
4853 }()
4954
55+ var err error
5056 select {
51- case err : = <- errc :
57+ case err = <- errc :
5258 if err != nil {
5359 metrics .GetOrRegisterCounter (fmt .Sprintf ("%s.fail" , commandName ), nil ).Inc (1 )
5460 }
55- return err
5661 case <- time .After (time .Duration (timeout ) * time .Second ):
5762 metrics .GetOrRegisterCounter (fmt .Sprintf ("%s.timeout" , commandName ), nil ).Inc (1 )
5863
59- e := fmt .Errorf ("timeout after %v sec" , timeout )
60- // trigger debug functionality on randomBytes
61- err := trackChunks (randomBytes [:])
62- if err != nil {
63- e = fmt .Errorf ("%v; triggerChunkDebug failed: %v" , e , err )
64- }
65-
66- return e
64+ err = fmt .Errorf ("timeout after %v sec" , timeout )
6765 }
6866
69- // trigger debug functionality on randomBytes even on successful runs
70- err := trackChunks (randomBytes [:])
71- if err != nil {
72- log .Error (err .Error ())
67+ // trigger debug functionality on randomBytes
68+ e := trackChunks (randomBytes [:])
69+ if e != nil {
70+ log .Error (e .Error ())
7371 }
7472
75- return nil
73+ return err
7674}
7775
7876func trackChunks (testData []byte ) error {
79- log .Warn ("Test timed out, running chunk debug sequence" )
80-
8177 addrs , err := getAllRefs (testData )
8278 if err != nil {
8379 return err
@@ -94,14 +90,14 @@ func trackChunks(testData []byte) error {
9490
9591 rpcClient , err := rpc .Dial (httpHost )
9692 if err != nil {
97- log .Error ("Error dialing host" , "err" , err )
93+ log .Error ("error dialing host" , "err" , err , "host" , httpHost )
9894 continue
9995 }
10096
10197 var hasInfo []api.HasInfo
10298 err = rpcClient .Call (& hasInfo , "bzz_has" , addrs )
10399 if err != nil {
104- log .Error ("Error calling host " , "err" , err )
100+ log .Error ("error calling rpc client " , "err" , err , "host" , httpHost )
105101 continue
106102 }
107103
@@ -125,7 +121,6 @@ func trackChunks(testData []byte) error {
125121}
126122
127123func getAllRefs (testData []byte ) (storage.AddressCollection , error ) {
128- log .Trace ("Getting all references for given root hash" )
129124 datadir , err := ioutil .TempDir ("" , "chunk-debug" )
130125 if err != nil {
131126 return nil , fmt .Errorf ("unable to create temp dir: %v" , err )
0 commit comments