Skip to content

Commit 43bf277

Browse files
committed
feat(e2e): add elasticsearch multi-version test
Signed-off-by: Bence Csati <bence.csati@axoflow.com>
1 parent 495c872 commit 43bf277

File tree

2 files changed

+811
-0
lines changed

2 files changed

+811
-0
lines changed

e2e/common/cond/conditions.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/cisco-open/operator-tools/pkg/utils"
2222
"github.com/kube-logging/logging-operator/e2e/common"
2323
"github.com/kube-logging/logging-operator/pkg/sdk/logging/api/v1beta1"
24+
appsv1 "k8s.io/api/apps/v1"
2425
corev1 "k8s.io/api/core/v1"
2526
apierrors "k8s.io/apimachinery/pkg/api/errors"
2627
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -191,3 +192,50 @@ func CheckExcessSyslogNGStatus(t *testing.T, c *common.Cluster, ctx *context.Con
191192

192193
return true
193194
}
195+
196+
// DeploymentAvailable returns a condition function that checks if a deployment
197+
// is available with all replicas ready.
198+
func DeploymentAvailable(t *testing.T, c client.Client, ctx *context.Context, namespace, name string) func() bool {
199+
return func() bool {
200+
deployment := &appsv1.Deployment{}
201+
if err := c.Get(*ctx, client.ObjectKey{
202+
Name: name,
203+
Namespace: namespace,
204+
}, deployment); err != nil {
205+
t.Logf("Failed to get deployment %s/%s: %v", namespace, name, err)
206+
return false
207+
}
208+
209+
if deployment.Spec.Replicas == nil {
210+
return false
211+
}
212+
desiredReplicas := *deployment.Spec.Replicas
213+
214+
if deployment.Status.ReadyReplicas != desiredReplicas {
215+
t.Logf("Deployment %s/%s: %d/%d replicas ready",
216+
namespace, name, deployment.Status.ReadyReplicas, desiredReplicas)
217+
return false
218+
}
219+
220+
if deployment.Status.AvailableReplicas != desiredReplicas {
221+
t.Logf("Deployment %s/%s: %d/%d replicas available",
222+
namespace, name, deployment.Status.AvailableReplicas, desiredReplicas)
223+
return false
224+
}
225+
226+
for _, condition := range deployment.Status.Conditions {
227+
if condition.Type == appsv1.DeploymentAvailable {
228+
if condition.Status == corev1.ConditionTrue {
229+
t.Logf("Deployment %s/%s is available", namespace, name)
230+
return true
231+
}
232+
t.Logf("Deployment %s/%s Available condition is %s: %s",
233+
namespace, name, condition.Status, condition.Message)
234+
return false
235+
}
236+
}
237+
238+
t.Logf("Deployment %s/%s has no Available condition", namespace, name)
239+
return false
240+
}
241+
}

0 commit comments

Comments
 (0)