Skip to content

Commit

Permalink
FAB-6193 Update dev environment to latest tools
Browse files Browse the repository at this point in the history
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 <gari.r.singh@gmail.com>
  • Loading branch information
mastersingh24 committed Sep 19, 2017
1 parent 3f83afc commit 0e5bec3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 37 deletions.
2 changes: 2 additions & 0 deletions core/scc/scc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package scc

import (
"fmt"
"os"
"testing"

"github.com/hyperledger/fabric/core/common/ccprovider"
Expand All @@ -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()
}
Expand Down
2 changes: 0 additions & 2 deletions devenv/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions devenv/install_nvm.sh
Original file line number Diff line number Diff line change
@@ -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
45 changes: 11 additions & 34 deletions devenv/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion orderer/common/server/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package server

import (
"os"
"path/filepath"
"testing"

config "github.com/hyperledger/fabric/orderer/common/localconfig"
Expand All @@ -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},
}

Expand Down

0 comments on commit 0e5bec3

Please sign in to comment.