mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
kubeadm: fix flaky test TestRunRenewCommands
Signed-off-by: xin.li <xin.li@daocloud.io>
This commit is contained in:
parent
3be9a8cc73
commit
97db0caf6b
@ -23,6 +23,7 @@ import (
|
||||
"crypto"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -269,7 +270,7 @@ func TestRunRenewCommands(t *testing.T) {
|
||||
if len(test.Args) > 0 {
|
||||
args = test.Args + " " + args
|
||||
}
|
||||
err := cmdtestutil.RunSubCommand(t, renewCmds, test.command, args)
|
||||
err := cmdtestutil.RunSubCommand(t, renewCmds, test.command, io.Discard, args)
|
||||
// certs renew doesn't support positional Args
|
||||
if (err != nil) != test.expectedError {
|
||||
t.Errorf("failed to run renew commands, expected error: %t, actual error: %v", test.expectedError, err)
|
||||
|
@ -18,6 +18,7 @@ package kubeadm
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
@ -50,8 +51,9 @@ func RunCmd(command string, args ...string) (string, string, int, error) {
|
||||
}
|
||||
|
||||
// RunSubCommand is a utility function for kubeadm testing that executes a Cobra sub command
|
||||
func RunSubCommand(t *testing.T, subCmds []*cobra.Command, command string, args ...string) error {
|
||||
func RunSubCommand(t *testing.T, subCmds []*cobra.Command, command string, output io.Writer, args ...string) error {
|
||||
subCmd := getSubCommand(t, subCmds, command)
|
||||
subCmd.SetOut(output)
|
||||
subCmd.SetArgs(args)
|
||||
if err := subCmd.Execute(); err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user