From 5031ee6b2aaac1a3201416ac9b7951cf84824858 Mon Sep 17 00:00:00 2001 From: Sami Sankari Date: Tue, 16 Apr 2019 10:46:47 +0200 Subject: [PATCH 1/4] changed the test to do what the name implies --- src/test/functional/functional-tests.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/test/functional/functional-tests.js b/src/test/functional/functional-tests.js index 5d5fba78..99c77fff 100644 --- a/src/test/functional/functional-tests.js +++ b/src/test/functional/functional-tests.js @@ -625,16 +625,21 @@ describe('functional tests', function() { client.putObject(bucketName, _5mbObjectName, stream, _5mb.length, {}, done) }) step(`fGetObject(bucketName, objectName, filePath, callback)_bucketName:${bucketName}, objectName:${_5mbObjectName}, filePath:${localFile}`, done => { - var tmpFile = `${tmpDir}/${_5mbObjectName}.${_5mbmd5}.part.minio` - // create a partial file - fs.writeFileSync(tmpFile, _100kb) - client.fGetObject(bucketName, _5mbObjectName, localFile) - .then(() => { - var md5sum = crypto.createHash('md5').update(fs.readFileSync(localFile)).digest('hex') - if (md5sum === _5mbmd5) return done() - return done(new Error('md5sum mismatch')) - }) - .catch(done) + client.statObject(bucketName, _5mbObjectName, (err, stat) => { + if (err) return done(new Error('failed to stat object')) + var bufPart = new Buffer(_100kb.length); + _5mb.copy(bufPart, 0, 0, _100kb.length); + var tmpFile = `${tmpDir}/${_5mbObjectName}.${stat.etag}.part.minio` + // create a partial file + fs.writeFileSync(tmpFile, bufPart) + client.fGetObject(bucketName, _5mbObjectName, localFile) + .then(() => { + var md5sum = crypto.createHash('md5').update(fs.readFileSync(localFile)).digest('hex') + if (md5sum === _5mbmd5) return done() + return done(new Error('md5sum mismatch')) + }) + .catch(done) + }) }) step(`removeObject(bucketName, objectName, callback)_bucketName:${bucketName}, objectName:${_5mbObjectName}_`, done => { fs.unlinkSync(localFile) From c2ac6dc93ed5ffb36bfac394b32ca07a3fe19baa Mon Sep 17 00:00:00 2001 From: Sami Sankari Date: Tue, 16 Apr 2019 11:01:33 +0200 Subject: [PATCH 2/4] Removed semicolons on end of line --- src/test/functional/functional-tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/functional/functional-tests.js b/src/test/functional/functional-tests.js index 99c77fff..8f753da3 100644 --- a/src/test/functional/functional-tests.js +++ b/src/test/functional/functional-tests.js @@ -627,8 +627,8 @@ describe('functional tests', function() { step(`fGetObject(bucketName, objectName, filePath, callback)_bucketName:${bucketName}, objectName:${_5mbObjectName}, filePath:${localFile}`, done => { client.statObject(bucketName, _5mbObjectName, (err, stat) => { if (err) return done(new Error('failed to stat object')) - var bufPart = new Buffer(_100kb.length); - _5mb.copy(bufPart, 0, 0, _100kb.length); + var bufPart = new Buffer(_100kb.length) + _5mb.copy(bufPart, 0, 0, _100kb.length) var tmpFile = `${tmpDir}/${_5mbObjectName}.${stat.etag}.part.minio` // create a partial file fs.writeFileSync(tmpFile, bufPart) From a23c831891d0d23d9864223e74b6da6b46f5c9cf Mon Sep 17 00:00:00 2001 From: Sami Sankari Date: Tue, 23 Apr 2019 11:09:57 +0200 Subject: [PATCH 3/4] Skipped unnecessary stat object --- src/test/functional/functional-tests.js | 35 ++++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/test/functional/functional-tests.js b/src/test/functional/functional-tests.js index 8f753da3..ecb48b27 100644 --- a/src/test/functional/functional-tests.js +++ b/src/test/functional/functional-tests.js @@ -620,26 +620,29 @@ describe('functional tests', function() { }) describe('fGetObject-resume', () => { var localFile = `${tmpDir}/${_5mbObjectName}` + var etag = '' step(`putObject(bucketName, objectName, stream, metaData, cb)_bucketName:${bucketName}, objectName:${_5mbObjectName}, stream:5mb_`, done => { var stream = readableStream(_5mb) - client.putObject(bucketName, _5mbObjectName, stream, _5mb.length, {}, done) + client.putObject(bucketName, _5mbObjectName, stream, _5mb.length, {}) + .then((resp) => { + etag = resp + done() + }) + .catch(done) }) step(`fGetObject(bucketName, objectName, filePath, callback)_bucketName:${bucketName}, objectName:${_5mbObjectName}, filePath:${localFile}`, done => { - client.statObject(bucketName, _5mbObjectName, (err, stat) => { - if (err) return done(new Error('failed to stat object')) - var bufPart = new Buffer(_100kb.length) - _5mb.copy(bufPart, 0, 0, _100kb.length) - var tmpFile = `${tmpDir}/${_5mbObjectName}.${stat.etag}.part.minio` - // create a partial file - fs.writeFileSync(tmpFile, bufPart) - client.fGetObject(bucketName, _5mbObjectName, localFile) - .then(() => { - var md5sum = crypto.createHash('md5').update(fs.readFileSync(localFile)).digest('hex') - if (md5sum === _5mbmd5) return done() - return done(new Error('md5sum mismatch')) - }) - .catch(done) - }) + var bufPart = new Buffer(_100kb.length) + _5mb.copy(bufPart, 0, 0, _100kb.length) + var tmpFile = `${tmpDir}/${_5mbObjectName}.${etag}.part.minio` + // create a partial file + fs.writeFileSync(tmpFile, bufPart) + client.fGetObject(bucketName, _5mbObjectName, localFile) + .then(() => { + var md5sum = crypto.createHash('md5').update(fs.readFileSync(localFile)).digest('hex') + if (md5sum === _5mbmd5) return done() + return done(new Error('md5sum mismatch')) + }) + .catch(done) }) step(`removeObject(bucketName, objectName, callback)_bucketName:${bucketName}, objectName:${_5mbObjectName}_`, done => { fs.unlinkSync(localFile) From 775afec5c9883022031c9e570582cdeda795c936 Mon Sep 17 00:00:00 2001 From: Sami Sankari Date: Tue, 23 Apr 2019 11:25:18 +0200 Subject: [PATCH 4/4] fixed indentation --- src/test/functional/functional-tests.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/functional/functional-tests.js b/src/test/functional/functional-tests.js index ecb48b27..47587b70 100644 --- a/src/test/functional/functional-tests.js +++ b/src/test/functional/functional-tests.js @@ -624,10 +624,10 @@ describe('functional tests', function() { step(`putObject(bucketName, objectName, stream, metaData, cb)_bucketName:${bucketName}, objectName:${_5mbObjectName}, stream:5mb_`, done => { var stream = readableStream(_5mb) client.putObject(bucketName, _5mbObjectName, stream, _5mb.length, {}) - .then((resp) => { - etag = resp - done() - }) + .then((resp) => { + etag = resp + done() + }) .catch(done) }) step(`fGetObject(bucketName, objectName, filePath, callback)_bucketName:${bucketName}, objectName:${_5mbObjectName}, filePath:${localFile}`, done => {