Skip to content

Commit

Permalink
test: decreased ha replicas to 2 + dynamic pods counter
Browse files Browse the repository at this point in the history
  • Loading branch information
fra98 committed Nov 5, 2024
1 parent 373dc94 commit aaed7eb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/e2e/pipeline/installer/liqoctl/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion test/e2e/postinstall/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -92,8 +95,24 @@ 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 := ptr.Deref(gwDeployments.Items[0].Spec.Replicas, 1)
// Get deployment virtual-kubelet
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 := ptr.Deref(vkDeployments.Items[0].Spec.Replicas, 1)
return len(notReadyPods) == 0 &&
len(readyPods) == util.NumPodsInTenantNs(true, cluster.Role, int(gwReplicas), int(vkReplicas))
}, timeout, interval).Should(BeTrue())
}
},
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/testutils/util/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit aaed7eb

Please sign in to comment.