summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/test_commands.cpp
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2018-05-17 13:45:46 -0400
committerHenrik Edin <henrik.edin@mongodb.com>2018-05-17 15:10:36 -0400
commit53d264b01621f815e1c80673c4cbc874bbd45e32 (patch)
tree4f083521e5e3ae3379a1516a74e2da1beef3d06d /src/mongo/db/commands/test_commands.cpp
parent65aed83ec433fba0cb62ec51ce876f3c7139bcf0 (diff)
downloadmongo-53d264b01621f815e1c80673c4cbc874bbd45e32.tar.gz
SERVER-33889 Separate sleep from shell_commands so the capi unittests don't drag in new commands.
Diffstat (limited to 'src/mongo/db/commands/test_commands.cpp')
-rw-r--r--src/mongo/db/commands/test_commands.cpp92
1 files changed, 0 insertions, 92 deletions
diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp
index 74e09ab87ae..a25810fb6ec 100644
--- a/src/mongo/db/commands/test_commands.cpp
+++ b/src/mongo/db/commands/test_commands.cpp
@@ -110,98 +110,6 @@ public:
MONGO_REGISTER_TEST_COMMAND(GodInsert);
-/* for diagnostic / testing purposes. Enabled via command line. */
-class CmdSleep : public BasicCommand {
-public:
- virtual bool supportsWriteConcern(const BSONObj& cmd) const override {
- return false;
- }
-
- virtual bool adminOnly() const {
- return true;
- }
-
- AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
- return AllowedOnSecondary::kAlways;
- }
-
- std::string help() const override {
- return "internal testing command. Run a no-op command for an arbitrary amount of time. "
- "If neither 'secs' nor 'millis' is set, command will sleep for 10 seconds. "
- "If both are set, command will sleep for the sum of 'secs' and 'millis.'\n"
- " w:<bool> (deprecated: use 'lock' instead) if true, takes a write lock.\n"
- " lock: r, w, none. If r or w, db will block under a lock. Defaults to r."
- " 'lock' and 'w' may not both be set.\n"
- " secs:<seconds> Amount of time to sleep, in seconds.\n"
- " millis:<milliseconds> Amount of time to sleep, in ms.\n";
- }
-
- // No auth needed because it only works when enabled via command line.
- virtual void addRequiredPrivileges(const std::string& dbname,
- const BSONObj& cmdObj,
- std::vector<Privilege>* out) const {}
-
- void _sleepInReadLock(mongo::OperationContext* opCtx, long long millis) {
- Lock::GlobalRead lk(opCtx);
- opCtx->sleepFor(Milliseconds(millis));
- }
-
- void _sleepInWriteLock(mongo::OperationContext* opCtx, long long millis) {
- Lock::GlobalWrite lk(opCtx);
- opCtx->sleepFor(Milliseconds(millis));
- }
-
- CmdSleep() : BasicCommand("sleep") {}
- bool run(OperationContext* opCtx,
- const string& ns,
- const BSONObj& cmdObj,
- BSONObjBuilder& result) {
- log() << "test only command sleep invoked";
- long long millis = 0;
-
- if (cmdObj["secs"] || cmdObj["millis"]) {
- if (cmdObj["secs"]) {
- uassert(34344, "'secs' must be a number.", cmdObj["secs"].isNumber());
- millis += cmdObj["secs"].numberLong() * 1000;
- }
- if (cmdObj["millis"]) {
- uassert(34345, "'millis' must be a number.", cmdObj["millis"].isNumber());
- millis += cmdObj["millis"].numberLong();
- }
- } else {
- millis = 10 * 1000;
- }
-
- if (!cmdObj["lock"]) {
- // Legacy implementation
- if (cmdObj.getBoolField("w")) {
- _sleepInWriteLock(opCtx, millis);
- } else {
- _sleepInReadLock(opCtx, millis);
- }
- } else {
- uassert(34346, "Only one of 'w' and 'lock' may be set.", !cmdObj["w"]);
-
- std::string lock(cmdObj.getStringField("lock"));
- if (lock == "none") {
- opCtx->sleepFor(Milliseconds(millis));
- } else if (lock == "w") {
- _sleepInWriteLock(opCtx, millis);
- } else {
- uassert(34347, "'lock' must be one of 'r', 'w', 'none'.", lock == "r");
- _sleepInReadLock(opCtx, millis);
- }
- }
-
- // Interrupt point for testing (e.g. maxTimeMS).
- opCtx->checkForInterrupt();
-
- return true;
- }
-};
-
-MONGO_REGISTER_TEST_COMMAND(CmdSleep);
-
// Testing only, enabled via command-line.
class CapTrunc : public BasicCommand {
public: