Tests that assert on the clusterTime value of the vectorClock may fail due to a race condition caused by the clusterTime bump done by the key generator.
All these tests have the following structure:
1. First, enable the key generator. Like here
2. Second, update the cluster time and keep its new value. Example here.
3. Verify that the vector clock cluster time is the same as the expected one. Example here.
The problem is that enabling the key generation spawns an asynchronous task to generate new keys if needed, which will bump the cluster time of the vector clock. If this bumping happens before the cluster time assertion, the test will fail.
To fix this, we could join the KeysCollectionManager thread and disable it once it has performed one refresh. All this should be done before step 2.