From b4b9a84dcaf0dbabf99bc16231e0b33ae76bddd3 Mon Sep 17 00:00:00 2001 From: Wisdom Omuya Date: Mon, 17 Nov 2014 13:37:46 -0500 Subject: TOOLS-373: move legacy/legacy26 to test/ Former-commit-id: 1d532749e40012811ef1ad1addaba76254cc88e8 --- test/legacy28/jstests/libs/analyze_plan.js | 80 ++ test/legacy28/jstests/libs/authTestsKey | 1 + test/legacy28/jstests/libs/badSAN.pem | 48 ++ test/legacy28/jstests/libs/ca.pem | 48 ++ test/legacy28/jstests/libs/client.pem | 48 ++ test/legacy28/jstests/libs/client_revoked.pem | 48 ++ test/legacy28/jstests/libs/cluster_cert.pem | 48 ++ .../libs/command_line/test_parsed_options.js | 214 +++++ .../jstests/libs/config_files/disable_auth.ini | 1 + .../jstests/libs/config_files/disable_dur.ini | 1 + .../libs/config_files/disable_httpinterface.ini | 1 + .../jstests/libs/config_files/disable_ipv6.ini | 1 + .../jstests/libs/config_files/disable_journal.ini | 1 + .../jstests/libs/config_files/disable_jsonp.ini | 1 + .../jstests/libs/config_files/disable_jsonp.json | 7 + .../libs/config_files/disable_moveparanoia.ini | 1 + .../jstests/libs/config_files/disable_noauth.ini | 1 + .../libs/config_files/disable_noautosplit.ini | 1 + .../jstests/libs/config_files/disable_nodur.ini | 1 + .../libs/config_files/disable_nohttpinterface.ini | 1 + .../config_files/disable_noindexbuildretry.ini | 1 + .../libs/config_files/disable_nojournal.ini | 1 + .../libs/config_files/disable_nomoveparanoia.ini | 1 + .../libs/config_files/disable_noobjcheck.ini | 1 + .../libs/config_files/disable_noprealloc.ini | 1 + .../libs/config_files/disable_noscripting.ini | 1 + .../libs/config_files/disable_nounixsocket.ini | 1 + .../jstests/libs/config_files/disable_objcheck.ini | 1 + .../libs/config_files/disable_rest_interface.json | 7 + .../jstests/libs/config_files/enable_auth.json | 5 + .../libs/config_files/enable_autosplit.json | 5 + .../libs/config_files/enable_httpinterface.json | 7 + .../libs/config_files/enable_indexbuildretry.json | 5 + .../jstests/libs/config_files/enable_journal.json | 7 + .../jstests/libs/config_files/enable_objcheck.json | 5 + .../jstests/libs/config_files/enable_paranoia.json | 5 + .../jstests/libs/config_files/enable_prealloc.json | 5 + .../libs/config_files/enable_scripting.json | 5 + .../libs/config_files/enable_unixsocket.json | 7 + .../libs/config_files/implicitly_enable_dur.ini | 1 + .../config_files/implicitly_enable_journal.ini | 1 + .../libs/config_files/implicitly_enable_nodur.ini | 1 + .../config_files/implicitly_enable_nojournal.ini | 1 + .../libs/config_files/set_component_verbosity.json | 16 + .../jstests/libs/config_files/set_profiling.json | 5 + .../jstests/libs/config_files/set_replsetname.json | 5 + .../libs/config_files/set_shardingrole.json | 5 + .../jstests/libs/config_files/set_verbosity.json | 5 + test/legacy28/jstests/libs/crl.pem | 38 + test/legacy28/jstests/libs/crl_client_revoked.pem | 41 + test/legacy28/jstests/libs/crl_expired.pem | 38 + .../jstests/libs/dur_checksum_bad_first.journal | Bin 0 -> 32768 bytes .../jstests/libs/dur_checksum_bad_last.journal | Bin 0 -> 32768 bytes .../jstests/libs/dur_checksum_good.journal | Bin 0 -> 32768 bytes test/legacy28/jstests/libs/expired.pem | 48 ++ test/legacy28/jstests/libs/fts.js | 18 + test/legacy28/jstests/libs/geo_near_random.js | 101 +++ test/legacy28/jstests/libs/host_ipaddr.js | 38 + test/legacy28/jstests/libs/key1 | 1 + test/legacy28/jstests/libs/key2 | 1 + test/legacy28/jstests/libs/localhostnameCN.pem | 48 ++ test/legacy28/jstests/libs/localhostnameSAN.pem | 49 ++ test/legacy28/jstests/libs/mockkrb5.conf | 13 + test/legacy28/jstests/libs/mockservice.keytab | Bin 0 -> 442 bytes test/legacy28/jstests/libs/mockuser.keytab | Bin 0 -> 340 bytes test/legacy28/jstests/libs/not_yet_valid.pem | 48 ++ test/legacy28/jstests/libs/parallelTester.js | 259 ++++++ test/legacy28/jstests/libs/password_protected.pem | 51 ++ test/legacy28/jstests/libs/server.pem | 48 ++ test/legacy28/jstests/libs/servers.js | 957 +++++++++++++++++++++ test/legacy28/jstests/libs/servers_misc.js | 357 ++++++++ test/legacy28/jstests/libs/slow_weekly_util.js | 20 + test/legacy28/jstests/libs/smoke.pem | 48 ++ test/legacy28/jstests/libs/test_background_ops.js | 340 ++++++++ test/legacy28/jstests/libs/testconfig | 6 + test/legacy28/jstests/libs/testconfig.json | 4 + test/legacy28/jstests/libs/trace_missing_docs.js | 90 ++ test/legacy28/jstests/replsets/rslib.js | 115 +++ test/legacy28/jstests/tool/csv1.js | 43 + test/legacy28/jstests/tool/csvexport1.js | 65 ++ test/legacy28/jstests/tool/csvexport2.js | 32 + test/legacy28/jstests/tool/csvimport1.js | 41 + test/legacy28/jstests/tool/data/a.tsv | 2 + test/legacy28/jstests/tool/data/csvimport1.csv | 8 + .../jstests/tool/data/dumprestore6/foo.bson | Bin 0 -> 44 bytes .../tool/data/dumprestore6/system.indexes.bson | Bin 0 -> 144 bytes test/legacy28/jstests/tool/dumpauth.js | 39 + test/legacy28/jstests/tool/dumpfilename1.js | 13 + test/legacy28/jstests/tool/dumprestore1.js | 32 + test/legacy28/jstests/tool/dumprestore10.js | 64 ++ test/legacy28/jstests/tool/dumprestore3.js | 61 ++ test/legacy28/jstests/tool/dumprestore4.js | 43 + test/legacy28/jstests/tool/dumprestore6.js | 28 + test/legacy28/jstests/tool/dumprestore7.js | 66 ++ test/legacy28/jstests/tool/dumprestore8.js | 106 +++ test/legacy28/jstests/tool/dumprestore9.js | 79 ++ .../jstests/tool/dumprestoreWithNoOptions.js | 112 +++ test/legacy28/jstests/tool/dumprestore_auth.js | 99 +++ test/legacy28/jstests/tool/dumprestore_auth2.js | 98 +++ test/legacy28/jstests/tool/dumprestore_auth3.js | 200 +++++ .../jstests/tool/dumprestore_excludecollections.js | 112 +++ test/legacy28/jstests/tool/dumpsecondary.js | 39 + test/legacy28/jstests/tool/exportimport1.js | 67 ++ test/legacy28/jstests/tool/exportimport3.js | 28 + test/legacy28/jstests/tool/exportimport4.js | 57 ++ test/legacy28/jstests/tool/exportimport5.js | 82 ++ test/legacy28/jstests/tool/exportimport6.js | 27 + .../legacy28/jstests/tool/exportimport_bigarray.js | 59 ++ test/legacy28/jstests/tool/exportimport_date.js | 50 ++ .../jstests/tool/exportimport_minkey_maxkey.js | 38 + test/legacy28/jstests/tool/files1.js | 28 + test/legacy28/jstests/tool/oplog1.js | 27 + test/legacy28/jstests/tool/oplog_all_ops.js | 62 ++ test/legacy28/jstests/tool/restorewithauth.js | 114 +++ test/legacy28/jstests/tool/stat1.js | 18 + test/legacy28/jstests/tool/tool1.js | 44 + test/legacy28/jstests/tool/tool_replset.js | 89 ++ test/legacy28/jstests/tool/tsv1.js | 33 + 118 files changed, 5646 insertions(+) create mode 100644 test/legacy28/jstests/libs/analyze_plan.js create mode 100644 test/legacy28/jstests/libs/authTestsKey create mode 100644 test/legacy28/jstests/libs/badSAN.pem create mode 100644 test/legacy28/jstests/libs/ca.pem create mode 100644 test/legacy28/jstests/libs/client.pem create mode 100644 test/legacy28/jstests/libs/client_revoked.pem create mode 100644 test/legacy28/jstests/libs/cluster_cert.pem create mode 100644 test/legacy28/jstests/libs/command_line/test_parsed_options.js create mode 100644 test/legacy28/jstests/libs/config_files/disable_auth.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_dur.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_httpinterface.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_ipv6.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_journal.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_jsonp.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_jsonp.json create mode 100644 test/legacy28/jstests/libs/config_files/disable_moveparanoia.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_noauth.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_noautosplit.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_nodur.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_nohttpinterface.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_noindexbuildretry.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_nojournal.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_nomoveparanoia.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_noobjcheck.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_noprealloc.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_noscripting.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_nounixsocket.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_objcheck.ini create mode 100644 test/legacy28/jstests/libs/config_files/disable_rest_interface.json create mode 100644 test/legacy28/jstests/libs/config_files/enable_auth.json create mode 100644 test/legacy28/jstests/libs/config_files/enable_autosplit.json create mode 100644 test/legacy28/jstests/libs/config_files/enable_httpinterface.json create mode 100644 test/legacy28/jstests/libs/config_files/enable_indexbuildretry.json create mode 100644 test/legacy28/jstests/libs/config_files/enable_journal.json create mode 100644 test/legacy28/jstests/libs/config_files/enable_objcheck.json create mode 100644 test/legacy28/jstests/libs/config_files/enable_paranoia.json create mode 100644 test/legacy28/jstests/libs/config_files/enable_prealloc.json create mode 100644 test/legacy28/jstests/libs/config_files/enable_scripting.json create mode 100644 test/legacy28/jstests/libs/config_files/enable_unixsocket.json create mode 100644 test/legacy28/jstests/libs/config_files/implicitly_enable_dur.ini create mode 100644 test/legacy28/jstests/libs/config_files/implicitly_enable_journal.ini create mode 100644 test/legacy28/jstests/libs/config_files/implicitly_enable_nodur.ini create mode 100644 test/legacy28/jstests/libs/config_files/implicitly_enable_nojournal.ini create mode 100644 test/legacy28/jstests/libs/config_files/set_component_verbosity.json create mode 100644 test/legacy28/jstests/libs/config_files/set_profiling.json create mode 100644 test/legacy28/jstests/libs/config_files/set_replsetname.json create mode 100644 test/legacy28/jstests/libs/config_files/set_shardingrole.json create mode 100644 test/legacy28/jstests/libs/config_files/set_verbosity.json create mode 100644 test/legacy28/jstests/libs/crl.pem create mode 100644 test/legacy28/jstests/libs/crl_client_revoked.pem create mode 100644 test/legacy28/jstests/libs/crl_expired.pem create mode 100644 test/legacy28/jstests/libs/dur_checksum_bad_first.journal create mode 100644 test/legacy28/jstests/libs/dur_checksum_bad_last.journal create mode 100644 test/legacy28/jstests/libs/dur_checksum_good.journal create mode 100644 test/legacy28/jstests/libs/expired.pem create mode 100644 test/legacy28/jstests/libs/fts.js create mode 100644 test/legacy28/jstests/libs/geo_near_random.js create mode 100644 test/legacy28/jstests/libs/host_ipaddr.js create mode 100644 test/legacy28/jstests/libs/key1 create mode 100644 test/legacy28/jstests/libs/key2 create mode 100644 test/legacy28/jstests/libs/localhostnameCN.pem create mode 100644 test/legacy28/jstests/libs/localhostnameSAN.pem create mode 100644 test/legacy28/jstests/libs/mockkrb5.conf create mode 100644 test/legacy28/jstests/libs/mockservice.keytab create mode 100644 test/legacy28/jstests/libs/mockuser.keytab create mode 100644 test/legacy28/jstests/libs/not_yet_valid.pem create mode 100644 test/legacy28/jstests/libs/parallelTester.js create mode 100644 test/legacy28/jstests/libs/password_protected.pem create mode 100644 test/legacy28/jstests/libs/server.pem create mode 100755 test/legacy28/jstests/libs/servers.js create mode 100644 test/legacy28/jstests/libs/servers_misc.js create mode 100644 test/legacy28/jstests/libs/slow_weekly_util.js create mode 100644 test/legacy28/jstests/libs/smoke.pem create mode 100644 test/legacy28/jstests/libs/test_background_ops.js create mode 100644 test/legacy28/jstests/libs/testconfig create mode 100644 test/legacy28/jstests/libs/testconfig.json create mode 100644 test/legacy28/jstests/libs/trace_missing_docs.js create mode 100644 test/legacy28/jstests/replsets/rslib.js create mode 100644 test/legacy28/jstests/tool/csv1.js create mode 100644 test/legacy28/jstests/tool/csvexport1.js create mode 100644 test/legacy28/jstests/tool/csvexport2.js create mode 100644 test/legacy28/jstests/tool/csvimport1.js create mode 100644 test/legacy28/jstests/tool/data/a.tsv create mode 100644 test/legacy28/jstests/tool/data/csvimport1.csv create mode 100644 test/legacy28/jstests/tool/data/dumprestore6/foo.bson create mode 100644 test/legacy28/jstests/tool/data/dumprestore6/system.indexes.bson create mode 100644 test/legacy28/jstests/tool/dumpauth.js create mode 100644 test/legacy28/jstests/tool/dumpfilename1.js create mode 100644 test/legacy28/jstests/tool/dumprestore1.js create mode 100644 test/legacy28/jstests/tool/dumprestore10.js create mode 100644 test/legacy28/jstests/tool/dumprestore3.js create mode 100644 test/legacy28/jstests/tool/dumprestore4.js create mode 100644 test/legacy28/jstests/tool/dumprestore6.js create mode 100644 test/legacy28/jstests/tool/dumprestore7.js create mode 100644 test/legacy28/jstests/tool/dumprestore8.js create mode 100644 test/legacy28/jstests/tool/dumprestore9.js create mode 100644 test/legacy28/jstests/tool/dumprestoreWithNoOptions.js create mode 100644 test/legacy28/jstests/tool/dumprestore_auth.js create mode 100644 test/legacy28/jstests/tool/dumprestore_auth2.js create mode 100644 test/legacy28/jstests/tool/dumprestore_auth3.js create mode 100644 test/legacy28/jstests/tool/dumprestore_excludecollections.js create mode 100644 test/legacy28/jstests/tool/dumpsecondary.js create mode 100644 test/legacy28/jstests/tool/exportimport1.js create mode 100644 test/legacy28/jstests/tool/exportimport3.js create mode 100644 test/legacy28/jstests/tool/exportimport4.js create mode 100644 test/legacy28/jstests/tool/exportimport5.js create mode 100644 test/legacy28/jstests/tool/exportimport6.js create mode 100644 test/legacy28/jstests/tool/exportimport_bigarray.js create mode 100644 test/legacy28/jstests/tool/exportimport_date.js create mode 100644 test/legacy28/jstests/tool/exportimport_minkey_maxkey.js create mode 100644 test/legacy28/jstests/tool/files1.js create mode 100644 test/legacy28/jstests/tool/oplog1.js create mode 100644 test/legacy28/jstests/tool/oplog_all_ops.js create mode 100644 test/legacy28/jstests/tool/restorewithauth.js create mode 100644 test/legacy28/jstests/tool/stat1.js create mode 100644 test/legacy28/jstests/tool/tool1.js create mode 100644 test/legacy28/jstests/tool/tool_replset.js create mode 100644 test/legacy28/jstests/tool/tsv1.js (limited to 'test/legacy28/jstests') diff --git a/test/legacy28/jstests/libs/analyze_plan.js b/test/legacy28/jstests/libs/analyze_plan.js new file mode 100644 index 00000000000..9c2ebffd890 --- /dev/null +++ b/test/legacy28/jstests/libs/analyze_plan.js @@ -0,0 +1,80 @@ +// Contains helpers for checking, based on the explain output, properties of a +// plan. For instance, there are helpers for checking whether a plan is a collection +// scan or whether the plan is covered (index only). + +/** + * Given the root stage of explain's BSON representation of a query plan ('root'), + * returns true if the plan has a stage called 'stage'. + */ +function planHasStage(root, stage) { + if (root.stage === stage) { + return true; + } + else if ("inputStage" in root) { + return planHasStage(root.inputStage, stage); + } + else if ("inputStages" in root) { + for (var i = 0; i < root.inputStages.length; i++) { + if (planHasStage(root.inputStages[i], stage)) { + return true; + } + } + } + + return false; +} + +/** + * A query is covered iff it does *not* have a FETCH stage or a COLLSCAN. + * + * Given the root stage of explain's BSON representation of a query plan ('root'), + * returns true if the plan is index only. Otherwise returns false. + */ +function isIndexOnly(root) { + return !planHasStage(root, "FETCH") && !planHasStage(root, "COLLSCAN"); +} + +/** + * Returns true if the BSON representation of a plan rooted at 'root' is using + * an index scan, and false otherwise. + */ +function isIxscan(root) { + return planHasStage(root, "IXSCAN"); +} + +/** + * Returns true if the BSON representation of a plan rooted at 'root' is using + * the idhack fast path, and false otherwise. + */ +function isIdhack(root) { + return planHasStage(root, "IDHACK"); +} + +/** + * Returns true if the BSON representation of a plan rooted at 'root' is using + * a collection scan, and false otherwise. + */ +function isCollscan(root) { + return planHasStage(root, "COLLSCAN"); +} + +/** + * Get the number of chunk skips for the BSON exec stats tree rooted at 'root'. + */ +function getChunkSkips(root) { + if (root.stage === "SHARDING_FILTER") { + return root.chunkSkips; + } + else if ("inputStage" in root) { + return getChunkSkips(root.inputStage); + } + else if ("inputStages" in root) { + var skips = 0; + for (var i = 0; i < root.inputStages.length; i++) { + skips += getChunkSkips(root.inputStages[0]); + } + return skips; + } + + return 0; +} diff --git a/test/legacy28/jstests/libs/authTestsKey b/test/legacy28/jstests/libs/authTestsKey new file mode 100644 index 00000000000..573898a4f05 --- /dev/null +++ b/test/legacy28/jstests/libs/authTestsKey @@ -0,0 +1 @@ +This key is only for running the suite with authentication dont use it in any tests directly diff --git a/test/legacy28/jstests/libs/badSAN.pem b/test/legacy28/jstests/libs/badSAN.pem new file mode 100644 index 00000000000..d8e362731e0 --- /dev/null +++ b/test/legacy28/jstests/libs/badSAN.pem @@ -0,0 +1,48 @@ +-----BEGIN CERTIFICATE----- +MIIDdTCCAl2gAwIBAgIDAYKXMA0GCSqGSIb3DQEBBQUAMHQxFzAVBgNVBAMTDktl +cm5lbCBUZXN0IENBMQ8wDQYDVQQLEwZLZXJuZWwxEDAOBgNVBAoTB01vbmdvREIx +FjAUBgNVBAcTDU5ldyBZb3JrIENpdHkxETAPBgNVBAgTCE5ldyBZb3JrMQswCQYD +VQQGEwJVUzAeFw0xNDA5MjMxNTE3MjNaFw0zNDA5MjMxNTE3MjNaMG8xEjAQBgNV +BAMTCTEyNy4wLjAuMTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RC +MRYwFAYDVQQHEw1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkG +A1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCDB/lxuzeU +OHR5nnOTJM0fHz0WeicnuUfGG5wP89Mbkd3Y+BNS0ozbnkW+NAGhD+ehNBjogISZ +jLCd+uaYu7TLWpkgki+1+gM99Ro0vv7dIc8vD7ToILKMbM8xQmLbSxDT2tCUoXlc +m7ccgDZl9oW1scQYQ8gWHjmk3yK8sCoGa/uwr49u74aVM7673tLsK41m8oYPzt/q +VGT+mXpBJQcGXkTNQtIPxBtD25jr+aPietS3u70zrVPY6ZDsGE7DofEeRl97kVoF +NcpaQmVEwEo8KCWaT6OaPaUUUjAMwzqiZaHNZ6mL1pCr65bLXP6T9tiMtWLw5+SG +3E09fhQuWod5AgMBAAGjFTATMBEGA1UdEQQKMAiCBmJhZFNBTjANBgkqhkiG9w0B +AQUFAAOCAQEAQzlibJ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525tw90QVI048fr9SL3ftLHOt4FhucSCn0Z +CjylP4ECgYEA+nQrNVdVwmxcWCVn69LR1grNXUSz+fLHCo+QKma4IyC1kuuZ+BBo +Iwdf9t/S1tgtTYru3uxzCpQg7J1iDeEFEsMHl0rc6U1MmIE+6OvACVG3yotqoOqE +852pi1OWIe94yTk2ZmNXJ8gpUE/gtMprbcSWOb7IzzrXy2lDcaEMuGkCgYEAhe7L +ZvYI4LEvu6GSPp97qBzDH9m5UrHaTZIJk/Nu7ie919Sdg62LTfphsaK+pSyA55XQ +8L9P7wNUPC44NnE+7CIJZsIuKdYqR5QI6No9RdTyij0Hgljfc7KuH2b8lf8EjvuH +qZAf5zL3pIOQs8E8/MYHlGIqmTkYK41eCAcS9JECgYEADnra6KmU9rmnGR2IhZTZ +tuNG/kZzlVbY9R5ZumnX6YgBl23xp+ri6muJu88y9GLpM5t9tfu7pvfrc2KiAaVp +0qzd6nxUi1SBwituxK6kmqVT1+z5jDYi26bY34pEms+qjw+0unSx3EXxRYhouGsf +jOgZu1rxZzHCuirq0E38W0kCgYBzOK16RX37t9OFywlioJekWCIxu4BouSNCirl8 +s/eiIUR8cqiUCPAIRLhZNtZmiTPYiBW5mAyvZiDIqUao56InSVznL3TBf0LeU2ea +023VLs79yGU2aTjLc1PDJjl03XDRhWj/okMgBsPvn1QUoNDT8ZXBvPZC3VCC31qe +818GUQKBgQDBUP2BC/Th/0dErOQ5lWkY3YbmzrTp2pDsHGZJRD+OdQ5B8FUvCP8m +JESk/0ATn7niUqawnOy/2KlKIkeBBV2XL1rjIGEhCkBUuhCiInNDqz1AGdXzIKaT +myoZ4PhIsH1D643e6iLhyAZuUAA4yB31E2a3l7EMyhV3vKbdWWygGQ== +-----END RSA PRIVATE KEY----- diff --git a/test/legacy28/jstests/libs/ca.pem b/test/legacy28/jstests/libs/ca.pem new file mode 100644 index 00000000000..d1a5689cf0f --- /dev/null +++ b/test/legacy28/jstests/libs/ca.pem @@ -0,0 +1,48 @@ +-----BEGIN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hHGt5sGGxTkCgYEAhAaw +voHI6Cb+4z3PNAKRnf2rExBYRyCz1KF16ksuwJyQSLzFleXRyRWFUEwLuVRL0+EZ +JXhMbtrILrc23dJGEsB8kOCFehSH/IuL5eB0QfKpDFA+e6pimsbVeggx/rZhcERB +WkcV3jN4O82gSL3EnIgvAT1/nwhmbmjvDhFJhZcCgYBaW4E3IbaZaz9S/O0m69Fa +GbQWvS3CRV1oxqgK9cTUcE9Qnd9UC949O3GwHw0FMERjz3N7B/8FGW/dEuQ9Hniu +NLmvqWbGlnqWywNcMihutJKbDCdp/Km5olUPkiNbB3sWsOkViXoiU/V0pK6BZvir +d67EZpGwydpogyH9kVVCEQKBgGHXc3Q7SmCBRbOyQrQQk0m6i+V8328W1S5m2bPg +M62aWXMOMn976ZRT1pBDSwz1Y5yJ3NDf7gTZLjEwpgCNrFCJRcc4HLL0NDL8V5js +VjvpUU5GyYdsJdb+M4ZUPHi/QEaqzqPQumwJSLlJEdfWirZWVj9dDA8XcpGwQjjy +psHRAoGBAJUTgeJYhjK7k5sgfh+PRqiRJP0msIH8FK7SenBGRUkelWrW6td2Riey +EcOCMFkRWBeDgnZN5xDyWLBgrzpw9iHQQIUyyBaFknQcRUYKHkCx+k+fr0KHHCUb +X2Kvf0rbeMucb4y/h7950HkBBq83AYKMAoI8Ql3cx7pKmyOLXRov +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/test/legacy28/jstests/libs/client.pem b/test/legacy28/jstests/libs/client.pem new file mode 100644 index 00000000000..50a64e41728 --- /dev/null +++ b/test/legacy28/jstests/libs/client.pem @@ -0,0 +1,48 @@ +-----BEGIN CERTIFICATE----- +MIIDXTCCAkWgAwIBAgIBAzANBgkqhkiG9w0BAQUFADB0MRcwFQYDVQQDEw5LZXJu +ZWwgVGVzdCBDQTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYw +FAYDVQQHEw1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9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MNKFLKOpWm5z2zeyhYOGahc5cxNppBMpNUxwTb6AuwsyMjxhty+E +nqi2PU4IDXVWDWd3cLIdfB2r/OA99Ez4ZI0QmaLw0L8QoJZUVL7QurdqR9JsyHs6 +puUqIrb195s/yiPR7sjeJe0CgYEAuJviKEd3JxCN52RcJ58OGrh2oKsJ9/EbV0rX +Ixfs7th9GMDDHuOOQbNqKOR4yMSlhCU/hKA4PgTFWPIEbOiM08XtuZIb2i0qyNjH +N4qnqr166bny3tJnzOAgl1ljNHa8y+UsBTO3cCr17Jh0vL0KLSAGa9XvBAWKaG6b +1iIXwXkCgYAVz+DA1yy0qfXdS1pgPiCJGlGZXpbBcFnqvbpGSclKWyUG4obYCbrb +p5VKVfoK7uU0ly60w9+PNIRsX/VN/6SVcoOzKx40qQBMuYfJ72DQrsPjPYvNg/Nb +4SK94Qhp9TlAyXbqKJ02DjtuDim44sGZ8g7b+k3FfoK4OtzNsqdVdQ== +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/test/legacy28/jstests/libs/client_revoked.pem b/test/legacy28/jstests/libs/client_revoked.pem new file mode 100644 index 00000000000..03db67deb50 --- /dev/null +++ b/test/legacy28/jstests/libs/client_revoked.pem @@ -0,0 +1,48 @@ +-----BEGIN CERTIFICATE----- +MIIDZTCCAk2gAwIBAgIBAjANBgkqhkiG9w0BAQUFADB0MRcwFQYDVQQDEw5LZXJu +ZWwgVGVzdCBDQTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYw +FAYDVQQHEw1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkGA1UE +BhMCVVMwHhcNMTQwNzE3MTYwMDAwWhcNMjAwNzE3MTYwMDAwWjB4MRcwFQYDVQQD +Ew5jbGllbnRfcmV2b2tlZDETMBEGA1UECxMKS2VybmVsVXNlcjEQMA4GA1UEChMH +TW9uZ29EQjEWMBQGA1UEBxMNTmV3IFlvcmsgQ2l0eTERMA8GA1UECBMITm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BHoLlifkdmM +18U23QbmcwdESg/LAQF6MoGVTf//rJ/v2/ltTHBZZ2aDex7uKZxoImjHsWpXokhW +cmz+zqmlFarWOzrGQl1hD2s0P1sQrVg3KXe8z1KrD/Fw0/Yitga7GlWWZrGmG6li +lvu4YQKBgQANODQYEaz739IoPNnMfTpTqAoQIOR4PNdMfCXSQrCB8i0Hh4z48E4F +DEAd1xIYyxI8pu7r52dQlBk7yrILOTG0gmgLJd5xKdtCTrasYAICI3hsRLtP8dVA +8WeykXY4Wf1bYQ+VzKVImkwL/SBm2ik5woyxCzT8JSjyoAwRrQp9Vw== +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/test/legacy28/jstests/libs/cluster_cert.pem b/test/legacy28/jstests/libs/cluster_cert.pem new file mode 100644 index 00000000000..a8623ab67ef --- /dev/null +++ b/test/legacy28/jstests/libs/cluster_cert.pem @@ -0,0 +1,48 @@ +-----BEGIN CERTIFICATE----- +MIIDXjCCAkagAwIBAgIBBDANBgkqhkiG9w0BAQUFADB0MRcwFQYDVQQDEw5LZXJu +ZWwgVGVzdCBDQTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYw +FAYDVQQHEw1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkGA1UE +BhMCVVMwHhcNMTQwNzE3MTYwMDAwWhcNMjAwNzE3MTYwMDAwWjBxMRQwEgYDVQQD +EwtjbHVzdGVydGVzdDEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RC +MRYwFAYDVQQHEw1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkG +A1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCX42ZTwADG +sEkS7ijfADlDQaJpbdgrnQKa5ssMQK3oRGSqXfTp0ThsJiVBbYZ8ZZRpPMgJdowa +pFCGHQJh6VOdKelR0f/uNVpBGVz1yD4E4AtkA6UY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B27e6g33rfGGAW+/+RJ7/uHxuYCuKhstbq/x+rf9i4nl93emlMV +PC3yuZsCmpk9Uypzi2+PT10yVgXkXRYtLpuUpoABWRzVXGnEsXo= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/test/legacy28/jstests/libs/command_line/test_parsed_options.js b/test/legacy28/jstests/libs/command_line/test_parsed_options.js new file mode 100644 index 00000000000..f194b73ce7f --- /dev/null +++ b/test/legacy28/jstests/libs/command_line/test_parsed_options.js @@ -0,0 +1,214 @@ +// Merge the two options objects. Used as a helper when we are trying to actually compare options +// despite the fact that our test framework adds extra stuff to it. Anything set in the second +// options object overrides the first options object. The two objects must have the same structure. +function mergeOptions(obj1, obj2) { + var obj3 = {}; + for (var attrname in obj1) { + if (typeof obj1[attrname] === "object" && + typeof obj2[attrname] !== "undefined") { + if (typeof obj2[attrname] !== "object") { + throw Error("Objects being merged must have the same structure"); + } + obj3[attrname] = mergeOptions(obj1[attrname], obj2[attrname]); + } + else { + obj3[attrname] = obj1[attrname]; + } + } + for (var attrname in obj2) { + if (typeof obj2[attrname] === "object" && + typeof obj1[attrname] !== "undefined") { + if (typeof obj1[attrname] !== "object") { + throw Error("Objects being merged must have the same structure"); + } + // Already handled above + } + else { + obj3[attrname] = obj2[attrname]; + } + } + return obj3; +} + +// Test that the parsed result of setting certain command line options has the correct format in +// mongod. See SERVER-13379. +// +// Arguments: +// mongoRunnerConfig - Configuration object to pass to the mongo runner +// expectedResult - Object formatted the same way as the result of running the "getCmdLineOpts" +// command, but with only the fields that should be set by the options implied by the first +// argument set. +// +// Example: +// +// testGetCmdLineOptsMongod({ port : 10000 }, { "parsed" : { "net" : { "port" : 10000 } } }); +// +var getCmdLineOptsBaseMongod; +function testGetCmdLineOptsMongod(mongoRunnerConfig, expectedResult) { + + // Get the options object returned by "getCmdLineOpts" when we spawn a mongod using our test + // framework without passing any additional options. We need this because the framework adds + // options of its own, and we only want to compare against the options we care about. + function getBaseOptsObject() { + + // Start mongod with no options + var baseMongod = MongoRunner.runMongod(); + + // Get base command line opts. Needed because the framework adds its own options + var getCmdLineOptsBaseMongod = baseMongod.adminCommand("getCmdLineOpts"); + + // Stop the mongod we used to get the options + MongoRunner.stopMongod(baseMongod.port); + + return getCmdLineOptsBaseMongod; + } + + if (typeof getCmdLineOptsBaseMongod === "undefined") { + getCmdLineOptsBaseMongod = getBaseOptsObject(); + } + + // Get base command line opts. Needed because the framework adds its own options + var getCmdLineOptsExpected = getCmdLineOptsBaseMongod; + + // Delete port and dbPath if we are not explicitly setting them, since they will change on + // multiple runs of the test framework and cause false failures. + if (typeof expectedResult.parsed === "undefined" || + typeof expectedResult.parsed.net === "undefined" || + typeof expectedResult.parsed.net.port === "undefined") { + delete getCmdLineOptsExpected.parsed.net.port; + } + if (typeof expectedResult.parsed === "undefined" || + typeof expectedResult.parsed.storage === "undefined" || + typeof expectedResult.parsed.storage.dbPath === "undefined") { + delete getCmdLineOptsExpected.parsed.storage.dbPath; + } + + // Merge with the result that we expect + expectedResult = mergeOptions(getCmdLineOptsExpected, expectedResult); + + // Start mongod with options + var mongod = MongoRunner.runMongod(mongoRunnerConfig); + + // Create and authenticate high-privilege user in case mongod is running with authorization. + // Try/catch is necessary in case this is being run on an uninitiated replset, by a test + // such as repl_options.js for example. + var ex; + try { + mongod.getDB("admin").createUser({user: "root", pwd: "pass", roles: ["root"]}); + mongod.getDB("admin").auth("root", "pass"); + } + catch (ex) { + } + + // Get the parsed options + var getCmdLineOptsResult = mongod.adminCommand("getCmdLineOpts"); + + // Delete port and dbPath if we are not explicitly setting them, since they will change on + // multiple runs of the test framework and cause false failures. + if (typeof expectedResult.parsed === "undefined" || + typeof expectedResult.parsed.net === "undefined" || + typeof expectedResult.parsed.net.port === "undefined") { + delete getCmdLineOptsResult.parsed.net.port; + } + if (typeof expectedResult.parsed === "undefined" || + typeof expectedResult.parsed.storage === "undefined" || + typeof expectedResult.parsed.storage.dbPath === "undefined") { + delete getCmdLineOptsResult.parsed.storage.dbPath; + } + + // Make sure the options are equal to what we expect + assert.docEq(getCmdLineOptsResult.parsed, expectedResult.parsed); + + // Cleanup + mongod.getDB("admin").logout(); + MongoRunner.stopMongod(mongod.port); +} + +// Test that the parsed result of setting certain command line options has the correct format in +// mongos. See SERVER-13379. +// +// Arguments: +// mongoRunnerConfig - Configuration object to pass to the mongo runner +// expectedResult - Object formatted the same way as the result of running the "getCmdLineOpts" +// command, but with only the fields that should be set by the options implied by the first +// argument set. +// +// Example: +// +// testGetCmdLineOptsMongos({ port : 10000 }, { "parsed" : { "net" : { "port" : 10000 } } }); +// +var getCmdLineOptsBaseMongos; +function testGetCmdLineOptsMongos(mongoRunnerConfig, expectedResult) { + + // Get the options object returned by "getCmdLineOpts" when we spawn a mongos using our test + // framework without passing any additional options. We need this because the framework adds + // options of its own, and we only want to compare against the options we care about. + function getBaseOptsObject() { + + // Start mongod with no options + var baseMongod = MongoRunner.runMongod(); + + // Start mongos with only the configdb option + var baseMongos = MongoRunner.runMongos({ configdb : baseMongod.host }); + + // Get base command line opts. Needed because the framework adds its own options + var getCmdLineOptsBaseMongos = baseMongos.adminCommand("getCmdLineOpts"); + + // Remove the configdb option + delete getCmdLineOptsBaseMongos.parsed.sharding.configDB; + + // Stop the mongod and mongos we used to get the options + MongoRunner.stopMongos(baseMongos.port); + MongoRunner.stopMongod(baseMongod.port); + + return getCmdLineOptsBaseMongos; + } + + if (typeof getCmdLineOptsBaseMongos === "undefined") { + getCmdLineOptsBaseMongos = getBaseOptsObject(); + } + + // Get base command line opts. Needed because the framework adds its own options + var getCmdLineOptsExpected = getCmdLineOptsBaseMongos; + + // Delete port if we are not explicitly setting it, since it will change on multiple runs of the + // test framework and cause false failures. + if (typeof expectedResult.parsed === "undefined" || + typeof expectedResult.parsed.net === "undefined" || + typeof expectedResult.parsed.net.port === "undefined") { + delete getCmdLineOptsExpected.parsed.net.port; + } + + // Merge with the result that we expect + expectedResult = mergeOptions(getCmdLineOptsExpected, expectedResult); + + // Start mongod with no options + var mongod = MongoRunner.runMongod(); + + // Add configdb option + mongoRunnerConfig['configdb'] = mongod.host; + + // Start mongos connected to mongod + var mongos = MongoRunner.runMongos(mongoRunnerConfig); + + // Get the parsed options + var getCmdLineOptsResult = mongos.adminCommand("getCmdLineOpts"); + + // Delete port if we are not explicitly setting it, since it will change on multiple runs of the + // test framework and cause false failures. + if (typeof expectedResult.parsed === "undefined" || + typeof expectedResult.parsed.net === "undefined" || + typeof expectedResult.parsed.net.port === "undefined") { + delete getCmdLineOptsResult.parsed.net.port; + } + + // Remove the configdb option + delete getCmdLineOptsResult.parsed.sharding.configDB; + + // Make sure the options are equal to what we expect + assert.docEq(getCmdLineOptsResult.parsed, expectedResult.parsed); + + // Cleanup + MongoRunner.stopMongos(mongos.port); + MongoRunner.stopMongod(mongod.port); +} diff --git a/test/legacy28/jstests/libs/config_files/disable_auth.ini b/test/legacy28/jstests/libs/config_files/disable_auth.ini new file mode 100644 index 00000000000..c1193be1b03 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_auth.ini @@ -0,0 +1 @@ +auth=false diff --git a/test/legacy28/jstests/libs/config_files/disable_dur.ini b/test/legacy28/jstests/libs/config_files/disable_dur.ini new file mode 100644 index 00000000000..8f83f3ae5a7 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_dur.ini @@ -0,0 +1 @@ +dur=false diff --git a/test/legacy28/jstests/libs/config_files/disable_httpinterface.ini b/test/legacy28/jstests/libs/config_files/disable_httpinterface.ini new file mode 100644 index 00000000000..fc839a98a76 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_httpinterface.ini @@ -0,0 +1 @@ +httpinterface=false diff --git a/test/legacy28/jstests/libs/config_files/disable_ipv6.ini b/test/legacy28/jstests/libs/config_files/disable_ipv6.ini new file mode 100644 index 00000000000..a091421022d --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_ipv6.ini @@ -0,0 +1 @@ +ipv6=false diff --git a/test/legacy28/jstests/libs/config_files/disable_journal.ini b/test/legacy28/jstests/libs/config_files/disable_journal.ini new file mode 100644 index 00000000000..d0010a86906 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_journal.ini @@ -0,0 +1 @@ +journal=false diff --git a/test/legacy28/jstests/libs/config_files/disable_jsonp.ini b/test/legacy28/jstests/libs/config_files/disable_jsonp.ini new file mode 100644 index 00000000000..82847f50b2b --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_jsonp.ini @@ -0,0 +1 @@ +jsonp=false diff --git a/test/legacy28/jstests/libs/config_files/disable_jsonp.json b/test/legacy28/jstests/libs/config_files/disable_jsonp.json new file mode 100644 index 00000000000..4d5477a8547 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_jsonp.json @@ -0,0 +1,7 @@ +{ + "net" : { + "http" : { + "JSONPEnabled" : false + } + } +} diff --git a/test/legacy28/jstests/libs/config_files/disable_moveparanoia.ini b/test/legacy28/jstests/libs/config_files/disable_moveparanoia.ini new file mode 100644 index 00000000000..f21b50f9513 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_moveparanoia.ini @@ -0,0 +1 @@ +moveParanoia=false diff --git a/test/legacy28/jstests/libs/config_files/disable_noauth.ini b/test/legacy28/jstests/libs/config_files/disable_noauth.ini new file mode 100644 index 00000000000..a65f909baf3 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_noauth.ini @@ -0,0 +1 @@ +noauth=false diff --git a/test/legacy28/jstests/libs/config_files/disable_noautosplit.ini b/test/legacy28/jstests/libs/config_files/disable_noautosplit.ini new file mode 100644 index 00000000000..b490f9038dd --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_noautosplit.ini @@ -0,0 +1 @@ +noAutoSplit=false diff --git a/test/legacy28/jstests/libs/config_files/disable_nodur.ini b/test/legacy28/jstests/libs/config_files/disable_nodur.ini new file mode 100644 index 00000000000..b0c73a48b30 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_nodur.ini @@ -0,0 +1 @@ +nodur=false diff --git a/test/legacy28/jstests/libs/config_files/disable_nohttpinterface.ini b/test/legacy28/jstests/libs/config_files/disable_nohttpinterface.ini new file mode 100644 index 00000000000..52c4958da6e --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_nohttpinterface.ini @@ -0,0 +1 @@ +nohttpinterface=false diff --git a/test/legacy28/jstests/libs/config_files/disable_noindexbuildretry.ini b/test/legacy28/jstests/libs/config_files/disable_noindexbuildretry.ini new file mode 100644 index 00000000000..79e428c492f --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_noindexbuildretry.ini @@ -0,0 +1 @@ +noIndexBuildRetry=false diff --git a/test/legacy28/jstests/libs/config_files/disable_nojournal.ini b/test/legacy28/jstests/libs/config_files/disable_nojournal.ini new file mode 100644 index 00000000000..17172363d25 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_nojournal.ini @@ -0,0 +1 @@ +nojournal=false diff --git a/test/legacy28/jstests/libs/config_files/disable_nomoveparanoia.ini b/test/legacy28/jstests/libs/config_files/disable_nomoveparanoia.ini new file mode 100644 index 00000000000..4696304134f --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_nomoveparanoia.ini @@ -0,0 +1 @@ +noMoveParanoia=false diff --git a/test/legacy28/jstests/libs/config_files/disable_noobjcheck.ini b/test/legacy28/jstests/libs/config_files/disable_noobjcheck.ini new file mode 100644 index 00000000000..471e83c3172 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_noobjcheck.ini @@ -0,0 +1 @@ +noobjcheck=false diff --git a/test/legacy28/jstests/libs/config_files/disable_noprealloc.ini b/test/legacy28/jstests/libs/config_files/disable_noprealloc.ini new file mode 100644 index 00000000000..08c78be3507 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_noprealloc.ini @@ -0,0 +1 @@ +noprealloc=false diff --git a/test/legacy28/jstests/libs/config_files/disable_noscripting.ini b/test/legacy28/jstests/libs/config_files/disable_noscripting.ini new file mode 100644 index 00000000000..4cfaf3395f6 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_noscripting.ini @@ -0,0 +1 @@ +noscripting=false diff --git a/test/legacy28/jstests/libs/config_files/disable_nounixsocket.ini b/test/legacy28/jstests/libs/config_files/disable_nounixsocket.ini new file mode 100644 index 00000000000..66da9f08391 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_nounixsocket.ini @@ -0,0 +1 @@ +nounixsocket=false diff --git a/test/legacy28/jstests/libs/config_files/disable_objcheck.ini b/test/legacy28/jstests/libs/config_files/disable_objcheck.ini new file mode 100644 index 00000000000..bd19d026bbf --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_objcheck.ini @@ -0,0 +1 @@ +objcheck=false diff --git a/test/legacy28/jstests/libs/config_files/disable_rest_interface.json b/test/legacy28/jstests/libs/config_files/disable_rest_interface.json new file mode 100644 index 00000000000..f9ad93a4f5d --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/disable_rest_interface.json @@ -0,0 +1,7 @@ +{ + "net" : { + "http" : { + "RESTInterfaceEnabled" : false + } + } +} diff --git a/test/legacy28/jstests/libs/config_files/enable_auth.json b/test/legacy28/jstests/libs/config_files/enable_auth.json new file mode 100644 index 00000000000..9f9cc84d107 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/enable_auth.json @@ -0,0 +1,5 @@ +{ + "security" : { + "authorization" : "enabled" + } +} diff --git a/test/legacy28/jstests/libs/config_files/enable_autosplit.json b/test/legacy28/jstests/libs/config_files/enable_autosplit.json new file mode 100644 index 00000000000..a0d4f8af1be --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/enable_autosplit.json @@ -0,0 +1,5 @@ +{ + "sharding" : { + "autoSplit" : true + } +} diff --git a/test/legacy28/jstests/libs/config_files/enable_httpinterface.json b/test/legacy28/jstests/libs/config_files/enable_httpinterface.json new file mode 100644 index 00000000000..c87dabe125d --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/enable_httpinterface.json @@ -0,0 +1,7 @@ +{ + "net" : { + "http" : { + "enabled" : true + } + } +} diff --git a/test/legacy28/jstests/libs/config_files/enable_indexbuildretry.json b/test/legacy28/jstests/libs/config_files/enable_indexbuildretry.json new file mode 100644 index 00000000000..362db08edd3 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/enable_indexbuildretry.json @@ -0,0 +1,5 @@ +{ + "storage" : { + "indexBuildRetry" : true + } +} diff --git a/test/legacy28/jstests/libs/config_files/enable_journal.json b/test/legacy28/jstests/libs/config_files/enable_journal.json new file mode 100644 index 00000000000..d75b94ccbc7 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/enable_journal.json @@ -0,0 +1,7 @@ +{ + "storage" : { + "journal" : { + "enabled" : false + } + } +} diff --git a/test/legacy28/jstests/libs/config_files/enable_objcheck.json b/test/legacy28/jstests/libs/config_files/enable_objcheck.json new file mode 100644 index 00000000000..b52be7382ed --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/enable_objcheck.json @@ -0,0 +1,5 @@ +{ + "net" : { + "wireObjectCheck" : true + } +} diff --git a/test/legacy28/jstests/libs/config_files/enable_paranoia.json b/test/legacy28/jstests/libs/config_files/enable_paranoia.json new file mode 100644 index 00000000000..218646b1662 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/enable_paranoia.json @@ -0,0 +1,5 @@ +{ + "sharding" : { + "archiveMovedChunks" : true + } +} diff --git a/test/legacy28/jstests/libs/config_files/enable_prealloc.json b/test/legacy28/jstests/libs/config_files/enable_prealloc.json new file mode 100644 index 00000000000..15ecefbb546 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/enable_prealloc.json @@ -0,0 +1,5 @@ +{ + "storage" : { + "preallocDataFiles" : true + } +} diff --git a/test/legacy28/jstests/libs/config_files/enable_scripting.json b/test/legacy28/jstests/libs/config_files/enable_scripting.json new file mode 100644 index 00000000000..e8f32f2c23c --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/enable_scripting.json @@ -0,0 +1,5 @@ +{ + "security" : { + "javascriptEnabled" : true + } +} diff --git a/test/legacy28/jstests/libs/config_files/enable_unixsocket.json b/test/legacy28/jstests/libs/config_files/enable_unixsocket.json new file mode 100644 index 00000000000..660d21eb17f --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/enable_unixsocket.json @@ -0,0 +1,7 @@ +{ + "net" : { + "unixDomainSocket" : { + "enabled" : true + } + } +} diff --git a/test/legacy28/jstests/libs/config_files/implicitly_enable_dur.ini b/test/legacy28/jstests/libs/config_files/implicitly_enable_dur.ini new file mode 100644 index 00000000000..43495fbd0bd --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/implicitly_enable_dur.ini @@ -0,0 +1 @@ +dur= diff --git a/test/legacy28/jstests/libs/config_files/implicitly_enable_journal.ini b/test/legacy28/jstests/libs/config_files/implicitly_enable_journal.ini new file mode 100644 index 00000000000..f750ac2e185 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/implicitly_enable_journal.ini @@ -0,0 +1 @@ +journal= diff --git a/test/legacy28/jstests/libs/config_files/implicitly_enable_nodur.ini b/test/legacy28/jstests/libs/config_files/implicitly_enable_nodur.ini new file mode 100644 index 00000000000..f1046df16a9 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/implicitly_enable_nodur.ini @@ -0,0 +1 @@ +nodur= diff --git a/test/legacy28/jstests/libs/config_files/implicitly_enable_nojournal.ini b/test/legacy28/jstests/libs/config_files/implicitly_enable_nojournal.ini new file mode 100644 index 00000000000..737e5c28029 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/implicitly_enable_nojournal.ini @@ -0,0 +1 @@ +nojournal= diff --git a/test/legacy28/jstests/libs/config_files/set_component_verbosity.json b/test/legacy28/jstests/libs/config_files/set_component_verbosity.json new file mode 100644 index 00000000000..69c200834a1 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/set_component_verbosity.json @@ -0,0 +1,16 @@ +{ + "systemLog" : { + "verbosity" : 2, + "component" : { + "accessControl" : { + "verbosity" : 0 + }, + "storage" : { + "verbosity" : 3, + "journaling" : { + "verbosity" : 5 + } + } + } + } +} diff --git a/test/legacy28/jstests/libs/config_files/set_profiling.json b/test/legacy28/jstests/libs/config_files/set_profiling.json new file mode 100644 index 00000000000..944f0de1575 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/set_profiling.json @@ -0,0 +1,5 @@ +{ + "operationProfiling" : { + "mode" : "all" + } +} diff --git a/test/legacy28/jstests/libs/config_files/set_replsetname.json b/test/legacy28/jstests/libs/config_files/set_replsetname.json new file mode 100644 index 00000000000..522ca2b766f --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/set_replsetname.json @@ -0,0 +1,5 @@ +{ + "replication" : { + "replSetName" : "myconfigname" + } +} diff --git a/test/legacy28/jstests/libs/config_files/set_shardingrole.json b/test/legacy28/jstests/libs/config_files/set_shardingrole.json new file mode 100644 index 00000000000..71f92f122db --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/set_shardingrole.json @@ -0,0 +1,5 @@ +{ + "sharding" : { + "clusterRole" : "configsvr" + } +} diff --git a/test/legacy28/jstests/libs/config_files/set_verbosity.json b/test/legacy28/jstests/libs/config_files/set_verbosity.json new file mode 100644 index 00000000000..47a1cce1b03 --- /dev/null +++ b/test/legacy28/jstests/libs/config_files/set_verbosity.json @@ -0,0 +1,5 @@ +{ + "systemLog" : { + "verbosity" : 5 + } +} diff --git a/test/legacy28/jstests/libs/crl.pem b/test/legacy28/jstests/libs/crl.pem new file mode 100644 index 00000000000..275c9e2d91c --- /dev/null +++ b/test/legacy28/jstests/libs/crl.pem @@ -0,0 +1,38 @@ +Certificate Revocation List (CRL): + Version 2 (0x1) + Signature Algorithm: sha256WithRSAEncryption + Issuer: /CN=Kernel Test CA/OU=Kernel/O=MongoDB/L=New York City/ST=New York/C=US + Last Update: Aug 21 13:56:28 2014 GMT + Next Update: Aug 18 13:56:28 2024 GMT + CRL extensions: + X509v3 CRL Number: + 4096 +No Revoked Certificates. + Signature Algorithm: sha256WithRSAEncryption + 48:1b:0b:b1:89:f5:6f:af:3c:dd:2a:a0:e5:55:04:80:16:b4: + 23:98:39:bb:9f:16:c9:25:73:72:c6:a6:73:21:1d:1a:b6:99: + fc:47:5e:bc:af:64:29:02:9c:a5:db:15:8a:65:48:3c:4f:a6: + cd:35:47:aa:c6:c0:39:f5:a6:88:8f:1b:6c:26:61:4e:10:d7: + e2:b0:20:3a:64:92:c1:d3:2a:11:3e:03:e2:50:fd:4e:3c:de: + e2:e5:78:dc:8e:07:a5:69:55:13:2b:8f:ae:21:00:42:85:ff: + b6:b1:2b:69:08:40:5a:25:8c:fe:57:7f:b1:06:b0:72:ff:61: + de:21:59:05:a8:1b:9e:c7:8a:08:ab:f5:bc:51:b3:36:68:0f: + 54:65:3c:8d:b7:80:d0:27:01:3e:43:97:89:19:89:0e:c5:01: + 2c:55:9f:b6:e4:c8:0b:35:f8:52:45:d3:b4:09:ce:df:73:98: + f5:4c:e4:5a:06:ac:63:4c:f8:4d:9c:af:88:fc:19:f7:77:ea: + ee:56:18:49:16:ce:62:66:d1:1b:8d:66:33:b5:dc:b1:25:b3: + 6c:81:e9:d0:8a:1d:83:61:49:0e:d9:94:6a:46:80:41:d6:b6: + 59:a9:30:55:3d:5b:d3:5b:f1:37:ec:2b:76:d0:3a:ac:b2:c8: + 7c:77:04:78 +-----BEGIN X509 CRL----- +MIIBzjCBtwIBATANBgkqhkiG9w0BAQsFADB0MRcwFQYDVQQDEw5LZXJuZWwgVGVz +dCBDQTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYwFAYDVQQH +Ew1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkGA1UEBhMCVVMX +DTE0MDgyMTEzNTYyOFoXDTI0MDgxODEzNTYyOFqgDzANMAsGA1UdFAQEAgIQADAN +BgkqhkiG9w0BAQsFAAOCAQEASBsLsYn1b6883Sqg5VUEgBa0I5g5u58WySVzcsam +cyEdGraZ/EdevK9kKQKcpdsVimVIPE+mzTVHqsbAOfWmiI8bbCZhThDX4rAgOmSS +wdMqET4D4lD9Tjze4uV43I4HpWlVEyuPriEAQoX/trEraQhAWiWM/ld/sQawcv9h +3iFZBagbnseKCKv1vFGzNmgPVGU8jbeA0CcBPkOXiRmJDsUBLFWftuTICzX4UkXT +tAnO33OY9UzkWgasY0z4TZyviPwZ93fq7lYYSRbOYmbRG41mM7XcsSWzbIHp0Iod +g2FJDtmUakaAQda2WakwVT1b01vxN+wrdtA6rLLIfHcEeA== +-----END X509 CRL----- diff --git a/test/legacy28/jstests/libs/crl_client_revoked.pem b/test/legacy28/jstests/libs/crl_client_revoked.pem new file mode 100644 index 00000000000..0b99d56936e --- /dev/null +++ b/test/legacy28/jstests/libs/crl_client_revoked.pem @@ -0,0 +1,41 @@ +Certificate Revocation List (CRL): + Version 2 (0x1) + Signature Algorithm: sha256WithRSAEncryption + Issuer: /CN=Kernel Test CA/OU=Kernel/O=MongoDB/L=New York City/ST=New York/C=US + Last Update: Aug 21 13:43:27 2014 GMT + Next Update: Aug 18 13:43:27 2024 GMT + CRL extensions: + X509v3 CRL Number: + 4096 +Revoked Certificates: + Serial Number: 02 + Revocation Date: Aug 21 13:43:27 2014 GMT + Signature Algorithm: sha256WithRSAEncryption + 24:86:73:8d:7f:55:15:d0:d6:8a:47:53:cf:97:f7:e5:3d:0b: + 4a:ea:fb:02:6a:2e:79:c6:b1:38:b2:ac:f0:c0:64:47:b0:3e: + ad:4e:2e:94:e6:64:ed:79:34:bd:74:c0:d4:3d:b9:a1:bb:38: + 89:5c:02:6a:ad:6b:dc:3b:64:34:6a:2d:4c:90:36:82:95:0c: + 19:88:e2:a3:bf:8e:1b:56:98:37:32:87:ed:f0:bd:dd:e2:0d: + f9:80:dc:f2:a5:b4:ee:d9:bb:83:fe:b8:3a:13:e0:da:fc:04: + 77:fb:ce:f9:c5:2a:54:a7:f0:34:09:2a:b2:3d:46:1b:48:e6: + e8:16:c7:a1:3c:88:8c:72:cd:cc:53:dc:f8:54:63:1f:b9:8b: + ea:2c:e5:26:c5:b4:a4:9f:8b:e1:6c:85:9b:c6:63:6f:2f:ae: + 18:c5:6a:23:f0:58:27:85:5c:0f:01:04:da:d2:8b:de:9e:ab: + 46:00:22:07:28:e1:ef:46:91:90:06:58:95:05:68:67:58:6e: + 67:a8:0b:06:1a:73:d9:04:18:c9:a3:e4:e3:d6:94:a3:e1:5c: + e5:08:1b:b3:9d:ab:3e:ea:20:b1:04:e5:90:e1:42:54:b2:58: + bb:51:1a:48:87:60:b0:95:4a:2e:ce:a0:4f:8c:17:6d:6b:4c: + 37:aa:4d:d7 +-----BEGIN X509 CRL----- +MIIB5DCBzQIBATANBgkqhkiG9w0BAQsFADB0MRcwFQYDVQQDEw5LZXJuZWwgVGVz +dCBDQTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYwFAYDVQQH +Ew1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkGA1UEBhMCVVMX +DTE0MDgyMTEzNDMyN1oXDTI0MDgxODEzNDMyN1owFDASAgECFw0xNDA4MjExMzQz +MjdaoA8wDTALBgNVHRQEBAICEAAwDQYJKoZIhvcNAQELBQADggEBACSGc41/VRXQ +1opHU8+X9+U9C0rq+wJqLnnGsTiyrPDAZEewPq1OLpTmZO15NL10wNQ9uaG7OIlc +Amqta9w7ZDRqLUyQNoKVDBmI4qO/jhtWmDcyh+3wvd3iDfmA3PKltO7Zu4P+uDoT +4Nr8BHf7zvnFKlSn8DQJKrI9RhtI5ugWx6E8iIxyzcxT3PhUYx+5i+os5SbFtKSf +i+FshZvGY28vrhjFaiPwWCeFXA8BBNrSi96eq0YAIgco4e9GkZAGWJUFaGdYbmeo +CwYac9kEGMmj5OPWlKPhXOUIG7Odqz7qILEE5ZDhQlSyWLtRGkiHYLCVSi7OoE+M +F21rTDeqTdc= +-----END X509 CRL----- diff --git a/test/legacy28/jstests/libs/crl_expired.pem b/test/legacy28/jstests/libs/crl_expired.pem new file mode 100644 index 00000000000..c9b3abb05a7 --- /dev/null +++ b/test/legacy28/jstests/libs/crl_expired.pem @@ -0,0 +1,38 @@ +Certificate Revocation List (CRL): + Version 2 (0x1) + Signature Algorithm: sha256WithRSAEncryption + Issuer: /CN=Kernel Test CA/OU=Kernel/O=MongoDB/L=New York City/ST=New York/C=US + Last Update: Jul 21 19:45:56 2014 GMT + Next Update: Jul 21 20:45:56 2014 GMT + CRL extensions: + X509v3 CRL Number: + 4096 +No Revoked Certificates. + Signature Algorithm: sha256WithRSAEncryption + 14:e8:6d:51:fc:0e:66:08:22:b2:4d:fb:da:7a:5f:4d:d1:a0: + 80:f0:18:f3:c5:ca:c7:05:6c:70:59:fa:d5:96:68:fa:c7:1d: + 7e:fb:53:3b:4a:8f:ed:bb:51:04:e8:fb:db:d7:b8:96:d9:e2: + 8d:bb:54:cc:11:60:c8:20:ea:81:28:5f:e1:eb:d6:8c:94:bf: + 42:e0:7f:a3:13:0c:76:05:f2:f0:34:98:a3:e8:64:74:4c:cb: + bf:39:bb:fa:d5:2d:72:02:d1:fa:56:15:59:12:b7:ff:a3:cc: + c9:d6:14:ca:4a:1e:0b:b4:47:cf:58:b0:e5:24:d2:21:71:0d: + 2d:09:77:5c:2f:ef:40:f8:74:90:03:cc:37:2e:ea:6a:25:59: + c0:bf:48:90:00:55:9c:db:bf:1f:f0:7b:b6:5a:90:94:b6:8d: + 7c:7d:bb:2d:11:5f:0c:f5:4a:9b:c5:ed:ab:e3:fd:35:c8:76: + 3b:2e:41:cb:df:76:b5:f4:e9:05:72:f6:56:7a:fc:34:07:d6: + a2:55:eb:7c:58:33:5b:9d:3e:b2:03:89:01:c6:d1:54:75:1a: + 5c:73:3f:5e:2e:fd:3b:38:ed:d4:e1:fa:ec:ff:84:f0:55:ee: + 83:e0:f0:13:97:e7:f0:55:8c:00:a3:1a:31:e4:31:9e:68:d0: + 6d:3e:81:b0 +-----BEGIN X509 CRL----- +MIIBzjCBtwIBATANBgkqhkiG9w0BAQsFADB0MRcwFQYDVQQDEw5LZXJuZWwgVGVz +dCBDQTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYwFAYDVQQH +Ew1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkGA1UEBhMCVVMX +DTE0MDcyMTE5NDU1NloXDTE0MDcyMTIwNDU1NlqgDzANMAsGA1UdFAQEAgIQADAN +BgkqhkiG9w0BAQsFAAOCAQEAFOhtUfwOZggisk372npfTdGggPAY88XKxwVscFn6 +1ZZo+scdfvtTO0qP7btRBOj729e4ltnijbtUzBFgyCDqgShf4evWjJS/QuB/oxMM +dgXy8DSYo+hkdEzLvzm7+tUtcgLR+lYVWRK3/6PMydYUykoeC7RHz1iw5STSIXEN +LQl3XC/vQPh0kAPMNy7qaiVZwL9IkABVnNu/H/B7tlqQlLaNfH27LRFfDPVKm8Xt +q+P9Nch2Oy5By992tfTpBXL2Vnr8NAfWolXrfFgzW50+sgOJAcbRVHUaXHM/Xi79 +Ozjt1OH67P+E8FXug+DwE5fn8FWMAKMaMeQxnmjQbT6BsA== +-----END X509 CRL----- diff --git a/test/legacy28/jstests/libs/dur_checksum_bad_first.journal b/test/legacy28/jstests/libs/dur_checksum_bad_first.journal new file mode 100644 index 00000000000..687317844a7 Binary files /dev/null and b/test/legacy28/jstests/libs/dur_checksum_bad_first.journal differ diff --git a/test/legacy28/jstests/libs/dur_checksum_bad_last.journal b/test/legacy28/jstests/libs/dur_checksum_bad_last.journal new file mode 100644 index 00000000000..7dd98e2c97b Binary files /dev/null and b/test/legacy28/jstests/libs/dur_checksum_bad_last.journal differ diff --git a/test/legacy28/jstests/libs/dur_checksum_good.journal b/test/legacy28/jstests/libs/dur_checksum_good.journal new file mode 100644 index 00000000000..d76790d2451 Binary files /dev/null and b/test/legacy28/jstests/libs/dur_checksum_good.journal differ diff --git a/test/legacy28/jstests/libs/expired.pem b/test/legacy28/jstests/libs/expired.pem new file mode 100644 index 00000000000..e1d2ceb8de8 --- /dev/null +++ b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V4Wd7mPWEVNDHa0G8ZndquPK40s +YSjh9u0KesUegncBFfIiwzxsk9724iaXq3aXOexc0btQB2xltRzj6/0CgYEA9E2A +QU6pnCOzGDyOV7+TFr0ha7TXaMOb5aIVz6tJ7r5Nb7oZP9T9UCdUnw2Tls5Ce5tI +J23O7JqwT4CudnWnk5ZtVtGBYA23mUryrgf/Utfg08hU2uRyq9LOxVaVqfV/AipN +62GmfuxkK4PatOcAOhKqmS/zGfZqIg7V6rtX2ocCgYEAlY1ogpR8ij6mvfBgPmGr +9nues+uBDwXYOCXlzCYKTN2OIgkQ8vEZb3RDfy9CllVDgccWfd6iPnlVcvUJLOrt +gwxlL2x8ryvwCc1ahv+A/1g0gmtuDdy9HW0XTnjcFMWViKUm4DrGsl5+/GkF67PV +SVOmllwifOthpjJGaHmAlmUCgYB6EFMZzlzud+PfIzqX20952Avfzd6nKL03EjJF +rbbmA82bGmfNPfVHXC9qvRTWD76mFeMKWFJAY9XeE1SYOZb+JfYBn/I9dP0cKZdx +nutSkCx0hK7pI6Wr9kt7zBRBdDj+cva1ufe/iQtPtrTLGHRDj9oPaibT/Qvwcmst +umdd9wKBgQDM7j6Rh7v8AeLy2bw73Qtk0ORaHqRBHSQw87srOLwtfQzE92zSGMj+ +FVt/BdPgzyaddegKvJ9AFCPAxbA8Glnmc89FO7pcXn9Wcy+ZoZIF6YwgUPhPCp/4 +r9bKuXuQiutFbKyes/5PTXqbJ/7xKRZIpQCvxg2syrW3hxx8LIx/kQ== +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/test/legacy28/jstests/libs/fts.js b/test/legacy28/jstests/libs/fts.js new file mode 100644 index 00000000000..73b7d339ba5 --- /dev/null +++ b/test/legacy28/jstests/libs/fts.js @@ -0,0 +1,18 @@ + +function queryIDS( coll, search, filter, extra ){ + var cmd = { search : search } + if ( filter ) + cmd.filter = filter; + if ( extra ) + Object.extend( cmd, extra ); + lastCommadResult = coll.runCommand( "text" , cmd); + + return getIDS( lastCommadResult ); +} + +function getIDS( commandResult ){ + if ( ! ( commandResult && commandResult.results ) ) + return [] + + return commandResult.results.map( function(z){ return z.obj._id; } ) +} diff --git a/test/legacy28/jstests/libs/geo_near_random.js b/test/legacy28/jstests/libs/geo_near_random.js new file mode 100644 index 00000000000..248f5e49a6c --- /dev/null +++ b/test/legacy28/jstests/libs/geo_near_random.js @@ -0,0 +1,101 @@ +GeoNearRandomTest = function(name) { + this.name = name; + this.t = db[name]; + this.nPts = 0; + + // reset state + this.t.drop(); + Random.srand(1234); + + print("starting test: " + name); +} + + +GeoNearRandomTest.prototype.mkPt = function mkPt(scale, indexBounds){ + if(!indexBounds){ + scale = scale || 1; // scale is good for staying away from edges + return [((Random.rand() * 359.8) - 179.9) * scale, ((Random.rand() * 180) - 90) * scale]; + } + else{ + var range = indexBounds.max - indexBounds.min; + var eps = Math.pow(2, -40); + // Go very close to the borders but not quite there. + return [( Random.rand() * (range - eps) + eps) + indexBounds.min, ( Random.rand() * (range - eps) + eps ) + indexBounds.min]; + } + +} + +GeoNearRandomTest.prototype.insertPts = function(nPts, indexBounds, scale) { + assert.eq(this.nPts, 0, "insertPoints already called"); + this.nPts = nPts; + + var bulk = this.t.initializeUnorderedBulkOp(); + for (var i=0; i>>>>>>>>>>>>>> skipping " + x.name); + return; + } + // add the test to run in one of the threads. + params[ i % n ].push( x.name ); + ++i; + } + ); + + // randomize ordering of the serialTests + params[ 0 ] = Array.shuffle( params[ 0 ] ); + + for( var i in params ) { + params[ i ].unshift( i ); + } + + return params; + } + + // runs a set of test files + // first argument is an identifier for this tester, remaining arguments are file names + ParallelTester.fileTester = function() { + var args = argumentsToArray( arguments ); + var suite = args.shift(); + args.forEach( + function( x ) { + print(" S" + suite + " Test : " + x + " ..."); + var time = Date.timeFunc( function() { load(x); }, 1); + print(" S" + suite + " Test : " + x + " " + time + "ms" ); + } + ); + } + + // params: array of arrays, each element of which consists of a function followed + // by zero or more arguments to that function. Each function and its arguments will + // be called in a separate thread. + // msg: failure message + // newScopes: if true, each thread starts in a fresh scope + assert.parallelTests = function( params, msg, newScopes ) { + newScopes = newScopes || false; + var wrapper = function( fun, argv ) { + eval ( + "var z = function() {" + + "var __parallelTests__fun = " + fun.toString() + ";" + + "var __parallelTests__argv = " + tojson( argv ) + ";" + + "var __parallelTests__passed = false;" + + "try {" + + "__parallelTests__fun.apply( 0, __parallelTests__argv );" + + "__parallelTests__passed = true;" + + "} catch ( e ) {" + + "print('');" + + "print( '********** Parallel Test FAILED: ' + tojson(e) );" + + "print('');" + + "}" + + "return __parallelTests__passed;" + + "}" + ); + return z; + } + var runners = new Array(); + for( var i in params ) { + var param = params[ i ]; + var test = param.shift(); + var t; + if ( newScopes ) + t = new ScopedThread( wrapper( test, param ) ); + else + t = new Thread( wrapper( test, param ) ); + runners.push( t ); + } + + runners.forEach( function( x ) { x.start(); } ); + var nFailed = 0; + // v8 doesn't like it if we exit before all threads are joined (SERVER-529) + runners.forEach( function( x ) { if( !x.returnData() ) { ++nFailed; } } ); + assert.eq( 0, nFailed, msg ); + } +} diff --git a/test/legacy28/jstests/libs/password_protected.pem b/test/legacy28/jstests/libs/password_protected.pem new file mode 100644 index 00000000000..25e47bc2402 --- /dev/null +++ b/test/legacy28/jstests/libs/password_protected.pem @@ -0,0 +1,51 @@ +-----BEGIN CERTIFICATE----- +MIIDezCCAmOgAwIBAgIBCTANBgkqhkiG9w0BAQUFADB4MRswGQYDVQQDExJwYXNz +d29yZF9wcm90ZWN0ZWQxDzANBgNVBAsTBktlcm5lbDEQMA4GA1UEChMHTW9uZ29E +QjEWMBQGA1UEBxMNTmV3IFlvcmsgQ2l0eTERMA8GA1UECBMITmV3IFlvcmsxCzAJ +BgNVBAYTAlVTMB4XDTE0MDcxNzE2MDAwMFoXDTIwMDcxNzE2MDAwMFoweDEbMBkG +A1UEAxMScGFzc3dvcmRfcHJvdGVjdGVkMQ8wDQYDVQQLEwZLZXJuZWwxEDAOBgNV +BAoTB01vbmdvREIxFjAUBgNVBAcTDU5ldyBZb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jEx8p4Z+rejJIC5CqZLbz9sDgCtIL+92k ++x4mlT1Rfmz9pU+RQqik83nFFRBGWxeW9iWWEgocWtmezvnK6E241v78zkqxNkvF +JJo7BsBw7DiEHEfLhBZYuqV2q6+kwqgYrzyGIwAJkBGrkYfalVzgR+3/uN04h005 +M3jQRpSkDVGYr3JKEAlh3Sc+JD9VPbu6/RXNwy5mY67UCgWGaFwRqJE3DC9aKfNC +OET8m8+8oQgFzhw3pNpENsgwR+Sx3K4q0GI3YwxT02pieBFNQaw53O3B3TtoCjkk +UsuyIWqcLonwo4I3z0kjU3gEFN+0m4E4/A1DNt0J3rsKN+toCk1FqbxQg9xTZzXu +hYmA3HMMwugzXmCanqBhmMsniPg+dRxCIfiHZhLuEpjKxZWcMWcW4M6l/wbM+LbE +oDcTuI9ezfPTZ3xA8hNIHBT3MhuI7EJQnvKKvJDJeyX5sAtmSsSFqhEr8QZD8RgV +5H9eOyUdfcWxLlstcq982V0oGg== +-----END ENCRYPTED PRIVATE KEY----- \ No newline at end of file diff --git a/test/legacy28/jstests/libs/server.pem b/test/legacy28/jstests/libs/server.pem new file mode 100644 index 00000000000..df2b49163d6 --- /dev/null +++ b/test/legacy28/jstests/libs/server.pem @@ -0,0 +1,48 @@ +-----BEGIN CERTIFICATE----- +MIIDfjCCAmagAwIBAgIBBzANBgkqhkiG9w0BAQUFADB0MRcwFQYDVQQDEw5LZXJu +ZWwgVGVzdCBDQTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYw +FAYDVQQHEw1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkGA1UE +BhMCVVMwHhcNMTQwNzE3MTYwMDAwWhcNMjAwNzE3MTYwMDAwWjBsMQ8wDQYDVQQD +EwZzZXJ2ZXIxDzANBgNVBAsTBktlcm5lbDEQMA4GA1UEChMHTW9uZ29EQjEWMBQG +A1UEBxMNTmV3IFlvcmsgQ2l0eTERMA8GA1UECBMITmV3IFlvcms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KBgQCxL2luepeZHx82H9T+38BkYgHLHw0HQzLkxlyd +LjlE4QCEjSB4cmukvkZbuYXfEVEgAvQKVW6p/SWhGkpT4Gt8EXftKV9dyF21GVXQ +JZnhUOcm1xBsrWYGLXYi2agrpvgONBTlprERfq5tdnz2z8giZL+RZswu45Nnh8bz +AcKzuQKBgQCGOQvKvNL5XKKmws/KRkfJbXgsyRT2ubO6pVL9jGQG5wntkeIRaEpT +oxFtWMdPx3b3cxtgSP2ojllEiISk87SFIN1zEhHZy/JpTF0GlU1qg3VIaA78M1p2 +ZdpUsuqJzYmc3dDbQMepIaqdW4xMoTtZFyenUJyoezz6eWy/NlZ/XQ== +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/test/legacy28/jstests/libs/servers.js b/test/legacy28/jstests/libs/servers.js new file mode 100755 index 00000000000..30734822845 --- /dev/null +++ b/test/legacy28/jstests/libs/servers.js @@ -0,0 +1,957 @@ +// Wrap whole file in a function to avoid polluting the global namespace +(function() { + +_parsePath = function() { + var dbpath = ""; + for( var i = 0; i < arguments.length; ++i ) + if ( arguments[ i ] == "--dbpath" ) + dbpath = arguments[ i + 1 ]; + + if ( dbpath == "" ) + throw Error("No dbpath specified"); + + return dbpath; +} + +_parsePort = function() { + var port = ""; + for( var i = 0; i < arguments.length; ++i ) + if ( arguments[ i ] == "--port" ) + port = arguments[ i + 1 ]; + + if ( port == "" ) + throw Error("No port specified"); + return port; +} + +connectionURLTheSame = function( a , b ){ + + if ( a == b ) + return true; + + if ( ! a || ! b ) + return false; + + if( a.host ) return connectionURLTheSame( a.host, b ) + if( b.host ) return connectionURLTheSame( a, b.host ) + + if( a.name ) return connectionURLTheSame( a.name, b ) + if( b.name ) return connectionURLTheSame( a, b.name ) + + if( a.indexOf( "/" ) < 0 && b.indexOf( "/" ) < 0 ){ + a = a.split( ":" ) + b = b.split( ":" ) + + if( a.length != b.length ) return false + + if( a.length == 2 && a[1] != b[1] ) return false + + if( a[0] == "localhost" || a[0] == "127.0.0.1" ) a[0] = getHostName() + if( b[0] == "localhost" || b[0] == "127.0.0.1" ) b[0] = getHostName() + + return a[0] == b[0] + } + else { + var a0 = a.split( "/" )[0] + var b0 = b.split( "/" )[0] + return a0 == b0 + } +} + +assert( connectionURLTheSame( "foo" , "foo" ) ) +assert( ! connectionURLTheSame( "foo" , "bar" ) ) + +assert( connectionURLTheSame( "foo/a,b" , "foo/b,a" ) ) +assert( ! connectionURLTheSame( "foo/a,b" , "bar/a,b" ) ) + +createMongoArgs = function( binaryName , args ){ + var fullArgs = [ binaryName ]; + + if ( args.length == 1 && isObject( args[0] ) ){ + var o = args[0]; + for ( var k in o ){ + if ( o.hasOwnProperty(k) ){ + if ( k == "v" && isNumber( o[k] ) ){ + var n = o[k]; + if ( n > 0 ){ + if ( n > 10 ) n = 10; + var temp = "-"; + while ( n-- > 0 ) temp += "v"; + fullArgs.push( temp ); + } + } + else { + fullArgs.push( "--" + k ); + if ( o[k] != "" ) + fullArgs.push( "" + o[k] ); + } + } + } + } + else { + for ( var i=0; i}|{String}|{versionIterator} + */ +MongoRunner.versionIterator = function( arr, isRandom ){ + + // If this isn't an array of versions, or is already an iterator, just use it + if( typeof arr == "string" ) return arr + if( arr.isVersionIterator ) return arr + + if (isRandom == undefined) isRandom = false; + + // Starting pos + var i = isRandom ? parseInt( Random.rand() * arr.length ) : 0; + + return new MongoRunner.versionIterator.iterator(i, arr); +} + +MongoRunner.versionIterator.iterator = function(i, arr) { + + this.toString = function() { + i = ( i + 1 ) % arr.length + print( "Returning next version : " + i + + " (" + arr[i] + ") from " + tojson( arr ) + "..." ); + return arr[ i ] + } + + this.isVersionIterator = true; + +} + +/** + * Converts the args object by pairing all keys with their value and appending + * dash-dash (--) to the keys. The only exception to this rule are keys that + * are defined in MongoRunner.logicalOptions, of which they will be ignored. + * + * @param {string} binaryName + * @param {Object} args + * + * @return {Array.} an array of parameter strings that can be passed + * to the binary. + */ +MongoRunner.arrOptions = function( binaryName , args ){ + + var fullArgs = [ "" ] + + // isObject returns true even if "args" is an array, so the else branch of this statement is + // dead code. See SERVER-14220. + if ( isObject( args ) || ( args.length == 1 && isObject( args[0] ) ) ){ + + var o = isObject( args ) ? args : args[0] + + // If we've specified a particular binary version, use that + if (o.binVersion && o.binVersion != "") { + binaryName += "-" + o.binVersion; + } + + // Manage legacy options + var isValidOptionForBinary = function( option, value ){ + + if( ! o.binVersion ) return true + + // Version 1.x options + if( o.binVersion.startsWith( "1." ) ){ + + return [ "nopreallocj" ].indexOf( option ) < 0 + } + + return true + } + + for ( var k in o ){ + + // Make sure our logical option should be added to the array of options + if( ! o.hasOwnProperty( k ) || + k in MongoRunner.logicalOptions || + ! isValidOptionForBinary( k, o[k] ) ) continue + + if ( ( k == "v" || k == "verbose" ) && isNumber( o[k] ) ){ + var n = o[k] + if ( n > 0 ){ + if ( n > 10 ) n = 10 + var temp = "-" + while ( n-- > 0 ) temp += "v" + fullArgs.push( temp ) + } + } + else { + if( o[k] == undefined || o[k] == null ) continue + fullArgs.push( "--" + k ) + if ( o[k] != "" ) + fullArgs.push( "" + o[k] ) + } + } + } + else { + for ( var i=0; i i + 1 && ! arr[ i + 1 ].startsWith( "-" ) ){ + opts[ opt ] = arr[ i + 1 ] + i++ + } + else{ + opts[ opt ] = "" + } + + if( opt.replace( /v/g, "" ) == "" ){ + opts[ "verbose" ] = opt.length + } + } + } + + return opts +} + +MongoRunner.savedOptions = {} + +MongoRunner.mongoOptions = function( opts ){ + + // Don't remember waitForConnect + var waitForConnect = opts.waitForConnect; + delete opts.waitForConnect; + + // If we're a mongo object + if( opts.getDB ){ + opts = { restart : opts.runId } + } + + // Initialize and create a copy of the opts + opts = Object.merge( opts || {}, {} ) + + if( ! opts.restart ) opts.restart = false + + // RunId can come from a number of places + // If restart is passed as an old connection + if( opts.restart && opts.restart.getDB ){ + opts.runId = opts.restart.runId + opts.restart = true + } + // If it's the runId itself + else if( isObject( opts.restart ) ){ + opts.runId = opts.restart + opts.restart = true + } + + if( isObject( opts.remember ) ){ + opts.runId = opts.remember + opts.remember = true + } + else if( opts.remember == undefined ){ + // Remember by default if we're restarting + opts.remember = opts.restart + } + + // If we passed in restart : or runId : + if( isObject( opts.runId ) && opts.runId.runId ) opts.runId = opts.runId.runId + + if( opts.restart && opts.remember ) opts = Object.merge( MongoRunner.savedOptions[ opts.runId ], opts ) + + // Create a new runId + opts.runId = opts.runId || ObjectId() + + // Save the port if required + if( ! opts.forgetPort ) opts.port = opts.port || MongoRunner.nextOpenPort() + + var shouldRemember = ( ! opts.restart && ! opts.noRemember ) || ( opts.restart && opts.appendOptions ) + + // Normalize and get the binary version to use + opts.binVersion = MongoRunner.getBinVersionFor(opts.binVersion); + + if ( shouldRemember ){ + MongoRunner.savedOptions[ opts.runId ] = Object.merge( opts, {} ) + } + + // Default for waitForConnect is true + opts.waitForConnect = (waitForConnect == undefined || waitForConnect == null) ? + true : waitForConnect; + + if( jsTestOptions().useSSL ) { + if (!opts.sslMode) opts.sslMode = "requireSSL"; + if (!opts.sslPEMKeyFile) opts.sslPEMKeyFile = "jstests/libs/server.pem"; + if (!opts.sslCAFile) opts.sslCAFile = "jstests/libs/ca.pem"; + + // Needed for jstest/ssl/upgrade_to_ssl.js + opts.sslWeakCertificateValidation = ""; + + // Needed for jstest/ssl/ssl_hostname_validation.js + opts.sslAllowInvalidHostnames = ""; + } + + if ( jsTestOptions().useX509 && !opts.clusterAuthMode ) { + opts.clusterAuthMode = "x509"; + } + + opts.port = opts.port || MongoRunner.nextOpenPort() + MongoRunner.usedPortMap[ "" + parseInt( opts.port ) ] = true + + opts.pathOpts = Object.merge( opts.pathOpts || {}, { port : "" + opts.port, runId : "" + opts.runId } ) + + return opts +} + +/** + * @option {object} opts + * + * { + * dbpath {string} + * useLogFiles {boolean}: use with logFile option. + * logFile {string}: path to the log file. If not specified and useLogFiles + * is true, automatically creates a log file inside dbpath. + * noJournalPrealloc {boolean} + * noJournal {boolean} + * keyFile + * replSet + * oplogSize + * } + */ +MongoRunner.mongodOptions = function( opts ){ + + opts = MongoRunner.mongoOptions( opts ) + + opts.dbpath = MongoRunner.toRealDir( opts.dbpath || "$dataDir/mongod-$port", + opts.pathOpts ) + + opts.pathOpts = Object.merge( opts.pathOpts, { dbpath : opts.dbpath } ) + + if( ! opts.logFile && opts.useLogFiles ){ + opts.logFile = opts.dbpath + "/mongod.log" + } + else if( opts.logFile ){ + opts.logFile = MongoRunner.toRealFile( opts.logFile, opts.pathOpts ) + } + + if ( opts.logFile !== undefined ) { + opts.logpath = opts.logFile; + } + + if( jsTestOptions().noJournalPrealloc || opts.noJournalPrealloc ) + opts.nopreallocj = "" + + if( jsTestOptions().noJournal || opts.noJournal ) + opts.nojournal = "" + + if( jsTestOptions().keyFile && !opts.keyFile) { + opts.keyFile = jsTestOptions().keyFile + } + + if( jsTestOptions().useSSL ) { + if (!opts.sslMode) opts.sslMode = "requireSSL"; + if (!opts.sslPEMKeyFile) opts.sslPEMKeyFile = "jstests/libs/server.pem"; + if (!opts.sslCAFile) opts.sslCAFile = "jstests/libs/ca.pem"; + + // Needed for jstest/ssl/upgrade_to_ssl.js + opts.sslWeakCertificateValidation = ""; + + // Needed for jstest/ssl/ssl_hostname_validation.js + opts.sslAllowInvalidHostnames = ""; + } + + if ( jsTestOptions().useX509 && !opts.clusterAuthMode ) { + opts.clusterAuthMode = "x509"; + } + + if( opts.noReplSet ) opts.replSet = null + if( opts.arbiter ) opts.oplogSize = 1 + + return opts +} + +MongoRunner.mongosOptions = function( opts ){ + + opts = MongoRunner.mongoOptions( opts ) + + // Normalize configdb option to be host string if currently a host + if( opts.configdb && opts.configdb.getDB ){ + opts.configdb = opts.configdb.host + } + + opts.pathOpts = Object.merge( opts.pathOpts, + { configdb : opts.configdb.replace( /:|,/g, "-" ) } ) + + if( ! opts.logFile && opts.useLogFiles ){ + opts.logFile = MongoRunner.toRealFile( "$dataDir/mongos-$configdb-$port.log", + opts.pathOpts ) + } + else if( opts.logFile ){ + opts.logFile = MongoRunner.toRealFile( opts.logFile, opts.pathOpts ) + } + + if ( opts.logFile !== undefined ){ + opts.logpath = opts.logFile; + } + + if( jsTestOptions().keyFile && !opts.keyFile) { + opts.keyFile = jsTestOptions().keyFile + } + + return opts +} + +/** + * Starts a mongod instance. + * + * @param {Object} opts + * + * { + * useHostName {boolean}: Uses hostname of machine if true + * forceLock {boolean}: Deletes the lock file if set to true + * dbpath {string}: location of db files + * cleanData {boolean}: Removes all files in dbpath if true + * startClean {boolean}: same as cleanData + * noCleanData {boolean}: Do not clean files (cleanData takes priority) + * + * @see MongoRunner.mongodOptions for other options + * } + * + * @return {Mongo} connection object to the started mongod instance. + * + * @see MongoRunner.arrOptions + */ +MongoRunner.runMongod = function( opts ){ + + opts = opts || {} + var useHostName = false; + var runId = null; + var waitForConnect = true; + var fullOptions = opts; + + if( isObject( opts ) ) { + + opts = MongoRunner.mongodOptions( opts ); + fullOptions = opts; + + useHostName = opts.useHostName || opts.useHostname; + runId = opts.runId; + waitForConnect = opts.waitForConnect; + + if( opts.forceLock ) removeFile( opts.dbpath + "/mongod.lock" ) + if( ( opts.cleanData || opts.startClean ) || ( ! opts.restart && ! opts.noCleanData ) ){ + print( "Resetting db path '" + opts.dbpath + "'" ) + resetDbpath( opts.dbpath ) + } + + opts = MongoRunner.arrOptions( "mongod", opts ) + } + + var mongod = MongoRunner.startWithArgs(opts, waitForConnect); + if (!waitForConnect) mongos = {}; + if (!mongod) return null; + + mongod.commandLine = MongoRunner.arrToOpts( opts ) + mongod.name = (useHostName ? getHostName() : "localhost") + ":" + mongod.commandLine.port + mongod.host = mongod.name + mongod.port = parseInt( mongod.commandLine.port ) + mongod.runId = runId || ObjectId() + mongod.savedOptions = MongoRunner.savedOptions[ mongod.runId ]; + mongod.fullOptions = fullOptions; + + return mongod +} + +MongoRunner.runMongos = function( opts ){ + + opts = opts || {} + var useHostName = false; + var runId = null; + var waitForConnect = true; + var fullOptions = opts; + + if( isObject( opts ) ) { + + opts = MongoRunner.mongosOptions( opts ); + fullOptions = opts; + + useHostName = opts.useHostName || opts.useHostname; + runId = opts.runId; + waitForConnect = opts.waitForConnect; + + opts = MongoRunner.arrOptions( "mongos", opts ) + } + + var mongos = MongoRunner.startWithArgs(opts, waitForConnect); + if (!waitForConnect) mongos = {}; + if (!mongos) return null; + + mongos.commandLine = MongoRunner.arrToOpts( opts ) + mongos.name = (useHostName ? getHostName() : "localhost") + ":" + mongos.commandLine.port + mongos.host = mongos.name + mongos.port = parseInt( mongos.commandLine.port ) + mongos.runId = runId || ObjectId() + mongos.savedOptions = MongoRunner.savedOptions[ mongos.runId ] + mongos.fullOptions = fullOptions; + + return mongos +} + +/** + * Kills a mongod process. + * + * @param {number} port the port of the process to kill + * @param {number} signal The signal number to use for killing + * @param {Object} opts Additional options. Format: + * { + * auth: { + * user {string}: admin user name + * pwd {string}: admin password + * } + * } + * + * Note: The auth option is required in a authenticated mongod running in Windows since + * it uses the shutdown command, which requires admin credentials. + */ +MongoRunner.stopMongod = function( port, signal, opts ){ + + if( ! port ) { + print( "Cannot stop mongo process " + port ) + return + } + + signal = signal || 15 + + if( port.port ) + port = parseInt( port.port ) + + if( port instanceof ObjectId ){ + var opts = MongoRunner.savedOptions( port ) + if( opts ) port = parseInt( opts.port ) + } + + var exitCode = stopMongod( parseInt( port ), parseInt( signal ), opts ) + + delete MongoRunner.usedPortMap[ "" + parseInt( port ) ] + + return exitCode +} + +MongoRunner.stopMongos = MongoRunner.stopMongod + +MongoRunner.isStopped = function( port ){ + + if( ! port ) { + print( "Cannot detect if process " + port + " is stopped." ) + return + } + + if( port.port ) + port = parseInt( port.port ) + + if( port instanceof ObjectId ){ + var opts = MongoRunner.savedOptions( port ) + if( opts ) port = parseInt( opts.port ) + } + + return MongoRunner.usedPortMap[ "" + parseInt( port ) ] ? false : true +} + +/** + * Starts an instance of the specified mongo tool + * + * @param {String} binaryName The name of the tool to run + * @param {Object} opts options to pass to the tool + * { + * binVersion {string}: version of tool to run + * } + * + * @see MongoRunner.arrOptions + */ +MongoRunner.runMongoTool = function( binaryName, opts ){ + + var opts = opts || {} + // Normalize and get the binary version to use + opts.binVersion = MongoRunner.getBinVersionFor(opts.binVersion); + + var argsArray = MongoRunner.arrOptions(binaryName, opts) + + return runMongoProgram.apply(null, argsArray); + +} + +// Given a test name figures out a directory for that test to use for dump files and makes sure +// that directory exists and is empty. +MongoRunner.getAndPrepareDumpDirectory = function(testName) { + var dir = MongoRunner.dataPath + testName + "_external/"; + resetDbpath(dir); + return dir; +} + +// Start a mongod instance and return a 'Mongo' object connected to it. +// This function's arguments are passed as command line arguments to mongod. +// The specified 'dbpath' is cleared if it exists, created if not. +// var conn = startMongodEmpty("--port", 30000, "--dbpath", "asdf"); +startMongodEmpty = function () { + var args = createMongoArgs("mongod", arguments); + + var dbpath = _parsePath.apply(null, args); + resetDbpath(dbpath); + + return startMongoProgram.apply(null, args); +} +startMongod = function () { + print("startMongod WARNING DELETES DATA DIRECTORY THIS IS FOR TESTING ONLY"); + return startMongodEmpty.apply(null, arguments); +} +startMongodNoReset = function(){ + var args = createMongoArgs( "mongod" , arguments ); + return startMongoProgram.apply( null, args ); +} + +startMongos = function(args){ + return MongoRunner.runMongos(args); +} + +/** + * Returns a new argArray with any test-specific arguments added. + */ +function appendSetParameterArgs(argArray) { + var programName = argArray[0]; + if (programName.endsWith('mongod') || programName.endsWith('mongos')) { + if (jsTest.options().enableTestCommands) { + argArray.push.apply(argArray, ['--setParameter', "enableTestCommands=1"]); + } + if (jsTest.options().authMechanism && jsTest.options().authMechanism != "SCRAM-SHA-1") { + var hasAuthMechs = false; + for (i in argArray) { + if (typeof argArray[i] === 'string' && + argArray[i].indexOf('authenticationMechanisms') != -1) { + hasAuthMechs = true; + break; + } + } + if (!hasAuthMechs) { + argArray.push.apply(argArray, + ['--setParameter', + "authenticationMechanisms=" + jsTest.options().authMechanism]); + } + } + if (jsTest.options().auth) { + argArray.push.apply(argArray, ['--setParameter', "enableLocalhostAuthBypass=false"]); + } + + if ( jsTestOptions().useSSL ) { + if ( argArray.indexOf('--sslMode') < 0 ) { + argArray.push.apply(argArray, [ '--sslMode', 'requireSSL', '--sslPEMKeyFile', 'jstests/libs/server.pem', '--sslCAFile', 'jstests/libs/ca.pem', '--sslWeakCertificateValidation' ] ); + } + } + + // mongos only options + if (programName.endsWith('mongos')) { + // apply setParameters for mongos + if (jsTest.options().setParametersMongos) { + var params = jsTest.options().setParametersMongos.split(","); + if (params && params.length > 0) { + params.forEach(function(p) { + if (p) argArray.push.apply(argArray, ['--setParameter', p]) + }); + } + } + } + // mongod only options + else if (programName.endsWith('mongod')) { + // set storageEngine for mongod + if (jsTest.options().storageEngine) { + argArray.push.apply(argArray, ['--storageEngine', jsTest.options().storageEngine]); + } + // apply setParameters for mongod + if (jsTest.options().setParameters) { + var params = jsTest.options().setParameters.split(","); + if (params && params.length > 0) { + params.forEach(function(p) { + if (p) argArray.push.apply(argArray, ['--setParameter', p]) + }); + } + } + } + } + return argArray; +}; + +/** + * Start a mongo process with a particular argument array. If we aren't waiting for connect, + * return null. + */ +MongoRunner.startWithArgs = function(argArray, waitForConnect) { + // TODO: Make there only be one codepath for starting mongo processes + + argArray = appendSetParameterArgs(argArray); + var port = _parsePort.apply(null, argArray); + var pid = _startMongoProgram.apply(null, argArray); + + var conn = null; + if (waitForConnect) { + assert.soon( function() { + try { + conn = new Mongo("127.0.0.1:" + port); + return true; + } catch( e ) { + if (!checkProgram(pid)) { + + print("Could not start mongo program at " + port + ", process ended") + + // Break out + return true; + } + } + return false; + }, "unable to connect to mongo program on port " + port, 600 * 1000); + } + + return conn; +} + +/** + * DEPRECATED + * + * Start mongod or mongos and return a Mongo() object connected to there. + * This function's first argument is "mongod" or "mongos" program name, \ + * and subsequent arguments to this function are passed as + * command line arguments to the program. + */ +startMongoProgram = function(){ + var port = _parsePort.apply( null, arguments ); + + // Enable test commands. + // TODO: Make this work better with multi-version testing so that we can support + // enabling this on 2.4 when testing 2.6 + var args = argumentsToArray( arguments ); + args = appendSetParameterArgs(args); + var pid = _startMongoProgram.apply( null, args ); + + var m; + assert.soon + ( function() { + try { + m = new Mongo( "127.0.0.1:" + port ); + return true; + } catch( e ) { + if (!checkProgram(pid)) { + + print("Could not start mongo program at " + port + ", process ended") + + // Break out + m = null; + return true; + } + } + return false; + }, "unable to connect to mongo program on port " + port, 600 * 1000 ); + + return m; +} + +runMongoProgram = function() { + var args = argumentsToArray( arguments ); + var progName = args[0]; + + if ( jsTestOptions().auth ) { + args = args.slice(1); + args.unshift( progName, + '-u', jsTestOptions().authUser, + '-p', jsTestOptions().authPassword, + '--authenticationMechanism', DB.prototype._defaultAuthenticationMechanism, + '--authenticationDatabase=admin' + ); + } + + if ( jsTestOptions().useSSL ) { + args.push("--ssl", "--sslPEMKeyFile", "jstests/libs/server.pem", "--sslCAFile", "jstests/libs/ca.pem", "--sslAllowInvalidHosts"); + } + + if (progName == 'mongo' && !_useWriteCommandsDefault()) { + progName = args[0]; + args = args.slice(1); + args.unshift(progName, '--useLegacyWriteOps'); + } + + return _runMongoProgram.apply( null, args ); +} + +// Start a mongo program instance. This function's first argument is the +// program name, and subsequent arguments to this function are passed as +// command line arguments to the program. Returns pid of the spawned program. +startMongoProgramNoConnect = function() { + var args = argumentsToArray( arguments ); + var progName = args[0]; + + if ( jsTestOptions().auth ) { + args = args.slice(1); + args.unshift(progName, + '-u', jsTestOptions().authUser, + '-p', jsTestOptions().authPassword, + '--authenticationMechanism', DB.prototype._defaultAuthenticationMechanism, + '--authenticationDatabase=admin'); + } + + if (progName == 'mongo' && !_useWriteCommandsDefault()) { + args = args.slice(1); + args.unshift(progName, '--useLegacyWriteOps'); + } + + return _startMongoProgram.apply( null, args ); +} + +myPort = function() { + var m = db.getMongo(); + if ( m.host.match( /:/ ) ) + return m.host.match( /:(.*)/ )[ 1 ]; + else + return 27017; +} + +}()); diff --git a/test/legacy28/jstests/libs/servers_misc.js b/test/legacy28/jstests/libs/servers_misc.js new file mode 100644 index 00000000000..bb7ceae99bc --- /dev/null +++ b/test/legacy28/jstests/libs/servers_misc.js @@ -0,0 +1,357 @@ +/** + * Run a mongod process. + * + * After initializing a MongodRunner, you must call start() on it. + * @param {int} port port to run db on, use allocatePorts(num) to requision + * @param {string} dbpath path to use + * @param {boolean} peer pass in false (DEPRECATED, was used for replica pair host) + * @param {boolean} arbiter pass in false (DEPRECATED, was used for replica pair host) + * @param {array} extraArgs other arguments for the command line + * @param {object} options other options include no_bind to not bind_ip to 127.0.0.1 + * (necessary for replica set testing) + */ +MongodRunner = function( port, dbpath, peer, arbiter, extraArgs, options ) { + this.port_ = port; + this.dbpath_ = dbpath; + this.peer_ = peer; + this.arbiter_ = arbiter; + this.extraArgs_ = extraArgs; + this.options_ = options ? options : {}; +}; + +/** + * Start this mongod process. + * + * @param {boolean} reuseData If the data directory should be left intact (default is to wipe it) + */ +MongodRunner.prototype.start = function( reuseData ) { + var args = []; + if ( reuseData ) { + args.push( "mongod" ); + } + args.push( "--port" ); + args.push( this.port_ ); + args.push( "--dbpath" ); + args.push( this.dbpath_ ); + args.push( "--nohttpinterface" ); + args.push( "--noprealloc" ); + args.push( "--smallfiles" ); + if (!this.options_.no_bind) { + args.push( "--bind_ip" ); + args.push( "127.0.0.1" ); + } + if ( this.extraArgs_ ) { + args = args.concat( this.extraArgs_ ); + } + removeFile( this.dbpath_ + "/mongod.lock" ); + if ( reuseData ) { + return startMongoProgram.apply( null, args ); + } else { + return startMongod.apply( null, args ); + } +} + +MongodRunner.prototype.port = function() { return this.port_; } + +MongodRunner.prototype.toString = function() { return [ this.port_, this.dbpath_, this.peer_, this.arbiter_ ].toString(); } + +ToolTest = function( name, extraOptions ){ + this.name = name; + this.options = extraOptions; + this.port = allocatePorts(1)[0]; + this.baseName = "jstests_tool_" + name; + this.root = MongoRunner.dataPath + this.baseName; + this.dbpath = this.root + "/"; + this.ext = this.root + "_external/"; + this.extFile = this.root + "_external/a"; + this.useSSL = jsTestOptions().useSSL + resetDbpath( this.dbpath ); + resetDbpath( this.ext ); +} + +ToolTest.prototype.startDB = function( coll ){ + assert( ! this.m , "db already running" ); + + var options = {port : this.port, + dbpath : this.dbpath, + nohttpinterface : "", + noprealloc : "", + smallfiles : "", + bind_ip : "127.0.0.1"}; + + Object.extend(options, this.options); + + if ( this.useSSL ) { + Object.extend(options, { sslMode: "requireSSL", sslPEMKeyFile: "jstests/libs/server.pem", sslCAFile: "jstests/libs/ca.pem", sslWeakCertificateValidation: "" } ); + } + + this.m = startMongoProgram.apply(null, MongoRunner.arrOptions("mongod", options)); + this.db = this.m.getDB( this.baseName ); + if ( coll ) + return this.db.getCollection( coll ); + return this.db; +} + +ToolTest.prototype.stop = function(){ + if ( ! this.m ) + return; + stopMongod( this.port ); + this.m = null; + this.db = null; + + print('*** ' + this.name + " completed successfully ***"); +} + +ToolTest.prototype.runTool = function(){ + var a = [ "mongo" + arguments[0] ]; + + var hasdbpath = false; + + for ( var i=1; i= 2) { + var port = hostAndPort[1]; + } + } + if (port) { + args.push("--port", port); + } + + if( jsTestOptions().useSSL ) { + args.push( "--ssl" ) + args.push( "--sslPEMKeyFile" ) + args.push( "jstests/libs/client.pem" ) + args.push( "--sslCAFile" ) + args.push( "jstests/libs/ca.pem" ) + } + + x = startMongoProgramNoConnect.apply(null, args); + return function(){ + waitProgram( x ); + }; +} + +var testingReplication = false; + +function skipIfTestingReplication(){ + if (testingReplication) { + print("skipIfTestingReplication skipping"); + quit(0); + } +} diff --git a/test/legacy28/jstests/libs/slow_weekly_util.js b/test/legacy28/jstests/libs/slow_weekly_util.js new file mode 100644 index 00000000000..f5f89643f16 --- /dev/null +++ b/test/legacy28/jstests/libs/slow_weekly_util.js @@ -0,0 +1,20 @@ + +SlowWeeklyMongod = function( name ) { + this.name = name; + this.port = 30201; + + this.start = new Date(); + + this.conn = startMongodEmpty("--port", this.port, "--dbpath", MongoRunner.dataPath + this.name , "--smallfiles", "--nojournal" ); +}; + +SlowWeeklyMongod.prototype.getDB = function( name ) { + return this.conn.getDB( name ); +} + +SlowWeeklyMongod.prototype.stop = function(){ + stopMongod( this.port ); + var end = new Date(); + print( "slowWeekly test: " + this.name + " completed successfully in " + ( ( end.getTime() - this.start.getTime() ) / 1000 ) + " seconds" ); +}; + diff --git a/test/legacy28/jstests/libs/smoke.pem b/test/legacy28/jstests/libs/smoke.pem new file mode 100644 index 00000000000..7dddf222386 --- /dev/null +++ b/test/legacy28/jstests/libs/smoke.pem @@ -0,0 +1,48 @@ +-----BEGIN CERTIFICATE----- +MIIDYTCCAkmgAwIBAgIBCDANBgkqhkiG9w0BAQUFADBrMQ4wDAYDVQQDEwVzbW9r +ZTEPMA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYwFAYDVQQHEw1O +ZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkGA1UEBhMCVVMwHhcN +MTQwNzE3MTYwMDAwWhcNMjAwNzE3MTYwMDAwWjBrMQ4wDAYDVQQDEwVzbW9rZTEP +MA0GA1UECxMGS2VybmVsMRAwDgYDVQQKEwdNb25nb0RCMRYwFAYDVQQHEw1OZXcg +WW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkGA1UEBhMCVVMwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDb4fOWDomCPyYesh42pQ/bEHdK7r73 +06x1hdku9i+nytCSxhhuITGC1FA4ZIbYdQC/jgfzC0D+SDFKCCyNZA/2Pxam9y3F +QHrueNtD9bw/OB98D6hC2fCow5OxUqWDkee2hQRTwLKDzec+H72AkwURh8oTfJsl +LL/1YITZs9kfs59r8HG2YAT7QBbg3xBmK0wZvL4V/FY/OeeR92pIgjUU/6xm/1LU +bhNHl5JTrXQxPpmvDb1ysiI0mMLeUz7UI+Pe/9mn91dHwgkprWyFi6VnV3/aW7DC +nW/DklOPD8vMWu2A6iYU0fZbcj4vGM607vst5QLDMoD5Y2ilrKLiTRa5AgMBAAGj +EDAOMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAJc64d76+eyNGX6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kLx8Liy +JNjEHSLdAoGBAP9+KpjniozZIbrcS79wdRrW+ARyDp1Plzyd4nQxfWmQ//nsnK5T +EYCFXWTR/ldkAoHpD+bGGU02p1+1u4vmWqw/x+Qy56Gh/eylhe0RvYEjkVLyreuc +bXu0BFlKVgRlBq1ZyXnr2lz3bAIZxvZs13lZn6qVPMt7w2/JTCal9jw7AoGBANxR +sGik9mq/678nzLiNlf/LcwIz7siuyISoWDOaVEVva0uorqctVqL95w0f+3FXqBO/ +5BiJRFo5D8SfzRjkNkJ7V+rm+7/CjtsjEw2Ue+ZJYPlm+Wr545GYmhU9QH9NLZIN +JBwTVWjLgdsyQyi0Gc+xMraBwEwoyS8cO17uHO2bAoGBANRmO91/6BPt0ve4epR9 +Vi1o9yki9PlcmHtBOmikWAFyFQvd4+eckVlKBflyBkL6locPjTOqDpC9VengeDj2 +2PyHzZLtqtkZhbK9bJhIfkWknwTZUTMliXMkldTxUo82uZVVpoRgSdmtq7IXYeut +UnjExFMY3EDB9BizvUYIBKvPAoGAViQ6bS/SiPpxGlRdXus88r6BQSM9AYoVLIkF +s2dr+5oMwZA6eXLopOHRLPiMP0yekto8PLuu1ffpil9QuaLA9E11moqlc9yGLngQ +QwcDSo72M41nh8Qcjhi0ZgmE5kEuyCQLMk783fRz2VhVmdyRGvuVcHZa0WxA/QJ0 +1DEVbnECgYEA3i2PGHUvU2TIFNvubw3qdH5y7FXafF+O0ulQ8e6r/CbVAG14Z6xP +RHLc7/JIYK9CG1PWCbkjiHZ4MsKFuRWFrUMrwSj8M3euCaEIxa/Co60qQ/CnZiZ6 +geleTtUcTZ2T0pqGLnrHwlzhLpCkPJPyjcfQjjEZRwd0bVFX6b3C/rw= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/test/legacy28/jstests/libs/test_background_ops.js b/test/legacy28/jstests/libs/test_background_ops.js new file mode 100644 index 00000000000..b3f6f593947 --- /dev/null +++ b/test/legacy28/jstests/libs/test_background_ops.js @@ -0,0 +1,340 @@ +// +// Utilities related to background operations while other operations are working +// + +/** + * Allows synchronization between background ops and the test operations + */ +var waitForLock = function( mongo, name ){ + + var ts = new ObjectId() + var lockColl = mongo.getCollection( "config.testLocks" ) + + lockColl.update({ _id : name, state : 0 }, { $set : { state : 0 } }, true) + + // + // Wait until we can set the state to 1 with our id + // + + var startTime = new Date().getTime() + + assert.soon( function() { + lockColl.update({ _id : name, state : 0 }, { $set : { ts : ts, state : 1 } }) + var gleObj = lockColl.getDB().getLastErrorObj() + + if( new Date().getTime() - startTime > 20 * 1000 ){ + print( "Waiting for..." ) + printjson( gleObj ) + printjson( lockColl.findOne() ) + printjson( ts ) + } + + return gleObj.n == 1 || gleObj.updatedExisting + }, "could not acquire lock", 30 * 1000, 100 ) + + print( "Acquired lock " + tojson( { _id : name, ts : ts } ) + " curr : " + + tojson( lockColl.findOne({ _id : name }) ) ) + + // Set the state back to 0 + var unlock = function(){ + print( "Releasing lock " + tojson( { _id : name, ts : ts } ) + " curr : " + + tojson( lockColl.findOne({ _id : name }) ) ) + lockColl.update({ _id : name, ts : ts }, { $set : { state : 0 } }) + } + + // Return an object we can invoke unlock on + return { unlock : unlock } +} + +/** + * Allows a test or background op to say it's finished + */ +var setFinished = function( mongo, name, finished ){ + if( finished || finished == undefined ) + mongo.getCollection( "config.testFinished" ).update({ _id : name }, { _id : name }, true ) + else + mongo.getCollection( "config.testFinished" ).remove({ _id : name }) +} + +/** + * Checks whether a test or background op is finished + */ +var isFinished = function( mongo, name ){ + return mongo.getCollection( "config.testFinished" ).findOne({ _id : name }) != null +} + +/** + * Sets the result of a background op + */ +var setResult = function( mongo, name, result, err ){ + mongo.getCollection( "config.testResult" ).update({ _id : name }, { _id : name, result : result, err : err }, true ) +} + +/** + * Gets the result for a background op + */ +var getResult = function( mongo, name ){ + return mongo.getCollection( "config.testResult" ).findOne({ _id : name }) +} + +/** + * Overrides the parallel shell code in mongo + */ +function startParallelShell( jsCode, port ){ + + var x; + if ( port ) { + x = startMongoProgramNoConnect( "mongo" , "--port" , port , "--eval" , jsCode ); + } else { + x = startMongoProgramNoConnect( "mongo" , "--eval" , jsCode , db ? db.getMongo().host : null ); + } + + return function(){ + jsTestLog( "Waiting for shell " + x + "..." ) + waitProgram( x ); + jsTestLog( "Shell " + x + " finished." ) + }; +} + +startParallelOps = function( mongo, proc, args, context ){ + + var procName = proc.name + "-" + new ObjectId() + var seed = new ObjectId( new ObjectId().valueOf().split("").reverse().join("") ) + .getTimestamp().getTime() + + // Make sure we aren't finished before we start + setFinished( mongo, procName, false ) + setResult( mongo, procName, undefined, undefined ) + + // TODO: Make this a context of its own + var procContext = { procName : procName, + seed : seed, + waitForLock : waitForLock, + setFinished : setFinished, + isFinished : isFinished, + setResult : setResult, + + setup : function( context, stored ){ + + waitForLock = function(){ + return context.waitForLock( db.getMongo(), context.procName ) + } + setFinished = function( finished ){ + return context.setFinished( db.getMongo(), context.procName, finished ) + } + isFinished = function(){ + return context.isFinished( db.getMongo(), context.procName ) + } + setResult = function( result, err ){ + return context.setResult( db.getMongo(), context.procName, result, err ) + } + }} + + var bootstrapper = function( stored ){ + + var procContext = stored.procContext + procContext.setup( procContext, stored ) + + var contexts = stored.contexts + eval( "contexts = " + contexts ) + + for( var i = 0; i < contexts.length; i++ ){ + if( typeof( contexts[i] ) != "undefined" ){ + // Evaluate all contexts + contexts[i]( procContext ) + } + } + + var operation = stored.operation + eval( "operation = " + operation ) + + var args = stored.args + eval( "args = " + args ) + + result = undefined + err = undefined + + try{ + result = operation.apply( null, args ) + } + catch( e ){ + err = e + } + + setResult( result, err ) + } + + var contexts = [ RandomFunctionContext, context ] + + var testDataColl = mongo.getCollection( "config.parallelTest" ) + + testDataColl.insert({ _id : procName, + bootstrapper : tojson( bootstrapper ), + operation : tojson( proc ), + args : tojson( args ), + procContext : procContext, + contexts : tojson( contexts ) }) + + assert.eq( null, testDataColl.getDB().getLastError() ) + + var bootstrapStartup = + "{ var procName = '" + procName + "'; " + + "var stored = db.getMongo().getCollection( '" + testDataColl + "' )" + + ".findOne({ _id : procName }); " + + "var bootstrapper = stored.bootstrapper; " + + "eval( 'bootstrapper = ' + bootstrapper ); " + + "bootstrapper( stored ); " + + "}" + + + var oldDB = db + db = mongo.getDB( "test" ) + + jsTest.log( "Starting " + proc.name + " operations..." ) + + var rawJoin = startParallelShell( bootstrapStartup ) + + db = oldDB + + + var join = function(){ + setFinished( mongo, procName, true ) + + rawJoin(); + result = getResult( mongo, procName ) + + assert.neq( result, null ) + + if( result.err ) throw Error("Error in parallel ops " + procName + " : " + + tojson( result.err ) ) + + else return result.result + } + + join.isFinished = function(){ + return isFinished( mongo, procName ) + } + + join.setFinished = function( finished ){ + return setFinished( mongo, procName, finished ) + } + + join.waitForLock = function( name ){ + return waitForLock( mongo, name ) + } + + return join +} + +var RandomFunctionContext = function( context ){ + + Random.srand( context.seed ); + + Random.randBool = function(){ return Random.rand() > 0.5 } + + Random.randInt = function( min, max ){ + + if( max == undefined ){ + max = min + min = 0 + } + + return min + Math.floor( Random.rand() * max ) + } + + Random.randShardKey = function(){ + + var numFields = 2 //Random.randInt(1, 3) + + var key = {} + for( var i = 0; i < numFields; i++ ){ + var field = String.fromCharCode( "a".charCodeAt() + i ) + key[ field ] = 1 + } + + return key + } + + Random.randShardKeyValue = function( shardKey ){ + + var keyValue = {} + for( field in shardKey ){ + keyValue[ field ] = Random.randInt(1, 100) + } + + return keyValue + } + + Random.randCluster = function(){ + + var numShards = 2 //Random.randInt( 1, 10 ) + var rs = false //Random.randBool() + var st = new ShardingTest({ shards : numShards, + mongos : 4, + other : { separateConfig : true, rs : rs } }) + + return st + } +} + + +// +// Some utility operations +// + +function moveOps( collName, options ){ + + options = options || {} + + var admin = db.getMongo().getDB( "admin" ) + var config = db.getMongo().getDB( "config" ) + var shards = config.shards.find().toArray() + var shardKey = config.collections.findOne({ _id : collName }).key + + while( ! isFinished() ){ + + var findKey = Random.randShardKeyValue( shardKey ) + var toShard = shards[ Random.randInt( shards.length ) ]._id + + try { + printjson( admin.runCommand({ moveChunk : collName, + find : findKey, + to : toShard }) ) + } + catch( e ){ + printjson( e ) + } + + sleep( 1000 ) + } + + jsTest.log( "Stopping moveOps..." ) +} + +function splitOps( collName, options ){ + + options = options || {} + + var admin = db.getMongo().getDB( "admin" ) + var config = db.getMongo().getDB( "config" ) + var shards = config.shards.find().toArray() + var shardKey = config.collections.findOne({ _id : collName }).key + + while( ! isFinished() ){ + + var middleKey = Random.randShardKeyValue( shardKey ) + + try { + printjson( admin.runCommand({ split : collName, + middle : middleKey }) ) + } + catch( e ){ + printjson( e ) + } + + sleep( 1000 ) + } + + jsTest.log( "Stopping splitOps..." ) +} + diff --git a/test/legacy28/jstests/libs/testconfig b/test/legacy28/jstests/libs/testconfig new file mode 100644 index 00000000000..4b09f37ad13 --- /dev/null +++ b/test/legacy28/jstests/libs/testconfig @@ -0,0 +1,6 @@ +fastsync = true +#comment line +#commentedflagwithan = false +version = false +help = false +sysinfo = false diff --git a/test/legacy28/jstests/libs/testconfig.json b/test/legacy28/jstests/libs/testconfig.json new file mode 100644 index 00000000000..5af32aad7d3 --- /dev/null +++ b/test/legacy28/jstests/libs/testconfig.json @@ -0,0 +1,4 @@ +{ + "fastsync" : true, + "version" : false +} diff --git a/test/legacy28/jstests/libs/trace_missing_docs.js b/test/legacy28/jstests/libs/trace_missing_docs.js new file mode 100644 index 00000000000..3faf50b4606 --- /dev/null +++ b/test/legacy28/jstests/libs/trace_missing_docs.js @@ -0,0 +1,90 @@ + +// +// On error inserting documents, traces back and shows where the document was dropped +// + +function traceMissingDoc( coll, doc, mongos ) { + + if (mongos) coll = mongos.getCollection(coll + ""); + else mongos = coll.getMongo(); + + var config = mongos.getDB( "config" ); + var shards = config.shards.find().toArray(); + for ( var i = 0; i < shards.length; i++ ) { + shards[i].conn = new Mongo( shards[i].host ); + } + + var shardKeyPatt = config.collections.findOne({ _id : coll + "" }).key; + + // Project out the shard key + var shardKey = {}; + for ( var k in shardKeyPatt ) { + if ( doc[k] == undefined ) { + jsTest.log( "Shard key " + tojson( shardKey ) + + " not found in doc " + tojson( doc ) + + ", falling back to _id search..." ); + shardKeyPatt = { _id : 1 }; + shardKey = { _id : doc['_id'] }; + break; + } + shardKey[k] = doc[k]; + } + + if ( doc['_id'] == undefined ) { + jsTest.log( "Id not found in doc " + tojson( doc ) + " cannot trace oplog entries." ); + return; + } + + jsTest.log( "Using shard key : " + tojson( shardKey ) ); + + var allOps = []; + for ( var i = 0; i < shards.length; i++ ) { + + var oplog = shards[i].conn.getCollection( "local.oplog.rs" ); + if ( !oplog.findOne() ) { + oplog = shards[i].conn.getCollection( "local.oplog.$main" ); + } + + if ( !oplog.findOne() ) { + jsTest.log( "No oplog was found on shard " + shards[i]._id ); + continue; + } + + var addKeyQuery = function( query, prefix ) { + for ( var k in shardKey ) { + query[prefix + '.' + k] = shardKey[k]; + } + return query; + }; + + var addToOps = function( cursor ) { + cursor.forEach( function( doc ) { + doc.shard = shards[i]._id; + doc.realTime = new Date( doc.ts.getTime() * 1000 ); + allOps.push( doc ); + }); + }; + + // Find ops + addToOps( oplog.find( addKeyQuery( { op : 'i' }, 'o' ) ) ); + var updateQuery = { $or : [ addKeyQuery( { op : 'u' }, 'o2' ), + { op : 'u', 'o2._id' : doc['_id'] } ] }; + addToOps( oplog.find( updateQuery ) ); + addToOps( oplog.find({ op : 'd', 'o._id' : doc['_id'] }) ); + } + + var compareOps = function( opA, opB ) { + if ( opA.ts < opB.ts ) return -1; + if ( opB.ts < opA.ts ) return 1; + else return 0; + } + + allOps.sort( compareOps ); + + print( "Ops found for doc " + tojson( doc ) + " on each shard:\n" ); + for ( var i = 0; i < allOps.length; i++ ) { + printjson( allOps[i] ); + } + + return allOps; +} \ No newline at end of file diff --git a/test/legacy28/jstests/replsets/rslib.js b/test/legacy28/jstests/replsets/rslib.js new file mode 100644 index 00000000000..8b7d2ed1263 --- /dev/null +++ b/test/legacy28/jstests/replsets/rslib.js @@ -0,0 +1,115 @@ + +var count = 0; +var w = 0; + +var wait = function(f,msg) { + w++; + var n = 0; + while (!f()) { + if( n % 4 == 0 ) + print("waiting " + w); + if (++n == 4) { + print("" + f); + } + assert(n < 200, 'tried 200 times, giving up on ' + msg ); + sleep(1000); + } +}; + +/** + * Use this to do something once every 4 iterations. + * + *
+ * for (i=0; i<1000; i++) {
+ *   occasionally(function() { print("4 more iterations"); });
+ * }
+ * 
+ */ +var occasionally = function(f, n) { + var interval = n || 4; + if (count % interval == 0) { + f(); + } + count++; +}; + +var reconnect = function(a) { + wait(function() { + try { + // make this work with either dbs or connections + if (typeof(a.getDB) == "function") { + db = a.getDB('foo'); + } + else { + db = a; + } + db.bar.stats(); + if (jsTest.options().keyFile || jsTest.options().useX509) { // SERVER-4241: Shell connections don't re-authenticate on reconnect + return jsTest.authenticate(db.getMongo()); + } + return true; + } catch(e) { + print(e); + return false; + } + }); +}; + + +var getLatestOp = function(server) { + server.getDB("admin").getMongo().setSlaveOk(); + var log = server.getDB("local")['oplog.rs']; + var cursor = log.find({}).sort({'$natural': -1}).limit(1); + if (cursor.hasNext()) { + return cursor.next(); + } + return null; +}; + + +var waitForAllMembers = function(master, timeout) { + var failCount = 0; + + assert.soon( function() { + var state = null + try { + state = master.getSisterDB("admin").runCommand({replSetGetStatus:1}); + failCount = 0; + } catch ( e ) { + // Connection can get reset on replica set failover causing a socket exception + print( "Calling replSetGetStatus failed" ); + print( e ); + return false; + } + occasionally(function() { printjson(state); }, 10); + + for (var m in state.members) { + if (state.members[m].state != 1 && // PRIMARY + state.members[m].state != 2 && // SECONDARY + state.members[m].state != 7) { // ARBITER + return false; + } + } + printjson( state ); + return true; + }, "not all members ready", timeout || 60000); + + print( "All members are now in state PRIMARY, SECONDARY, or ARBITER" ); +}; + +var reconfig = function(rs, config) { + var admin = rs.getMaster().getDB("admin"); + + try { + var ok = admin.runCommand({replSetReconfig : config}); + assert.eq(ok.ok,1); + } + catch(e) { + print(e); + } + + master = rs.getMaster().getDB("admin"); + waitForAllMembers(master); + + return master; +}; diff --git a/test/legacy28/jstests/tool/csv1.js b/test/legacy28/jstests/tool/csv1.js new file mode 100644 index 00000000000..e95d8aa8b41 --- /dev/null +++ b/test/legacy28/jstests/tool/csv1.js @@ -0,0 +1,43 @@ +// csv1.js + + +t = new ToolTest( "csv1" ) + +c = t.startDB( "foo" ); + +base = { a : 1 , b : "foo,bar\"baz,qux" , c: 5, 'd d': -6 , e: '-', f : "."}; + +assert.eq( 0 , c.count() , "setup1" ); +c.insert( base ); +delete base._id +assert.eq( 1 , c.count() , "setup2" ); + +t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo" , "--csv" , "-f" , "a,b,c,d d,e,f" ) + +c.drop() +assert.eq( 0 , c.count() , "after drop" ) + +t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo" , "--type" , "csv" , "-f" , "a,b,c,d d,e,f" ); +assert.soon( "2 == c.count()" , "restore 2" ); + +a = c.find().sort( { a : 1 } ).toArray(); +delete a[0]._id +delete a[1]._id +assert.docEq( { a : "a" , b : "b" , c : "c" , 'd d': "d d", e: 'e', f : "f"}, a[1], "csv parse 1" ); +assert.docEq( base, a[0], "csv parse 0" ) + +c.drop() +assert.eq( 0 , c.count() , "after drop 2" ) + +t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo" , "--type" , "csv" , "--headerline" ) +assert.soon( "c.findOne()" , "no data after sleep" ); +assert.eq( 1 , c.count() , "after restore 2" ); + +x = c.findOne() +delete x._id; +assert.docEq( base, x, "csv parse 2" ) + + + + +t.stop() diff --git a/test/legacy28/jstests/tool/csvexport1.js b/test/legacy28/jstests/tool/csvexport1.js new file mode 100644 index 00000000000..2cd3c9c0447 --- /dev/null +++ b/test/legacy28/jstests/tool/csvexport1.js @@ -0,0 +1,65 @@ +// csvexport1.js + + +t = new ToolTest( "csvexport1" ) + +c = t.startDB( "foo" ); + +assert.eq( 0 , c.count() , "setup1" ); + +objId = ObjectId() + +c.insert({ a : new NumberInt(1) , b : objId , c: [1, 2, 3], d : {a : "hello", b : "world"} , e: '-'}) +c.insert({ a : -2.0, c : MinKey, d : "Then he said, \"Hello World!\"", e : new NumberLong(3)}) +c.insert({ a : new BinData(0, "1234"), b : ISODate("2009-08-27T12:34:56.789"), + c : new Timestamp(1234, 9876), d : /foo*\"bar\"/i, + e : function foo() { print("Hello World!"); }}) + +assert.eq( 3 , c.count() , "setup2" ); + +t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo" , "--csv", "-f", "a,b,c,d,e") + + +c.drop() + +assert.eq( 0 , c.count() , "after drop" ) + +t.runTool("import", "--file", t.extFile, "-d", t.baseName, "-c", "foo", "--type", "csv", "--headerline"); + +assert.soon ( 3 + " == c.count()", "after import"); + +// Note: Exporting and Importing to/from CSV is not designed to be round-trippable +expected = [] +expected.push({ a : 1, b : "ObjectId(" + objId.valueOf() + ")", c : [ 1, 2, 3 ], d : { "a" : "hello", "b" : "world" }, e : "-"}) +expected.push({ a : -2.0, b : "", c : "$MinKey", d : "Then he said, \"Hello World!\"", e : 3}) +// "t" should be 1234, but the shell interprets the first field of timestamps as milliseconds while +// they are stored as seconds. See SERVER-7718. +expected.push({ a : "D76DF8", b : "2009-08-27T12:34:56.789Z", + c : { "$timestamp" : { "t" : 1234, "i" : 9876 } }, + d : "/foo*\\\"bar\\\"/i", e : tojson(function foo() { print("Hello World!"); })}) + +actual = [] +actual.push(c.find({a : 1}).toArray()[0]); +actual.push(c.find({a : -2.0}).toArray()[0]); +actual.push(c.find({a : "D76DF8"}).toArray()[0]); + +for (i = 0; i < expected.length; i++) { + delete actual[i]._id + assert.eq(Object.keys(expected[i]).length, Object.keys(actual[i]).length) + keys = Object.keys(expected[i]) + for(var j=0;j 0, "No data on shard: " + s._connections[i].host); +} + +step("Stop cluster"); +s.stop(); +step("SUCCESS"); +} \ No newline at end of file diff --git a/test/legacy28/jstests/tool/dumprestoreWithNoOptions.js b/test/legacy28/jstests/tool/dumprestoreWithNoOptions.js new file mode 100644 index 00000000000..3f6360168b0 --- /dev/null +++ b/test/legacy28/jstests/tool/dumprestoreWithNoOptions.js @@ -0,0 +1,112 @@ +// SERVER-6366 +// relates to SERVER-808 +// +// This file tests that options are not restored upon +// mongorestore with --noOptionsRestore +// +// It checks that this works both when doing a full +// database dump/restore and when doing it just for a +// single db or collection. + + +t = new ToolTest( "dumprestoreWithNoOptions" ); + +t.startDB( "foo" ); +db = t.db; + +// We turn this off to prevent the server from touching the 'options' field in system.namespaces. +// This is important because we check exact values of the 'options' field in this test. +db.adminCommand({setParameter:1, newCollectionsUsePowerOf2Sizes: false}); + +dbname = db.getName(); +dbname2 = "NOT_"+dbname; + +db.dropDatabase(); + +var options = { capped: true, size: 4096, autoIndexId: true }; +db.createCollection('capped', options); +assert.eq( 1, db.system.indexes.count(), "auto index not created" ); +var cappedOptions = db.capped.exists().options; +for ( var opt in options ) { + assert.eq(options[opt], cappedOptions[opt], + 'invalid option:' + tojson(options) + " " + tojson(cappedOptions)); +} +assert.writeOK(db.capped.insert({ x: 1 })); + +// Full dump/restore + +t.runTool( "dump" , "--out" , t.ext ); + +db.dropDatabase(); +assert.eq( 0, db.capped.count(), "capped not dropped"); +assert.eq( 0, db.system.indexes.count(), "indexes not dropped" ); + +t.runTool( "restore" , "--dir" , t.ext , "--noOptionsRestore"); + +assert.eq( 1, db.capped.count() , "wrong number of docs restored to capped" ); +assert(true !== db.capped.stats().capped, "restore options were not ignored"); +assert.eq( {}, db.capped.exists().options, + "restore options not ignored: " + tojson( db.capped.exists() ) ); + +// Dump/restore single DB + +db.dropDatabase(); +var options = { capped: true, size: 4096, autoIndexId: true }; +db.createCollection('capped', options); +assert.eq( 1, db.system.indexes.count(), "auto index not created" ); +var cappedOptions = db.capped.exists().options; +for ( var opt in options ) { + assert.eq(options[opt], cappedOptions[opt], 'invalid option') +} +assert.writeOK(db.capped.insert({ x: 1 })); + +dumppath = t.ext + "noOptionsSingleDump/"; +mkdir(dumppath); +t.runTool( "dump" , "-d", dbname, "--out" , dumppath ); + +db.dropDatabase(); +assert.eq( 0, db.capped.count(), "capped not dropped"); +assert.eq( 0, db.system.indexes.count(), "indexes not dropped" ); + +t.runTool( "restore" , "-d", dbname2, "--dir" , dumppath + dbname, "--noOptionsRestore"); + +db = db.getSiblingDB(dbname2); + +assert.eq( 1, db.capped.count() , "wrong number of docs restored to capped" ); +assert(true !== db.capped.stats().capped, "restore options were not ignored"); +assert.eq( {}, db.capped.exists().options, + "restore options not ignored: " + tojson( db.capped.exists() ) ); + +// Dump/restore single collection + +db.dropDatabase(); +var options = { capped: true, size: 4096, autoIndexId: true }; +db.createCollection('capped', options); +assert.eq( 1, db.system.indexes.count(), "auto index not created" ); +var cappedOptions = db.capped.exists().options; +for ( var opt in options ) { + assert.eq(options[opt], cappedOptions[opt], 'invalid option') +} + +assert.writeOK(db.capped.insert({ x: 1 })); + +dumppath = t.ext + "noOptionsSingleColDump/"; +mkdir(dumppath); +dbname = db.getName(); +t.runTool( "dump" , "-d", dbname, "-c", "capped", "--out" , dumppath ); + +db.dropDatabase(); + +assert.eq( 0, db.capped.count(), "capped not dropped"); +assert.eq( 0, db.system.indexes.count(), "indexes not dropped" ); + +t.runTool( "restore", "-d", dbname, "--drop", "--noOptionsRestore", dumppath + dbname ); + +db = db.getSiblingDB(dbname); + +assert.eq( 1, db.capped.count() , "wrong number of docs restored to capped" ); +assert( true !== db.capped.stats().capped, "restore options were not ignored" ); +assert.eq( {}, db.capped.exists().options, + "restore options not ignored: " + tojson( db.capped.exists() ) ); + +t.stop(); diff --git a/test/legacy28/jstests/tool/dumprestore_auth.js b/test/legacy28/jstests/tool/dumprestore_auth.js new file mode 100644 index 00000000000..a2de1f983f5 --- /dev/null +++ b/test/legacy28/jstests/tool/dumprestore_auth.js @@ -0,0 +1,99 @@ +// dumprestore_auth.js + + +t = new ToolTest("dumprestore_auth", { auth : "" }); + +c = t.startDB("foo"); +var dbName = c.getDB().toString(); +print("DB is ",dbName); + +adminDB = c.getDB().getSiblingDB('admin'); +adminDB.createUser({user: 'admin', pwd: 'password', roles: ['root']}); +adminDB.auth('admin','password'); +adminDB.createUser({user: 'backup', pwd: 'password', roles: ['backup']}); +adminDB.createUser({user: 'restore', pwd: 'password', roles: ['restore']}); + +// Add user defined roles & users with those roles +var testUserAdmin = c.getDB().getSiblingDB(dbName); +var backupActions = ["find","listCollections", "listIndexes"]; +testUserAdmin.createRole({role: "backupFoo", + privileges: [{resource: {db: dbName, collection: "foo"}, actions:backupActions}, + {resource: {db: dbName, collection: "system.indexes"}, + actions: backupActions}, + {resource: {db: dbName, collection: "" }, + actions: backupActions}, + {resource: {db: dbName, collection: "system.namespaces"}, + actions: backupActions}], + roles: []}); +testUserAdmin.createUser({user: 'backupFoo', pwd: 'password', roles: ['backupFoo']}); + +var restoreActions = ["collMod", "createCollection","createIndex","dropCollection","insert"]; +var restoreActionsFind = restoreActions; +restoreActionsFind.push("find"); +testUserAdmin.createRole({role: "restoreChester", + privileges: [{resource: {db: dbName, collection: "chester"}, actions: restoreActions}, + {resource: {db: dbName, collection: "system.indexes"}, + actions: restoreActions}, + {resource: {db: dbName, collection: "system.namespaces"}, + actions: restoreActionsFind}], + roles: []}); +testUserAdmin.createRole({role: "restoreFoo", + privileges: [{resource: {db: dbName, collection: "foo"}, actions:restoreActions}, + {resource: {db: dbName, collection: "system.indexes"}, + actions: restoreActions}, + {resource: {db: dbName, collection: "system.namespaces"}, + actions: restoreActionsFind}], + roles: []}); +testUserAdmin.createUser({user: 'restoreChester', pwd: 'password', roles: ['restoreChester']}); +testUserAdmin.createUser({user: 'restoreFoo', pwd: 'password', roles: ['restoreFoo']}); + +var sysUsers = adminDB.system.users.count(); +assert.eq(0 , c.count() , "setup1"); +c.save({ a : 22 }); +assert.eq(1 , c.count() , "setup2"); + +assert.commandWorked(c.runCommand("collMod", {usePowerOf2Sizes: false})); +assert.eq(0, c.getDB().system.namespaces.findOne( +{name: c.getFullName()}).options.flags, "find namespaces 1"); + +t.runTool("dump" , "--out" , t.ext, "--username", "backup", "--password", "password"); + +c.drop(); +assert.eq(0 , c.count() , "after drop"); + +// Restore should fail without user & pass +t.runTool("restore" , "--dir" , t.ext, "--writeConcern" ,"0"); +assert.eq(0 , c.count() , "after restore without auth"); + +// Restore should pass with authorized user +t.runTool("restore" , "--dir" , t.ext, "--username", "restore", "--password", "password", "--writeConcern", "0"); +assert.soon("c.findOne()" , "no data after sleep"); +assert.eq(1 , c.count() , "after restore 2"); +assert.eq(22 , c.findOne().a , "after restore 2"); +assert.eq(0, c.getDB().system.namespaces.findOne( +{name: c.getFullName()}).options.flags, "find namespaces 2"); +assert.eq(sysUsers, adminDB.system.users.count()); + +// Ddump & restore DB/colection with user defined roles +t.runTool("dump" , "--out" , t.ext, "--username", "backupFoo", "--password", "password", + "--db", dbName, "--collection", "foo"); + +c.drop(); +assert.eq(0 , c.count() , "after drop"); + +// Restore with wrong user +t.runTool("restore" , "--username", "restoreChester", "--password", "password", + "--db", dbName, "--collection", "foo", t.ext+dbName+"/foo.bson", "--writeConcern", "0"); +assert.eq(0 , c.count() , "after restore with wrong user"); + +// Restore with proper user +t.runTool("restore" , "--username", "restoreFoo", "--password", "password", + "--db", dbName, "--collection", "foo", t.ext+dbName+"/foo.bson", "--writeConcern", "0"); +assert.soon("c.findOne()" , "no data after sleep"); +assert.eq(1 , c.count() , "after restore 3"); +assert.eq(22 , c.findOne().a , "after restore 3"); +assert.eq(0, c.getDB().system.namespaces.findOne( +{name: c.getFullName()}).options.flags, "find namespaces 3"); +assert.eq(sysUsers, adminDB.system.users.count()); + +t.stop(); diff --git a/test/legacy28/jstests/tool/dumprestore_auth2.js b/test/legacy28/jstests/tool/dumprestore_auth2.js new file mode 100644 index 00000000000..0392d1be3db --- /dev/null +++ b/test/legacy28/jstests/tool/dumprestore_auth2.js @@ -0,0 +1,98 @@ +// dumprestore_auth2.js +// Tests that mongodump and mongorestore properly handle access control information +// Tests that the default auth roles of backup and restore work properly. + +t = new ToolTest("dumprestore_auth2", {auth: ""}); + +coll = t.startDB("foo"); +admindb = coll.getDB().getSiblingDB("admin") + +// Create the relevant users and roles. +admindb.createUser({user: "root", pwd: "pass", roles: ["root"]}); +admindb.auth("root", "pass"); + +admindb.createUser({user: "backup", pwd: "pass", roles: ["backup"]}); +admindb.createUser({user: "restore", pwd: "pass", roles: ["restore"]}); + +admindb.createRole({role: "customRole", + privileges:[{resource: {db: "jstests_tool_dumprestore_auth2", + collection: "foo"}, + actions: ["find"]}], + roles:[]}); +admindb.createUser({user: "test", pwd: "pass", roles: ["customRole"]}); + +coll.insert({word: "tomato"}); +assert.eq(1, coll.count()); + +assert.eq(4, admindb.system.users.count(), "setup users") +assert.eq(2, admindb.system.users.getIndexes().length, + "setup2: " + tojson( admindb.system.users.getIndexes() ) ); +assert.eq(1, admindb.system.roles.count(), "setup3") +assert.eq(2, admindb.system.roles.getIndexes().length, "setup4") +assert.eq(1, admindb.system.version.count()); +var versionDoc = admindb.system.version.findOne(); + +// Logout root user. +admindb.logout(); + +// Verify that the custom role works as expected. +admindb.auth("test", "pass"); +assert.eq("tomato", coll.findOne().word); +admindb.logout(); + +// Dump the database. +t.runTool("dump", "--out", t.ext, "--username", "backup", "--password", "pass"); + +// Drop the relevant data in the database. +admindb.auth("root", "pass"); +coll.getDB().dropDatabase(); +admindb.dropUser("backup"); +admindb.dropUser("test"); +admindb.dropRole("customRole"); + +assert.eq(2, admindb.system.users.count(), "didn't drop backup and test users"); +assert.eq(0, admindb.system.roles.count(), "didn't drop roles"); +assert.eq(0, coll.count(), "didn't drop foo coll"); + +// This test depends on W=0 to mask unique index violations. +// This should be fixed once we implement TOOLS-341 +t.runTool("restore", "--dir", t.ext, "--username", "restore", "--password", "pass", "--writeConcern", "0"); + +assert.soon("admindb.system.users.findOne()", "no data after restore"); +assert.eq(4, admindb.system.users.count(), "didn't restore users"); +assert.eq(2, admindb.system.users.getIndexes().length, + "didn't restore user indexes"); +assert.eq(1, admindb.system.roles.find({role:'customRole'}).count(), "didn't restore roles"); +assert.eq(2, admindb.system.roles.getIndexes().length, + "didn't restore role indexes"); + +admindb.logout(); + +// Login as user with customRole to verify privileges are restored. +admindb.auth("test", "pass"); +assert.eq("tomato", coll.findOne().word); +admindb.logout(); + +admindb.auth("root", "pass"); +admindb.createUser({user: "root2", pwd: "pass", roles: ["root"]}); +admindb.dropRole("customRole"); +admindb.createRole({role: "customRole2", roles: [], privileges:[]}); +admindb.dropUser("root"); +admindb.logout(); + +t.runTool("restore", "--dir", t.ext, "--username", "restore", "--password", "pass", "--drop", "--writeConcern", "0"); + +admindb.auth("root", "pass"); +assert.soon("1 == admindb.system.users.find({user:'root'}).count()", "didn't restore users 2"); +assert.eq(0, admindb.system.users.find({user:'root2'}).count(), "didn't drop users"); +assert.eq(0, admindb.system.roles.find({role:'customRole2'}).count(), "didn't drop roles"); +assert.eq(1, admindb.system.roles.find({role:'customRole'}).count(), "didn't restore roles"); +assert.eq(2, admindb.system.users.getIndexes().length, + "didn't maintain user indexes"); +assert.eq(2, admindb.system.roles.getIndexes().length, + "didn't maintain role indexes"); +assert.eq(1, admindb.system.version.count(), "didn't restore version"); +assert.docEq(versionDoc, admindb.system.version.findOne(), "version doc wasn't restored properly"); +admindb.logout(); + +t.stop(); \ No newline at end of file diff --git a/test/legacy28/jstests/tool/dumprestore_auth3.js b/test/legacy28/jstests/tool/dumprestore_auth3.js new file mode 100644 index 00000000000..f65bed7abff --- /dev/null +++ b/test/legacy28/jstests/tool/dumprestore_auth3.js @@ -0,0 +1,200 @@ +// dumprestore_auth3.js +// Tests that mongodump and mongorestore properly handle access control information when doing +// single-db dumps and restores + +// Runs the tool with the given name against the given mongod. +function runTool(toolName, mongod, options) { + var opts = {host: mongod.host}; + Object.extend(opts, options); + MongoRunner.runMongoTool(toolName, opts); +} + +var mongod = MongoRunner.runMongod(); +var admindb = mongod.getDB("admin"); +var db = mongod.getDB("foo"); + +jsTestLog("Creating Admin user & initial data"); +admindb.createUser({user: 'root', pwd: 'pass', roles: ['root']}); +admindb.createUser({user: 'backup', pwd: 'pass', roles: ['backup']}); +admindb.createUser({user: 'restore', pwd: 'pass', roles: ['restore']}); +admindb.createRole({role: "dummyRole", roles: [], privileges:[]}); +db.createUser({user: 'user', pwd: 'pass', roles: jsTest.basicUserRoles}); +db.createRole({role: 'role', roles: [], privileges:[]}); +var backupActions = ['find']; +db.createRole({role: 'backupFooChester', + privileges: [{resource: {db: 'foo', collection: 'chester'}, actions: backupActions}], + roles: []}); +db.createUser({user: 'backupFooChester', pwd: 'pass', roles: ['backupFooChester']}); + +var userCount = db.getUsers().length; +var rolesCount = db.getRoles().length; +var adminUsersCount = admindb.getUsers().length; +var adminRolesCount = admindb.getRoles().length; +var systemUsersCount = admindb.system.users.count(); +var systemVersionCount = admindb.system.version.count(); + +db.bar.insert({a:1}); + +assert.eq(1, db.bar.findOne().a); +assert.eq(userCount, db.getUsers().length, "setup"); +assert.eq(rolesCount, db.getRoles().length, "setup2"); +assert.eq(adminUsersCount, admindb.getUsers().length, "setup3"); +assert.eq(adminRolesCount, admindb.getRoles().length, "setup4"); +assert.eq(systemUsersCount, admindb.system.users.count(), "setup5"); +assert.eq(systemVersionCount, admindb.system.version.count(),"system version"); +assert.eq(1, admindb.system.users.count({user: "restore"}), "Restore user is missing"); +assert.eq(1, admindb.system.users.count({user: "backup"}), "Backup user is missing"); +var versionDoc = admindb.system.version.findOne(); + +jsTestLog("Dump foo database without dumping user data"); +var dumpDir = MongoRunner.getAndPrepareDumpDirectory("dumprestore_auth3"); +runTool("mongodump", mongod, {out: dumpDir, db: "foo"}); +db = mongod.getDB('foo'); + +db.dropDatabase(); +db.dropAllUsers(); +db.dropAllRoles(); + +jsTestLog("Restore foo database from dump that doesn't contain user data "); +// This test depends on W=0 to mask unique index violations. +// This should be fixed once we implement TOOLS-341 +runTool("mongorestore", mongod, {dir: dumpDir + "foo/", db: 'foo', restoreDbUsersAndRoles: "", writeConcern: "0"}); + +db = mongod.getDB('foo'); + +assert.soon(function() { return db.bar.findOne(); }, "no data after restore"); +assert.eq(1, db.bar.findOne().a); +assert.eq(0, db.getUsers().length, "Restore created users somehow"); +assert.eq(0, db.getRoles().length, "Restore created roles somehow"); + +// Re-create user data +db.createUser({user: 'user', pwd: 'password', roles: jsTest.basicUserRoles}); +db.createRole({role: 'role', roles: [], privileges:[]}); +userCount = 1; +rolesCount = 1; + +assert.eq(1, db.bar.findOne().a); +assert.eq(userCount, db.getUsers().length, "didn't create user"); +assert.eq(rolesCount, db.getRoles().length, "didn't create role"); + +jsTestLog("Dump foo database *with* user data"); +runTool("mongodump", mongod, {out: dumpDir, db: "foo", dumpDbUsersAndRoles: ""}); +db = mongod.getDB('foo'); + +db.dropDatabase(); +db.dropAllUsers(); +db.dropAllRoles(); + +assert.eq(0, db.getUsers().length, "didn't drop users"); +assert.eq(0, db.getRoles().length, "didn't drop roles"); +assert.eq(0, db.bar.count(), "didn't drop 'bar' collection"); + +jsTestLog("Restore foo database without restoring user data, even though it's in the dump"); +runTool("mongorestore", mongod, {dir: dumpDir + "foo/", db: 'foo', writeConcern: "0"}); +db = mongod.getDB('foo'); + +assert.soon(function() { return db.bar.findOne(); }, "no data after restore"); +assert.eq(1, db.bar.findOne().a); +assert.eq(0, db.getUsers().length, "Restored users even though it shouldn't have"); +assert.eq(0, db.getRoles().length, "Restored roles even though it shouldn't have"); + +jsTestLog("Restore foo database *with* user data"); +runTool("mongorestore", mongod, {dir: dumpDir + "foo/", db: 'foo', restoreDbUsersAndRoles: "", writeConcern: "0"}); +db = mongod.getDB('foo'); +admindb = mongod.getDB('admin'); + +assert.soon(function() { return db.bar.findOne(); }, "no data after restore"); +assert.eq(1, db.bar.findOne().a); +assert.eq(userCount, db.getUsers().length, "didn't restore users"); +assert.eq(rolesCount, db.getRoles().length, "didn't restore roles"); +assert.eq(1, admindb.system.users.count({user: "restore", db: "admin"}), "Restore user is missing"); +assert.docEq(versionDoc, + db.getSiblingDB('admin').system.version.findOne(), + "version doc was changed by restore"); + +jsTestLog("Make modifications to user data that should be overridden by the restore"); +db.dropUser('user') +db.createUser({user: 'user2', pwd: 'password2', roles: jsTest.basicUserRoles}); +db.dropRole('role') +db.createRole({role: 'role2', roles: [], privileges:[]}); + +jsTestLog("Restore foo database (and user data) with --drop so it overrides the changes made"); +// Restore with --drop to override the changes to user data +runTool("mongorestore", mongod, + {dir: dumpDir + "foo/", db: 'foo', drop: "", restoreDbUsersAndRoles: "", writeConcern: "0"}); +db = mongod.getDB('foo'); +admindb = mongod.getDB('admin'); + +assert.soon(function() { return db.bar.findOne(); }, "no data after restore"); +assert.eq(adminUsersCount, admindb.getUsers().length, "Admin users were dropped"); +assert.eq(adminRolesCount, admindb.getRoles().length, "Admin roles were dropped"); +assert.eq(1, db.bar.findOne().a); +assert.eq(userCount, db.getUsers().length, "didn't restore users"); +assert.eq("user", db.getUser('user').user, "didn't update user"); +assert.eq(rolesCount, db.getRoles().length, "didn't restore roles"); +assert.eq("role", db.getRole('role').role, "didn't update role"); +assert.docEq(versionDoc, + db.getSiblingDB('admin').system.version.findOne(), + "version doc was changed by restore"); + + +jsTestLog("Dump just the admin database. User data should be dumped by default"); +// Make a user in another database to make sure it is properly captured +db.getSiblingDB('bar').createUser({user: "user", pwd: 'pwd', roles: []}); +db.getSiblingDB('admin').createUser({user: "user", pwd: 'pwd', roles: []}); +adminUsersCount += 1; +runTool("mongodump", mongod, {out: dumpDir, db: "admin"}); +db = mongod.getDB('foo'); + +// Change user data a bit. +db.dropAllUsers(); +db.getSiblingDB('bar').createUser({user: "user2", pwd: 'pwd', roles: []}); +db.getSiblingDB('admin').dropAllUsers(); + +jsTestLog("Restore just the admin database. User data should be restored by default"); +runTool("mongorestore", mongod, {dir: dumpDir + "admin/", db: 'admin', drop: "", writeConcern: "0"}); +db = mongod.getDB('foo'); +var otherdb = db.getSiblingDB('bar'); +var admindb = db.getSiblingDB('admin'); + +assert.soon(function() { return db.bar.findOne(); }, "no data after restore"); +assert.eq(1, db.bar.findOne().a); +assert.eq(userCount, db.getUsers().length, "didn't restore users"); +assert.eq("user", db.getUser('user').user, "didn't restore user"); +assert.eq(rolesCount, db.getRoles().length, "didn't restore roles"); +assert.eq("role", db.getRole('role').role, "didn't restore role"); +assert.eq(1, otherdb.getUsers().length, "didn't restore users for bar database"); +assert.eq("user", otherdb.getUsers()[0].user, "didn't restore user for bar database"); +assert.eq(adminUsersCount, admindb.getUsers().length, "didn't restore users for admin database"); +assert.eq("user", admindb.getUser("user").user, "didn't restore user for admin database"); +assert.eq(6, admindb.system.users.count(), "has the wrong # of users for the whole server"); +assert.eq(2, admindb.system.roles.count(), "has the wrong # of roles for the whole server"); +assert.docEq(versionDoc, + db.getSiblingDB('admin').system.version.findOne(), + "version doc was changed by restore"); + +jsTestLog("Dump all databases"); +runTool("mongodump", mongod, {out: dumpDir}); +db = mongod.getDB('foo'); + +db.dropDatabase(); +db.dropAllUsers(); +db.dropAllRoles(); + +assert.eq(0, db.getUsers().length, "didn't drop users"); +assert.eq(0, db.getRoles().length, "didn't drop roles"); +assert.eq(0, db.bar.count(), "didn't drop 'bar' collection"); + +jsTestLog("Restore all databases"); +runTool("mongorestore", mongod, {dir: dumpDir, writeConcern: "0"}); +db = mongod.getDB('foo'); + +assert.soon(function() { return db.bar.findOne(); }, "no data after restore"); +assert.eq(1, db.bar.findOne().a); +assert.eq(1, db.getUsers().length, "didn't restore users"); +assert.eq(1, db.getRoles().length, "didn't restore roles"); +assert.docEq(versionDoc, + db.getSiblingDB('admin').system.version.findOne(), + "version doc was changed by restore"); + +MongoRunner.stopMongod(mongod); \ No newline at end of file diff --git a/test/legacy28/jstests/tool/dumprestore_excludecollections.js b/test/legacy28/jstests/tool/dumprestore_excludecollections.js new file mode 100644 index 00000000000..dcfab742053 --- /dev/null +++ b/test/legacy28/jstests/tool/dumprestore_excludecollections.js @@ -0,0 +1,112 @@ +// Tests for mongodump options for excluding collections + + +var testBaseName = "jstests_tool_dumprestore_excludecollections"; + +var dumpDir = MongoRunner.dataPath + testBaseName + "_dump_external/"; + +var mongodSource = MongoRunner.runMongod(); +var sourceDB = mongodSource.getDB(testBaseName); +var mongodDest = MongoRunner.runMongod(); +var destDB = mongodDest.getDB(testBaseName); + +jsTest.log("Inserting documents into source mongod"); +sourceDB.test.insert({x:1}); +sourceDB.test2.insert({x:2}); +sourceDB.test3.insert({x:3}); +sourceDB.foo.insert({f:1}); +sourceDB.foo2.insert({f:2}); + +jsTest.log("Testing incompabible option combinations"); +resetDbpath(dumpDir); +ret = MongoRunner.runMongoTool("mongodump", { out : dumpDir, + excludeCollection : "test", + host : mongodSource.host }); +assert.neq(ret, 0, "mongodump started successfully with --excludeCollection but no --db option"); + +resetDbpath(dumpDir); +ret = MongoRunner.runMongoTool("mongodump", { out : dumpDir, + db : testBaseName, + collection : "foo", + excludeCollection : "test", + host : mongodSource.host }); +assert.neq(ret, 0, "mongodump started successfully with --excludeCollection and --collection"); + +resetDbpath(dumpDir); +ret = MongoRunner.runMongoTool("mongodump", { out : dumpDir, + excludeCollectionsWithPrefix : "test", + host : mongodSource.host }); +assert.neq(ret, 0, "mongodump started successfully with --excludeCollectionsWithPrefix but " + + "no --db option"); + +resetDbpath(dumpDir); +ret = MongoRunner.runMongoTool("mongodump", { out : dumpDir, + db : testBaseName, + collection : "foo", + excludeCollectionsWithPrefix : "test", + host : mongodSource.host }); +assert.neq(ret, 0, "mongodump started successfully with --excludeCollectionsWithPrefix and " + + "--collection"); + +jsTest.log("Testing proper behavior of collection exclusion"); +resetDbpath(dumpDir); +ret = MongoRunner.runMongoTool("mongodump", { out : dumpDir, + db : testBaseName, + excludeCollection : "test", + host : mongodSource.host }); + +ret = MongoRunner.runMongoTool("mongorestore", { dir : dumpDir, host : mongodDest.host }); +assert.eq(ret, 0, "failed to run mongodump on expected successful call"); +assert.eq(destDB.test.count(), 0, "Found documents in collection that we excluded"); +assert.eq(destDB.test2.count(), 1, "Did not find document in collection that we did not exclude"); +assert.eq(destDB.test2.findOne().x, 2, "Wrong value in document"); +assert.eq(destDB.test3.count(), 1, "Did not find document in collection that we did not exclude"); +assert.eq(destDB.test3.findOne().x, 3, "Wrong value in document"); +assert.eq(destDB.foo.count(), 1, "Did not find document in collection that we did not exclude"); +assert.eq(destDB.foo.findOne().f, 1, "Wrong value in document"); +assert.eq(destDB.foo2.count(), 1, "Did not find document in collection that we did not exclude"); +assert.eq(destDB.foo2.findOne().f, 2, "Wrong value in document"); +destDB.dropDatabase(); + +resetDbpath(dumpDir); +ret = MongoRunner.runMongoTool("mongodump", { out : dumpDir, + db : testBaseName, + excludeCollectionsWithPrefix : "test", + host : mongodSource.host }); + +ret = MongoRunner.runMongoTool("mongorestore", { dir : dumpDir, host : mongodDest.host }); +assert.eq(ret, 0, "failed to run mongodump on expected successful call"); +assert.eq(destDB.test.count(), 0, "Found documents in collection that we excluded"); +assert.eq(destDB.test2.count(), 0, "Found documents in collection that we excluded"); +assert.eq(destDB.test3.count(), 0, "Found documents in collection that we excluded"); +assert.eq(destDB.foo.count(), 1, "Did not find document in collection that we did not exclude"); +assert.eq(destDB.foo.findOne().f, 1, "Wrong value in document"); +assert.eq(destDB.foo2.count(), 1, "Did not find document in collection that we did not exclude"); +assert.eq(destDB.foo2.findOne().f, 2, "Wrong value in document"); +destDB.dropDatabase(); + +resetDbpath(dumpDir); +ret = MongoRunner.runMongoTool("mongodump", { out : dumpDir, + db : testBaseName, + excludeCollection : "foo", + excludeCollectionsWithPrefix : "test", + host : mongodSource.host }); + +ret = MongoRunner.runMongoTool("mongorestore", { dir : dumpDir, host : mongodDest.host }); +assert.eq(ret, 0, "failed to run mongodump on expected successful call"); +assert.eq(destDB.test.count(), 0, "Found documents in collection that we excluded"); +assert.eq(destDB.test2.count(), 0, "Found documents in collection that we excluded"); +assert.eq(destDB.test3.count(), 0, "Found documents in collection that we excluded"); +assert.eq(destDB.foo.count(), 0, "Found documents in collection that we excluded"); +assert.eq(destDB.foo2.count(), 1, "Did not find document in collection that we did not exclude"); +assert.eq(destDB.foo2.findOne().f, 2, "Wrong value in document"); +destDB.dropDatabase(); + +// The --excludeCollection and --excludeCollectionsWithPrefix options can be specified multiple +// times, but that is not tested here because right now MongoRunners can only be configured using +// javascript objects which do not allow duplicate keys. See SERVER-14220. + +MongoRunner.stopMongod(mongodDest.port); +MongoRunner.stopMongod(mongodSource.port); + +print(testBaseName + " success!"); diff --git a/test/legacy28/jstests/tool/dumpsecondary.js b/test/legacy28/jstests/tool/dumpsecondary.js new file mode 100644 index 00000000000..68a81210c12 --- /dev/null +++ b/test/legacy28/jstests/tool/dumpsecondary.js @@ -0,0 +1,39 @@ + +var replTest = new ReplSetTest( {name: 'testSet', nodes: 2} ); + +var nodes = replTest.startSet(); +replTest.initiate(); + +var master = replTest.getMaster(); +db = master.getDB("foo") +db.foo.save({a: 1000}); +replTest.awaitReplication(); +replTest.awaitSecondaryNodes(); + +assert.eq( 1 , db.foo.count() , "setup" ); + +var slaves = replTest.liveNodes.slaves; +assert( slaves.length == 1, "Expected 1 slave but length was " + slaves.length ); +slave = slaves[0]; + +var args = ['mongodump', '-h', slave.host, '--out', MongoRunner.dataDir + '/jstests_tool_dumpsecondary_external/']; +var authargs = ['--username', jsTest.options().authUser, '--password', jsTest.options().authPassword]; +if (jsTest.options().keyFile) { + args = args.concat(authargs); +} +runMongoProgram.apply(null, args); +db.foo.drop() + +assert.eq( 0 , db.foo.count() , "after drop" ); +args = ['mongorestore', '-h', master.host, MongoRunner.dataDir + '/jstests_tool_dumpsecondary_external/']; +if (jsTest.options().keyFile) { + args = args.concat(authargs); +} +runMongoProgram.apply(null, args) +assert.soon( "db.foo.findOne()" , "no data after sleep" ); +assert.eq( 1 , db.foo.count() , "after restore" ); +assert.eq( 1000 , db.foo.findOne().a , "after restore 2" ); + +resetDbpath(MongoRunner.dataDir + '/jstests_tool_dumpsecondary_external') + +replTest.stopSet(15) diff --git a/test/legacy28/jstests/tool/exportimport1.js b/test/legacy28/jstests/tool/exportimport1.js new file mode 100644 index 00000000000..5e206d8c40b --- /dev/null +++ b/test/legacy28/jstests/tool/exportimport1.js @@ -0,0 +1,67 @@ +// exportimport1.js + + +t = new ToolTest( "exportimport1" ); + +c = t.startDB( "foo" ); +assert.eq( 0 , c.count() , "setup1" ); +var arr = ["x", undefined, "y", undefined]; +c.save( { a : 22 , b : arr} ); +assert.eq( 1 , c.count() , "setup2" ); + +t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo" ); + +c.drop(); +assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" );; + +t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo" ); +assert.soon( "c.findOne()" , "no data after sleep" ); +assert.eq( 1 , c.count() , "after restore 2" ); +var doc = c.findOne(); +assert.eq( 22 , doc.a , "after restore 2" ); +for (var i=0; i