tests: Fix failing test_flushing_changes_to_shadow

This test was failing when valgrind was used, because either:
* shadow was losing connection with the master server due to a timeout
  -- 10000 directories were created while connection between master
  servers was blocked and it could last much more than the default
  timeout of 60 seconds.
* default timeout in assert_eventually was too short

This commit fixes the issue by making the changes smaller (only 2000
instead of 10000 directories), adding a huge timeout on the
master<->master connection and making the default timeout for
assert_eventually bigger if valgrind is enabled. This allows us to block
the traffic a bit more than for 3 seconds, eg. for 10 seconds, to make
it more certain that master server managed to process the TERM signal
before the traffic is restored.

Change-Id: Ib473f008f66d162ef46dd6ac8bf11dc6e7ea7537