diff --git a/test/e2e/pipeline/installer/liqoctl/setup.sh b/test/e2e/pipeline/installer/liqoctl/setup.sh index f47ddd4a18..e8fcb368b8 100755 --- a/test/e2e/pipeline/installer/liqoctl/setup.sh +++ b/test/e2e/pipeline/installer/liqoctl/setup.sh @@ -63,7 +63,7 @@ LIQO_VERSION="${LIQO_VERSION:-$(git rev-parse HEAD)}" export SERVICE_CIDR=10.100.0.0/16 export POD_CIDR=10.200.0.0/16 export POD_CIDR_OVERLAPPING=${POD_CIDR_OVERLAPPING:-"false"} -export HA_REPLICAS=3 +export HA_REPLICAS=2 for i in $(seq 1 "${CLUSTER_NUMBER}"); do diff --git a/test/e2e/postinstall/basic_test.go b/test/e2e/postinstall/basic_test.go index acbdbb8f15..0c551cceb6 100644 --- a/test/e2e/postinstall/basic_test.go +++ b/test/e2e/postinstall/basic_test.go @@ -26,9 +26,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/klog/v2" + "k8s.io/utils/ptr" "github.com/liqotech/liqo/pkg/consts" + gwconsts "github.com/liqotech/liqo/pkg/gateway" fcutils "github.com/liqotech/liqo/pkg/utils/foreigncluster" + "github.com/liqotech/liqo/pkg/vkMachinery" "github.com/liqotech/liqo/test/e2e/testutils/tester" "github.com/liqotech/liqo/test/e2e/testutils/util" ) @@ -92,8 +95,28 @@ var _ = Describe("Liqo E2E", func() { for _, tenantNs := range tenantNsList.Items { Eventually(func() bool { readyPods, notReadyPods, err := util.ArePodsUp(ctx, cluster.NativeClient, tenantNs.Name) + Expect(err).ToNot(HaveOccurred()) klog.Infof("Tenant pods status: %d ready, %d not ready", len(readyPods), len(notReadyPods)) - return err == nil && len(notReadyPods) == 0 && len(readyPods) == util.NumPodsInTenantNs(true, cluster.Role) + // Get deployment gateway + gwDeployments, err := cluster.NativeClient.AppsV1().Deployments(tenantNs.Name).List(ctx, metav1.ListOptions{ + LabelSelector: fmt.Sprintf("%s=%s", gwconsts.GatewayComponentKey, gwconsts.GatewayComponentGateway), + }) + Expect(err).ToNot(HaveOccurred()) + Expect(gwDeployments.Items).To(HaveLen(1)) + gwReplicas := int(ptr.Deref(gwDeployments.Items[0].Spec.Replicas, 1)) + + // Get deployment virtual-kubelet if role is consumer + vkReplicas := 0 + if fcutils.IsConsumer(cluster.Role) { + vkDeployments, err := cluster.NativeClient.AppsV1().Deployments(tenantNs.Name).List(ctx, metav1.ListOptions{ + LabelSelector: labels.SelectorFromSet(vkMachinery.KubeletBaseLabels).String(), + }) + Expect(err).ToNot(HaveOccurred()) + Expect(vkDeployments.Items).To(HaveLen(1)) + vkReplicas = int(ptr.Deref(vkDeployments.Items[0].Spec.Replicas, 1)) + } + return len(notReadyPods) == 0 && + len(readyPods) == util.NumPodsInTenantNs(true, cluster.Role, gwReplicas, vkReplicas) }, timeout, interval).Should(BeTrue()) } }, diff --git a/test/e2e/testutils/util/pod.go b/test/e2e/testutils/util/pod.go index 0c700511b9..b08bb7371b 100644 --- a/test/e2e/testutils/util/pod.go +++ b/test/e2e/testutils/util/pod.go @@ -79,15 +79,15 @@ func ArePodsUp(ctx context.Context, clientset kubernetes.Interface, namespace st } // NumPodsInTenantNs returns the number of pods that should be present in a tenant namespace. -func NumPodsInTenantNs(networkingEnabled bool, role liqov1beta1.RoleType) int { +func NumPodsInTenantNs(networkingEnabled bool, role liqov1beta1.RoleType, gwReplicas, vkReplicas int) int { count := 0 // If the network is enabled, it should have the gateway pod. if networkingEnabled { - count += 3 + count += gwReplicas } // If the cluster is a consumer, it should have the virtual-kubelet pod. if fcutils.IsConsumer(role) { - count++ + count += vkReplicas } return count }