Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup and reduce test duration #284

Merged
merged 2 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions go-chaos/internal/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,6 @@ func (c K8Client) CreatePodWithLabelsAndName(t *testing.T, selector *metav1.Labe
require.NoError(t, err)
}

func (c K8Client) CreateReadyPodWithLabelsAndName(t *testing.T, selector *metav1.LabelSelector, podName string) {
_, err := c.Clientset.CoreV1().Pods(c.GetCurrentNamespace()).Create(context.TODO(), &v1.Pod{
ObjectMeta: metav1.ObjectMeta{Labels: selector.MatchLabels, Name: podName},
Spec: v1.PodSpec{},
}, metav1.CreateOptions{})

require.NoError(t, err)
}

func (c K8Client) CreateBrokerPodsWithStatus(t *testing.T, selector *metav1.LabelSelector, podName string, podPhase v1.PodPhase, readyStatus bool) {
_, err := c.Clientset.CoreV1().Pods(c.GetCurrentNamespace()).Create(context.TODO(), &v1.Pod{
ObjectMeta: metav1.ObjectMeta{Labels: selector.MatchLabels, Name: podName},
Expand Down
6 changes: 3 additions & 3 deletions go-chaos/internal/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ func (c K8Client) RestartPodWithGracePeriod(podName string, gracePeriodSec *int6
}

func (c K8Client) AwaitReadiness() error {
return c.AwaitReadinessWithTimeout(5 * time.Minute)
return c.AwaitReadinessWithTimeout(5*time.Minute, 1*time.Second)
}

func (c K8Client) AwaitReadinessWithTimeout(timeout time.Duration) error {
func (c K8Client) AwaitReadinessWithTimeout(timeout time.Duration, tickTime time.Duration) error {
timedOut := time.After(timeout)
ticker := time.Tick(1 * time.Second)
ticker := time.Tick(tickTime)

// Keep checking until we're timed out
for {
Expand Down
6 changes: 3 additions & 3 deletions go-chaos/internal/pods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func Test_ShouldReturnTrueWhenBrokersAreReady(t *testing.T) {
k8Client.CreateDeploymentWithLabelsAndName(t, gatewaySelector, "gateway")

// when
err = k8Client.AwaitReadinessWithTimeout(2 * time.Second)
err = k8Client.AwaitReadinessWithTimeout(100*time.Millisecond, 1*time.Millisecond)

// then
require.NoError(t, err)
Expand All @@ -304,7 +304,7 @@ func Test_ShouldReturnErrorWhenAtleastOneBrokerIsNotReady(t *testing.T) {
k8Client.CreateDeploymentWithLabelsAndName(t, gatewaySelector, "gateway")

// when
err = k8Client.AwaitReadinessWithTimeout(2 * time.Second)
err = k8Client.AwaitReadinessWithTimeout(100*time.Millisecond, 1*time.Second)

// then
require.Error(t, err)
Expand All @@ -325,7 +325,7 @@ func Test_ShouldReturnErrorWhenAtleastOneBrokerIsNotRunning(t *testing.T) {
k8Client.CreateDeploymentWithLabelsAndName(t, gatewaySelector, "gateway")

// when
err = k8Client.AwaitReadinessWithTimeout(2 * time.Second)
err = k8Client.AwaitReadinessWithTimeout(100*time.Millisecond, 1*time.Second)

// then
require.Error(t, err)
Expand Down