Make the killop test more resilient

XMLWordPrintableJSON

    • Fully Compatible
    • ALL
    • v5.0
    • Hide

      Apply the following patch:

      diff --git a/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp b/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
      index 70a8eb6663..7bca91e242 100644
      --- a/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
      +++ b/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
      @@ -45,6 +45,7 @@
       #include "mongo/stdx/thread.h"
       #include "mongo/unittest/temp_dir.h"
       #include "mongo/unittest/unittest.h"
      +#include "mongo/util/duration.h"
       #include "mongo/util/options_parser/environment.h"
       #include "mongo/util/options_parser/option_section.h"
       #include "mongo/util/options_parser/options_parser.h"
      @@ -356,6 +357,8 @@ TEST_F(MongodbCAPITest, KillOp) {
               auto currentOpMsg = mongo::OpMsgRequest::fromDBAndBody("admin", currentOpObj);
               mongo::BSONObj outputBSON;
       
      +        sleepFor(mongo::Seconds(10));
      +
               // Wait for the sleep command to start in the main test thread.
               int opid = -1;
               do {
      
      Show
      Apply the following patch: diff --git a/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp b/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp index 70a8eb6663..7bca91e242 100644 --- a/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp +++ b/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp @@ -45,6 +45,7 @@ #include "mongo/stdx/thread.h" #include "mongo/unittest/temp_dir.h" #include "mongo/unittest/unittest.h" +#include "mongo/util/duration.h" #include "mongo/util/options_parser/environment.h" #include "mongo/util/options_parser/option_section.h" #include "mongo/util/options_parser/options_parser.h" @@ -356,6 +357,8 @@ TEST_F(MongodbCAPITest, KillOp) { auto currentOpMsg = mongo::OpMsgRequest::fromDBAndBody("admin", currentOpObj); mongo::BSONObj outputBSON; + sleepFor(mongo::Seconds(10)); + // Wait for the sleep command to start in the main test thread. int opid = -1; do {
    • 45
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The MongodbCAPITest::KillOp test verifies the behavior of killop by:

      • Running a long running operation: {'sleep': {'secs': 1000}}
      • Spawning a thread that kills the long running operation (once it appears in currentOp).
      • Verifying that the long running operation is not successful and returns ErrorCodes::Interrupted.

      The test may fail if the spawned thread takes too long (~10 seconds in observed failures) before killing the operation. Moreover, the assertions in the test are not thread-safe and should use the ThreadAssertionMonitor.

      The test should adopt ThreadAssertionMonitor and properly handle incidents in which the operation is not killed in time (and returns with an okay status).

              Assignee:
              Amirsaman Memaripour
              Reporter:
              Amirsaman Memaripour
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: