summaryrefslogtreecommitdiff
path: root/src/mongo/shell/shardingtest.js
diff options
context:
space:
mode:
authorKamran Khan <kamran.khan@mongodb.com>2016-03-07 16:29:55 -0500
committerKamran Khan <kamran.khan@mongodb.com>2016-03-07 16:33:09 -0500
commit63d332ff3c37b738ea7cc7fe0b203f3cece875a0 (patch)
tree1d9b8ca726bb6d80cb2c82660a49606bb22d33db /src/mongo/shell/shardingtest.js
parentc918dc295e6e5971e5f9f7c8fde5bee7e4c216b0 (diff)
downloadmongo-63d332ff3c37b738ea7cc7fe0b203f3cece875a0.tar.gz
SERVER-22969 Remove connectionURLTheSame from the global scope
connectionURLTheSame has been moved to ShardingTest's scope because it's only used from ShardingTest code.
Diffstat (limited to 'src/mongo/shell/shardingtest.js')
-rw-r--r--src/mongo/shell/shardingtest.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js
index f704308c6cf..f874b6520a7 100644
--- a/src/mongo/shell/shardingtest.js
+++ b/src/mongo/shell/shardingtest.js
@@ -165,6 +165,45 @@ var ShardingTest = function(params) {
}
}
+ function connectionURLTheSame( a , b ){
+ if ( a == b )
+ return true;
+
+ if ( ! a || ! b )
+ return false;
+
+ if( a.host ) return connectionURLTheSame( a.host, b );
+ if( b.host ) return connectionURLTheSame( a, b.host );
+
+ if( a.name ) return connectionURLTheSame( a.name, b );
+ if( b.name ) return connectionURLTheSame( a, b.name );
+
+ if( a.indexOf( "/" ) < 0 && b.indexOf( "/" ) < 0 ){
+ a = a.split( ":" );
+ b = b.split( ":" );
+
+ if( a.length != b.length ) return false;
+
+ if( a.length == 2 && a[1] != b[1] ) return false;
+
+ if( a[0] == "localhost" || a[0] == "127.0.0.1" ) a[0] = getHostName();
+ if( b[0] == "localhost" || b[0] == "127.0.0.1" ) b[0] = getHostName();
+
+ return a[0] == b[0];
+ }
+ else {
+ var a0 = a.split( "/" )[0];
+ var b0 = b.split( "/" )[0];
+ return a0 == b0;
+ }
+ }
+
+ assert( connectionURLTheSame( "foo" , "foo" ) );
+ assert( ! connectionURLTheSame( "foo" , "bar" ) );
+
+ assert( connectionURLTheSame( "foo/a,b" , "foo/b,a" ) );
+ assert( ! connectionURLTheSame( "foo/a,b" , "bar/a,b" ) );
+
// ShardingTest API
this.getRSEntry = function(setName) {