Skip to content

Commit

Permalink
increase kubectl timeout to 90s
Browse files Browse the repository at this point in the history
- add variable for configuring timeout
- timeout was triggering locally on intel mac machine, so this timeout should cover our devs lowest performing machines
  • Loading branch information
wilkermichael committed Jul 27, 2023
1 parent dac937f commit cd29019
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions acceptance/framework/k8s/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package k8s

import (
"fmt"
"strings"
"testing"
"time"
Expand All @@ -16,6 +17,10 @@ import (
"github.com/stretchr/testify/require"
)

const (
kubectlTimeout = "--timeout=90s"
)

// kubeAPIConnectErrs are errors that sometimes occur when talking to the
// Kubernetes API related to connection issues.
var kubeAPIConnectErrs = []string{
Expand Down Expand Up @@ -97,7 +102,7 @@ func KubectlApplyK(t *testing.T, options *k8s.KubectlOptions, kustomizeDir strin
// deletes it from the cluster by running 'kubectl delete -f'.
// If there's an error deleting the file, fail the test.
func KubectlDelete(t *testing.T, options *k8s.KubectlOptions, configPath string) {
_, err := RunKubectlAndGetOutputE(t, options, "delete", "--timeout=60s", "-f", configPath)
_, err := RunKubectlAndGetOutputE(t, options, "delete", kubectlTimeout, "-f", configPath)
require.NoError(t, err)
}

Expand All @@ -107,7 +112,13 @@ func KubectlDelete(t *testing.T, options *k8s.KubectlOptions, configPath string)
func KubectlDeleteK(t *testing.T, options *k8s.KubectlOptions, kustomizeDir string) {
// Ignore not found errors because Kubernetes automatically cleans up the kube secrets that we deployed
// referencing the ServiceAccount when it is deleted.
_, err := RunKubectlAndGetOutputE(t, options, "delete", "--timeout=60s", "--ignore-not-found", "-k", kustomizeDir)
_, err := RunKubectlAndGetOutputE(t, options, "delete", kubectlTimeout, "--ignore-not-found", "-k", kustomizeDir)
require.NoError(t, err)
}

// KubectlScale takes a deployment and scales it to the provided number of replicas.
func KubectlScale(t *testing.T, options *k8s.KubectlOptions, deployment string, replicas int) {
_, err := RunKubectlAndGetOutputE(t, options, "scale", kubectlTimeout, fmt.Sprintf("--replicas=%d", replicas), deployment)
require.NoError(t, err)
}

Expand Down

0 comments on commit cd29019

Please sign in to comment.