From 0e5bec33b2d442b701fbb9858e8db136f10544e5 Mon Sep 17 00:00:00 2001 From: Gari Singh Date: Sun, 17 Sep 2017 17:13:13 -0400 Subject: [PATCH] FAB-6193 Update dev environment to latest tools The versions of many tools have been upgraded for the master branch. The following updates were made: - Update to Go 1.9 - Update to the official Docker repo (for now this will install 17.06.2-ce) - Remove out of date Docker config options - Use nvm to manage multiple versions of Node.js (8.4 is the default but 6.9.5 is also installed) - modified a few test files to use the os.TempDir() rather than relative paths in the source tree as Go 1.9 did not like it with Vagrant and VirtualBox Change-Id: I3140790f420da8dddb7ac3c2630c948962649fbd Signed-off-by: Gari Singh --- core/scc/scc_test.go | 2 ++ devenv/Vagrantfile | 2 -- devenv/install_nvm.sh | 24 ++++++++++++++++ devenv/setup.sh | 45 ++++++++---------------------- orderer/common/server/util_test.go | 3 +- 5 files changed, 39 insertions(+), 37 deletions(-) create mode 100755 devenv/install_nvm.sh diff --git a/core/scc/scc_test.go b/core/scc/scc_test.go index 95f16d359cd..53726fa90c1 100644 --- a/core/scc/scc_test.go +++ b/core/scc/scc_test.go @@ -18,6 +18,7 @@ package scc import ( "fmt" + "os" "testing" "github.com/hyperledger/fabric/core/common/ccprovider" @@ -30,6 +31,7 @@ import ( func init() { viper.Set("chaincode.system", map[string]string{"lscc": "enable", "a": "enable"}) + viper.Set("peer.fileSystemPath", os.TempDir()) ccprovider.RegisterChaincodeProviderFactory(&ccprovider2.MockCcProviderFactory{}) RegisterSysCCs() } diff --git a/devenv/Vagrantfile b/devenv/Vagrantfile index d704725f2f0..fcb6d798361 100644 --- a/devenv/Vagrantfile +++ b/devenv/Vagrantfile @@ -25,8 +25,6 @@ set -x echo "127.0.0.1 couchdb" | tee -a /etc/hosts -export DOCKER_STORAGE_BACKEND="#{ENV['DOCKER_STORAGE_BACKEND']}" - cd #{SRCMOUNT}/devenv ./setup.sh diff --git a/devenv/install_nvm.sh b/devenv/install_nvm.sh new file mode 100755 index 00000000000..0dc00d2bbd2 --- /dev/null +++ b/devenv/install_nvm.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Copyright IBM Corp. All Rights Reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# + + +set -e +set -x + +# ---------------------------------------------------------------- +# Install nvm to manage multiple NodeJS versions +# ---------------------------------------------------------------- +curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm + +# ---------------------------------------------------------------- +# Install NodeJS +# ---------------------------------------------------------------- +nvm install v6.9.5 +nvm install v8.4 +nvm alias default v8.4 #set default to v8.4 diff --git a/devenv/setup.sh b/devenv/setup.sh index 28db8381ecb..bef258131a8 100755 --- a/devenv/setup.sh +++ b/devenv/setup.sh @@ -28,50 +28,30 @@ apt-get install -y build-essential git make curl unzip g++ libtool # Install Docker # ---------------------------------------------------------------- -# Storage backend logic -case "${DOCKER_STORAGE_BACKEND}" in - aufs|AUFS|"") - DOCKER_STORAGE_BACKEND_STRING="aufs" ;; - btrfs|BTRFS) - # mkfs - apt-get install -y btrfs-tools - mkfs.btrfs -f /dev/sdb - rm -Rf /var/lib/docker - mkdir -p /var/lib/docker - . <(sudo blkid -o udev /dev/sdb) - echo "UUID=${ID_FS_UUID} /var/lib/docker btrfs defaults 0 0" >> /etc/fstab - mount /var/lib/docker - - DOCKER_STORAGE_BACKEND_STRING="btrfs" ;; - *) echo "Unknown storage backend ${DOCKER_STORAGE_BACKEND}" - exit 1;; -esac - # Update system apt-get update -qq # Prep apt-get for docker install apt-get install -y apt-transport-https ca-certificates -apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - # Add docker repository -echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list +add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) \ + stable" # Update system apt-get update -qq # Install docker -apt-get install -y linux-image-extra-$(uname -r) apparmor docker-engine +#apt-get install -y docker-ce=17.06.2~ce~0~ubuntu # in case we need to set the version +apt-get install -y docker-ce # Install docker-compose -curl -L https://github.com/docker/compose/releases/download/1.8.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose +curl -L https://github.com/docker/compose/releases/download/1.14.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose -# Configure docker -DOCKER_OPTS="-s=${DOCKER_STORAGE_BACKEND_STRING} -r=true --api-cors-header='*' -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock ${DOCKER_OPTS}" -sed -i.bak '/^DOCKER_OPTS=/{h;s|=.*|=\"'"${DOCKER_OPTS}"'\"|};${x;/^$/{s||DOCKER_OPTS=\"'"${DOCKER_OPTS}"'\"|;H};x}' /etc/default/docker - -service docker restart usermod -a -G docker ubuntu # Add ubuntu user to the docker group # Test docker @@ -80,7 +60,7 @@ docker run --rm busybox echo All good # ---------------------------------------------------------------- # Install Golang # ---------------------------------------------------------------- -GO_VER=1.7.5 +GO_VER=1.9 GO_URL=https://storage.googleapis.com/golang/go${GO_VER}.linux-amd64.tar.gz # Set Go environment variables needed by other scripts @@ -99,12 +79,9 @@ mkdir -p $GOROOT curl -sL $GO_URL | (cd $GOROOT && tar --strip-components 1 -xz) # ---------------------------------------------------------------- -# Install NodeJS +# Install nvm and Node.js # ---------------------------------------------------------------- -NODE_VER=6.9.5 -NODE_URL=https://nodejs.org/dist/v$NODE_VER/node-v$NODE_VER-linux-x64.tar.gz - -curl -sL $NODE_URL | (cd /usr/local && tar --strip-components 1 -xz ) +runuser -l ubuntu -c '/hyperledger/devenv/install_nvm.sh' # ---------------------------------------------------------------- # Install Behave diff --git a/orderer/common/server/util_test.go b/orderer/common/server/util_test.go index 13148cb6226..ec50eb87171 100644 --- a/orderer/common/server/util_test.go +++ b/orderer/common/server/util_test.go @@ -8,6 +8,7 @@ package server import ( "os" + "path/filepath" "testing" config "github.com/hyperledger/fabric/orderer/common/localconfig" @@ -25,7 +26,7 @@ func TestCreateLedgerFactory(t *testing.T) { {"RAM", "ram", "", "", false}, {"JSONwithPathSet", "json", "test-dir", "", false}, {"JSONwithPathUnset", "json", "", "test-prefix", false}, - {"FilewithPathSet", "file", "test-dir", "", false}, + {"FilewithPathSet", "file", filepath.Join(os.TempDir(), "test-dir"), "", false}, {"FilewithPathUnset", "file", "", "test-prefix", false}, }