Thanks Bibin A Chundatt for the patch. Analysis is correct.
The fix will work but I do see a lot of deterministic sleeps in the test. This however becomes necessary because there is no way to drain multiple dispatchers across multiple NMs' and RM in MiniYarnCluster.
For the extra sleeps we have added to fix the test, can we have them in a loop and exit whenever the values for increased and decreased containers have reached the required number or not OR after a fixed number of times, whichever is earlier.
This would mean that test would not have sleep extra time if not required. Pls note this test passes more than it fails.