summaryrefslogtreecommitdiff
path: root/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2020-06-18 16:39:50 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-23 15:34:45 +0000
commit2f8f944c0b660a647d5648f2a820e33221baf8be (patch)
treead1267fa58b6f6d9e20fac4cb37dbd4ef75070d8 /src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
parent5d604bc927c8143ce73d3cd664f1c50ea03e4e6e (diff)
downloadmongo-2f8f944c0b660a647d5648f2a820e33221baf8be.tar.gz
SERVER-48970 Prevent concurrent uses of the same mongo_embedded_v1_status in mongo_embedded_test KillOp
Diffstat (limited to 'src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp')
-rw-r--r--src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp b/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
index 9e5bfd7038f..1d83ec54aff 100644
--- a/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
+++ b/src/mongo/embedded/mongo_embedded/mongo_embedded_test.cpp
@@ -97,9 +97,6 @@ using MongoDBCAPIClientPtr = std::unique_ptr<mongo_embedded_v1_client, ClientDes
class MongodbCAPITest : public mongo::unittest::Test {
protected:
void setUp() {
- status = mongo_embedded_v1_status_create();
- ASSERT(status != nullptr);
-
if (!globalTempDir) {
globalTempDir = std::make_unique<mongo::unittest::TempDir>("embedded_mongo");
}
@@ -122,18 +119,27 @@ protected:
params.yaml_config = yaml.c_str();
+ auto* status = mongo_embedded_v1_status_create();
+ ASSERT(status);
+
lib = mongo_embedded_v1_lib_init(&params, status);
ASSERT(lib != nullptr) << mongo_embedded_v1_status_get_explanation(status);
db = mongo_embedded_v1_instance_create(lib, yaml.c_str(), status);
ASSERT(db != nullptr) << mongo_embedded_v1_status_get_explanation(status);
+
+ mongo_embedded_v1_status_destroy(status);
}
void tearDown() {
+ auto* status = mongo_embedded_v1_status_create();
+ ASSERT(status);
+
ASSERT_EQUALS(mongo_embedded_v1_instance_destroy(db, status), MONGO_EMBEDDED_V1_SUCCESS)
<< mongo_embedded_v1_status_get_explanation(status);
ASSERT_EQUALS(mongo_embedded_v1_lib_fini(lib, status), MONGO_EMBEDDED_V1_SUCCESS)
<< mongo_embedded_v1_status_get_explanation(status);
+
mongo_embedded_v1_status_destroy(status);
}
@@ -142,8 +148,13 @@ protected:
}
MongoDBCAPIClientPtr createClient() const {
+ auto* status = mongo_embedded_v1_status_create();
+ ASSERT(status);
+
MongoDBCAPIClientPtr client(mongo_embedded_v1_client_create(db, status));
ASSERT(client.get() != nullptr) << mongo_embedded_v1_status_get_explanation(status);
+
+ mongo_embedded_v1_status_destroy(status);
return client;
}
@@ -161,11 +172,16 @@ protected:
void* output;
size_t outputSize;
+ auto* status = mongo_embedded_v1_status_create();
+ ASSERT(status);
+
// call the wire protocol
int err = mongo_embedded_v1_client_invoke(
client.get(), inputMessage.buf(), inputMessage.size(), &output, &outputSize, status);
ASSERT_EQUALS(err, MONGO_EMBEDDED_V1_SUCCESS);
+ mongo_embedded_v1_status_destroy(status);
+
// convert the shared buffer to a mongo::message and ensure that it is valid
auto outputMessage = messageFromBuffer(output, outputSize);
ASSERT(outputMessage.size() > 0);
@@ -181,7 +197,6 @@ protected:
protected:
mongo_embedded_v1_lib* lib;
mongo_embedded_v1_instance* db;
- mongo_embedded_v1_status* status;
};
TEST_F(MongodbCAPITest, CreateAndDestroyDB) {