-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore e2e test failures on cluster health retrieval (#1805)
* Restore e2e test failures on cluster health retrieval We disabled error reporting (leading to e2e test failure) when we cannot retrieve the health. A "valid case" to not being able to retrieve the cluster health is when we're restarting/removing the master node of a v6 cluster. During leader election, the cluster is temporarily unavailable to such requests. This is way better with v7 clusters and zen2, for which unavailability is made a lot smaller. Let's restore that check, but make sure we ignore any errors resulting from a v6 cluster upgrade. * Allow http errors during mutations Only if they don't happen contiguously for more than 60sec, which should help allowing unavailability during leader election, but not if that lasts too long. * Add missing license header * Make linter happy
- Loading branch information
Showing
2 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package elasticsearch | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_clusterUnavailability(t *testing.T) { | ||
// set an arbitrary large threshold we'll not reach | ||
cu := clusterUnavailability{threshold: 1 * time.Hour} | ||
|
||
// no threshold should be exceeded while the cluster is available | ||
require.False(t, cu.hasExceededThreshold()) | ||
cu.markAvailable() | ||
require.True(t, cu.start.IsZero()) | ||
require.False(t, cu.hasExceededThreshold()) | ||
|
||
// mark the cluster as available, we're still below the threshold | ||
cu.markUnavailable() | ||
require.False(t, cu.start.IsZero()) | ||
require.False(t, cu.hasExceededThreshold()) | ||
|
||
// marking as unavailable again should not change the start time | ||
initialStartTime := cu.start | ||
cu.markUnavailable() | ||
require.Equal(t, initialStartTime, cu.start) | ||
require.False(t, cu.hasExceededThreshold()) | ||
|
||
// marking as available again should reset the start time | ||
cu.markAvailable() | ||
require.True(t, cu.start.IsZero()) | ||
require.False(t, cu.hasExceededThreshold()) | ||
|
||
// simulate a lower threshold we should have exceeded | ||
cu.markUnavailable() | ||
cu.threshold = time.Duration(0) | ||
require.True(t, cu.hasExceededThreshold()) | ||
} |