Skip to content

Commit

Permalink
E2E: add frr-k8s-external deployment entry
Browse files Browse the repository at this point in the history
We add an entry for frr-k8s-external bgp mode,
which should be ran with the namespace where frr-k8s is
already deployed. We skip it in CI until we put a
setup that deploys frr-k8s before running the tests.

Signed-off-by: Ori Braunshtein <obraunsh@redhat.com>
  • Loading branch information
oribon committed Jan 22, 2025
1 parent dedfed2 commit 64a6761
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: |
export KUBECONFIG=${HOME}/.kube/config
make test-validation
SKIP="frr-k8s" make test-e2e
SKIP="FRR-K8s-external" make test-e2e
- name: Archive E2E Tests logs
if: ${{ failure() }}
Expand Down
25 changes: 15 additions & 10 deletions test/e2e/functional/tests/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
UseMetallbResourcesFromFile = false
OperatorNameSpace = consts.DefaultOperatorNameSpace
isOpenshift = false
frrk8sNamespace = OperatorNameSpace
)

func init() {
Expand All @@ -43,6 +44,9 @@ func init() {
if os.Getenv("IS_OPENSHIFT") != "" {
isOpenshift = true
}
if ns := os.Getenv("FRRK8S_EXTERNAL_NAMESPACE"); ns != "" {
frrk8sNamespace = ns
}
}

var _ = Describe("metallb", func() {
Expand Down Expand Up @@ -81,8 +85,8 @@ var _ = Describe("metallb", func() {
})

DescribeTable("with BGP type", func(bgpType metallbv1beta1.BGPType) {
if isOpenshift && bgpType == metallbv1beta1.NativeMode {
Skip("Native mode not supported with openshift")
if isOpenshift && bgpType != metallbv1beta1.FRRK8sExternalMode {
Skip("only frr-k8s-external is supported on OpenShift")
}
checkControllerBGPMode := func(mode metallbv1beta1.BGPType) {
bgpTypeMatcher := ContainElement(corev1.EnvVar{Name: "METALLB_BGP_TYPE", Value: string(mode)})
Expand Down Expand Up @@ -255,24 +259,24 @@ var _ = Describe("metallb", func() {
}
By("checking frr-k8s daemonset is in running state")
Eventually(func() error {
daemonset, err := testclient.Client.DaemonSets(metallb.Namespace).Get(context.Background(), consts.FRRK8SDaemonsetName, metav1.GetOptions{})
daemonset, err := testclient.Client.DaemonSets(frrk8sNamespace).Get(context.Background(), consts.FRRK8SDaemonsetName, metav1.GetOptions{})
if err != nil {
return err
}

pods, err := testclient.Client.Pods(OperatorNameSpace).List(context.Background(), metav1.ListOptions{
pods, err := testclient.Client.Pods(frrk8sNamespace).List(context.Background(), metav1.ListOptions{
LabelSelector: "component=frr-k8s"})
if err != nil {
return err
}

if len(pods.Items) != int(daemonset.Status.DesiredNumberScheduled) {
return fmt.Errorf("daemonset %s pods are not ready, expected %d generations got %d pods", consts.MetalLBDaemonsetName, int(daemonset.Status.DesiredNumberScheduled), len(pods.Items))
return fmt.Errorf("daemonset %s pods are not ready, expected %d generations got %d pods", consts.FRRK8SDaemonsetName, int(daemonset.Status.DesiredNumberScheduled), len(pods.Items))
}

for _, pod := range pods.Items {
if pod.Status.Phase != corev1.PodRunning {
return fmt.Errorf("daemonset %s pod %s is not running, expected status %s got %s", consts.MetalLBDaemonsetName, pod.Name, corev1.PodRunning, pod.Status.Phase)
return fmt.Errorf("daemonset %s pod %s is not running, expected status %s got %s", consts.FRRK8SDaemonsetName, pod.Name, corev1.PodRunning, pod.Status.Phase)
}
}

Expand All @@ -281,24 +285,24 @@ var _ = Describe("metallb", func() {

By("checking frr-k8s webhook deployment is in running state")
Eventually(func() error {
deploy, err := testclient.Client.Deployments(metallb.Namespace).Get(context.Background(), consts.FRRK8SWebhookDeploymentName, metav1.GetOptions{})
deploy, err := testclient.Client.Deployments(frrk8sNamespace).Get(context.Background(), consts.FRRK8SWebhookDeploymentName, metav1.GetOptions{})
if err != nil {
return err
}

pods, err := testclient.Client.Pods(OperatorNameSpace).List(context.Background(), metav1.ListOptions{
pods, err := testclient.Client.Pods(frrk8sNamespace).List(context.Background(), metav1.ListOptions{
LabelSelector: "component=frr-k8s-webhook-server"})
if err != nil {
return err
}

if len(pods.Items) != int(deploy.Status.Replicas) {
return fmt.Errorf("deployment %s pods are not ready, expected %d replicas got %d pods", consts.MetalLBOperatorDeploymentName, deploy.Status.Replicas, len(pods.Items))
return fmt.Errorf("deployment %s pods are not ready, expected %d replicas got %d pods", consts.FRRK8SWebhookDeploymentName, deploy.Status.Replicas, len(pods.Items))
}

for _, pod := range pods.Items {
if pod.Status.Phase != corev1.PodRunning {
return fmt.Errorf("deployment %s pod %s is not running, expected status %s got %s", consts.MetalLBOperatorDeploymentName, pod.Name, corev1.PodRunning, pod.Status.Phase)
return fmt.Errorf("deployment %s pod %s is not running, expected status %s got %s", consts.FRRK8SWebhookDeploymentName, pod.Name, corev1.PodRunning, pod.Status.Phase)
}
}

Expand All @@ -309,6 +313,7 @@ var _ = Describe("metallb", func() {
Entry("Native Mode", metallbv1beta1.NativeMode),
Entry("FRR Mode", metallbv1beta1.FRRMode),
Entry("FRR-K8s Mode", metallbv1beta1.FRRK8sMode),
Entry("FRR-K8s-external Mode", metallbv1beta1.FRRK8sExternalMode),
)

})
Expand Down

0 comments on commit 64a6761

Please sign in to comment.