From 3ff2f756368f2d8ec0d1d9d25f6ba9cdabd7383e Mon Sep 17 00:00:00 2001 From: Balint Gabor Date: Thu, 13 Sep 2018 11:42:19 +0200 Subject: swarm: Chunk refactor (#17659) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Janos Guljas Co-authored-by: Balint Gabor Co-authored-by: Anton Evangelatov Co-authored-by: Viktor TrĂ³n --- cmd/swarm/hash.go | 2 +- cmd/swarm/swarm-smoke/main.go | 6 +++--- cmd/swarm/swarm-smoke/upload_and_sync.go | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'cmd') diff --git a/cmd/swarm/hash.go b/cmd/swarm/hash.go index bca4955b1..d679806e3 100644 --- a/cmd/swarm/hash.go +++ b/cmd/swarm/hash.go @@ -39,7 +39,7 @@ func hash(ctx *cli.Context) { defer f.Close() stat, _ := f.Stat() - fileStore := storage.NewFileStore(storage.NewMapChunkStore(), storage.NewFileStoreParams()) + fileStore := storage.NewFileStore(&storage.FakeChunkStore{}, storage.NewFileStoreParams()) addr, _, err := fileStore.Store(context.TODO(), f, stat.Size(), false) if err != nil { utils.Fatalf("%v\n", err) diff --git a/cmd/swarm/swarm-smoke/main.go b/cmd/swarm/swarm-smoke/main.go index 87bc39816..70aee1922 100644 --- a/cmd/swarm/swarm-smoke/main.go +++ b/cmd/swarm/swarm-smoke/main.go @@ -48,7 +48,7 @@ func main() { cli.StringFlag{ Name: "cluster-endpoint", Value: "testing", - Usage: "cluster to point to (open, or testing)", + Usage: "cluster to point to (local, open or testing)", Destination: &cluster, }, cli.IntFlag{ @@ -76,8 +76,8 @@ func main() { }, cli.IntFlag{ Name: "filesize", - Value: 1, - Usage: "file size for generated random file in MB", + Value: 1024, + Usage: "file size for generated random file in KB", Destination: &filesize, }, } diff --git a/cmd/swarm/swarm-smoke/upload_and_sync.go b/cmd/swarm/swarm-smoke/upload_and_sync.go index d5300b63d..5e0ff4b0f 100644 --- a/cmd/swarm/swarm-smoke/upload_and_sync.go +++ b/cmd/swarm/swarm-smoke/upload_and_sync.go @@ -39,6 +39,11 @@ import ( func generateEndpoints(scheme string, cluster string, from int, to int) { if cluster == "prod" { cluster = "" + } else if cluster == "local" { + for port := from; port <= to; port++ { + endpoints = append(endpoints, fmt.Sprintf("%s://localhost:%v", scheme, port)) + } + return } else { cluster = cluster + "." } @@ -53,13 +58,13 @@ func generateEndpoints(scheme string, cluster string, from int, to int) { } func cliUploadAndSync(c *cli.Context) error { - defer func(now time.Time) { log.Info("total time", "time", time.Since(now), "size", filesize) }(time.Now()) + defer func(now time.Time) { log.Info("total time", "time", time.Since(now), "size (kb)", filesize) }(time.Now()) generateEndpoints(scheme, cluster, from, to) log.Info("uploading to " + endpoints[0] + " and syncing") - f, cleanup := generateRandomFile(filesize * 1000000) + f, cleanup := generateRandomFile(filesize * 1000) defer cleanup() hash, err := upload(f, endpoints[0]) @@ -76,12 +81,7 @@ func cliUploadAndSync(c *cli.Context) error { log.Info("uploaded successfully", "hash", hash, "digest", fmt.Sprintf("%x", fhash)) - if filesize < 10 { - time.Sleep(35 * time.Second) - } else { - time.Sleep(15 * time.Second) - time.Sleep(2 * time.Duration(filesize) * time.Second) - } + time.Sleep(3 * time.Second) wg := sync.WaitGroup{} for _, endpoint := range endpoints { @@ -109,7 +109,7 @@ func cliUploadAndSync(c *cli.Context) error { // fetch is getting the requested `hash` from the `endpoint` and compares it with the `original` file func fetch(hash string, endpoint string, original []byte, ruid string) error { log.Trace("sleeping", "ruid", ruid) - time.Sleep(5 * time.Second) + time.Sleep(3 * time.Second) log.Trace("http get request", "ruid", ruid, "api", endpoint, "hash", hash) res, err := http.Get(endpoint + "/bzz:/" + hash + "/") -- cgit v1.2.3