Description
TestRecovery has several tests inserting updates and deletes into a shared core. The tests are using fixed version number which can overlap and can cause issues depending on the order of the tests.
Proposing using a monotonically incrementing counter for each test and changing tests that they would allocate the used versions would ensure that later running tests would send updates with higher version only. That would prevent any unintentional reordering.
Example:
Before:
... updateJ(jsonAdd(sdoc("id", "RDBQ1_1", "_version_", "1010")), params(DISTRIB_UPDATE_PARAM, FROM_LEADER)); updateJ(jsonDelQ("id:RDBQ1_2"), params(DISTRIB_UPDATE_PARAM, FROM_LEADER, "_version_", "-1017")); // This should've arrived after the 1015th update updateJ(jsonAdd(sdoc("id", "RDBQ1_2", "_version_", "1015")), params(DISTRIB_UPDATE_PARAM, FROM_LEADER)); updateJ(jsonAdd(sdoc("id", "RDBQ1_3", "_version_", "1020")), params(DISTRIB_UPDATE_PARAM, FROM_LEADER)); ...
After:
... String insVer1 = getNextVersion(); String insVer2 = getNextVersion(); String deleteVer = getNextVersion(); String insVer3 = getNextVersion(); updateJ(jsonAdd(sdoc("id", "RDBQ1_1", "_version_",insVer1)), params(DISTRIB_UPDATE_PARAM, FROM_LEADER)); updateJ(jsonDelQ("id:RDBQ1_2"), params(DISTRIB_UPDATE_PARAM, FROM_LEADER, "_version_", "-"+deleteVer)); // This should've arrived after the 1015th update updateJ(jsonAdd(sdoc("id", "RDBQ1_2", "_version_", insVer2)), params(DISTRIB_UPDATE_PARAM, FROM_LEADER)); updateJ(jsonAdd(sdoc("id", "RDBQ1_3", "_version_", insVer3)), params(DISTRIB_UPDATE_PARAM, FROM_LEADER)); ...
It might increase readability as the generation of the versions happen in the preferred replay order.