Skip to content

Commit 09839fc

Browse files
bestbeforetodaydenyeart
authored andcommitted
Ensure tests wait for microfab to start
Rather than fixed sleep after lauching microfab, watch the container logs until the "Microfab started" message appears. Signed-off-by: Mark S. Lewis <[email protected]>
1 parent cb29b36 commit 09839fc

File tree

1 file changed

+28
-30
lines changed
  • fabric-chaincode-integration-test/src/test/resources/scripts

1 file changed

+28
-30
lines changed

fabric-chaincode-integration-test/src/test/resources/scripts/mfsetup.sh

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,52 +21,50 @@ docker run --name microfab \
2121
-e MICROFAB_CONFIG="${MICROFAB_CONFIG}" \
2222
-e FABRIC_LOGGING_SPEC=info \
2323
ghcr.io/hyperledger-labs/microfab
24+
timeout 60s bash -c 'docker logs -f microfab | grep --max-count=1 "Microfab started"'
2425

25-
26-
sleep 10
27-
28-
curl -sSL http://console.localho.st:8080/ak/api/v1/components > $CFG/cfg.json
26+
curl -sSL http://console.localho.st:8080/ak/api/v1/components > $CFG/cfg.json
2927
npx @hyperledger-labs/weft microfab -w $CFG/_wallets -p $CFG/_gateways -m $CFG/_msp -f --config $CFG/cfg.json
3028

3129
# bring in the helper bash scripts
3230
. $DIR/scripts/ccutils.sh
3331

3432

3533
function deployCC() {
36-
## package the chaincode
37-
packageChaincode
34+
## package the chaincode
35+
packageChaincode
3836

39-
## Install chaincode on peer0.org1 and peer0.org2
40-
infoln "Installing chaincode on peer0.org1..."
41-
installChaincode 1
42-
infoln "Install chaincode on peer0.org2..."
43-
installChaincode 2
37+
## Install chaincode on peer0.org1 and peer0.org2
38+
infoln "Installing chaincode on peer0.org1..."
39+
installChaincode 1
40+
infoln "Install chaincode on peer0.org2..."
41+
installChaincode 2
4442

45-
## query whether the chaincode is installed
46-
queryInstalled 1
43+
## query whether the chaincode is installed
44+
queryInstalled 1
4745

48-
## approve the definition for org1
49-
approveForMyOrg 1
46+
## approve the definition for org1
47+
approveForMyOrg 1
5048

51-
## check whether the chaincode definition is ready to be committed
52-
## expect org1 to have approved and org2 not to
53-
checkCommitReadiness 1 "\"org1MSP\": true" "\"org2MSP\": false"
54-
checkCommitReadiness 2 "\"org1MSP\": true" "\"org2MSP\": false"
49+
## check whether the chaincode definition is ready to be committed
50+
## expect org1 to have approved and org2 not to
51+
checkCommitReadiness 1 "\"org1MSP\": true" "\"org2MSP\": false"
52+
checkCommitReadiness 2 "\"org1MSP\": true" "\"org2MSP\": false"
5553

56-
## now approve also for org2
57-
approveForMyOrg 2
54+
## now approve also for org2
55+
approveForMyOrg 2
5856

59-
## check whether the chaincode definition is ready to be committed
60-
## expect them both to have approved
61-
checkCommitReadiness 1 "\"org1MSP\": true" "\"org2MSP\": true"
62-
checkCommitReadiness 2 "\"org1MSP\": true" "\"org2MSP\": true"
57+
## check whether the chaincode definition is ready to be committed
58+
## expect them both to have approved
59+
checkCommitReadiness 1 "\"org1MSP\": true" "\"org2MSP\": true"
60+
checkCommitReadiness 2 "\"org1MSP\": true" "\"org2MSP\": true"
6361

64-
## now that we know for sure both orgs have approved, commit the definition
65-
commitChaincodeDefinition 1 2
62+
## now that we know for sure both orgs have approved, commit the definition
63+
commitChaincodeDefinition 1 2
6664

67-
## query on both orgs to see that the definition committed successfully
68-
queryCommitted 1
69-
queryCommitted 2
65+
## query on both orgs to see that the definition committed successfully
66+
queryCommitted 1
67+
queryCommitted 2
7068
}
7169
#./gradlew -I ./chaincode-init.gradle -PchaincodeRepoDir=$(realpath ./fabric-chaincode-integration-test/src/contracts/fabric-ledger-api/repository) publishShimPublicationToFabricRepository
7270

0 commit comments

Comments
 (0)