Skip to content

Commit

Permalink
test: fix thanos TLS test
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzigold committed Oct 23, 2024
1 parent 5e522d7 commit 5a3a41c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
27 changes: 27 additions & 0 deletions test/e2e/framework/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,33 @@ func (f *Framework) AssertDeploymentReady(name, namespace string, fns ...OptionF
}
}

// AssertDeploymentReadyAndStable asserts that a deployment has the desired number of pods running for 2 consecutive polls 5 seconds appart
func (f *Framework) AssertDeploymentReadyAndStable(name, namespace string, fns ...OptionFn) func(t *testing.T) {
option := AssertOption{
PollInterval: 5 * time.Second,
WaitTimeout: DefaultTestTimeout,
}
for _, fn := range fns {
fn(&option)
}
return func(t *testing.T) {
key := types.NamespacedName{Name: name, Namespace: namespace}
if err := wait.PollUntilContextTimeout(context.Background(), option.PollInterval, option.WaitTimeout, true, func(ctx context.Context) (bool, error) {
deployment := &appsv1.Deployment{}
err := f.K8sClient.Get(context.Background(), key, deployment)
if err == nil && deployment.Status.ReadyReplicas == *deployment.Spec.Replicas {
time.Sleep(5 * time.Second)
err := f.K8sClient.Get(context.Background(), key, deployment)
return err == nil && deployment.Status.ReadyReplicas == *deployment.Spec.Replicas, nil
} else {
return false, nil
}
}); err != nil {
t.Fatal(err)
}
}
}

func (f *Framework) GetResourceWithRetry(t *testing.T, name, namespace string, obj client.Object) {
option := AssertOption{
PollInterval: 5 * time.Second,
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/thanos_querier_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ func singleStackWithSidecarTLS(t *testing.T) {
thanosService := corev1.Service{}
f.GetResourceWithRetry(t, querierName, tq.Namespace, &thanosService)

f.AssertDeploymentReady(querierName, tq.Namespace, framework.WithTimeout(5*time.Minute))(t)
f.AssertDeploymentReadyAndStable(querierName, tq.Namespace, framework.WithTimeout(5*time.Minute))(t)

// Assert prometheus instance can be queried
stopChan := make(chan struct{})
defer close(stopChan)
Expand Down

0 comments on commit 5a3a41c

Please sign in to comment.