Fix docs and scripts

pull/108/head
Baohua Yang 2017-12-07 13:55:24 +08:00
parent 1a66a9efa8
commit 09b0726eae
11 changed files with 138 additions and 87 deletions

View File

@ -12,25 +12,47 @@ If you're not familiar with Docker and Blockchain, can have a look at these book
## Getting Started ## Getting Started
### Pick up a fabric version to test ### Pick up a fabric version
Take fabric latest stable code for example Enter the subdir of specific version, e.g.,
```bash ```bash
$ cd 1.0.5 # $ cd 1.0.5 # select a fabric version
$ HLF_MODE=solo make
$ HLF_MODE=kafka make
$ HLF_MODE=couchdb make
$ HLF_MODE=dev make
``` ```
## Supported Releases ### Quick Test
* [Fabric v0.6.0](v0.6.0/): stable with fabric v0.6.0 code. The following command will run the entire process (start a fabric network, create channel, test chaincode and stop it.) pass-through.
* [Fabric v1.0.0](v1.0.0/): stable with fabric v1.0.0 code.
* [Fabric v1.0.2](v1.0.2/): deprecated, test fabric v1.0.2 code.
* [Fabric v1.0.3](v1.0.3/): deprecated, test fabric v1.0.3 code.
* [Fabric v1.0.4](v1.0.4/): test fabric v1.0.4 code.
* [Fabric v1.0.5](v1.0.5/): latest stable fabric code with v1.0.5.
* [Fabric Latest](latest/): experimental with latest fabric code, unstable.
```bash
$ make setup # Install docker/compose, and pull required images
$ make test # Test with default fabric solo mode
```
### Test with more modes
```bash
$ HLF_MODE=solo make test # in solo mode
$ HLF_MODE=kafka make test # in kafka mode
$ HLF_MODE=couchdb make test # solo+couchdb support, web UI is at `http://localhost:5984/_utils`
$ HLF_MODE=event make test # Enable eventhub listener
```
### Detailed Steps
See [detailed steps](docs/steps.md)
## Supported Fabric Releases
Fabric Release | Description
--- | ---
[Fabric v0.6.0](v0.6.0/) | stable with fabric v0.6.0 code.
[Fabric v1.0.0](v1.0.0/) | stable with fabric v1.0.0 code.
[Fabric v1.0.2](v1.0.2/) | deprecated, test fabric v1.0.2 code.
[Fabric v1.0.4](v1.0.4/) | test fabric v1.0.4 code.
[Fabric v1.0.5](v1.0.5/) | latest stable fabric code with v1.0.5.
[Fabric Latest](latest/) | experimental with latest fabric code, unstable.
## Acknowledgement
* [Hyperledger Fabric](https://github.com/hyperledger/fabric/) project.
* [Hyperledger Fabric Getting Started](http://hyperledger-fabric.readthedocs.io/en/latest/getting_started.html).

View File

@ -3,7 +3,8 @@ Events didn't support TLS, so make sure TLS has been disabled by setting *_TLS_E
Next, start the network with following command: Next, start the network with following command:
```bash ```bash
$ HLF_MODE=event make restart $ HLF_MODE=event
$ make restart
``` ```
when the network starts successfully, we started a block-listener in container `fabric-event-listener`. when the network starts successfully, we started a block-listener in container `fabric-event-listener`.
@ -18,8 +19,8 @@ $ docker logs -f fabric-event-listener
And init channels and chaincodes. And init channels and chaincodes.
```bash ```bash
$ HLF_MODE=event make test_channel_create test_channel_join $ make test_channel_create test_channel_join
$ HFL_MODE=event make test_cc_install test_cc_instantiate test_cc_invoke_query # Enable eventhub listener $ make test_cc_install test_cc_instantiate test_cc_invoke_query # Enable eventhub listener
``` ```
Then we will get some events at listening terminal looks like following: Then we will get some events at listening terminal looks like following:

View File

@ -1,4 +1,6 @@
## Environment Setup ## Detailed Steps
### Environment Setup
The following scripts will setup the environment by installing Docker, Docker-Compose and download required docker images. The following scripts will setup the environment by installing Docker, Docker-Compose and download required docker images.
@ -8,13 +10,24 @@ $ make setup # setup environment
If you want to setup the environment manually, then have a look at [manually setup](docs/setup.md). If you want to setup the environment manually, then have a look at [manually setup](docs/setup.md).
## Bootup Fabric Network ### Generate crypto-config and channel-artifacts
```bash
$ make gen_config
```
The cmd actually calls `scripts/gen_config.sh` to generate the `crypto-config` and `channel-artifacts`.
More details can be found at [Config Generation](docs/config_generation.md).
### Bootup Fabric Network
Start a 4 peer (belonging to 2 organizations) fabric network. Start a 4 peer (belonging to 2 organizations) fabric network.
```sh ```sh
$ make start # Start a fabric network $ make start # Start a fabric network
``` ```
The script actually uses docker-compose to boot up the fabric network with several containers. The script actually uses docker-compose to boot up the fabric network with several containers.
There will be 7 running containers, include 4 peers, 1 cli, 1 ca and 1 orderer. There will be 7 running containers, include 4 peers, 1 cli, 1 ca and 1 orderer.
@ -30,35 +43,39 @@ c6c5f69f2d53 yeasy/hyperledger-fabric-peer:1.0.4 "peer node start"
ba1f00a9c83c hyperledger/fabric-orderer:x86_64-1.0.4 "orderer start" 6 seconds ago Up 14 seconds 0.0.0.0:7050->7050/tcp orderer.example.com ba1f00a9c83c hyperledger/fabric-orderer:x86_64-1.0.4 "orderer start" 6 seconds ago Up 14 seconds 0.0.0.0:7050->7050/tcp orderer.example.com
``` ```
### Initialize Fabric network ### Create Application Channel
```bash ```bash
$ make init # Start a fabric network $ make test_channel_create
``` ```
The command actually calls the `./scripts/initialize.sh` script in the `fabric-cli` container to: The command actually calls the `scripts/test_channel_create.sh` script in the `fabric-cli` container, to create a new application channel with default name of `businesschannel`.
* create a new application channel `businesschannel`
* join all peers into the channel
* install and instantiate chaincode `example02` for testing
This script only needs to be executed once. ### Join Peers into Application Channel
You should see result like the following if the initialization is successful.
```bash ```bash
============================================== $ make test_channel_join
==========initialize businesschannel==========
==============================================
Channel name: businesschannel
Creating channel...
...
===================== All GOOD, initialization completed =====================
``` ```
The command actually calls the `scripts/test_channel_join.sh` script in the `fabric-cli` container, to join all peers into the channel.
### Intall Chaincode to All Peers
```bash
$ make test_cc_install
```
The command actually calls the `scripts/test_cc_install.sh` script in the `fabric-cli` container, to install chaincode `example02` for testing.
### Instantiate Chaincode in the Application Channel
```bash
$ make test_cc_instantiate
```
The command actually calls the `scripts/test_cc_instantiate.sh` script in the `fabric-cli` container, to instantiate chaincode `example02`.
And there will be new chaincode container generated in the system, looks like And there will be new chaincode container generated in the system, looks like
```bash ```bash
@ -69,24 +86,48 @@ e3092961b81b dev-peer1.org1.example.com-mycc-1.0 "chaincode -peer.a..."
57d3555f56e5 dev-peer0.org2.example.com-mycc-1.0 "chaincode -peer.a..." About a minute ago Up About a minute dev-peer0.org2.example.com-mycc-1.0 57d3555f56e5 dev-peer0.org2.example.com-mycc-1.0 "chaincode -peer.a..." About a minute ago Up About a minute dev-peer0.org2.example.com-mycc-1.0
c9974dbc21d9 dev-peer0.org1.example.com-mycc-1.0 "chaincode -peer.a..." 23 minutes ago Up 23 minutes dev-peer0.org1.example.com-mycc-1.0 c9974dbc21d9 dev-peer0.org1.example.com-mycc-1.0 "chaincode -peer.a..." 23 minutes ago Up 23 minutes dev-peer0.org1.example.com-mycc-1.0
``` ```
### Test Chaincode
## Test Chaincode
```bash ```bash
$ make test_cc # test invoke and query with chaincode $ make test_cc_invoke_query
``` ```
More details, see [chaincode test](docs/chaincode_test.md). The command actually calls the `scripts/test_cc_invoke_query.sh` script in the `fabric-cli` container, to test chaincode `example02` with invoke and query.
### Test System Chaincode
## Stop the network ```bash
$ make test_lscc # test LSCC
$ make test_qscc # test QSCC
```
The command actually calls the `scripts/test_lscc.sh` and `scripts/test_qscc.sh` script in the `fabric-cli` container, to test LSCC and QSCC.
### Test Fetch Blocks
```bash
$ make test_fetch_blocks # test fetch blocks
```
The command actually calls the `scripts/test_fetch_blocks.sh` script in the `fabric-cli` container, to test fetching blocks from channels.
### Test Configtxlator
```bash
$ make test_configtxlator
```
The command actually calls the `scripts/test_configtxlator.sh` script in the `fabric-cli` container, to test configtxlator to change the channel configuration.
More details can be found at [Configtxlator](docs/configtxlator.md).
### Stop the network
```bash ```bash
$ make stop # stop the fabric network $ make stop # stop the fabric network
``` ```
## Clean environment ### Clean environment
Clean all related containers and images. Clean all related containers and images.
@ -94,7 +135,12 @@ Clean all related containers and images.
$ make clean # clean the environment $ make clean # clean the environment
``` ```
## More to learn
### Enable Event Listener
See [Event Listener](docs/event_listener.md).
### More to learn
Topics | Description Topics | Description
-- | -- -- | --
@ -108,6 +154,3 @@ Topics | Description
[WIP] [Some verification tests](docs/verification_test.md) | [WIP] [Some verification tests](docs/verification_test.md) |
## Acknowledgement
* [Hyperledger Fabric](https://github.com/hyperledger/fabric/) project.
* [Hyperledger Fabric Getting Started](http://hyperledger-fabric.readthedocs.io/en/latest/getting_started.html).

View File

@ -18,7 +18,9 @@ else ifeq ($(HLF_MODE),dev)
COMPOSE_FILE="docker-compose-1orgs-1peers-dev.yaml" COMPOSE_FILE="docker-compose-1orgs-1peers-dev.yaml"
endif endif
all: all: test
test:
@echo "Run test with $(COMPOSE_FILE)" @echo "Run test with $(COMPOSE_FILE)"
@echo "Please make sure u have setup Docker and pulled images by 'make setup'." @echo "Please make sure u have setup Docker and pulled images by 'make setup'."
@ -113,7 +115,7 @@ test_lscc: # test lscc quries
# FIXME: docker doesn't support wildcard in cp right now # FIXME: docker doesn't support wildcard in cp right now
test_fetch_blocks: # test fetching channel blocks fetch test_fetch_blocks: # test fetching channel blocks fetch
@echo "Test fetching block files" @echo "Test fetching block files"
docker exec -it fabric-cli bash -c "cd /tmp; bash scripts/test_fetch.sh" docker exec -it fabric-cli bash -c "cd /tmp; bash scripts/test_fetch_blocks.sh"
################## Env setup related, no need to see usually ################ ################## Env setup related, no need to see usually ################
@ -178,7 +180,7 @@ download: # download required images
docker pull yeasy/hyperledger-fabric-peer:latest docker pull yeasy/hyperledger-fabric-peer:latest
docker pull yeasy/hyperledger-fabric-orderer:latest docker pull yeasy/hyperledger-fabric-orderer:latest
docker pull yeasy/hyperledger-fabric-ca:latest docker pull yeasy/hyperledger-fabric-ca:latest
docker pull yeasy/hyperledger-fabric-kafka:0.10.2.0 # official repo does not provide the latest image currently docker pull yeasy/hyperledger-fabric-kafka:0.10.2.0 # TODO:official repo does not provide the latest image currently
docker pull hyperledger/fabric-baseos:x86_64-0.4.2 docker pull hyperledger/fabric-baseos:x86_64-0.4.2
docker pull hyperledger/fabric-zookeeper:x86_64-1.1.0-preview docker pull hyperledger/fabric-zookeeper:x86_64-1.1.0-preview
docker pull hyperledger/fabric-kafka:x86_64-1.1.0-preview docker pull hyperledger/fabric-kafka:x86_64-1.1.0-preview

View File

@ -1,13 +1,8 @@
## Start a network base on kafka ## Start a network base on kafka
### Quick testing with kafka ### Quick testing
```bash ```bash
$ KAFKA_ENABLED=true make $ HLF_MODE=kafka make
``` ```
When the fabric-network fully started, it takes about 30~60s to finish all the test. When the fabric-network fully started, it takes about 30~60s to finish all the test.
## Generate crypto-config and channel-artifacts
```bash
$ make gen_kafka
```

View File

@ -254,7 +254,7 @@ chaincodeInstantiate () {
res=$? res=$?
cat log.txt cat log.txt
verifyResult $res "ChaincodeInstantiation on peer$peer in channel ${channel} failed" verifyResult $res "ChaincodeInstantiation on peer$peer in channel ${channel} failed"
echo_g "=== ChaincodeInstantiation on peer$peer in channel ${channel} is successful ===" echo_g "=== Chaincode Instantiated in channel ${channel} by peer$peer ==="
} }

View File

@ -1,13 +1,7 @@
## Start a network base on solo ## Start a network base on solo
### Quick testing with solo ### Quick testing
```bash ```bash
$ HLF_MODE=solo make $ HLF_MODE=solo make
``` ```
When the fabric-network fully started, it takes about 30~60s to finish all the test. When the fabric-network fully started, it takes about 30~60s to finish all the test.
## Generate crypto-config and channel-artifacts
```bash
$ make gen_solo gen_kafka
```

View File

@ -18,7 +18,9 @@ else ifeq ($(HLF_MODE),dev)
COMPOSE_FILE="docker-compose-1orgs-1peers-dev.yaml" COMPOSE_FILE="docker-compose-1orgs-1peers-dev.yaml"
endif endif
all: all: test
test:
@echo "Run test with $(COMPOSE_FILE)" @echo "Run test with $(COMPOSE_FILE)"
@echo "Please make sure u have setup Docker and pulled images by 'make setup'." @echo "Please make sure u have setup Docker and pulled images by 'make setup'."
@ -29,15 +31,18 @@ all:
ready: # create/join channel, install/instantiate cc ready: # create/join channel, install/instantiate cc
make gen_config # Will ignore if local config path exists make gen_config # Will ignore if local config path exists
make restart make restart
make test_channel_create make test_channel_create
make test_channel_join make test_channel_join
# make update_anchors # make update_anchors
make test_cc_install make test_cc_install
make test_cc_instantiate make test_cc_instantiate
make test_cc_invoke_query make test_cc_invoke_query
make test_lscc # test lscc operations make test_lscc # test lscc operations
make test_qscc # test qscc operations make test_qscc # test qscc operations
make test_fetch_blocks # fetch block files make test_fetch_blocks # fetch block files
make logs_save make logs_save
@ -110,7 +115,7 @@ test_lscc: # test lscc quries
# FIXME: docker doesn't support wildcard in cp right now # FIXME: docker doesn't support wildcard in cp right now
test_fetch_blocks: # test fetching channel blocks fetch test_fetch_blocks: # test fetching channel blocks fetch
@echo "Test fetching block files" @echo "Test fetching block files"
docker exec -it fabric-cli bash -c "cd /tmp; bash scripts/test_fetch.sh" docker exec -it fabric-cli bash -c "cd /tmp; bash scripts/test_fetch_blocks.sh"
################## Env setup related, no need to see usually ################ ################## Env setup related, no need to see usually ################

View File

@ -1,13 +1,8 @@
## Start a network base on kafka ## Start a network base on kafka
### Quick testing with kafka ### Quick testing
```bash ```bash
$ KAFKA_ENABLED=true make $ HLF_MODE=kafka make
``` ```
When the fabric-network fully started, it takes about 30~60s to finish all the test. When the fabric-network fully started, it takes about 30~60s to finish all the test.
## Generate crypto-config and channel-artifacts
```bash
$ make gen_kafka
```

View File

@ -1,13 +1,7 @@
## Start a network base on solo ## Start a network base on solo
### Quick testing with solo ### Quick testing
```bash ```bash
$ HLF_MODE=solo make $ HLF_MODE=solo make
``` ```
When the fabric-network fully started, it takes about 30~60s to finish all the test. When the fabric-network fully started, it takes about 30~60s to finish all the test.
## Generate crypto-config and channel-artifacts
```bash
$ make gen_solo gen_kafka
```