jstests/serverless/libs/basic_serverless_test.js
/*
     * Add recipient nodes to the current donor set.
     * @param {numNodes} indicates the number of recipient nodes to be added.
     */
Add recipient nodes to the current donor set.
@param {numNodes} indicates the number of recipient nodes to be added.
Add recipient nodes to the current donor set . @param { numNodes } indicates the number of recipient nodes to be added .
addRecipientNodes(numNodes) {
        numNodes = numNodes || 3;  
        if (this.recipientNodes.lengh > 0) {
            throw new Error("Recipient nodes may only be added once");
        }
        jsTestLog(`Adding ${numNodes} non-voting recipient nodes to donor`);
        const donor = this.donor;
        for (let i = 0; i < numNodes; ++i) {
            this.recipientNodes.push(donor.add());
        }
        const primary = donor.getPrimary();
        const admin = primary.getDB('admin');
        const config = donor.getReplSetConfigFromNode();
        config.version++;
        this.recipientNodes.forEach(node => {
            config.members.push({
                host: node.host,
                votes: 0,
                priority: 0,
                tags: {[this.recipientTagName]: ObjectId().valueOf()}
            });
        });
        config.members = config.members.map((member, idx) => {
            member._id = idx;
            return member;
        });
        assert.commandWorked(admin.runCommand({replSetReconfig: config}));
        this.recipientNodes.forEach(node => donor.waitForState(node, ReplSetTest.State.SECONDARY));
    }
addRecipientNodes ( numNodes ) { numNodes = numNodes || 3 ; if ( this . recipientNodes . lengh > 0 ) { throw new Error ( "Recipient nodes may only be added once" ) ; } jsTestLog ( ` ${ numNodes } ` ) ; const donor = this . donor ; for ( let i = 0 ; i < numNodes ; ++ i ) { this . recipientNodes . push ( donor . add ( ) ) ; } const primary = donor . getPrimary ( ) ; const admin = primary . getDB ( 'admin' ) ; const config = donor . getReplSetConfigFromNode ( ) ; config . version ++ ; this . recipientNodes . forEach ( node => { config . members . push ( { host : node . host , votes : 0 , priority : 0 , tags : { [ this . recipientTagName ] : ObjectId ( ) . valueOf ( ) } } ) ; } ) ; config . members = config . members . map ( ( member , idx ) => { member . _id = idx ; return member ; } ) ; assert . commandWorked ( admin . runCommand ( { replSetReconfig : config } ) ) ; this . recipientNodes . forEach ( node => donor . waitForState ( node , ReplSetTest . State . SECONDARY ) ) ; }
Add recipient nodes to the current donor set.
Add recipient nodes to the current donor set .
// default to three nodes // ensure recipient nodes are added as non-voting members // reindex all members from 0