summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Jesse Jiryu Davis <jesse@mongodb.com>2019-06-10 21:56:34 -0400
committerA. Jesse Jiryu Davis <jesse@mongodb.com>2019-06-11 08:08:44 -0400
commit3dfc6949c246c833aebca65d4e9ac41bb2cc9fd9 (patch)
treea74576f916f04b18bf75e3dd4f02fd9cafe45696
parent41bf8a1db10f682aad8b7b28a98c4f2f062931d4 (diff)
downloadmongo-3dfc6949c246c833aebca65d4e9ac41bb2cc9fd9.tar.gz
Revert "SERVER-41181 Fix sharding tests for hostname normalization"
This reverts commit 0ed0b97e6f62bba38cf4c93f5a7270569e79f24d (SERVER-41614).
-rw-r--r--jstests/aggregation/sources/collStats/shard_host_info.js10
-rw-r--r--jstests/sharding/aggregation_currentop.js12
-rw-r--r--jstests/sharding/mongos_local_explain.js2
-rw-r--r--jstests/sharding/read_pref.js4
-rw-r--r--src/mongo/util/net/socket_utils.cpp8
5 files changed, 10 insertions, 26 deletions
diff --git a/jstests/aggregation/sources/collStats/shard_host_info.js b/jstests/aggregation/sources/collStats/shard_host_info.js
index aac6413167e..34e1d8a195e 100644
--- a/jstests/aggregation/sources/collStats/shard_host_info.js
+++ b/jstests/aggregation/sources/collStats/shard_host_info.js
@@ -14,7 +14,7 @@
let testColl = testDB.test;
// getHostName() doesn't include port, db.getMongo().host is 127.0.0.1:<port>
- const hostName = (getHostName().toLowerCase() + ":" + db.getMongo().host.split(":")[1]);
+ const hostName = (getHostName() + ":" + db.getMongo().host.split(":")[1]);
// Test that the shard field is absent and the host field is present when run on mongoD.
assert.eq(testColl
@@ -41,10 +41,6 @@
assert.commandWorked(
testDB.adminCommand({shardCollection: testColl.getFullName(), key: {_id: "hashed"}}));
- const getPrimary = (rs) => {
- return rs.getPrimary().host.toLowerCase();
- };
-
// Group $collStats result by $shard and $host to confirm that both fields are present.
assert.eq(testColl
.aggregate([
@@ -54,8 +50,8 @@
])
.toArray(),
[
- {_id: {shard: st.shard0.shardName, host: getPrimary(st.rs0)}},
- {_id: {shard: st.shard1.shardName, host: getPrimary(st.rs1)}},
+ {_id: {shard: st.shard0.shardName, host: st.rs0.getPrimary().host}},
+ {_id: {shard: st.shard1.shardName, host: st.rs1.getPrimary().host}},
]);
st.stop();
diff --git a/jstests/sharding/aggregation_currentop.js b/jstests/sharding/aggregation_currentop.js
index f48a7af8fac..5e7ed32f09a 100644
--- a/jstests/sharding/aggregation_currentop.js
+++ b/jstests/sharding/aggregation_currentop.js
@@ -478,10 +478,6 @@ TestData.skipAwaitingReplicationOnShardsBeforeCheckingUUIDs = true;
assert(clusterAdminDB.logout());
assert(clusterAdminDB.auth("user_inprog", "pwd"));
- const getPrimary = (rs) => {
- return rs.getPrimary().host.toLowerCase();
- };
-
assert.eq(clusterAdminDB
.aggregate([
{$currentOp: {allUsers: true, idleConnections: true}},
@@ -490,9 +486,9 @@ TestData.skipAwaitingReplicationOnShardsBeforeCheckingUUIDs = true;
])
.toArray(),
[
- {_id: {shard: "aggregation_currentop-rs0", host: getPrimary(st.rs0)}},
- {_id: {shard: "aggregation_currentop-rs1", host: getPrimary(st.rs1)}},
- {_id: {shard: "aggregation_currentop-rs2", host: getPrimary(st.rs2)}}
+ {_id: {shard: "aggregation_currentop-rs0", host: st.rs0.getPrimary().host}},
+ {_id: {shard: "aggregation_currentop-rs1", host: st.rs1.getPrimary().host}},
+ {_id: {shard: "aggregation_currentop-rs2", host: st.rs2.getPrimary().host}}
]);
// Test that a $currentOp pipeline with {localOps:true} returns operations from the mongoS
@@ -873,7 +869,7 @@ TestData.skipAwaitingReplicationOnShardsBeforeCheckingUUIDs = true;
])
.toArray(),
[
- {_id: {host: shardConn.host.toLowerCase()}},
+ {_id: {host: shardConn.host}},
]);
// Test that attempting to 'spoof' a sharded request on non-shardsvr mongoD fails.
diff --git a/jstests/sharding/mongos_local_explain.js b/jstests/sharding/mongos_local_explain.js
index 4fd44f38150..bf9ab379e53 100644
--- a/jstests/sharding/mongos_local_explain.js
+++ b/jstests/sharding/mongos_local_explain.js
@@ -25,7 +25,7 @@
// We expect the stages to appear under the 'mongos' heading, for 'splitPipeline' to be
// null, and for the 'mongos.host' field to be the hostname:port of the mongoS itself.
assert.docEq(explainPlan.mongos.stages, expectedExplainStages);
- assert.eq(explainPlan.mongos.host.toLowerCase(), mongosConn.name.toLowerCase());
+ assert.eq(explainPlan.mongos.host, mongosConn.name);
assert.isnull(explainPlan.splitPipeline);
st.stop();
diff --git a/jstests/sharding/read_pref.js b/jstests/sharding/read_pref.js
index 1fd8e5b1185..99e662d57b1 100644
--- a/jstests/sharding/read_pref.js
+++ b/jstests/sharding/read_pref.js
@@ -58,7 +58,7 @@ TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
for (var idx = 0; idx < NODES; idx++) {
var node = replConf.members[idx];
- if (node.host.toLowerCase() == nodeToCheck.toLowerCase()) {
+ if (node.host == nodeToCheck) {
jsTest.log('node[' + node.host + '], Tag: ' + tojson(node['tags']));
jsTest.log('tagToCheck: ' + tojson(tag));
@@ -125,7 +125,7 @@ TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
var getExplainServer = function(explain) {
assert.eq("SINGLE_SHARD", explain.queryPlanner.winningPlan.stage);
var serverInfo = explain.queryPlanner.winningPlan.shards[0].serverInfo;
- return serverInfo.host.toLowerCase() + ":" + serverInfo.port.toString();
+ return serverInfo.host + ":" + serverInfo.port.toString();
};
// Read pref should work without slaveOk
diff --git a/src/mongo/util/net/socket_utils.cpp b/src/mongo/util/net/socket_utils.cpp
index 947f43a7c32..f58ff484ec7 100644
--- a/src/mongo/util/net/socket_utils.cpp
+++ b/src/mongo/util/net/socket_utils.cpp
@@ -62,8 +62,6 @@
#include "mongo/util/str.h"
#include "mongo/util/winutil.h"
-#include <string>
-
namespace mongo {
#if defined(_WIN32)
@@ -201,12 +199,6 @@ std::string getHostName() {
log() << "can't get this server's hostname " << errnoWithDescription();
return "";
}
-
- for (char* c = buf; *c; c++) {
- // See https://en.cppreference.com/w/cpp/string/byte/tolower
- *c = static_cast<char>(::tolower(static_cast<unsigned char>(*c)));
- }
-
return buf;
}