From c08ca361d83b252da8ba466896f23fdc6dddc1d9 Mon Sep 17 00:00:00 2001 From: Yaroslav Vorobiov Date: Thu, 13 May 2021 20:05:49 +0300 Subject: [PATCH] cmd/storj-sim: add multinode process Change-Id: I7e6c8db045daa87c5d89f49e58fc82453d4024c6 --- Makefile | 3 ++- cmd/storj-sim/network.go | 21 +++++++++++++++++++++ multinode/console/server/server.go | 2 +- scripts/test-sim-backwards.sh | 7 +++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 18597ee52..0661d4721 100644 --- a/Makefile +++ b/Makefile @@ -88,7 +88,8 @@ install-sim: ## install storj-sim storj.io/storj/cmd/versioncontrol \ storj.io/storj/cmd/uplink \ storj.io/storj/cmd/identity \ - storj.io/storj/cmd/certificates + storj.io/storj/cmd/certificates \ + storj.io/storj/cmd/multinode ## install exact version of storj/gateway ## TODO replace 'main' with 'latest' when gateway with multipart will be released diff --git a/cmd/storj-sim/network.go b/cmd/storj-sim/network.go index 4b917a2c9..07825fb2f 100644 --- a/cmd/storj-sim/network.go +++ b/cmd/storj-sim/network.go @@ -56,6 +56,7 @@ const ( gatewayPeer = 1 versioncontrolPeer = 2 storagenodePeer = 3 + multinodePeer = 5 // Endpoints. publicRPC = 0 @@ -620,6 +621,26 @@ func newNetwork(flags *Flags) (*Processes, error) { } } + { // setup multinode + process := processes.New(Info{ + Name: fmt.Sprintf("multinode/%d", 0), + Executable: "multinode", + Directory: filepath.Join(processes.Directory, "multinode", fmt.Sprint(0)), + }) + + process.Arguments = withCommon(process.Directory, Arguments{ + "setup": { + "--identity-dir", process.Directory, + "--console.address", net.JoinHostPort(host, port(multinodePeer, 0, publicHTTP)), + "--console.static-dir", filepath.Join(storjRoot, "web/multinode/"), + "--debug.addr", net.JoinHostPort(host, port(multinodePeer, 0, debugHTTP)), + }, + "run": {}, + }) + + process.AddExtra("SETUP_ARGS", strings.Join(process.Arguments["setup"], " ")) + } + { // verify that we have all binaries missing := map[string]bool{} for _, process := range processes.List { diff --git a/multinode/console/server/server.go b/multinode/console/server/server.go index ae2e15f9c..6db5955fa 100644 --- a/multinode/console/server/server.go +++ b/multinode/console/server/server.go @@ -146,5 +146,5 @@ func (server *Server) initializeTemplates() (err error) { server.log.Error("dist folder is not generated. use 'npm run build' command", zap.Error(err)) } - return err + return nil } diff --git a/scripts/test-sim-backwards.sh b/scripts/test-sim-backwards.sh index 3403914f8..b46096be3 100755 --- a/scripts/test-sim-backwards.sh +++ b/scripts/test-sim-backwards.sh @@ -123,6 +123,13 @@ if [ ! -f "$REDIS_CONFIG" ] ; then } >> "$REDIS_CONFIG" fi +# setup multinode if config is missing +MULTINODE_DIR=$(storj-sim network env MULTINODE_0_DIR) +if [ ! -f "$MULTINODE_DIR/config.yaml" ]; then + identity --identity-dir $MULTINODE_DIR --concurrency 1 --difficulty 8 create . + multinode $(storj-sim --host "$STORJ_NETWORK_HOST4" network env MULTINODE_0_SETUP_ARGS) +fi + # keep half of the storage nodes on the old version ln "$RELEASE_DIR"/bin/storagenode "$(storj-sim network env STORAGENODE_0_DIR)"/storagenode ln "$RELEASE_DIR"/bin/storagenode "$(storj-sim network env STORAGENODE_1_DIR)"/storagenode