diff options
author | Haley Connelly <haley.connelly@mongodb.com> | 2020-04-27 17:05:22 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-12 19:25:44 +0000 |
commit | 694b92620fe581f57ed78ca9c4c59ece4d5b9a74 (patch) | |
tree | 7b8879eefd41acccc4788d9a7f367a3f1db24bdc /src/mongo/client/sdam | |
parent | 5a14578a131325525fc92cbb1ee315ebb35add8d (diff) | |
download | mongo-694b92620fe581f57ed78ca9c4c59ece4d5b9a74.tar.gz |
SERVER-47074 Clean up log lines in mongo/client/sdam and RSM-related files
Diffstat (limited to 'src/mongo/client/sdam')
-rw-r--r-- | src/mongo/client/sdam/json_test_arg_parser.cpp | 8 | ||||
-rw-r--r-- | src/mongo/client/sdam/sdam_json_test_runner.cpp | 65 | ||||
-rw-r--r-- | src/mongo/client/sdam/server_description.cpp | 3 | ||||
-rw-r--r-- | src/mongo/client/sdam/server_selection_json_test_runner.cpp | 44 | ||||
-rw-r--r-- | src/mongo/client/sdam/topology_description.cpp | 5 | ||||
-rw-r--r-- | src/mongo/client/sdam/topology_manager.cpp | 5 | ||||
-rw-r--r-- | src/mongo/client/sdam/topology_state_machine.cpp | 48 | ||||
-rw-r--r-- | src/mongo/client/sdam/topology_state_machine.h | 2 |
8 files changed, 56 insertions, 124 deletions
diff --git a/src/mongo/client/sdam/json_test_arg_parser.cpp b/src/mongo/client/sdam/json_test_arg_parser.cpp index a7138b183ac..51f995c133a 100644 --- a/src/mongo/client/sdam/json_test_arg_parser.cpp +++ b/src/mongo/client/sdam/json_test_arg_parser.cpp @@ -86,12 +86,10 @@ ArgParser::ArgParser(int argc, char* argv[]) { } void ArgParser::LogParams() const { - LOGV2(20199, "Verbosity: {verbose}", "verbose"_attr = _verbose); - LOGV2(20200, "Source Directory: {sourceDirectory}", "sourceDirectory"_attr = _sourceDirectory); + LOGV2(20199, "Verbosity", "verbose"_attr = _verbose); + LOGV2(20200, "Source directory", "directory"_attr = _sourceDirectory); if (_testFilters.size()) { - LOGV2(20201, - "Filters: {boost_join_testFilters}", - "boost_join_testFilters"_attr = boost::join(_testFilters, ", ")); + LOGV2(20201, "Test filters", "filters"_attr = boost::join(_testFilters, ", ")); } } diff --git a/src/mongo/client/sdam/sdam_json_test_runner.cpp b/src/mongo/client/sdam/sdam_json_test_runner.cpp index 115c97c745d..21d7e5d5770 100644 --- a/src/mongo/client/sdam/sdam_json_test_runner.cpp +++ b/src/mongo/client/sdam/sdam_json_test_runner.cpp @@ -72,13 +72,6 @@ using namespace mongo::sdam; namespace mongo::sdam { -std::string emphasize(const std::string text) { - std::stringstream output; - const auto border = std::string(3, '#'); - output << border << " " << text << " " << border << std::endl; - return output.str(); -} - /** * This class is responsible for parsing and executing a single 'phase' of the json test */ @@ -120,17 +113,16 @@ public: auto descriptionStr = (response.getResponse()) ? response.getResponse()->toString() : "[ Network Error ]"; LOGV2(20202, - "Sending server description: {response_getServer} : {descriptionStr}", - "response_getServer"_attr = response.getServer(), - "descriptionStr"_attr = descriptionStr); + "Sending server description", + "server"_attr = response.getServer(), + "description"_attr = descriptionStr); topology.onServerDescription(response); } LOGV2(20203, - "TopologyDescription after Phase {phaseNum}: {topology_getTopologyDescription}", - "phaseNum"_attr = _phaseNum, - "topology_getTopologyDescription"_attr = - topology.getTopologyDescription()->toString()); + "TopologyDescription after phase", + "phaseNumber"_attr = _phaseNum, + "topologyDescription"_attr = topology.getTopologyDescription()->toString()); validateServers( &testResult, topology.getTopologyDescription(), _topologyOutcome["servers"].Obj()); @@ -465,16 +457,11 @@ public: TestCaseResult result{{}, _testFilePath, _testName}; for (const auto& testPhase : _testPhases) { - LOGV2(20204, - "{emphasize_Phase_std_to_string_testPhase_getPhaseNum}", - "emphasize_Phase_std_to_string_testPhase_getPhaseNum"_attr = - emphasize("Phase " + std::to_string(testPhase.getPhaseNum()))); + LOGV2(20204, "### Phase Number ###", "phase"_attr = testPhase.getPhaseNum()); auto phaseResult = testPhase.execute(topology); result.phaseResults.push_back(phaseResult); if (!result.Success()) { - LOGV2(20205, - "Phase {phaseResult_phaseNumber} failed.", - "phaseResult_phaseNumber"_attr = phaseResult.phaseNumber); + LOGV2(20205, "Phase failed", "phase"_attr = phaseResult.phaseNumber); break; } } @@ -489,11 +476,7 @@ public: private: void parseTest(fs::path testFilePath) { _testFilePath = testFilePath.string(); - LOGV2(20206, ""); - LOGV2(20207, - "{emphasize_Parsing_testFilePath_string}", - "emphasize_Parsing_testFilePath_string"_attr = - emphasize("Parsing " + testFilePath.string())); + LOGV2(20207, "### Parsing Test File ###", "testFilePath"_attr = testFilePath.string()); { std::ifstream testFile(_testFilePath); std::ostringstream json; @@ -556,10 +539,7 @@ public: for (auto jsonTest : testFiles) { auto testCase = JsonTestCase(jsonTest); try { - LOGV2(20208, - "{emphasize_Executing_testCase_Name}", - "emphasize_Executing_testCase_Name"_attr = - emphasize("Executing " + testCase.Name())); + LOGV2(20208, "### Executing Test Case ###", "test"_attr = testCase.Name()); results.push_back(testCase.execute()); } catch (const DBException& ex) { std::stringstream error; @@ -584,9 +564,7 @@ public: results.begin(), results.end(), [](const JsonTestCase::TestCaseResult& result) { return !result.Success(); })) { - LOGV2(20209, - "{emphasize_Failed_Test_Results}", - "emphasize_Failed_Test_Results"_attr = emphasize("Failed Test Results")); + LOGV2(20209, "### Failed Test Results ###"); } for (const auto result : results) { @@ -596,20 +574,17 @@ public: if (result.Success()) { ++numSuccess; } else { - LOGV2( - 20210, "{emphasize_testName}", "emphasize_testName"_attr = emphasize(testName)); - LOGV2(20211, "error in file: {file}", "file"_attr = file); + LOGV2(20210, "### Test Name ###", "name"_attr = testName); + LOGV2(20211, "Error in file", "file"_attr = file); ++numFailed; for (auto phaseResult : phaseResults) { - LOGV2(20212, - "Phase {phaseResult_phaseNumber}: ", - "phaseResult_phaseNumber"_attr = phaseResult.phaseNumber); + LOGV2(20212, "Phase", "phaseNumber"_attr = phaseResult.phaseNumber); if (!phaseResult.Success()) { for (auto error : phaseResult.errorDescriptions) { LOGV2(20213, - "\t{error_first}: {error_second}", - "error_first"_attr = error.first, - "error_second"_attr = error.second); + "Errors", + "errorFirst"_attr = error.first, + "errorSecond"_attr = error.second); } } } @@ -617,7 +592,7 @@ public: } } LOGV2(20215, - "{numTestCases} test cases; {numSuccess} success; {numFailed} failed.", + "Test cases summary", "numTestCases"_attr = numTestCases, "numSuccess"_attr = numSuccess, "numFailed"_attr = numFailed); @@ -657,8 +632,8 @@ private: } else { LOGV2_DEBUG(20216, 2, - "'{filePath_string}' skipped due to filter configuration.", - "filePath_string"_attr = filePath.string()); + "Test skipped due to filter configuration", + "filePath"_attr = filePath.string()); } } diff --git a/src/mongo/client/sdam/server_description.cpp b/src/mongo/client/sdam/server_description.cpp index 81ea0f7e3ed..ffdcd232e4d 100644 --- a/src/mongo/client/sdam/server_description.cpp +++ b/src/mongo/client/sdam/server_description.cpp @@ -231,7 +231,8 @@ void ServerDescription::parseTypeFromIsMaster(const BSONObj isMaster) { t = ServerType::kRSGhost; } else { LOGV2_ERROR(23931, - "unknown server type from successful ismaster reply: {isMaster}", + "Unknown server type from successful isMaster reply: {isMaster}", + "Unknown server type from successful isMaster reply", "isMaster"_attr = isMaster.toString()); t = ServerType::kUnknown; } diff --git a/src/mongo/client/sdam/server_selection_json_test_runner.cpp b/src/mongo/client/sdam/server_selection_json_test_runner.cpp index b2ce37d45a5..e4764c2db2a 100644 --- a/src/mongo/client/sdam/server_selection_json_test_runner.cpp +++ b/src/mongo/client/sdam/server_selection_json_test_runner.cpp @@ -73,13 +73,6 @@ using namespace mongo::sdam; namespace mongo::sdam { -std::string emphasize(const std::string text) { - std::stringstream output; - const auto border = std::string(3, '#'); - output << border << " " << text << " " << border << std::endl; - return output.str(); -} - std::ostream& operator<<(std::ostream& os, const std::vector<HostAndPort>& input) { for (auto const& i : input) { os << i.toString() << " "; @@ -119,8 +112,7 @@ public: ~JsonRttTestCase() = default; TestCaseResult execute() { - LOGV2( - 4333500, "{testFilePath}", "testFilePath"_attr = emphasize("Running " + _testFilePath)); + LOGV2(4333500, "### Running Test ###", "testFilePath"_attr = _testFilePath); ServerDescriptionPtr updatedServerDescription; if (_serverDescription) { @@ -141,7 +133,7 @@ public: validateNewAvgRtt(&result, updatedServerDescription); if (!result.Success()) { - LOGV2(4333501, "Test {testFilePath} failed.", "testFilePath"_attr = _testFilePath); + LOGV2(4333501, "Test failed", "testFilePath"_attr = _testFilePath); } return result; @@ -154,10 +146,7 @@ public: private: void parseTest(fs::path testFilePath) { _testFilePath = testFilePath.string(); - LOGV2(4333502, ""); - LOGV2(4333503, - "{testFilePath}", - "testFilePath"_attr = emphasize("Parsing " + testFilePath.string())); + LOGV2(4333503, "### Parsing Test ###", "testFilePath"_attr = testFilePath.string()); { std::ifstream testFile(_testFilePath); std::ostringstream json; @@ -222,8 +211,7 @@ public: ~JsonServerSelectionTestCase() = default; TestCaseResult execute() { - LOGV2( - 4333504, "{testFilePath}", "testFilePath"_attr = emphasize("Running " + _testFilePath)); + LOGV2(4333504, "### Running Test ###", "testFilePath"_attr = _testFilePath); SdamServerSelector serverSelector( sdam::ServerSelectionConfiguration::defaultConfiguration()); @@ -233,7 +221,7 @@ public: validateServersInLatencyWindow(&result, selectedServers); if (!result.Success()) { - LOGV2(4333505, "Test {testFilePath} failed.", "testFilePath"_attr = _testFilePath); + LOGV2(4333505, "Test failed", "testFilePath"_attr = _testFilePath); } return result; @@ -246,10 +234,7 @@ public: private: void parseTest(fs::path testFilePath) { _testFilePath = testFilePath.string(); - LOGV2(4333506, ""); - LOGV2(4333507, - "{testFilePath}", - "testFilePath"_attr = emphasize("Parsing " + testFilePath.string())); + LOGV2(4333507, "### Parsing Test ###", "testFilePath"_attr = testFilePath.string()); { std::ifstream testFile(_testFilePath); std::ostringstream json; @@ -400,9 +385,8 @@ public: }(); try { - LOGV2(4333508, - "{testFilePath}", - "testFilePath"_attr = emphasize("Executing " + testCase->FilePath())); + LOGV2( + 4333508, "### Executing Test ###", "testFilePath"_attr = testCase->FilePath()); results.push_back(testCase->execute()); } catch (const DBException& ex) { std::stringstream error; @@ -425,9 +409,7 @@ public: results.begin(), results.end(), [](const JsonTestCase::TestCaseResult& result) { return !result.Success(); })) { - LOGV2(4333509, - "{Failed_Test_Results}", - "Failed_Test_Results"_attr = emphasize("Failed Test Results")); + LOGV2(4333509, "### Failed Test Results ###"); } for (const auto result : results) { @@ -435,14 +417,12 @@ public: if (result.Success()) { ++numSuccess; } else { - LOGV2(4333510, "{testFilePath}", "testFilePath"_attr = emphasize(file)); - LOGV2(4333511, "error in file: {file}", "file"_attr = file); + LOGV2(4333510, "### Failed Test File ###", "testFilePath"_attr = file); ++numFailed; - LOGV2(4333512, ""); } } LOGV2(4333513, - "{numTestCases} test cases; {numSuccess} success; {numFailed} failed.", + "Results summary", "numTestCases"_attr = numTestCases, "numSuccess"_attr = numSuccess, "numFailed"_attr = numFailed); @@ -482,7 +462,7 @@ private: } else { LOGV2_DEBUG(4333514, 2, - "'{filePath}' skipped due to filter configuration.", + "Test skipped due to filter configuration", "filePath"_attr = filePath.string()); } } diff --git a/src/mongo/client/sdam/topology_description.cpp b/src/mongo/client/sdam/topology_description.cpp index fdd8f36191d..6f688367055 100644 --- a/src/mongo/client/sdam/topology_description.cpp +++ b/src/mongo/client/sdam/topology_description.cpp @@ -111,11 +111,6 @@ const boost::optional<ServerDescriptionPtr> TopologyDescription::findServerByAdd boost::optional<ServerDescriptionPtr> TopologyDescription::installServerDescription( const ServerDescriptionPtr& newServerDescription) { - LOGV2_DEBUG(4333202, - 2, - "install server description {description}", - "description"_attr = newServerDescription->toString()); - boost::optional<ServerDescriptionPtr> previousDescription; if (getType() == TopologyType::kSingle) { // For Single, there is always one ServerDescription in TopologyDescription.servers; diff --git a/src/mongo/client/sdam/topology_manager.cpp b/src/mongo/client/sdam/topology_manager.cpp index 28070ef17e5..1807e9d1f0c 100644 --- a/src/mongo/client/sdam/topology_manager.cpp +++ b/src/mongo/client/sdam/topology_manager.cpp @@ -92,6 +92,8 @@ bool TopologyManager::onServerDescription(const IsMasterOutcome& isMasterOutcome 23930, "Ignoring this isMaster response because our topologyVersion: {lastTopologyVersion} is " "fresher than the provided topologyVersion: {newTopologyVersion}", + "Ignoring this isMaster response because our last topologyVersion is fresher than the " + "new topologyVersion provided", "lastTopologyVersion"_attr = lastTopologyVersion->toBSON(), "newTopologyVersion"_attr = newTopologyVersion->toBSON()); return false; @@ -148,7 +150,8 @@ void TopologyManager::onServerRTTUpdated(HostAndPort hostAndPort, IsMasterRTT rt // otherwise, the server was removed from the topology. Nothing to do. LOGV2(4333201, "Not updating RTT. Server {server} does not exist in {replicaSet}", - "host"_attr = hostAndPort, + "Not updating RTT. The server does not exist in the replica set", + "server"_attr = hostAndPort, "replicaSet"_attr = getTopologyDescription()->getSetName()); } diff --git a/src/mongo/client/sdam/topology_state_machine.cpp b/src/mongo/client/sdam/topology_state_machine.cpp index faa3cea1368..bce0c3717ae 100644 --- a/src/mongo/client/sdam/topology_state_machine.cpp +++ b/src/mongo/client/sdam/topology_state_machine.cpp @@ -35,6 +35,10 @@ #include "mongo/logv2/log.h" namespace mongo::sdam { +namespace { +static constexpr auto kLogLevel = 2; +} // namespace + TopologyStateMachine::TopologyStateMachine(const SdamConfiguration& config) : _config(config) { initTransitionTable(); } @@ -147,11 +151,12 @@ void mongo::sdam::TopologyStateMachine::initTransitionTable() { void TopologyStateMachine::onServerDescription(TopologyDescription& topologyDescription, const ServerDescriptionPtr& serverDescription) { if (!topologyDescription.containsServerAddress(serverDescription->getAddress())) { - LOGV2(20219, - "{kLogPrefix}ignoring ismaster reply from server that is not in the topology: " - "{serverDescription_getAddress}", - "kLogPrefix"_attr = kLogPrefix, - "serverDescription_getAddress"_attr = serverDescription->getAddress()); + LOGV2_DEBUG(20219, + kLogLevel, + "Ignoring isMaster reply from server that is not in the topology: " + "{serverAddress}", + "Ignoring isMaster reply from server that is not in the topology", + "serverAddress"_attr = serverDescription->getAddress()); return; } @@ -365,59 +370,36 @@ void TopologyStateMachine::setTopologyTypeAndUpdateRSWithoutPrimary( void TopologyStateMachine::removeServerDescription(TopologyDescription& topologyDescription, const HostAndPort serverAddress) { topologyDescription.removeServerDescription(serverAddress); - LOGV2(20220, - "{kLogPrefix}server '{serverAddress}' was removed from the topology.", - "kLogPrefix"_attr = kLogPrefix, - "serverAddress"_attr = serverAddress); + LOGV2_DEBUG(20220, + kLogLevel, + "Server '{serverAddress}' was removed from the topology", + "Server was removed from the topology", + "serverAddress"_attr = serverAddress); } void TopologyStateMachine::modifyTopologyType(TopologyDescription& topologyDescription, TopologyType topologyType) { topologyDescription._type = topologyType; - LOGV2(20221, - "{kLogPrefix}the topology type was set to {topologyType}", - "kLogPrefix"_attr = kLogPrefix, - "topologyType"_attr = toString(topologyType)); } void TopologyStateMachine::modifySetName(TopologyDescription& topologyDescription, const boost::optional<std::string>& setName) { topologyDescription._setName = setName; - LOGV2(20222, - "{kLogPrefix}the topology setName was set to {setName_setName_null}", - "kLogPrefix"_attr = kLogPrefix, - "setName_setName_null"_attr = ((setName) ? *setName : "[null]")); } void TopologyStateMachine::installServerDescription(TopologyDescription& topologyDescription, ServerDescriptionPtr newServerDescription, bool newServer) { topologyDescription.installServerDescription(newServerDescription); - LOGV2_DEBUG(20223, - 1, - "{kLogPrefix}{newServer_installed_new_updated_existing} server description: " - "{newServerDescription}", - "kLogPrefix"_attr = kLogPrefix, - "newServer_installed_new_updated_existing"_attr = - ((newServer) ? "installed new" : "updated existing"), - "newServerDescription"_attr = newServerDescription->toString()); } void TopologyStateMachine::modifyMaxElectionId(TopologyDescription& topologyDescription, const OID& newMaxElectionId) { topologyDescription._maxElectionId = newMaxElectionId; - LOGV2(20224, - "{kLogPrefix}topology max election id set to {newMaxElectionId}", - "kLogPrefix"_attr = kLogPrefix, - "newMaxElectionId"_attr = newMaxElectionId); } void TopologyStateMachine::modifyMaxSetVersion(TopologyDescription& topologyDescription, int& newMaxSetVersion) { topologyDescription._maxSetVersion = newMaxSetVersion; - LOGV2(20225, - "{kLogPrefix}topology max set version set to {newMaxSetVersion}", - "kLogPrefix"_attr = kLogPrefix, - "newMaxSetVersion"_attr = newMaxSetVersion); } } // namespace mongo::sdam diff --git a/src/mongo/client/sdam/topology_state_machine.h b/src/mongo/client/sdam/topology_state_machine.h index e0505806e1f..5c631123887 100644 --- a/src/mongo/client/sdam/topology_state_machine.h +++ b/src/mongo/client/sdam/topology_state_machine.h @@ -100,8 +100,6 @@ private: StateTransitionTable _stt; SdamConfiguration _config; - - static inline auto kLogPrefix = "sdam : "; }; using TopologyStateMachinePtr = std::unique_ptr<TopologyStateMachine>; } // namespace mongo::sdam |