This test manually restarts a shard, which should not be done with the inMemory storage engine, since it doesn't persist any data from before the restart. The test only runs one command after the restart, which isn't wrapped in an assert.commandWorked, which is likely the only reason this test doesn't always fail on the inMemory variants.
The test should add the requires_persistence tag to prevent inMemory variants from running it.