-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: talosctl health should not check kube-proxy when it is disabled
Fixes #3299. Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com> (cherry picked from commit 7662d03)
- Loading branch information
Showing
6 changed files
with
157 additions
and
6 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
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
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,76 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
package conditions_test | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/talos-systems/talos/pkg/conditions" | ||
) | ||
|
||
func TestPollingCondition(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("OK", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
var calls int | ||
cond := conditions.PollingCondition("Test condition", func(ctx context.Context) error { | ||
calls++ | ||
|
||
if calls < 2 { | ||
return errors.New("failed") | ||
} | ||
|
||
return nil | ||
}, time.Second, time.Millisecond) | ||
|
||
err := cond.Wait(context.Background()) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "Test condition: OK", cond.String()) | ||
assert.Equal(t, 2, calls) | ||
}) | ||
|
||
t.Run("Skip", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
var calls int | ||
cond := conditions.PollingCondition("Test condition", func(ctx context.Context) error { | ||
calls++ | ||
|
||
if calls < 2 { | ||
return errors.New("failed") | ||
} | ||
|
||
return conditions.ErrSkipAssertion | ||
}, time.Second, time.Millisecond) | ||
|
||
err := cond.Wait(context.Background()) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "Test condition: SKIP", cond.String()) | ||
assert.Equal(t, 2, calls) | ||
}) | ||
|
||
t.Run("Fatal", func(t *testing.T) { | ||
t.Parallel() | ||
|
||
var calls int | ||
cond := conditions.PollingCondition("Test condition", func(ctx context.Context) error { | ||
calls++ | ||
|
||
return errors.New("failed") | ||
}, time.Second, 750*time.Millisecond) | ||
|
||
err := cond.Wait(context.Background()) | ||
assert.Equal(t, context.DeadlineExceeded, err) | ||
assert.Equal(t, "Test condition: failed", cond.String()) | ||
assert.Equal(t, 2, calls) | ||
}) | ||
} |