jstests/concurrency/fsm_workload_helpers/delete_in_transaction_states.js
/**
 * Asserts only the expected documents for this thread are present in the collection.
 */
Asserts only the expected documents for this thread are present in the collection.
Asserts only the expected documents for this thread are present in the collection .
function verifyDocuments(db, collName, tid) {
    const docs = db[collName].find({tid: tid}).toArray();
    assertWhenOwnColl.eq(expectedDocuments[collName].length, docs.length, () => {
        return 'unexpected number of documents for ' + db[collName] + ', docs: ' + tojson(docs) +
            ', expected docs: ' + tojson(expectedDocuments[collName]);
    });
    const expectedDocIds = new Set(expectedDocuments[collName].map(doc => doc._id));
    docs.forEach(doc => {
        assertWhenOwnColl(expectedDocIds.has(doc._id), () => {
            return 'expected document for collection ' + db[collName] +
                ' to be deleted, doc: ' + tojson(doc);
        });
        expectedDocIds.delete(doc._id);
    });
    assertWhenOwnColl.eq(0, expectedDocIds.size, () => {
        return 'did not find all expected documents for collection ' + db[collName] +
            ', _ids not found: ' + tojson(expectedDocIds);
    });
}
function verifyDocuments ( db , collName , tid ) { const docs = db [ collName ] . find ( { tid : tid } ) . toArray ( ) ; assertWhenOwnColl . eq ( expectedDocuments [ collName ] . length , docs . length , ( ) => { return 'unexpected number of documents for ' + db [ collName ] + ', docs: ' + tojson ( docs ) + ', expected docs: ' + tojson ( expectedDocuments [ collName ] ) ; } ) ; const expectedDocIds = new Set ( expectedDocuments [ collName ] . map ( doc => doc . _id ) ) ; docs . forEach ( doc => { assertWhenOwnColl ( expectedDocIds . has ( doc . _id ) , ( ) => { return 'expected document for collection ' + db [ collName ] + ' to be deleted, doc: ' + tojson ( doc ) ; } ) ; expectedDocIds . delete ( doc . _id ) ; } ) ; assertWhenOwnColl . eq ( 0 , expectedDocIds . size , ( ) => { return 'did not find all expected documents for collection ' + db [ collName ] + ', _ids not found: ' + tojson ( expectedDocIds ) ; } ) ; }
Asserts only the expected documents for this thread are present in the collection.
Asserts only the expected documents for this thread are present in the collection .
// Verify only the documents we haven't tried to delete were found. // All expected document ids should have been found in the collection.