summaryrefslogtreecommitdiff
path: root/src/mongo/transport/service_state_machine_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/transport/service_state_machine_test.cpp')
-rw-r--r--src/mongo/transport/service_state_machine_test.cpp51
1 files changed, 33 insertions, 18 deletions
diff --git a/src/mongo/transport/service_state_machine_test.cpp b/src/mongo/transport/service_state_machine_test.cpp
index caf064f91c6..3373f2ece2a 100644
--- a/src/mongo/transport/service_state_machine_test.cpp
+++ b/src/mongo/transport/service_state_machine_test.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/client.h"
#include "mongo/db/dbmessage.h"
#include "mongo/db/service_context.h"
+#include "mongo/logv2/log.h"
#include "mongo/rpc/op_msg.h"
#include "mongo/transport/mock_session.h"
#include "mongo/transport/service_entry_point.h"
@@ -73,7 +74,7 @@ public:
void startSession(transport::SessionHandle session) override {}
DbResponse handleRequest(OperationContext* opCtx, const Message& request) override {
- log() << "In handleRequest";
+ LOGV2(22994, "In handleRequest");
_ranHandler = true;
ASSERT_TRUE(haveClient());
@@ -152,7 +153,7 @@ public:
tl->_lastTicketSource = true;
tl->_ranSource = true;
- log() << "In sourceMessage";
+ LOGV2(22995, "In sourceMessage");
if (tl->_waitHook)
tl->_waitHook();
@@ -176,7 +177,7 @@ public:
ASSERT_EQ(tl->_ssm->state(), ServiceStateMachine::State::SinkWait);
tl->_lastTicketSource = false;
- log() << "In sinkMessage";
+ LOGV2(22996, "In sinkMessage");
tl->_ranSink = true;
if (tl->_waitHook)
@@ -365,7 +366,7 @@ protected:
void ServiceStateMachineFixture::runPingTest(State first, State second) {
ASSERT_FALSE(haveClient());
ASSERT_EQ(_ssm->state(), State::Created);
- log() << "run next";
+ LOGV2(22997, "run next");
_ssm->runNext();
ASSERT_EQ(_ssm->state(), first);
@@ -382,7 +383,7 @@ void ServiceStateMachineFixture::sourceAndSink(State afterSource, State afterSin
invariant(_ssm->state() == State::Source || _ssm->state() == State::Created);
// Source a new message from the network.
- log() << "(sourceAndSink) runNext to source a message";
+ LOGV2(22998, "(sourceAndSink) runNext to source a message");
_ssm->runNext();
ASSERT_TRUE(_tl->ranSource());
ASSERT_EQ(_ssm->state(), afterSource);
@@ -390,7 +391,7 @@ void ServiceStateMachineFixture::sourceAndSink(State afterSource, State afterSin
// Let the message be processed by sending it to the database, receiving the response, and then
// sinking it.
- log() << "(sourceAndSink) runNext to process and sink the response message";
+ LOGV2(22999, "(sourceAndSink) runNext to process and sink the response message");
_ssm->runNext();
ASSERT_FALSE(haveClient());
ASSERT_TRUE(_tl->ranSink());
@@ -474,7 +475,7 @@ TEST_F(ServiceStateMachineFixture, TestGetMoreWithExhaust) {
// terminal getMore, indicating that the exhaust stream should be ended.
_sep->setResponseMessage(getMoreTerminalRes);
- log() << "runNext to terminate the exhaust stream";
+ LOGV2(23000, "runNext to terminate the exhaust stream");
_ssm->runNext();
ASSERT_FALSE(haveClient());
ASSERT_EQ(_ssm->state(), State::Source);
@@ -560,7 +561,7 @@ TEST_F(ServiceStateMachineFixture, TerminateWorksForAllStates) {
SimpleEvent hookRan, okayToContinue;
auto cleanupHook = [&hookRan] {
- log() << "Cleaning up session";
+ LOGV2(23001, "Cleaning up session");
hookRan.signal();
};
@@ -569,8 +570,10 @@ TEST_F(ServiceStateMachineFixture, TerminateWorksForAllStates) {
State waitFor = State::Created;
SimpleEvent atDesiredState;
auto waitForHook = [this, &waitFor, &atDesiredState, &okayToContinue]() {
- log() << "Checking for wakeup at " << stateToString(_ssm->state()) << ". Expecting "
- << stateToString(waitFor);
+ LOGV2(23002,
+ "Checking for wakeup at {stateToString_ssm_state}. Expecting {stateToString_waitFor}",
+ "stateToString_ssm_state"_attr = stateToString(_ssm->state()),
+ "stateToString_waitFor"_attr = stateToString(waitFor));
if (_ssm->state() == waitFor) {
atDesiredState.signal();
okayToContinue.wait();
@@ -589,7 +592,9 @@ TEST_F(ServiceStateMachineFixture, TerminateWorksForAllStates) {
// Run this same test for each state.
auto states = {State::Source, State::SourceWait, State::Process, State::SinkWait};
for (const auto testState : states) {
- log() << "Testing termination during " << stateToString(testState);
+ LOGV2(23003,
+ "Testing termination during {stateToString_testState}",
+ "stateToString_testState"_attr = stateToString(testState));
// Reset the _ssm to a fresh SSM and reset our tracking variables.
_ssm = ServiceStateMachine::create(
@@ -607,7 +612,9 @@ TEST_F(ServiceStateMachineFixture, TerminateWorksForAllStates) {
// Wait for the SSM to advance to the expected state
atDesiredState.wait();
- log() << "Terminating session at " << stateToString(_ssm->state());
+ LOGV2(23004,
+ "Terminating session at {stateToString_ssm_state}",
+ "stateToString_ssm_state"_attr = stateToString(_ssm->state()));
// Terminate the SSM
_ssm->terminate();
@@ -634,7 +641,7 @@ TEST_F(ServiceStateMachineFixture, TerminateWorksForAllStatesWithScheduleFailure
bool scheduleFailed = false;
auto cleanupHook = [&hookRan] {
- log() << "Cleaning up session";
+ LOGV2(23005, "Cleaning up session");
hookRan.signal();
};
@@ -643,8 +650,10 @@ TEST_F(ServiceStateMachineFixture, TerminateWorksForAllStatesWithScheduleFailure
State waitFor = State::Created;
SimpleEvent atDesiredState;
auto waitForHook = [this, &waitFor, &scheduleFailed, &okayToContinue, &atDesiredState]() {
- log() << "Checking for wakeup at " << stateToString(_ssm->state()) << ". Expecting "
- << stateToString(waitFor);
+ LOGV2(23006,
+ "Checking for wakeup at {stateToString_ssm_state}. Expecting {stateToString_waitFor}",
+ "stateToString_ssm_state"_attr = stateToString(_ssm->state()),
+ "stateToString_waitFor"_attr = stateToString(waitFor));
if (_ssm->state() == waitFor) {
atDesiredState.signal();
okayToContinue.wait();
@@ -660,7 +669,9 @@ TEST_F(ServiceStateMachineFixture, TerminateWorksForAllStatesWithScheduleFailure
auto states = {State::Source, State::SourceWait, State::Process, State::SinkWait};
for (const auto testState : states) {
- log() << "Testing termination during " << stateToString(testState);
+ LOGV2(23007,
+ "Testing termination during {stateToString_testState}",
+ "stateToString_testState"_attr = stateToString(testState));
_ssm = ServiceStateMachine::create(
getGlobalServiceContext(), _tl->createSession(), transport::Mode::kSynchronous);
_tl->setSSM(_ssm.get());
@@ -678,7 +689,9 @@ TEST_F(ServiceStateMachineFixture, TerminateWorksForAllStatesWithScheduleFailure
// Wait for the SSM to advance to the expected state
atDesiredState.wait();
ASSERT_EQ(_ssm->state(), testState);
- log() << "Terminating session at " << stateToString(_ssm->state());
+ LOGV2(23008,
+ "Terminating session at {stateToString_ssm_state}",
+ "stateToString_ssm_state"_attr = stateToString(_ssm->state()));
// Terminate the SSM
_ssm->terminate();
@@ -708,7 +721,9 @@ TEST_F(ServiceStateMachineFixture, SSMRunsRecursively) {
// The scheduleHook just runs the task, effectively making this a recursive executor.
int recursionDepth = 0;
_sexec->setScheduleHook([&recursionDepth](auto task) {
- log() << "running task in executor. depth: " << ++recursionDepth;
+ LOGV2(23009,
+ "running task in executor. depth: {recursionDepth}",
+ "recursionDepth"_attr = ++recursionDepth);
task();
return true;
});