summaryrefslogtreecommitdiff
path: root/src/mongo/gotools/test/qa-tests/jstests/files
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/gotools/test/qa-tests/jstests/files')
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_db.js61
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_delete.js47
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_get.js81
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_host.js59
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_invalid.js37
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_list.js96
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_local.js102
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_port.js52
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_prefix.js49
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_put.js108
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_replace.js79
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_search.js110
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_type.js63
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_version.js29
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_write_concern.js54
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_write_concern_mongos.js59
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/testdata/files1.txt1
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/testdata/files2.txt1
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/testdata/files3.txt1
-rw-r--r--src/mongo/gotools/test/qa-tests/jstests/files/util/mongofiles_common.js10
20 files changed, 0 insertions, 1099 deletions
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_db.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_db.js
deleted file mode 100644
index fd647d03bff..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_db.js
+++ /dev/null
@@ -1,61 +0,0 @@
-// mongofiles_db.js; ensure that running mongofiles using the db flag works as
-// expected
-var testName = 'mognofiles_db';
-load('jstests/files/util/mongofiles_common.js');
-(function() {
- jsTest.log('Testing mongofiles --host option');
-
- var runTests = function(topology, passthrough) {
- jsTest.log('Putting file with valid host name with ' + passthrough.name + ' passthrough');
- var t = topology.init(passthrough);
- var conn = t.connection();
- var db = conn.getDB('otherdb');
-
- // ensure tool runs without error
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--db', 'otherdb',
- '--port', conn.port,
- '--host', 'localhost',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put 1 failed');
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--db', 'otherdb',
- '--port', conn.port,
- '--host', 'localhost',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put 2 failed');
-
- // ensure the files were inserted into the right db
- assert.eq(2, db.getCollection('fs.files').count(), 'unexpected fs.files count 1');
-
- // test short form
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '-d', 'otherdb',
- '--port', conn.port,
- '--host', 'localhost',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put 3 failed');
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '-d', 'otherdb',
- '--port', conn.port,
- '--host', 'localhost',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put 4 failed');
-
- // ensure the file was inserted into the right db
- assert.eq(4, db.getCollection('fs.files').count(), 'unexpected fs.files count 2s');
-
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_delete.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_delete.js
deleted file mode 100644
index 89e72b3f366..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_delete.js
+++ /dev/null
@@ -1,47 +0,0 @@
-// mongofiles_delete.js; ensure that delete command works as expected
-var testName = 'mongofiles_delete';
-load('jstests/files/util/mongofiles_common.js');
-(function() {
- jsTest.log('Testing mongofiles delete command');
-
- var runTests = function(topology, passthrough) {
- jsTest.log('Putting file with ' + passthrough.name + ' passthrough');
-
- var t = topology.init(passthrough);
- var conn = t.connection();
- var db = conn.getDB('test');
-
- // ensure tool runs without error
- for (var i = 0; i < 10; i++) {
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put failed');
- }
-
- // ensure all the files were written
- assert.eq(10, db.fs.files.count(), 'unexpected fs.files count');
-
- jsTest.log('Deleting file');
-
- // ensure tool runs without error
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'delete', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'delete failed');
-
- // ensure all the files were deleted
- assert.eq(0, db.fs.files.count(), 'unexpected fs.files count');
- assert.eq(0, db.fs.chunks.count(), 'unexpected fs.chunks count');
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_get.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_get.js
deleted file mode 100644
index 04a8c93832a..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_get.js
+++ /dev/null
@@ -1,81 +0,0 @@
-// mongofiles_get.js; ensure that get command works as expected
-var testName = 'mongofiles_get';
-(function() {
- jsTest.log('Testing mongofiles get command');
- load('jstests/files/util/mongofiles_common.js');
- load('jstests/libs/extended_assert.js');
- var assert = extendedAssert;
-
- var runTests = function(topology, passthrough) {
- var t = topology.init(passthrough);
- var conn = t.connection();
- var db = conn.getDB('test');
- var getFile = testName + (Math.random() + 1).toString(36).substring(7);
-
- jsTest.log('Putting file with ' + passthrough.name + ' passthrough');
-
- // ensure tool runs without error
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put 1 failed');
-
- // ensure the file was inserted
- assert.eq(1, db.fs.files.count(), 'unexpected fs.files count 1');
- var fileId = db.fs.files.findOne()._id;
-
- jsTest.log('Getting file with ' + passthrough.name + ' passthrough');
-
- // ensure tool runs without error
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--local', getFile,
- 'get', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'get failed');
-
- // ensure the retrieved file is exactly the same as that inserted
- var actual = md5sumFile(filesToInsert[0]);
- var expected = md5sumFile(getFile);
-
- assert.eq(actual, expected, 'mismatched md5 sum - expected ' + expected + ' got ' + actual);
-
- // ensure tool runs get_id without error
- var idAsJSON = fileId.tojson();
- if (_isWindows()) {
- idAsJSON = '"' + idAsJSON.replace(/"/g, '\\"') + '"';
- }
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--local', getFile,
- 'get_id', idAsJSON]
- .concat(passthrough.args)),
- 0, 'get_id failed');
- expected = md5sumFile(getFile);
- assert.eq(actual, expected, 'mismatched md5 sum on _id - expected ' + expected + ' got ' + actual);
-
- // clear the output buffer
- clearRawMongoProgramOutput();
-
- // test getting to stdout
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--local', '-',
- 'get', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'get stdout failed');
- var expectedContent = "this is a text file";
- assert.strContains.soon(expectedContent, rawMongoProgramOutput,
- "stdout get didn't match expected file content");
-
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_host.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_host.js
deleted file mode 100644
index 8fac1af3c81..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_host.js
+++ /dev/null
@@ -1,59 +0,0 @@
-// mongofiles_host.js; ensure that running mongofiles using valid and invalid
-// host names or IP addresses succeeds/fails as expected
-var testName = 'mongofiles_host';
-load('jstests/files/util/mongofiles_common.js');
-(function() {
- jsTest.log('Testing mongofiles --host option');
-
- var runTests = function(topology, passthrough) {
- jsTest.log('Putting file with valid host name with ' + passthrough.name + ' passthrough');
- var t = topology.init(passthrough);
- var conn = t.connection();
- var db = conn.getDB('test');
-
- // ensure tool runs without error
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--host', 'localhost',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put 1 failed');
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--host', '127.0.0.1',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put 2 failed');
-
- // ensure the file was inserted
- assert.eq(2, db.getCollection('fs.files').count(), 'unexpected fs.files count 1');
-
- jsTest.log('Putting file with invalid host name with ' + passthrough.name + ' passthrough');
-
- // ensure tool exits with a non-zero exit code when supplied invalid hosts
- assert.neq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--host', 'does-not-exist',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'expected mongofiles to fail but it succeeded 1');
- assert.neq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--host', '555.555.555.555',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'expected mongofiles to fail but it succeeded 2');
-
- // ensure the file was not inserted
- assert.eq(2, db.getCollection('fs.files').count(), 'unexpected fs.files count 2');
-
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_invalid.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_invalid.js
deleted file mode 100644
index 0cd8bca00a9..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_invalid.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// mongofiles_invalid.js; runs mongofiles with an invalid command and
-// option - ensures it fails in all cases
-var testName = 'mongofiles_invalid';
-load('jstests/files/util/mongofiles_common.js');
-(function() {
- jsTest.log('Testing mongofiles with invalid commands and options');
-
- var runTests = function(topology, passthrough) {
- var t = topology.init(passthrough);
- var conn = t.connection();
-
- jsTest.log('Running with file with invalid options onw passthrough ' + passthrough.name);
-
- // run with invalid option
- assert.neq(runMongoProgram.apply(this, ['mongofiles',
- '--invalid', conn.port,
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'invalid-option: mongofiles succeeded when it should have failed');
-
- // run with invalid command
- assert.neq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'invalid', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'invalid-command: mongofiles succeeded when it should have failed');
-
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_list.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_list.js
deleted file mode 100644
index d48994ebc54..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_list.js
+++ /dev/null
@@ -1,96 +0,0 @@
-// mongofiles_list.js; tests the mongofiles list option by doing the following:
-//
-// 1. Inserts the mongod/mongo binaries using mongofiles put
-// 2. Checks that the actual md5 of the file matches what's stored in the database
-// 3. Runs the mongofiles list command to view all files stored.
-// 4. Ensures that all the files inserted and returned.
-// 5. Ensures that the returned list matches thae actual filesToInsert[0] and size of
-// files inserted.
-var testName = 'mongofiles_list';
-(function() {
- jsTest.log('Testing mongofiles list command');
- load('jstests/libs/extended_assert.js');
- load('jstests/files/util/mongofiles_common.js');
- var assert = extendedAssert;
-
- var putFile = function(passthrough, conn, file) {
- // ensure tool runs without error
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'put', file]
- .concat(passthrough.args)),
- 0, 'put for ' + file + 'failed');
- var db = conn.getDB('test');
- var fileObj = db.fs.files.findOne({
- filename: file,
- });
- assert(fileObj, 'could not find put file ' + file);
- assert.eq(md5sumFile(file), fileObj.md5, file + ' md5 did not match - expected ' + md5sumFile(file) + ' got ' + fileObj.md5);
- return fileObj.length;
- };
-
- var runTests = function(topology, passthrough) {
- jsTest.log('Putting GridFS files with ' + passthrough.name + ' passthrough');
-
- var inputFileRegex = /^sh.*files.*/;
- var whitespaceSplitRegex = /,?\s+/;
- var fileSizes = [];
-
- var t = topology.init(passthrough);
- var conn = t.connection();
-
- filesToInsert.forEach(function(file) {
- var fileSize = putFile(passthrough, conn, file);
- fileSizes.push(fileSize);
- });
-
- jsTest.log('Running mongofiles list');
-
- // clear the output buffer
- clearRawMongoProgramOutput();
-
- // ensure tool runs without error
- var pid = startMongoProgramNoConnect.apply(this, ['mongofiles',
- '--port', conn.port,
- '--quiet', 'list']
- .concat(passthrough.args));
- assert.eq(waitProgram(pid), 0, 'list command failed but was expected to succeed');
-
- jsTest.log('Verifying list output');
-
- var files;
- assert.neq.soon(0, function() {
- files = rawMongoProgramOutput()
- .split('\n')
- .filter(function(line) {
- return line.indexOf('sh'+pid) !== -1 && line.match(inputFileRegex);
- });
- return files.length;
- }, 'should find some files');
-
- // ensure that the returned files and their sizes are as expected
- files.forEach(function(currentFile, index) {
- // should print mongod and then mongo
- var fileEntry = currentFile.split(whitespaceSplitRegex);
-
- // the list command should have 2 entries - the file name and its size
- // we check for 3 files because of the sh. prefix in our js test framework
- assert.eq(fileEntry.length, 3, 'unexpected list output on ' + currentFile + ' - expected 3 but got ' + fileEntry.length);
-
- // ensure the expected file name is what is printed
- assert.eq(fileEntry[1], filesToInsert[index], 'expected file ' + filesToInsert[1] + ' got ' + fileEntry[1]);
-
- // ensure the expected file size is what is printed
- assert.eq(fileEntry[2], fileSizes[index], 'expected size ' + fileSizes[2] + ' got ' + fileEntry[2]);
- });
-
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_local.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_local.js
deleted file mode 100644
index bc874499cba..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_local.js
+++ /dev/null
@@ -1,102 +0,0 @@
-// mongofiles_local.js; ensure that when --local is passed:
-// a. for puts, the supplied argument is read and stored using the gridfs filename
-// b. for gets, the supplied argument is used to store the retrieved file
-// c. for puts, if the supplied argument is the empty string, an error should occur
-// d. for gets, if the supplied argument is the empty string, the file name is used
-var testName = 'mongofiles_local';
-load('jstests/files/util/mongofiles_common.js');
-(function() {
- jsTest.log('Testing mongofiles --local option');
-
- var runTests = function(topology, passthrough) {
- var t = topology.init(passthrough);
- var conn = t.connection();
- var db = conn.getDB('test');
-
- // generate a random GridFS name for the file
- var putFSName = testName + (Math.random() + 1).toString(36).substring(7);
- var getFSName = testName + (Math.random() + 1).toString(36).substring(7);
-
- jsTest.log('Running put on file with --local');
-
- // ensure tool runs without error with a non-empty --local argument
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '-l', filesToInsert[0],
- 'put', putFSName]
- .concat(passthrough.args)),
- 0, 'put failed when it should have succeeded 1');
-
- // ensure the file exists
- assert(db.fs.files.findOne({
- filename: putFSName
- }), 'did not find expected GridFS file - ' + putFSName);
-
- // ensure tool returns an error if the --local argument does not exist
- assert.neq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--local', filesToInsert[0] + '?',
- 'put', putFSName]
- .concat(passthrough.args)),
- 0, 'put succeeded when it should have failed 2');
-
- // if the argument is empty, use the putFSName - which should cause an error since it doesn't exist
- assert.neq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--local', '',
- 'put', putFSName]
- .concat(passthrough.args)),
- 0, 'put succeeded when it should have failed 3');
-
- // if the argument is empty, and the GridFS file exists, it should run
- // without error on linux and fails on windows
- var comparison = 'eq';
- if (_isWindows()) {
- comparison = 'neq';
- }
- assert[comparison](runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--local', '',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put failed when it should have succeeded 2');
-
- jsTest.log('Running get on file with --local');
-
- // ensure tool runs without error
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--local', getFSName,
- 'get', putFSName]
- .concat(passthrough.args)),
- 0, 'get failed when it should have succeeded 1');
-
- // ensure the right file name was written
- assert.eq(md5sumFile(filesToInsert[0]), md5sumFile(getFSName), 'files do not match!');
-
- // ensure tool uses the GridFS name if the --local argument is empty on linux
- // and fails on windows
- comparison = 'eq';
- if (_isWindows()) {
- comparison = 'neq';
- }
- assert[comparison](runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--local', '',
- 'get', putFSName]
- .concat(passthrough.args)),
- 0, 'get failed unexpectedly');
-
- if (!_isWindows()) {
- assert.eq(md5sumFile(filesToInsert[0]), md5sumFile(putFSName), 'md5sums do not match - expected ' + md5sumFile(filesToInsert[0]) + ' got ' + md5sumFile(putFSName));
- }
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_port.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_port.js
deleted file mode 100644
index 88d6d8f1417..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_port.js
+++ /dev/null
@@ -1,52 +0,0 @@
-// mongofiles_port.js; ensure that supplying valid/invalid port addresses
-// succeeds/fails as expected
-var testName = 'mongofiles_port';
-load('jstests/files/util/mongofiles_common.js');
-(function() {
- jsTest.log('Testing mongofiles --port option');
-
- var runTests = function(topology, passthrough) {
- var t = topology.init(passthrough);
- var conn = t.connection();
- var db = conn.getDB('test');
-
- jsTest.log('Putting file with valid port with ' + passthrough.name + ' passthrough');
-
- // ensure tool runs without error
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put 1 failed');
-
- // ensure the file was inserted
- assert.eq(1, db.fs.files.count(), 'unexpected fs.files count 1');
-
- jsTest.log('Putting file with invalid port with ' + passthrough.name + ' passthrough');
-
- // ensure tool exits with a non-zero exit code when supplied invalid ports
- assert.neq(runMongoProgram.apply(this, ['mongofiles',
- '--port', '12345',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'expected mongofiles to fail but it succeeded 1');
- assert.neq(runMongoProgram.apply(this, ['mongofiles',
- '--port', 'random',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'expected mongofiles to fail but it succeeded 2');
-
- // ensure the file was not inserted
- var count = db.fs.files.count();
- assert.eq(1, count, 'unexpected fs.files count - expected 2 but got ' + count);
-
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_prefix.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_prefix.js
deleted file mode 100644
index 3d19bd141ee..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_prefix.js
+++ /dev/null
@@ -1,49 +0,0 @@
-// mongofiles_prefix.js; ensure that passing --prefix works as expected - the
-// provided prefix is used as the collection name prefix
-var testName = 'mongofiles_prefix';
-load('jstests/files/util/mongofiles_common.js');
-(function() {
- jsTest.log('Testing mongofiles --prefix option');
-
- var runTests = function(topology, passthrough) {
- var t = topology.init(passthrough);
- var conn = t.connection();
- var db = conn.getDB('test');
-
- jsTest.log('Putting file without --prefix with ' + passthrough.name + ' passthrough');
-
- // ensure tool runs without error
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put 1 failed');
-
- // ensure the default collection name prefix was used
- assert.eq(1, db.fs.files.count(), 'unexpected fs.files count');
- assert.eq(0, db[testName + '.files'].count(), 'unexpected ' + testName + '.files count');
-
- jsTest.log('Putting file with --prefix with ' + passthrough.name + ' passthrough');
-
- // ensure tool runs without error
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--prefix', testName,
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put 2 failed');
-
- // ensure the supplied collection name prefix was used
- assert.eq(1, db.fs.files.count(), 'unexpected fs.files count');
- assert.eq(1, db[testName + '.files'].count(), 'unexpected ' + testName + '.files count');
-
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_put.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_put.js
deleted file mode 100644
index 87678df0bcb..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_put.js
+++ /dev/null
@@ -1,108 +0,0 @@
-// mongofiles_put.js; ensure that put works with very large files.
-// NOTE: this test uses mongodump to create a large file
-var testName = 'mongofiles_put';
-load('jstests/files/util/mongofiles_common.js');
-(function() {
- jsTest.log('Testing mongofiles put command');
-
- var runTests = function(topology, passthrough) {
- var t = topology.init(passthrough);
- var conn = t.connection();
- var db = conn.getDB('test');
-
- // create a large collection and dump it
- jsTest.log('Creating large collection with ' + passthrough.name + ' passthrough');
-
- var insertString = new Array(100).join("mongoDB");
- var inserted = 0;
- var num = 0;
- var dbName = 'test';
- var collection = 'foo';
- var bulk = db[collection].initializeUnorderedBulkOp();
-
- while (inserted < (40 * 1024 * 1024)) {
- bulk.insert({
- _id: num++,
- str: insertString
- });
- inserted += insertString.length;
- }
-
- assert.writeOK(bulk.execute({w: "majority"}));
-
- // dumping large collection to single large file
- jsTest.log('Dumping collection to filesystem with ' + passthrough.name + ' passthrough');
-
- var dumpDir = './dumpDir';
-
- assert.eq(runMongoProgram.apply(this, ['mongodump',
- '-d', dbName,
- '--port', conn.port,
- '-c', collection,
- '--out', dumpDir]
- .concat(passthrough.args)),
- 0, 'dump failed when it should have succeeded');
-
- jsTest.log('Putting directory');
-
- // putting a directory should fail
- assert.neq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'put', dumpDir]
- .concat(passthrough.args)),
- 0, 'put succeeded when it should have failed');
-
- jsTest.log('Putting file with ' + passthrough.name + ' passthrough');
-
- var putFile = dumpDir + '/' + dbName + '/' + collection + '.bson';
-
- // ensure putting of the large file succeeds
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--local', putFile,
- 'put', testName]
- .concat(passthrough.args)),
- 0, 'put failed when it should have succeeded');
-
- // verify file metadata
- var fileObj = db.fs.files.findOne({
- filename: testName
- });
- assert(fileObj, testName + ' was not found');
-
- var numDbChunks = db.fs.chunks.count();
-
- // the number of chunks should be equal to math.ceil[fileSize (KB) / 255 KB]
- // filesize for the dump should be s bytes
- var expectedNumChunks = Math.ceil(fileObj.length / (1024 * 255));
-
- assert.eq(expectedNumChunks, numDbChunks, 'expected ' + expectedNumChunks + ' chunks; got ' + numDbChunks);
-
- // now attempt to get the large file
- jsTest.log('Getting file with ' + passthrough.name + ' passthrough');
-
- // ensure tool runs without error
- var getFile = testName + (Math.random() + 1).toString(36).substring(7);
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--local', getFile,
- 'get', testName]
- .concat(passthrough.args)),
- 0, 'get failed');
-
- // ensure the retrieved file is exactly the same as that inserted
- var actual = md5sumFile(putFile);
- var expected = md5sumFile(getFile);
-
- assert.eq(actual, expected, 'mismatched md5 sum - expected ' + expected + ' got ' + actual);
-
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_replace.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_replace.js
deleted file mode 100644
index baef44033e0..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_replace.js
+++ /dev/null
@@ -1,79 +0,0 @@
-// mongofiles_replace.js; ensure that after putting a file once multiple times,
-// on using --replace, any and all occurences of the given file is replaced in
-// the GridFS collection - all other files are left as is
-var testName = 'mongofiles_replace';
-load('jstests/files/util/mongofiles_common.js');
-(function() {
- jsTest.log('Testing mongofiles --replace option');
-
- var runTests = function(topology, passthrough) {
- var t = topology.init(passthrough);
- var conn = t.connection();
- var db = conn.getDB('test');
-
- jsTest.log('Running put on file with --replace with ' + passthrough.name + ' passthrough');
-
- // insert the same file a couple of times
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put failed when it should have succeeded 1');
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put failed when it should have succeeded 2');
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put failed when it should have succeeded 3');
-
- // ensure that it is never overwritten
- db.fs.files.findOne({
- filename: filesToInsert[0]
- });
-
- assert.eq(db.fs.files.count(), 3, 'expected 3 files inserted but got ' + db.fs.files.count());
-
- // now run with --replace
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--replace',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put failed when it should have succeeded 4');
-
- assert.eq(db.fs.files.count(), 1, 'expected 1 file inserted but got ' + db.fs.files.count());
-
- // insert other files but ensure only 1 is replaced
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'put', filesToInsert[1]]
- .concat(passthrough.args)),
- 0, 'put failed when it should have succeeded 5');
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'put', filesToInsert[2]]
- .concat(passthrough.args)),
- 0, 'put failed when it should have succeeded 6');
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--replace',
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put failed when it should have succeeded 7');
-
- assert.eq(db.fs.files.count(), 3, 'expected 3 files inserted but got ' + db.fs.files.count());
-
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_search.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_search.js
deleted file mode 100644
index 0a39326ff33..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_search.js
+++ /dev/null
@@ -1,110 +0,0 @@
-// mongofiles_search.js; ensures that the search command returns any and all
-// files that match the regex supplied
-var testName = 'mongofiles_search';
-(function() {
- load('jstests/files/util/mongofiles_common.js');
- load('jstests/libs/extended_assert.js');
- var assert = extendedAssert;
-
- var conn;
-
- // Given a list of search strings and an expected result - 0 for present or 1 for
- // hasMatch takes in raw mongofiles search output and a matchItem; it returns 0
- // if it finds the match item in any line of the output and 1 otherwise. If the
- // exactString argument is not empty, hasMatch further checks that the line
- // matches the argument
- var hasMatch = function(output, matchItem, exactString) {
- var lines = output.split('\n');
- var shellOutputRegex = /^sh.*/;
- for (var i = 0; i < lines.length; i++) {
- if (lines[i].match(shellOutputRegex) && lines[i].match(matchItem)) {
- if (exactString && !lines[i].match(exactString)) {
- continue;
- }
- return 0;
- }
- }
- // matchItem wasn't found
- return 1;
- };
-
- // note - assertHasFiles checks that the output of running mongofiles search with
- // each of the search strings meets the expected result supplied. If exactString
- // is not empty, it further checks that the output also matches exactString
- var assertHasFiles = function(passthrough, searchStrings, expectedResult, exactString) {
- // perform a couple of search commands against the GridFS collection
- for (var i = 0; i < searchStrings.length; i++) {
- clearRawMongoProgramOutput();
- var queryString = searchStrings[i];
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--quiet',
- '--port', conn.port,
- 'search', queryString]
- .concat(passthrough.args)),
- 0, 'search command failed on ' + queryString + ' - part of ' + searchStrings);
-
- // eslint-disable-next-line no-loop-func
- assert.eq.soon(expectedResult, function() {
- return hasMatch(rawMongoProgramOutput(), queryString, exactString);
- }, 'search failed: expected "' + queryString + '" to be ' + (expectedResult ? 'found' : 'missing'));
- }
- };
-
- var runTests = function(topology, passthrough) {
- jsTest.log('Testing mongofiles search command');
- var t = topology.init(passthrough);
- conn = t.connection();
-
- jsTest.log('Putting files into GridFS with ' + passthrough.name + ' passthrough');
-
- for (var i = 0; i < filesToInsert.length; i++) {
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- 'put', filesToInsert[i]]
- .concat(passthrough.args)),
- 0, 'put failed on ' + filesToInsert[i] + ' when it should have succeeded');
- }
-
- jsTest.log('Searching files in GridFS with ' + passthrough.name + ' passthrough');
-
- // these search strings should be matched
- var searchStrings = ['files', '.txt', 'ile', '.'];
-
- // add the verbatim file names put into GridFS
- for (i = 0; i < filesToInsert.length; i++) {
- searchStrings.push(filesToInsert[i]);
- }
-
- // all inserted files should be returned
- assertHasFiles(passthrough, searchStrings, 0);
-
- // these search strings should NOT be matched
- searchStrings = ['random', 'always', 'filer'];
- assertHasFiles(passthrough, searchStrings, 1);
-
- // test that only the requested file is returned
- for (i = 0; i < filesToInsert.length; i++) {
- var currentFile = filesToInsert[i];
- jsTest.log('Searching for file ' + currentFile + ' with ' + passthrough.name + ' passthrough');
-
- // ensure the requested file is returned
- assertHasFiles(passthrough, [currentFile], 0);
-
- // ensure no other files are returned
- assertHasFiles(passthrough,
- // eslint-disable-next-line no-loop-func
- filesToInsert.filter(function(file) {
- return file !== currentFile;
- }), 1, currentFile);
- }
-
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_type.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_type.js
deleted file mode 100644
index c5af7b3e70f..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_type.js
+++ /dev/null
@@ -1,63 +0,0 @@
-// mongofiles_type.js; ensure that the given content type is stored when passed
-// as the --type argument. If no argument is passed, it should be omitted in the
-// database.
-var testName = 'mongofiles_type';
-load('jstests/files/util/mongofiles_common.js');
-(function() {
- jsTest.log('Testing mongofiles --type option');
-
- var runTests = function(topology, passthrough) {
- var t = topology.init(passthrough);
- var conn = t.connection();
- var db = conn.getDB('test');
- var contentType = 'txt';
-
- jsTest.log('Running put on file with --type with ' + passthrough.name + ' passthrough');
-
- // ensure tool runs without error with a non-empty --type argument
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '-t', contentType,
- 'put', filesToInsert[0]]
- .concat(passthrough.args)),
- 0, 'put failed when it should have succeeded 1');
-
- var fileObj = db.fs.files.findOne({
- filename: filesToInsert[0]
- });
-
- assert(fileObj, 'did not find expected GridFS file - ' + filesToInsert[0]);
-
- assert.eq(fileObj.contentType, contentType, 'unexpected content type - found ' + fileObj.contentType + ' but expected ' + contentType);
-
- // ensure tool runs without error with empty --type argument on linux
- // and fails on windows
- var comparison = 'eq';
- if (_isWindows()) {
- comparison = 'neq';
- }
- assert[comparison](runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--type', '',
- 'put', filesToInsert[1]]
- .concat(passthrough.args)),
- 0, 'put failed unexpectedly');
-
- if (!_isWindows()) {
- fileObj = db.fs.files.findOne({
- filename: filesToInsert[1]
- });
- assert.neq(fileObj, null, 'did not find expected GridFS file - ' + filesToInsert[1]);
- assert.eq(fileObj.contentType, undefined, 'unexpected content type - found ' + fileObj.contentType + ' but expected undefined');
- }
-
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_version.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_version.js
deleted file mode 100644
index 3c2c3a6d959..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_version.js
+++ /dev/null
@@ -1,29 +0,0 @@
-// mongofiles_version.js; ensure that getting the version works without error
-var testName = 'mongofiles_version';
-load('jstests/files/util/mongofiles_common.js');
-(function() {
- jsTest.log('Testing mongofiles --version option');
-
- var runTests = function(topology, passthrough) {
- var t = topology.init(passthrough);
- var conn = t.connection();
-
- jsTest.log('Testing --version with ' + passthrough.name + ' passthrough');
-
- // ensure tool runs without error
- assert.eq(runMongoProgram.apply(this, ['mongofiles',
- '--port', conn.port,
- '--version']
- .concat(passthrough.args)),
- 0, '--version failed');
-
- t.stop();
- };
-
- // run with plain and auth passthroughs
- passthroughs.forEach(function(passthrough) {
- runTests(standaloneTopology, passthrough);
- runTests(replicaSetTopology, passthrough);
- runTests(shardedClusterTopology, passthrough);
- });
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_write_concern.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_write_concern.js
deleted file mode 100644
index 4e261536273..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_write_concern.js
+++ /dev/null
@@ -1,54 +0,0 @@
-(function() {
- if (typeof getToolTest === 'undefined') {
- load('jstests/configs/plain_28.config.js');
- }
-
- var toolTest = new ToolTest('write_concern', null);
- var commonToolArgs = getCommonToolArguments();
-
- var rs = new ReplSetTest({
- name: "rpls",
- nodes: 3,
- useHostName: true,
- settings: {chainingAllowed: false},
- });
-
- rs.startSet();
- rs.initiate();
- rs.awaitReplication();
- toolTest.port = rs.getPrimary().port;
- var dbOne = rs.nodes[0].getDB("dbOne");
-
- function writeConcernTestFunc(exitCode, writeConcern, name) {
- jsTest.log(name);
- ret = toolTest.runTool.apply(toolTest, ['files',
- '-vvvvv',
- '-d', 'dbOne']
- .concat(writeConcern)
- .concat(commonToolArgs)
- .concat(['put', 'jstests/files/testdata/files1.txt']));
- assert.eq(exitCode, ret, name);
- dbOne.dropDatabase();
- }
-
- function noConnectTest() {
- return startMongoProgramNoConnect.apply(null, ['mongofiles',
- '-d', 'dbOne',
- '--writeConcern={w:3}',
- '--host', rs.getPrimary().host]
- .concat(commonToolArgs)
- .concat(['put', 'jstests/files/testdata/files1.txt']));
- }
-
- // drop the database so it's empty
- dbOne.dropDatabase();
-
- // load and run the write concern suite
- load('jstests/libs/wc_framework.js');
- runWCTest("mongofiles", rs, toolTest, writeConcernTestFunc, noConnectTest);
-
- dbOne.dropDatabase();
- rs.stopSet();
- toolTest.stop();
-
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_write_concern_mongos.js b/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_write_concern_mongos.js
deleted file mode 100644
index 45386f2cc2f..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/mongofiles_write_concern_mongos.js
+++ /dev/null
@@ -1,59 +0,0 @@
-(function() {
- if (typeof getToolTest === 'undefined') {
- load('jstests/configs/plain_28.config.js');
- }
-
- var toolTest = new ToolTest('write_concern', null);
- var commonToolArgs = getCommonToolArguments();
-
- var st = new ShardingTest({
- shards: {
- rs0: {
- nodes: 3,
- useHostName: true,
- settings: {chainingAllowed: false},
- },
- },
- mongos: 1,
- config: 1,
- configReplSetTestOptions: {
- settings: {chainingAllowed: false},
- },
- });
- var rs = st.rs0;
- rs.awaitReplication();
- toolTest.port = st.s.port;
- var dbOne = st.s.getDB('dbOne');
- function writeConcernTestFunc(exitCode, writeConcern, name) {
- jsTest.log(name);
- ret = toolTest.runTool.apply(toolTest, ['files',
- '-vvvvv',
- '-d', 'dbOne']
- .concat(writeConcern)
- .concat(commonToolArgs)
- .concat(['put', 'jstests/files/testdata/files1.txt']));
- assert.eq(exitCode, ret, name);
- dbOne.dropDatabase();
- }
-
- function noConnectTest() {
- return startMongoProgramNoConnect.apply(null, ['mongofiles',
- '-d', 'dbOne',
- '--writeConcern={w:3}',
- '--host', st.s.host]
- .concat(commonToolArgs)
- .concat(['put', 'jstests/files/testdata/files1.txt']));
- }
-
- // drop the database so it's empty
- dbOne.dropDatabase();
-
- // load and run the write concern suite
- load('jstests/libs/wc_framework.js');
- runWCTest("mongofiles", rs, toolTest, writeConcernTestFunc, noConnectTest);
-
- dbOne.dropDatabase();
- rs.stopSet();
- toolTest.stop();
-
-}());
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/testdata/files1.txt b/src/mongo/gotools/test/qa-tests/jstests/files/testdata/files1.txt
deleted file mode 100644
index e9ea42a12b9..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/testdata/files1.txt
+++ /dev/null
@@ -1 +0,0 @@
-this is a text file
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/testdata/files2.txt b/src/mongo/gotools/test/qa-tests/jstests/files/testdata/files2.txt
deleted file mode 100644
index 6d65e626d46..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/testdata/files2.txt
+++ /dev/null
@@ -1 +0,0 @@
-this is another text file
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/testdata/files3.txt b/src/mongo/gotools/test/qa-tests/jstests/files/testdata/files3.txt
deleted file mode 100644
index 181ba5fd828..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/testdata/files3.txt
+++ /dev/null
@@ -1 +0,0 @@
-this is yet another test file
diff --git a/src/mongo/gotools/test/qa-tests/jstests/files/util/mongofiles_common.js b/src/mongo/gotools/test/qa-tests/jstests/files/util/mongofiles_common.js
deleted file mode 100644
index 7ff85d959b1..00000000000
--- a/src/mongo/gotools/test/qa-tests/jstests/files/util/mongofiles_common.js
+++ /dev/null
@@ -1,10 +0,0 @@
-// mongofiles_common.js; contains variables used by mongofiles tests
-load('jstests/common/topology_helper.js');
-
-/* exported filesToInsert */
-// these must have unique names
-var filesToInsert = [
- 'jstests/files/testdata/files1.txt',
- 'jstests/files/testdata/files2.txt',
- 'jstests/files/testdata/files3.txt'
-];