Skip to content
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
13 changes: 6 additions & 7 deletions tests/e2e/ambient/ambient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

const (
Expand Down Expand Up @@ -256,19 +257,17 @@ spec:
Expect(k.Label("namespace", common.HttpbinNamespace, "istio.io/dataplane-mode", "ambient")).To(Succeed(), "Error labeling httpbin namespace")

// Deploy the test pods.
Expect(k.WithNamespace(common.SleepNamespace).Apply(common.GetSampleYAML(version, "sleep"))).To(Succeed(), "error deploying sleep pod")
Expect(k.WithNamespace(common.HttpbinNamespace).Apply(common.GetSampleYAML(version, "httpbin"))).To(Succeed(), "error deploying httpbin pod")
Expect(k.WithNamespace(common.SleepNamespace).Apply(common.GetSampleYAML(version, "sleep"))).To(Succeed(), "Error deploying sleep pod")
Expect(k.WithNamespace(common.HttpbinNamespace).Apply(common.GetSampleYAML(version, "httpbin"))).To(Succeed(), "Error deploying httpbin pod")

Success("Ambient validation pods deployed")
})

sleepPod := &corev1.PodList{}
It("updates the status of pods to Running", func(ctx SpecContext) {
sleepPod, err = common.CheckPodsReady(ctx, cl, common.SleepNamespace)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("Error checking status of sleep pod: %v", err))

_, err = common.CheckPodsReady(ctx, cl, common.HttpbinNamespace)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("Error checking status of httpbin pod: %v", err))
Eventually(common.CheckPodsReady).WithArguments(ctx, cl, common.SleepNamespace).Should(Succeed(), "Error checking status of sleep pod")
Eventually(common.CheckPodsReady).WithArguments(ctx, cl, common.HttpbinNamespace).Should(Succeed(), "Error checking status of httpbin pod")
Expect(cl.List(ctx, sleepPod, client.InNamespace(common.SleepNamespace))).To(Succeed(), "Error getting the pod in sleep namespace")

Success("Pods are ready")
})
Expand Down
15 changes: 2 additions & 13 deletions tests/e2e/controlplane/control_plane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,10 @@ spec:
})

samplePods := &corev1.PodList{}

It("updates the pods status to Running", func(ctx SpecContext) {
Eventually(func() bool {
// Wait until the sample pod exists. Is wraped inside a function to avoid failure on the first iteration
Expect(cl.List(ctx, samplePods, client.InNamespace(sampleNamespace))).To(Succeed())
return len(samplePods.Items) > 0
}).Should(BeTrue(), "No sample pods found")

Expect(cl.List(ctx, samplePods, client.InNamespace(sampleNamespace))).To(Succeed())
Expect(samplePods.Items).ToNot(BeEmpty(), "No pods found in sample namespace")
Eventually(common.CheckPodsReady).WithArguments(ctx, cl, sampleNamespace).Should(Succeed(), "Error checking status of sample pods")
Expect(cl.List(ctx, samplePods, client.InNamespace(sampleNamespace))).To(Succeed(), "Error getting the pods in sample namespace")

for _, pod := range samplePods.Items {
Eventually(common.GetObject).WithArguments(ctx, cl, kube.Key(pod.Name, sampleNamespace), &corev1.Pod{}).
Should(HaveConditionStatus(corev1.PodReady, metav1.ConditionTrue), "Pod is not Ready")
}
Success("sample pods are ready")
})

Expand Down
11 changes: 2 additions & 9 deletions tests/e2e/controlplane/control_plane_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,9 @@ spec:
Success("sample deployed")

samplePods := &corev1.PodList{}
Eventually(common.CheckPodsReady).WithArguments(ctx, cl, sampleNamespace).Should(Succeed(), "Error checking status of sample pods")
Expect(cl.List(ctx, samplePods, client.InNamespace(sampleNamespace))).To(Succeed(), "Error getting the pods in sample namespace")

Eventually(func() bool {
Expect(cl.List(ctx, samplePods, client.InNamespace(sampleNamespace))).To(Succeed())
return len(samplePods.Items) > 0
}).Should(BeTrue(), "No sample pods found")

for _, pod := range samplePods.Items {
Eventually(common.GetObject).WithArguments(ctx, cl, kube.Key(pod.Name, sampleNamespace), &corev1.Pod{}).
Should(HaveConditionStatus(corev1.PodReady, metav1.ConditionTrue), "Pod is not Ready")
}
Success("sample pods are ready")

for _, pod := range samplePods.Items {
Expand Down
17 changes: 6 additions & 11 deletions tests/e2e/dualstack/dualstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

const (
Expand Down Expand Up @@ -207,17 +208,11 @@ spec:

sleepPod := &corev1.PodList{}
It("updates the status of pods to Running", func(ctx SpecContext) {
_, err = common.CheckPodsReady(ctx, cl, DualStackNamespace)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("Error checking status of dual-stack pods: %v", err))

_, err = common.CheckPodsReady(ctx, cl, IPv4Namespace)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("Error checking status of ipv4 pods: %v", err))

_, err = common.CheckPodsReady(ctx, cl, IPv6Namespace)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("Error checking status of ipv6 pods: %v", err))

sleepPod, err = common.CheckPodsReady(ctx, cl, SleepNamespace)
Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("Error checking status of sleep pods: %v", err))
Eventually(common.CheckPodsReady).WithArguments(ctx, cl, DualStackNamespace).Should(Succeed(), "Error checking status of dual-stack pod")
Eventually(common.CheckPodsReady).WithArguments(ctx, cl, IPv4Namespace).Should(Succeed(), "Error checking status of ipv4 pod")
Eventually(common.CheckPodsReady).WithArguments(ctx, cl, IPv6Namespace).Should(Succeed(), "Error checking status of ipv6 pod")
Eventually(common.CheckPodsReady).WithArguments(ctx, cl, SleepNamespace).Should(Succeed(), "Error checking status of sleep pod")
Expect(cl.List(ctx, sleepPod, client.InNamespace(SleepNamespace))).To(Succeed(), "Error getting the pod in sleep namespace")

Success("Pods are ready")
})
Expand Down
32 changes: 19 additions & 13 deletions tests/e2e/util/common/e2e_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@ import (
"github.com/Masterminds/semver/v3"
"github.com/istio-ecosystem/sail-operator/pkg/env"
"github.com/istio-ecosystem/sail-operator/pkg/istioversion"
"github.com/istio-ecosystem/sail-operator/pkg/kube"
"github.com/istio-ecosystem/sail-operator/pkg/test/project"
. "github.com/istio-ecosystem/sail-operator/tests/e2e/util/gomega"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/helm"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/istioctl"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/kubectl"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

"istio.io/istio/pkg/ptr"
Expand Down Expand Up @@ -291,22 +288,31 @@ func GetVersionFromIstiod() (*semver.Version, error) {
return nil, fmt.Errorf("error getting version from istiod: version not found in output: %s", output)
}

func CheckPodsReady(ctx SpecContext, cl client.Client, namespace string) (*corev1.PodList, error) {
podList := &corev1.PodList{}

err := cl.List(ctx, podList, client.InNamespace(namespace))
if err != nil {
return nil, fmt.Errorf("failed to list pods in %s namespace: %w", namespace, err)
func isPodReady(pod *corev1.Pod) bool {
for _, cond := range pod.Status.Conditions {
if cond.Type == corev1.PodReady && cond.Status == corev1.ConditionTrue {
return true
}
}
return false
}

Expect(podList.Items).ToNot(BeEmpty(), fmt.Sprintf("No pods found in %s namespace", namespace))
func CheckPodsReady(ctx context.Context, cl client.Client, namespace string) error {
podList := &corev1.PodList{}
if err := cl.List(ctx, podList, client.InNamespace(namespace)); err != nil {
return fmt.Errorf("Failed to list pods: %w", err)
}
if len(podList.Items) == 0 {
return fmt.Errorf("No pods found in namespace %q", namespace)
}

for _, pod := range podList.Items {
Eventually(GetObject).WithArguments(ctx, cl, kube.Key(pod.Name, namespace), &corev1.Pod{}).
Should(HaveConditionStatus(corev1.PodReady, metav1.ConditionTrue), fmt.Sprintf("%q Pod in %q namespace is not Ready", pod.Name, namespace))
if !isPodReady(&pod) {
return fmt.Errorf("pod %q in namespace %q is not ready", pod.Name, namespace)
}
}

return podList, nil
return nil
}

func InstallOperatorViaHelm(extraArgs ...string) error {
Expand Down