I'm using mongodb-memory-server for the e2e-testing on the project and want to identify potential problems with replication lag. Is there any way we can emulate a large replication delay? Maybe there is some other solution to use mongodb-memory-server and configure replication lag?
Have already tried to use secondaryDelaySecs as a configuration option for the replica instance. But it's supported and works only with hidden instances. Hidden instances shouldn't be accessible from the application, so it's not a solution for this case.
You can try db.fsyncLock(), it locks all write operations to file system and at certain time it should cause a time out on your replica set.