Skip to content

Commit

Permalink
[FABN-1379] Timing problems in packaging UT
Browse files Browse the repository at this point in the history
10:31:56  not ok 288 Failed to extract generated
chaincode package. Error: ENOENT: no such file or
directory, utime '/w/workspace/...

We need to actually wait for the untar operation
to complete before continuing with the test,
the next step of which is to remove the directory
we're still untar'ing into.

Signed-off-by: Simon Stone <[email protected]>
Change-Id: I7fcdf8af85b2866028d29633c8bed4b6997522f1
  • Loading branch information
Simon Stone authored and harrisob committed Sep 20, 2019
1 parent 1a4f191 commit 13e8a8e
Showing 1 changed file with 34 additions and 25 deletions.
59 changes: 34 additions & 25 deletions test/unit/packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,39 +108,48 @@ test('\n\n** Golang Packager tests **\n\n', (t) => {
const destDir = path.join(testutil.getTempDir(), 'test-deploy-copy-tar-gz');
fs.writeFileSync(tmpFile, data);
fs.removeSync(destDir);
targz.decompress({
src: tmpFile,
dest: destDir
}, (err) => {
if (err) {
t.fail('Failed to extract generated chaincode package. ' + err);
}

const checkPath = path.join(destDir, 'src', 'github.com', 'example_cc', 'example_cc.go');
console.log('***** tmpFile :: ' + tmpFile);
console.log('***** checkPath :: ' + checkPath);
t.equal(fs.existsSync(checkPath), true, 'The tar.gz file produced by Packager.package() has the "chaincode/github.com/example_cc/example_cc.go" file');

t.end();
return new Promise((resolve, reject) => {
targz.decompress({
src: tmpFile,
dest: destDir
}, (err) => {
if (err) {
t.fail('Failed to extract generated chaincode package. ' + err);
return reject(err);
}
resolve();
});
});
}).then(() => {
const destDir = path.join(testutil.getTempDir(), 'test-deploy-copy-tar-gz');
const checkPath = path.join(destDir, 'src', 'github.com', 'example_cc', 'example_cc.go');
console.log('***** tmpFile :: ' + tmpFile);
console.log('***** checkPath :: ' + checkPath);
t.equal(fs.existsSync(checkPath), true, 'The tar.gz file produced by Packager.package() has the "chaincode/github.com/example_cc/example_cc.go" file');
return Packager.package(testutil.CHAINCODE_PATH, '', false, testutil.METADATA_PATH);
}).then((data) => {
const tmpFile = path.join(testutil.getTempDir(), 'test-deploy-copy.tar.gz');
const destDir = path.join(testutil.getTempDir(), 'test-deploy-copy-tar-gz');
fs.writeFileSync(tmpFile, data);
fs.removeSync(destDir);
targz.decompress({
src: tmpFile,
dest: destDir
}, (err) => {
if (err) {
t.fail('Failed to extract generated chaincode package. ' + err);
const checkPath = path.join(destDir, 'META-INF', 'statedb', 'couchdb', 'indexes', 'index.json');
t.equal(fs.existsSync(checkPath), true,
'The tar.gz file produced by Packager.package() has the "META-INF/statedb/couchdb/indexes/index.json" file');
}
t.end();
return new Promise((resolve, reject) => {
targz.decompress({
src: tmpFile,
dest: destDir
}, (err) => {
if (err) {
t.fail('Failed to extract generated chaincode package. ' + err);
return reject(err);
}
resolve();
});
});
}).then(() => {
const destDir = path.join(testutil.getTempDir(), 'test-deploy-copy-tar-gz');
const checkPath = path.join(destDir, 'META-INF', 'statedb', 'couchdb', 'indexes', 'index.json');
t.equal(fs.existsSync(checkPath), true,
'The tar.gz file produced by Packager.package() has the "META-INF/statedb/couchdb/indexes/index.json" file');
t.end();
}).catch((err) => {
t.fail('Caught error in Package.package tests');
t.comment(err.stack ? err.stack : err);
Expand Down

0 comments on commit 13e8a8e

Please sign in to comment.