Skip to content

Commit

Permalink
[FAB-4435] gulp test recreates containers
Browse files Browse the repository at this point in the history
This patch adds a "docker-ready" task to make sure that necessary
containers are recreated and up before the "test" task.

The "docker-clean" task now calls "docker-compose" to delete containers,
and "docker-ready" task depends on the "docker-clean" task, and then calls
"docker-compose" to create containers.  The "test" task depends on
"docker-ready" task so that the containers are recreated and ready before
each test run.

Change-Id: I4161e54186247d781755aaa2fcec217eeacf695b
Signed-off-by: Taku Shimosawa <taku.shimosawa@hal.hitachi.com>
  • Loading branch information
shimos committed Jun 6, 2017
1 parent 4f03644 commit a156a23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ You can build the docker images in your native host (Mac, Ubuntu, Windows, etc.)
* build fabric peer and orderer docker images and other ancillary images
* `cd $GOPATH/src/github.com/hyperledger/fabric`
* run `make docker` to build the docker images (you may need to run `make docker-clean` first if you've built before)
* go to fabric-sdk-node/test/fixtures
* run `docker-compose up --force-recreate` to launch the network
* Now you are ready to run the tests:
* Clear out your previous key value stores that may have cached user enrollment certificates (`rm -rf /tmp/hfc-*`, `rm -rf ~/.hfc-key-store`)
* run `gulp test` to execute the entire test suite (800+ test cases), or you can run them individually
Expand Down
12 changes: 10 additions & 2 deletions build/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,21 @@ gulp.task('docker-clean', shell.task([
'docker rm $(docker ps -a | grep "dev-peer0.org[12].example.com-e" | awk \'{print $1}\')',

// remove chaincode images so that they get rebuilt during test
'docker rmi $(docker images | grep "^dev-peer0.org[12].example.com-e" | awk \'{print $3}\')'
'docker rmi $(docker images | grep "^dev-peer0.org[12].example.com-e" | awk \'{print $3}\')',

// clean up all the containers created by docker-compose
'docker-compose -f test/fixtures/docker-compose.yaml down'
], {
verbose: true, // so we can see the docker command output
ignoreErrors: true // kill and rm may fail because the containers may have been cleaned up
}));

gulp.task('test', ['clean-up', 'lint', 'docker-clean', 'pre-test', 'ca'], function() {
gulp.task('docker-ready', ['docker-clean'], shell.task([
// make sure that necessary containers are up by docker-compose
'docker-compose -f test/fixtures/docker-compose.yaml up -d'
]));

gulp.task('test', ['clean-up', 'lint', 'pre-test', 'docker-ready', 'ca'], function() {
// use individual tests to control the sequence they get executed
// first run the ca-tests that tests all the member registration
// and enrollment scenarios (good and bad calls). Then the rest
Expand Down

0 comments on commit a156a23

Please sign in to comment.