Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! test: decreased ha replicas to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
fra98 committed Nov 13, 2024
1 parent c9d5854 commit 26c7409
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 17 deletions.
17 changes: 11 additions & 6 deletions pkg/gateway/concurrent/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package concurrent

import (
"context"
"fmt"
"net"

corev1 "k8s.io/api/core/v1"
Expand All @@ -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)
Expand All @@ -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,
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/gateway/concurrent/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
20 changes: 15 additions & 5 deletions test/e2e/cruise/network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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() {
Expand All @@ -156,15 +162,19 @@ 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 {
args.remove = true
}

// Run the tests.
Eventually(runLiqoctlNetworkTests(args), timeout, interval).Should(Succeed())
Eventually(func() error {
return runLiqoctlNetworkTests(args)
}, timeout, interval).Should(Succeed())
}
})
})
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/pipeline/infra/cluster-api/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/e2e/pipeline/infra/kind/pre-requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
9 changes: 9 additions & 0 deletions test/e2e/pipeline/infra/kind/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 26c7409

Please sign in to comment.