mirror of https://github.com/mongodb/mongo
26 lines
824 B
JavaScript
26 lines
824 B
JavaScript
import {ShardingTest} from "jstests/libs/shardingtest.js";
|
|
|
|
let s = new ShardingTest({shards: 2});
|
|
|
|
assert.eq(2, s.config.shards.count(), "server count wrong");
|
|
|
|
let test1 = s.getDB("test1").foo;
|
|
assert.commandWorked(test1.insert({a: 1}));
|
|
assert.commandWorked(test1.insert({a: 2}));
|
|
assert.commandWorked(test1.insert({a: 3}));
|
|
assert.eq(3, test1.count());
|
|
|
|
assert.commandFailed(s.s0.adminCommand({addshard: "sdd$%", maxTimeMS: 60000}), "Bad hostname");
|
|
|
|
let portWithoutHostRunning = allocatePort();
|
|
assert.commandFailed(
|
|
s.s0.adminCommand({addshard: "127.0.0.1:" + portWithoutHostRunning, maxTimeMS: 60000}),
|
|
"Host which is not up",
|
|
);
|
|
assert.commandFailed(
|
|
s.s0.adminCommand({addshard: "10.0.0.1:" + portWithoutHostRunning, maxTimeMS: 60000}),
|
|
"Allowed shard in IP when config is localhost",
|
|
);
|
|
|
|
s.stop();
|