In migration_id_index.js, we create an empty collection and then attempt to migrate it from shard 0 to shard 1. We then verify the _id index is built on both shard1 primary and secondary.
When building an index, the replica set primary will wait until all voting members have successfully built the index before committing it (two-phase index build). However, for empty collections, we have an optimization where we don't wait for the _id index to be built. Instead, we rely on the createIndex command to be propagated via the oplog.
As a result, in the test, we don't wait for the index to be built on the secondary node before we attempt to verify it exists (even with majority write concern). We should simply insert a document into the collection at the beginning of the test, so that the index build is two-phase.