docker-compose-files/hyperledger_fabric/latest/Makefile

156 lines
4.8 KiB
Makefile
Raw Normal View History

KAFKA_ENABLED ?= false
COUCHDB_ENABLED ?= false
DEV_ENABLED ?= true
2017-10-28 14:41:13 +08:00
CODE_BUILD_WAIT=2
FABRIC_INIT_WAIT=2
COMPOSE_FILE ?= "docker-compose-2orgs-4peers.yaml"
ifeq ($(KAFKA_ENABLED),true)
COMPOSE_FILE="docker-compose-2orgs-4peers-kafka.yaml"
endif
ifeq ($(COUCHDB_ENABLED),true)
COMPOSE_FILE="docker-compose-2orgs-4peers-couchdb.yaml"
endif
ifeq ($(DEV_ENABLED),true)
COMPOSE_FILE="docker-compose-1orgs-1peers-dev.yaml"
endif
all:
@echo "Run test with ${COMPOSE_FILE}"
@echo "Please make sure u have setup Docker and pulled images by 'make setup'."
sleep 2
make ready
2017-10-08 13:55:16 +08:00
make lscc qscc fetch_block
make stop clean
ready: restart
@echo "Restart, init network and then do cc testing..."
if [ "$(DEV_ENABLED)" = "true" ]; then \
2017-10-28 14:41:13 +08:00
echo "In DEV mode, wait for rebuilding ..." && sleep $(CODE_BUILD_WAIT); \
make init_peer0; \
2017-10-28 14:41:13 +08:00
sleep $(FABRIC_INIT_WAIT); \
make test_cc_peer0; \
else \
echo "In Normal mode ..." && sleep 3; \
make init; \
2017-10-28 14:41:13 +08:00
sleep $(FABRIC_INIT_WAIT); \
make test_cc; \
fi
@echo "Now the fabric network is ready to play"
@echo "run 'make cli' to enter into the fabric-cli container."
@echo "run 'make stop' when done."
start: # bootup the fabric network
2017-10-06 14:47:32 +08:00
@echo "Start a fabric network with ${COMPOSE_FILE}"
make clean
docker-compose -f ${COMPOSE_FILE} up -d # Start a fabric network
init: # initialize the fabric network
@echo "Install and instantiate cc example02 on the fabric network"
docker exec -it fabric-cli bash -c "cd /tmp; bash scripts/initialize_all.sh"
init_peer0: # initialize the fabric network
@echo "Install and instantiate cc example02 on the fabric dev network"
docker exec -it fabric-cli bash -c "cd /tmp; bash scripts/initialize_peer0.sh"
stop: # stop the fabric network
@echo "Stop the fabric network"
docker-compose -f ${COMPOSE_FILE} down # Stop a fabric network
restart: stop start
2017-10-28 14:41:13 +08:00
chaincode_dev: restart chaincode_init test_cc_peer0 stop
################## Chaincode testing operations ################
2017-10-28 14:41:13 +08:00
test_cc_all: # test user chaincode on all peers
@echo "Invoke and query cc example02 on all peers"
docker exec -it fabric-cli bash -c "cd /tmp; bash scripts/test_cc_all.sh"
2017-10-28 14:41:13 +08:00
test_cc_peer0: # test single peer
@echo "Invoke and query cc example02 on single peer0"
docker exec -it fabric-cli bash -c "cd /tmp; bash scripts/test_cc_peer0.sh"
qscc: # test qscc queries
docker exec -it fabric-cli bash -c "cd /tmp; bash scripts/test_qscc.sh"
lscc: # test lscc quries
docker exec -it fabric-cli bash -c "cd /tmp; bash scripts/test_lscc.sh"
2017-10-08 13:55:16 +08:00
fetch_block: # test channel fetch
docker exec -it fabric-cli bash -c "cd /tmp; bash scripts/test_fetch.sh"
docker cp fabric-cli:/tmp/block_0.block kafka/channel-artifacts/
docker cp fabric-cli:/tmp/block_1.block kafka/channel-artifacts/
docker cp fabric-cli:/tmp/block_2.block kafka/channel-artifacts/
docker cp fabric-cli:/tmp/block_3.block kafka/channel-artifacts/
################## Env setup related, no need to see usually ################
setup: # setup the environment
bash scripts/setup_Docker.sh # Install Docker, Docker-Compose
bash scripts/download_images.sh # Pull required Docker images
clean: # clean up containers
@echo "Clean all containers and fabric cc images"
@-docker rm -f `docker ps -qa`
@-docker rmi $$(docker images | awk '$$1 ~ /dev-peer/ { print $$3}')
clean_env: # clean up environment
@echo "Clean all images and containers"
bash scripts/clean_env.sh
cli: # enter the cli container
docker exec -it fabric-cli bash
peer: # enter the peer container
docker exec -it peer0.org1.example.com bash
dev_compile: # rebuild the peer
docker exec -it peer0.org1.example.com bash /tmp/peer_build.sh
ps: # show existing docker images
docker ps -a
logs: # show logs
docker-compose -f ${COMPOSE_FILE} logs -f --tail 200
logs_check: logs_save logs_view
logs_save: # save logs
docker logs peer0.org1.example.com >& /tmp/dev_peer.log
docker logs orderer.example.com >& /tmp/dev_orderer.log
2017-10-17 14:47:30 +08:00
docker-compose -f ${COMPOSE_FILE} logs >& /tmp/dev_all.log
logs_view: # view logs
less /tmp/dev_peer.log
gen_e2e: # generate e2e_cli artifacts
cd e2e_cli && bash gen_artifacts.sh
gen_kafka: # generate kafka artifacts
cd kafka && bash gen_artifacts.sh
2017-10-06 14:47:32 +08:00
configtxlator: # run configtxlator
cd kafka && bash run_configtxlator.sh
download: # download required images
@echo "Download Docker images"
docker pull yeasy/hyperledger-fabric:latest
2017-10-06 14:47:32 +08:00
docker pull yeasy/hyperledger-fabric-kafka:0.10.2.0 # official repo does not provide the latest image currently
docker pull hyperledger/fabric-baseos:x86_64-0.4.2
docker tag yeasy/hyperledger-fabric:latest hyperledger/fabric-ccenv:x86_64-1.1.0
2017-10-28 14:41:13 +08:00
################## chaincode dev mode ################
chaincode_init: # start chaincode in dev mode and do install/instantiate
@echo "Install and instantiate cc example02 on the fabric dev network"
docker exec -it fabric-cli bash -c "cd /tmp; bash scripts/init_chaincode_dev.sh"