Skip to content

Commit

Permalink
[FAB-3604] e2e_cli sample improvements
Browse files Browse the repository at this point in the history
Covers the following :
1. Use cryptogen tool to generate org certificates for each run.

2. Make a generic docker-compose base file
   a. A docker-compose-cli.yaml extends the base and includes a cli
      container to run e2e test
   b. A docker-compose-e2e.yaml extends the base and includes
      fabric-ca container.(can be used for SDK or other tests)

3. A timer flag in docker-compose CLI container to stop killing CLI
   container

NOTE: A docker-compose-e2e-template.yaml also included. This is required
      to generate docker-compose-e2e.yaml, as we need to replace the
      private key dyamically.

USAGE:
	./network_setup.sh <up|down|restart> [channel] [CLI timeout in sec]

Ex:
	./network_setup.sh up mychannel 10
	This starts CLI with channelname mychannel, CLI timeout set to 10s

	./network_setup.sh down
	Shutdown the network and clear all the artifacts.

	./network_setup.sh restart xyz 10
	restarts the network.

Change-Id: I9bc80c0ad0e4dc259383038e7f69e3239a9409f3
Signed-off-by: ratnakar <asara.ratnakar@gmail.com>
  • Loading branch information
asararatnakar committed May 4, 2017
1 parent eff8380 commit 9937c36
Show file tree
Hide file tree
Showing 57 changed files with 628 additions and 853 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ report.xml
.gradle
build/
bin/
examples/e2e_cli/channel-artifacts/*.tx
examples/e2e_cli/channel-artifacts/*.block
examples/e2e_cli/crypto-config/*
157 changes: 157 additions & 0 deletions examples/e2e_cli/base/docker-compose-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
version: '2'

services:

orderer.example.com:
container_name: orderer.example.com
image: hyperledger/fabric-orderer
environment:
- ORDERER_GENERAL_LOGLEVEL=debug
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENERAL_GENESISMETHOD=file
- ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP
- ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
# enabled TLS
- ORDERER_GENERAL_TLS_ENABLED=true
- ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
- ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
- ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: orderer
volumes:
- ../channel-artifacts/orderer.genesis.block:/var/hyperledger/orderer/orderer.genesis.block
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
ports:
- 7050:7050

## To enable CouchDB as state database, uncomment the following sections of this file:
## 1) couchdb containers
## 2) peer environment variables CORE_LEDGER_STATE_STATEDATABASE and
## CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS
## 3) couch container names in "depends_on" section

# couchdb0:
# container_name: couchdb0
# image: hyperledger/fabric-couchdb
## Uncomment the port mapping if you want to expose the CouchDB service,
## for example to utilize Fauxton User Interface in dev environments.
# ports:
# - "5984:5984"

peer0.org1.example.com:
container_name: peer0.org1.example.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer0.org1.example.com
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
# - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
# - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
volumes:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
ports:
- 7051:7051
- 7053:7053
#depends_on:
# - couchdb0

# couchdb1:
# container_name: couchdb1
# image: hyperledger/fabric-couchdb
## Uncomment the port mapping if you want to expose the CouchDB service,
## for example to utilize Fauxton User Interface in dev environments.
# ports:
# - "6984:5984"

peer1.org1.example.com:
container_name: peer1.org1.example.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer1.org1.example.com
- CORE_PEER_ADDRESS=peer1.org1.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
# - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
# - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
volumes:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls

ports:
- 8051:7051
- 8053:7053
#depends_on:
# - couchdb1

# couchdb2:
# container_name: couchdb2
# image: hyperledger/fabric-couchdb
## Uncomment the port mapping if you want to expose the CouchDB service,
## for example to utilize Fauxton User Interface in dev environments.
# ports:
# - "7984:5984"

peer0.org2.example.com:
container_name: peer0.org2.example.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer0.org2.example.com
- CORE_PEER_ADDRESS=peer0.org2.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051
- CORE_PEER_LOCALMSPID=Org2MSP
# - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
# - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984
volumes:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
ports:
- 9051:7051
- 9053:7053
#depends_on:
# - couchdb2

# couchdb3:
# container_name: couchdb3
# image: hyperledger/fabric-couchdb
## Uncomment the port mapping if you want to expose the CouchDB service,
## for example to utilize Fauxton User Interface in dev environments.
# ports:
# - "8984:5984"

peer1.org2.example.com:
container_name: peer1.org2.example.com
extends:
file: peer-base.yaml
service: peer-base
environment:
- CORE_PEER_ID=peer1.org2.example.com
- CORE_PEER_ADDRESS=peer1.org2.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.example.com:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051
- CORE_PEER_LOCALMSPID=Org2MSP
# - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
# - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb3:5984
volumes:
- /var/run/:/host/var/run/
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp
- ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
ports:
- 10051:7051
- 10053:7053
#depends_on:
# - couchdb3
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ services:
peer-base:
image: hyperledger/fabric-peer
environment:
#- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
# the following setting starts chaincode containers on the same
# bridge network as the peers
Expand All @@ -12,13 +11,15 @@ services:
#- CORE_LOGGING_LEVEL=ERROR
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_TLS_ENABLED=true
- CORE_NEXT=true
- CORE_PEER_ENDORSER_ENABLED=true
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false
# The following setting skips the gossip handshake since we are
# are not doing mutual TLS
- CORE_PEER_GOSSIP_SKIPHANDSHAKE=true
- CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start --peer-defaultchain=false
Empty file.
43 changes: 14 additions & 29 deletions examples/e2e_cli/configtx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Profiles:
Consortiums:
SampleConsortium:
Organizations:
- *Org0
- *Org1
- *Org2
TwoOrgsChannel:
Consortium: SampleConsortium
Application:
<<: *ApplicationDefaults
Organizations:
- *Org0
- *Org1
- *Org2

################################################################################
#
Expand All @@ -48,12 +48,7 @@ Organizations:
ID: OrdererMSP

# MSPDir is the filesystem path which contains the MSP configuration
MSPDir: crypto/orderer/localMspConfig

# AdminPrincipal dictates the type of principal used for an organization's Admins policy
# Today, only the values of Role.ADMIN ad Role.MEMBER are accepted, which indicates a principal
# of role type ADMIN and role type MEMBER respectively
AdminPrincipal: Role.MEMBER
MSPDir: crypto-config/ordererOrganizations/example.com/msp

# BCCSP (Blockchain crypto provider): Select which crypto implementation or
# library to use
Expand All @@ -67,20 +62,15 @@ Organizations:
FileKeyStore:
KeyStore:

- &Org0
- &Org1
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: Org0MSP
Name: Org1MSP

# ID to load the MSP definition as
ID: Org0MSP

MSPDir: crypto/peer/peer0/localMspConfig
ID: Org1MSP

# AdminPrincipal dictates the type of principal used for an organization's Admins policy
# Today, only the values of Role.ADMIN ad Role.MEMBER are accepted, which indicates a principal
# of role type ADMIN and role type MEMBER respectively
AdminPrincipal: Role.MEMBER
MSPDir: crypto-config/peerOrganizations/org1.example.com/msp

# BCCSP (Blockchain crypto provider): Select which crypto implementation or
# library to use
Expand All @@ -98,23 +88,18 @@ Organizations:
# AnchorPeers defines the location of peers which can be used
# for cross org gossip communication. Note, this value is only
# encoded in the genesis block in the Application section context
- Host: peer0
- Host: peer0.org1.example.com
Port: 7051

- &Org1
- &Org2
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: Org1MSP
Name: Org2MSP

# ID to load the MSP definition as
ID: Org1MSP

MSPDir: crypto/peer/peer2/localMspConfig
ID: Org2MSP

# AdminPrincipal dictates the type of principal used for an organization's Admins policy
# Today, only the values of Role.ADMIN ad Role.MEMBER are accepted, which indicates a principal
# of role type ADMIN and role type MEMBER respectively
AdminPrincipal: Role.MEMBER
MSPDir: crypto-config/peerOrganizations/org2.example.com/msp

# BCCSP (Blockchain crypto provider): Select which crypto implementation or
# library to use
Expand All @@ -132,7 +117,7 @@ Organizations:
# AnchorPeers defines the location of peers which can be used
# for cross org gossip communication. Note, this value is only
# encoded in the genesis block in the Application section context
- Host: peer2
- Host: peer0.org2.example.com
Port: 7051

################################################################################
Expand All @@ -150,7 +135,7 @@ Orderer: &OrdererDefaults
OrdererType: solo

Addresses:
- orderer0:7050
- orderer.example.com:7050

# Batch Timeout: The amount of time to wait before creating a batch
BatchTimeout: 2s
Expand Down
76 changes: 76 additions & 0 deletions examples/e2e_cli/crypto-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# ---------------------------------------------------------------------------
# "OrdererOrgs" - Definition of organizations managing orderer nodes
# ---------------------------------------------------------------------------
OrdererOrgs:
# ---------------------------------------------------------------------------
# Orderer
# ---------------------------------------------------------------------------
- Name: Orderer
Domain: example.com
# ---------------------------------------------------------------------------
# "Specs" - See PeerOrgs below for complete description
# ---------------------------------------------------------------------------
Specs:
- Hostname: orderer
# ---------------------------------------------------------------------------
# "PeerOrgs" - Definition of organizations managing peer nodes
# ---------------------------------------------------------------------------
PeerOrgs:
# ---------------------------------------------------------------------------
# Org1
# ---------------------------------------------------------------------------
- Name: Org1
Domain: org1.example.com
# ---------------------------------------------------------------------------
# "Specs"
# ---------------------------------------------------------------------------
# Uncomment this section to enable the explicit definition of hosts in your
# configuration. Most users will want to use Template, below
#
# Specs is an array of Spec entries. Each Spec entry consists of two fields:
# - Hostname: (Required) The desired hostname, sans the domain.
# - CommonName: (Optional) Specifies the template or explicit override for
# the CN. By default, this is the template:
#
# "{{.Hostname}}.{{.Domain}}"
#
# which obtains its values from the Spec.Hostname and
# Org.Domain, respectively.
# ---------------------------------------------------------------------------
# Specs:
# - Hostname: foo # implicitly "foo.org1.example.com"
# CommonName: foo27.org5.example.com # overrides Hostname-based FQDN set above
# - Hostname: bar
# - Hostname: baz
# ---------------------------------------------------------------------------
# "Template"
# ---------------------------------------------------------------------------
# Allows for the definition of 1 or more hosts that are created sequentially
# from a template. By default, this looks like "peer%d" from 0 to Count-1.
# You may override the number of nodes (Count), the starting index (Start)
# or the template used to construct the name (Hostname).
#
# Note: Template and Specs are not mutually exclusive. You may define both
# sections and the aggregate nodes will be created for you. Take care with
# name collisions
# ---------------------------------------------------------------------------
Template:
Count: 2
# Start: 5
# Hostname: {{.Prefix}}{{.Index}} # default
# ---------------------------------------------------------------------------
# "Users"
# ---------------------------------------------------------------------------
# Count: The number of user accounts _in addition_ to Admin
# ---------------------------------------------------------------------------
Users:
Count: 1
# ---------------------------------------------------------------------------
# Org2: See "Org1" for full specification
# ---------------------------------------------------------------------------
- Name: Org2
Domain: org2.example.com
Template:
Count: 2
Users:
Count: 1

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9937c36

Please sign in to comment.