Skip to content

Commit

Permalink
[FAB-10196] Bootstrap test
Browse files Browse the repository at this point in the history
	This change adds a new bootstrap test based on the multi orgs test

	It sets a new bootstrap config using minimal configs with
	anchor peers only and uses the dynamic discovery service
	to discover other peers in the network.

	The config has peer0 of org1 and org2 as anchor peers
	The discovery service will discover peer1.org1 and
	propagate all of the multi orgs test suite to this
	newly discovered peer (ie: SaveChannel and JoinChannel)
	and executes all of the existing CC operations to ensure
	they're still working with the discovered peer as well.

Change-Id: I9d1594d2239188a750df5000dd2d7d478d94a8a5
Signed-off-by: Baha Shaaban <[email protected]>
  • Loading branch information
Baha Shaaban authored and troyronda committed May 23, 2018
1 parent 300b3e7 commit e255416
Show file tree
Hide file tree
Showing 5 changed files with 549 additions and 128 deletions.
2 changes: 1 addition & 1 deletion pkg/client/common/discovery/dynamicdiscovery/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func asPeers(ctx contextAPI.Client, endpoints []*discclient.Peer) []fab.Peer {

peerConfig, err := ctx.EndpointConfig().PeerConfig(url)
if err != nil {
logger.Warnf("Error getting peer config for url [%s]: %s", err)
logger.Warnf("Error getting peer config for url [%s]: %s", url, err)
continue
}

Expand Down
198 changes: 198 additions & 0 deletions test/fixtures/config/config_test_multiorg_bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# The network connection profile provides client applications the information about the target
# blockchain network that are necessary for the applications to interact with it. These are all
# knowledge that must be acquired from out-of-band sources. This file provides such a source.
#


#
# Schema version of the content. Used by the SDK to apply the corresponding parsing rules.
#
version: 1.0.0

#
# The client section used by GO SDK.
#
client:

organization: org1

logging:
level: info

# Root of the MSP directories with keys and certs.
cryptoconfig:
path: ${GOPATH}/src/github.com/hyperledger/fabric-sdk-go/${CRYPTOCONFIG_FIXTURES_PATH}

# Some SDKs support pluggable KV stores, the properties under "credentialStore"
# are implementation specific
credentialStore:
# [Optional]. Used by user store. Not needed if all credentials are embedded in configuration
# and enrollments are performed elswhere.
path: "/tmp/state-store"

# [Optional]. Specific to the CryptoSuite implementation used by GO SDK. Software-based implementations
# requiring a key store. PKCS#11 based implementations does not.
cryptoStore:
# Specific to the underlying KeyValueStore that backs the crypto key store.
path: /tmp/msp

# BCCSP config for the client. Used by GO SDK.
BCCSP:
security:
enabled: true
default:
provider: "SW"
hashAlgorithm: "SHA2"
softVerify: true
level: 256

tlsCerts:
# [Optional]. Use system certificate pool when connecting to peers, orderers (for negotiating TLS) Default: false
systemCertPool: true

# [Optional]. Client key and cert for TLS handshake with peers and orderers
client:
key:
path: ${GOPATH}/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/config/mutual_tls/client_sdk_go-key.pem
cert:
path: ${GOPATH}/src/github.com/hyperledger/fabric-sdk-go/test/fixtures/config/mutual_tls/client_sdk_go.pem

channels:
# multi-org test channel
orgchannel:

# anchor peers only for the bootstrap config is required, other org's peers will be discovered
peers:
peer0.org1.example.com:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true

peer0.org2.example.com:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true

policies:
queryChannelConfig:
minResponses: 1
maxTargets: 1
retryOpts:
attempts: 5
initialBackoff: 500ms
maxBackoff: 5s
backoffFactor: 2.0


#
# list of participating organizations in this network
#
organizations:
org1:
mspid: Org1MSP

# This org's MSP store (absolute path or relative to client.cryptoconfig)
cryptoPath: peerOrganizations/org1.example.com/users/{username}@org1.example.com/msp

peers:
- peer0.org1.example.com

org2:
mspid: Org2MSP

# This org's MSP store (absolute path or relative to client.cryptoconfig)
cryptoPath: peerOrganizations/org2.example.com/users/{username}@org2.example.com/msp

peers:
- peer0.org2.example.com

# Orderer Org name
ordererorg:
# Membership Service Provider ID for this organization
mspID: "OrdererOrg"

# Needed to load users crypto keys and certs for this org (absolute path or relative to global crypto path, DEV mode)
cryptoPath: ordererOrganizations/example.com/users/{username}@example.com/msp

#
# List of peers to send various requests to, including endorsement, query
# and event listener registration.
#
peers:
# defining bootstrap peers only
peer0.org1.example.com:
url: peer0.org1.example.com:7051
eventUrl: peer0.org1.example.com:7053

grpcOptions:
ssl-target-name-override: peer0.org1.example.com
keep-alive-time: 0s
keep-alive-timeout: 20s
keep-alive-permit: false
fail-fast: false
allow-insecure: false

tlsCACerts:
path: ${GOPATH}/src/github.com/hyperledger/fabric-sdk-go/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem

peer0.org2.example.com:
url: peer0.org2.example.com:8051
eventUrl: peer0.org2.example.com:8053
grpcOptions:
ssl-target-name-override: peer0.org2.example.com
keep-alive-time: 0s
keep-alive-timeout: 20s
keep-alive-permit: false
fail-fast: false
allow-insecure: false

tlsCACerts:
path: ${GOPATH}/src/github.com/hyperledger/fabric-sdk-go/${CRYPTOCONFIG_FIXTURES_PATH}/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem

#
# List of orderers to send transaction and channel create/update requests to. For the time
# being only one orderer is needed. If more than one is defined, which one get used by the
# SDK is implementation specific. Consult each SDK's documentation for its handling of orderers.
#
orderers:
# needed to fetch the ordrerer config for create channel
orderer.example.com:
url: orderer.example.com:7050

grpcOptions:
ssl-target-name-override: orderer.example.com
keep-alive-time: 0s
keep-alive-timeout: 20s
keep-alive-permit: false
fail-fast: false
allow-insecure: false

tlsCACerts:
path: ${GOPATH}/src/github.com/hyperledger/fabric-sdk-go/${CRYPTOCONFIG_FIXTURES_PATH}/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem


# EntityMatchers enable substitution of network hostnames with static configurations
# so that properties can be mapped. Regex can be used for this purpose
# UrlSubstitutionExp can be empty which means the same network hostname will be used
# UrlSubstitutionExp can be given same as mapped peer url, so that mapped peer url can be used
# UrlSubstitutionExp can have golang regex matchers like $1.local.example.$2:$3 for pattern
# like peer0.org1.example.com:1234 which converts peer0.org1.example.com to peer0.org1.local.example.com:1234
# EventUrlSubstitutionExp and sslTargetOverrideUrlSubstitutionExp follow in the same lines as
# SubstitutionExp for the fields eventUrl and gprcOptions.ssl-target-name-override respectively
# In any case mappedHost's config will be used, so mapped host cannot be empty, if entityMatchers are used
entityMatchers:
peer:
# the below matcher will allow dynamic discovery to use the anchor peer (peer0.org1.example.com)
# as a template for all org1 discovered peers config
- pattern: (\w+).org1.example.com:(\d+)
urlSubstitutionExp: $1.org1.example.com:$2
sslTargetOverrideUrlSubstitutionExp: $1.org1.example.com
mappedHost: peer0.org1.example.com
85 changes: 73 additions & 12 deletions test/fixtures/dockerenv/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ services:
- CORE_VM_DOCKER_ATTACHSTDOUT=true
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_LISTENADDRESS=0.0.0.0:7051
- CORE_PEER_ADDRESS=0.0.0.0:7051
- CORE_PEER_LISTENADDRESS=peer0.org1.example.com:7051
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_PEER_CHAINCODELISTENADDRESS=peer0.org1.example.com:7052
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_PEER_GOSSIP_BOOTSTRAP=127.0.0.1:7051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.example.com:7151
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_EVENTS_ADDRESS=0.0.0.0:7053
- CORE_PEER_EVENTS_ADDRESS=peer0.org1.example.com:7053
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/tls/peer/server.key
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/tls/peer/server.crt
Expand Down Expand Up @@ -151,6 +151,67 @@ services:
- builder
- golangruntime

org1peer2:
image: ${FABRIC_DOCKER_REGISTRY}${FABRIC_PEER_FIXTURE_IMAGE}:${ARCH}${ARCH_SEP}${FABRIC_PEER_FIXTURE_TAG}
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer1.org1.example.com
- CORE_LOGGING_PEER=debug
# - CORE_LOGGING_GRPC=debug
# - CORE_LOGGING_GOSSIP=debug
# - CORE_CHAINCODE_STARTUPTIMEOUT=30s
- CORE_CHAINCODE_LOGGING_SHIM=debug
- CORE_CHAINCODE_LOGGING_LEVEL=debug
- CORE_CHAINCODE_BUILDER=${FABRIC_DOCKER_REGISTRY}${FABRIC_BUILDER_FIXTURE_IMAGE}:${ARCH}${ARCH_SEP}${FABRIC_BUILDER_FIXTURE_TAG}
- CORE_CHAINCODE_GOLANG_RUNTIME=${FABRIC_DOCKER_REGISTRY}${FABRIC_BASEOS_FIXTURE_IMAGE}:${BASE_ARCH}-${FABRIC_BASEOS_FIXTURE_TAG}
## the following setting redirects chaincode container logs to the peer container logs
- CORE_VM_DOCKER_ATTACHSTDOUT=true
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_LISTENADDRESS=peer1.org1.example.com:7151
- CORE_PEER_ADDRESS=peer1.org1.example.com:7151
- CORE_PEER_CHAINCODELISTENADDRESS=peer1.org1.example.com:7152
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:7151
- CORE_PEER_EVENTS_ADDRESS=peer1.org1.example.com:7153
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/tls/peer/server.key
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/tls/peer/server.crt
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/tls/peer/ca.crt
- CORE_PEER_TLS_CLIENTAUTHREQUIRED
- CORE_PEER_TLS_CLIENTROOTCAS_FILES
# # the following setting starts chaincode containers on the same
# # bridge network as the peers
# # https://docs.docker.com/compose/networking/
- CORE_PEER_NETWORKID=${CORE_PEER_NETWORKID}
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${CORE_PEER_NETWORKID}_default
#comment out logging.driver in order to render the debug logs
logging:
driver: none
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
ports:
- "7151:7151"
- "7153:7153"
expose:
- "7151"
- "7152"
- "7153"
volumes:
- /var/run/:/host/var/run/
- ../fabric/${FABRIC_CRYPTOCONFIG_VERSION}/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/msp/peer
- ../fabric/${FABRIC_CRYPTOCONFIG_VERSION}/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/tls/peer
- ../fabric/${FABRIC_CRYPTOCONFIG_VERSION}/mutual_tls:/etc/hyperledger/mutual_tls/peer
networks:
default:
aliases:
- peer1.org1.example.com
depends_on:
- orderer1
- builder
- golangruntime

org2peer1:
image: ${FABRIC_DOCKER_REGISTRY}${FABRIC_PEER_FIXTURE_IMAGE}:${ARCH}${ARCH_SEP}${FABRIC_PEER_FIXTURE_TAG}
environment:
Expand All @@ -169,13 +230,13 @@ services:
- CORE_VM_DOCKER_ATTACHSTDOUT=true
- CORE_PEER_LOCALMSPID=Org2MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_LISTENADDRESS=0.0.0.0:8051
- CORE_PEER_ADDRESS=0.0.0.0:8051
- CORE_PEER_LISTENADDRESS=peer0.org2.example.com:8051
- CORE_PEER_ADDRESS=peer0.org2.example.com:8051
- CORE_PEER_CHAINCODELISTENADDRESS=peer0.org2.example.com:7052
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_PEER_GOSSIP_BOOTSTRAP=127.0.0.1:8051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:9051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:8051
- CORE_PEER_EVENTS_ADDRESS=0.0.0.0:8053
- CORE_PEER_EVENTS_ADDRESS=peer0.org2.example.com:8053
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/tls/peer/server.key
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/tls/peer/server.crt
Expand Down Expand Up @@ -231,13 +292,13 @@ services:
- CORE_VM_DOCKER_ATTACHSTDOUT=true
- CORE_PEER_LOCALMSPID=Org2MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_PEER_LISTENADDRESS=0.0.0.0:9051
- CORE_PEER_ADDRESS=0.0.0.0:9051
- CORE_PEER_LISTENADDRESS=peer1.org2.example.com:9051
- CORE_PEER_ADDRESS=peer1.org2.example.com:9051
- CORE_PEER_CHAINCODELISTENADDRESS=peer1.org2.example.com:9052
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_PEER_GOSSIP_BOOTSTRAP=127.0.0.1:9051
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:8051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.example.com:9051
- CORE_PEER_EVENTS_ADDRESS=0.0.0.0:9053
- CORE_PEER_EVENTS_ADDRESS=peer1.org2.example.com:9053
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/tls/peer/server.key
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/tls/peer/server.crt
Expand Down
Loading

0 comments on commit e255416

Please sign in to comment.