@@ -1904,23 +1904,28 @@ public void testSingleNodeDiscoveryWithQuorum() {
19041904 }
19051905 }
19061906
1907- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/89867" )
19081907 public void testSingleNodeDiscoveryStabilisesEvenWhenDisrupted () {
1909- try (
1910- Cluster cluster = new Cluster (
1911- 1 ,
1912- randomBoolean (),
1913- Settings .builder ().put (DiscoveryModule .DISCOVERY_TYPE_SETTING .getKey (), DiscoveryModule .SINGLE_NODE_DISCOVERY_TYPE ).build ()
1914- )
1915- ) {
1916-
1917- // A cluster using single-node discovery should not apply any timeouts to joining or cluster state publication. There are no
1918- // other options, so there's no point in failing and retrying from scratch no matter how badly disrupted we are and we may as
1919- // well just wait.
1908+ // A cluster using single-node discovery should not apply any timeouts to joining or cluster state publication. There are no
1909+ // other options, so there's no point in failing and retrying from scratch no matter how badly disrupted we are and we may as
1910+ // well just wait.
1911+
1912+ // larger variability is are good for checking that we don't time out, but smaller variability also tightens up the time bound
1913+ // within which we expect to converge, so use a mix of both
1914+ final long delayVariabilityMillis = randomLongBetween (DEFAULT_DELAY_VARIABILITY , TimeValue .timeValueMinutes (10 ).millis ());
1915+
1916+ Settings .Builder settings = Settings .builder ()
1917+ .put (DiscoveryModule .DISCOVERY_TYPE_SETTING .getKey (), DiscoveryModule .SINGLE_NODE_DISCOVERY_TYPE );
1918+
1919+ // If the delay variability is high, set election duration accordingly, to avoid the possible endless repetition of voting rounds.
1920+ // Note that elections could take even longer than the delay variability, but this seems to be long enough to avoid bad collisions.
1921+ if (ElectionSchedulerFactory .ELECTION_DURATION_SETTING .getDefault (Settings .EMPTY ).getMillis () < delayVariabilityMillis ) {
1922+ settings = settings .put (
1923+ ElectionSchedulerFactory .ELECTION_DURATION_SETTING .getKey (),
1924+ TimeValue .timeValueMillis (delayVariabilityMillis )
1925+ );
1926+ }
19201927
1921- // larger variability is are good for checking that we don't time out, but smaller variability also tightens up the time bound
1922- // within which we expect to converge, so use a mix of both
1923- final long delayVariabilityMillis = randomLongBetween (DEFAULT_DELAY_VARIABILITY , TimeValue .timeValueMinutes (10 ).millis ());
1928+ try (Cluster cluster = new Cluster (1 , randomBoolean (), settings .build ())) {
19241929 if (randomBoolean ()) {
19251930 cluster .runRandomly (true , false , delayVariabilityMillis );
19261931 }
0 commit comments