diff --git a/pkg/gateway/concurrent/gateway.go b/pkg/gateway/concurrent/gateway.go index 873e615ad6..9e834628c0 100644 --- a/pkg/gateway/concurrent/gateway.go +++ b/pkg/gateway/concurrent/gateway.go @@ -16,6 +16,7 @@ package concurrent import ( "context" + "fmt" "net" corev1 "k8s.io/api/core/v1" @@ -31,16 +32,16 @@ var _ manager.Runnable = &RunnableGateway{} type RunnableGateway struct { Client client.Client - PodName string - DeploymentName string - Namespace string + PodName string + GatewayName string + Namespace string Socket net.Listener GuestConnections ipc.GuestConnections } // NewRunnableGateway creates a new Runnable. -func NewRunnableGateway(cl client.Client, podName, deploymentName, namespace string, containerNames []string) (*RunnableGateway, error) { +func NewRunnableGateway(cl client.Client, podName, gatewayName, namespace string, containerNames []string) (*RunnableGateway, error) { guestConnections := ipc.NewGuestConnections(containerNames) socket, err := ipc.CreateListenSocket(unixSocketPath) @@ -56,7 +57,7 @@ func NewRunnableGateway(cl client.Client, podName, deploymentName, namespace str return &RunnableGateway{ Client: cl, PodName: podName, - DeploymentName: deploymentName, + GatewayName: gatewayName, Namespace: namespace, Socket: socket, GuestConnections: guestConnections, @@ -67,7 +68,7 @@ func NewRunnableGateway(cl client.Client, podName, deploymentName, namespace str func (rg *RunnableGateway) Start(ctx context.Context) error { defer rg.Close() - pods, err := ListAllGatewaysReplicas(ctx, rg.Client, rg.Namespace, rg.DeploymentName) + pods, err := ListAllGatewaysReplicas(ctx, rg.Client, rg.Namespace, rg.GatewayName) if err != nil { return err } @@ -84,6 +85,10 @@ func (rg *RunnableGateway) Start(ctx context.Context) error { } } + if activePod == nil { + return fmt.Errorf("active gateway pod not found") + } + if err := AddActiveGatewayLabel(ctx, rg.Client, client.ObjectKeyFromObject(activePod)); err != nil { return err } diff --git a/pkg/gateway/concurrent/k8s.go b/pkg/gateway/concurrent/k8s.go index 17350fb5d0..75ee108ce8 100644 --- a/pkg/gateway/concurrent/k8s.go +++ b/pkg/gateway/concurrent/k8s.go @@ -77,11 +77,11 @@ func RemoveActiveGatewayLabel(ctx context.Context, cl client.Client, key client. return nil } -// ListAllGatewaysReplicas returns the list of all the gateways replicas of the same deployment. -func ListAllGatewaysReplicas(ctx context.Context, cl client.Client, namespace, deploymentName string) ([]corev1.Pod, error) { +// ListAllGatewaysReplicas returns the list of all the gateways replicas of the same gateway. +func ListAllGatewaysReplicas(ctx context.Context, cl client.Client, namespace, gatewayName string) ([]corev1.Pod, error) { podList := &corev1.PodList{} if err := cl.List(ctx, podList, client.InNamespace(namespace), client.MatchingLabels{ - consts.K8sAppNameKey: deploymentName, + consts.K8sAppNameKey: gatewayName, }); err != nil { return nil, err } diff --git a/test/e2e/cruise/network/network_test.go b/test/e2e/cruise/network/network_test.go index 0afc3070b8..df70669559 100644 --- a/test/e2e/cruise/network/network_test.go +++ b/test/e2e/cruise/network/network_test.go @@ -126,7 +126,9 @@ var _ = Describe("Liqo E2E", func() { When("\"liqoctl test network\" runs", func() { It("should succeed both before and after gateway pods restart", func() { // Run the tests. - Eventually(runLiqoctlNetworkTests(defaultArgs), timeout, interval).Should(Succeed()) + Eventually(func() error { + return runLiqoctlNetworkTests(defaultArgs) + }, timeout, interval).Should(Succeed()) // Restart the gateway pods. for i := range testContext.Clusters { @@ -136,11 +138,15 @@ var _ = Describe("Liqo E2E", func() { // Check if there is only one active gateway pod per remote cluster. for i := range testContext.Clusters { numActiveGateway := testContext.Clusters[i].NumPeeredConsumers + testContext.Clusters[i].NumPeeredProviders - Eventually(checkUniqueActiveGatewayPod(testContext.Clusters[i].ControllerClient, numActiveGateway), timeout, interval).Should(Succeed()) + Eventually(func() error { + return checkUniqueActiveGatewayPod(testContext.Clusters[i].ControllerClient, numActiveGateway) + }, timeout, interval).Should(Succeed()) } // Run the tests again. - Eventually(runLiqoctlNetworkTests(defaultArgs), timeout, interval).Should(Succeed()) + Eventually(func() error { + return runLiqoctlNetworkTests(defaultArgs) + }, timeout, interval).Should(Succeed()) }) It("should succeed both before and after gateway pods restart (stress gateway deletion and run basic tests)", func() { @@ -156,7 +162,9 @@ var _ = Describe("Liqo E2E", func() { // Check if there is only one active gateway pod per remote cluster. for j := range testContext.Clusters { numActiveGateway := testContext.Clusters[j].NumPeeredConsumers + testContext.Clusters[j].NumPeeredProviders - Eventually(checkUniqueActiveGatewayPod(testContext.Clusters[j].ControllerClient, numActiveGateway), timeout, interval).Should(Succeed()) + Eventually(func() error { + return checkUniqueActiveGatewayPod(testContext.Clusters[i].ControllerClient, numActiveGateway) + }, timeout, interval).Should(Succeed()) } if i == stressMax-1 { @@ -164,7 +172,9 @@ var _ = Describe("Liqo E2E", func() { } // Run the tests. - Eventually(runLiqoctlNetworkTests(args), timeout, interval).Should(Succeed()) + Eventually(func() error { + return runLiqoctlNetworkTests(args) + }, timeout, interval).Should(Succeed()) } }) }) diff --git a/test/e2e/pipeline/infra/cluster-api/setup.sh b/test/e2e/pipeline/infra/cluster-api/setup.sh index 15a4f0edc3..7c84ad75f3 100755 --- a/test/e2e/pipeline/infra/cluster-api/setup.sh +++ b/test/e2e/pipeline/infra/cluster-api/setup.sh @@ -38,8 +38,8 @@ WORKDIR=$(dirname "$FILEPATH") source "$WORKDIR/../../utils.sh" # shellcheck disable=SC1091 -# shellcheck source=./cni.sh -source "$WORKDIR/cni.sh" +# shellcheck source=../cni.sh +source "$WORKDIR/../cni.sh" export K8S_VERSION=${K8S_VERSION:-"1.29.7"} K8S_VERSION=$(echo -n "$K8S_VERSION" | sed 's/v//g') # remove the leading v diff --git a/test/e2e/pipeline/infra/cluster-api/cni.sh b/test/e2e/pipeline/infra/cni.sh similarity index 100% rename from test/e2e/pipeline/infra/cluster-api/cni.sh rename to test/e2e/pipeline/infra/cni.sh diff --git a/test/e2e/pipeline/infra/kind/pre-requirements.sh b/test/e2e/pipeline/infra/kind/pre-requirements.sh index 83f49014c3..cad72e8095 100755 --- a/test/e2e/pipeline/infra/kind/pre-requirements.sh +++ b/test/e2e/pipeline/infra/kind/pre-requirements.sh @@ -47,7 +47,7 @@ install_kubectl "${OS}" "${ARCH}" "${K8S_VERSION}" install_helm "${OS}" "${ARCH}" -KIND_VERSION="v0.23.0" +KIND_VERSION="v0.24.0" echo "Downloading Kind ${KIND_VERSION}" diff --git a/test/e2e/pipeline/infra/kind/setup.sh b/test/e2e/pipeline/infra/kind/setup.sh index fbb3a3e066..ed6b63eaee 100755 --- a/test/e2e/pipeline/infra/kind/setup.sh +++ b/test/e2e/pipeline/infra/kind/setup.sh @@ -34,6 +34,10 @@ WORKDIR=$(dirname "$FILEPATH") # shellcheck source=../../utils.sh source "$WORKDIR/../../utils.sh" +# shellcheck disable=SC1091 +# shellcheck source=../cni.sh +source "$WORKDIR/../cni.sh" + KIND="${BINDIR}/kind" CLUSTER_NAME=cluster @@ -59,6 +63,11 @@ do echo "Creating cluster ${CLUSTER_NAME}${i}..." ${KIND} create cluster --name "${CLUSTER_NAME}${i}" --kubeconfig "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}" --config "${TMPDIR}/liqo-cluster-${CLUSTER_NAME}${i}.yaml" --wait 2m + # Install CNI if kindnet disabled + if [[ ${DISABLE_KINDNET} == "true" ]]; then + "install_${CNI}" "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}" + fi + # Install metrics-server install_metrics_server "${TMPDIR}/kubeconfigs/liqo_kubeconf_${i}" done