summaryrefslogtreecommitdiff
path: root/jstests/replsets/replsetinitiate_works_with_keyfile_profile_verbose_options.js
blob: ca6fd8e6d599e9f7de032033a0d047734f119fa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
 * Tests that a standalone node started with --verbose, --profile, and --keyfile can
 * successfully run the replSetInitiate command.
 */
(function() {
let options = {verbose: 1, profile: 1, keyFile: 'jstests/libs/key1', replSet: "rs0", port: 27017};

const conn = MongoRunner.runMongod(options);

assert.commandWorked(conn.getDB('admin').runCommand({
    replSetInitiate: {
        "_id": "rs0",
        "members": [{"_id": 0, "host": "127.0.0.1:27017"}],
        writeConcernMajorityJournalDefault: false
    }
}));

assert.soon(function() {
    const res = assert.commandWorked(conn.adminCommand({hello: 1}));
    return res.isWritablePrimary;
});

const admin = conn.getDB('admin');
admin.createUser({user: 'foo', pwd: 'bar', roles: jsTest.adminUserRoles});
assert(admin.auth({user: 'foo', pwd: 'bar'}));
assert.commandWorked(admin.test.insert({x: 1}));
MongoRunner.stopMongod(conn);
})();