Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions test/extended/networking/egress_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"fmt"
"net"
"strings"
"time"

configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/origin/test/extended/kubevirt"
Expand All @@ -12,6 +14,7 @@ import (

kapiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
frameworkpod "k8s.io/kubernetes/test/e2e/framework/pod"
admissionapi "k8s.io/pod-security-admission/api"
Expand Down Expand Up @@ -114,6 +117,21 @@ func doEgressFwTest(f *e2e.Framework, mgmtFw *e2e.Framework, oc *exutil.CLI, man
err := oc.AsAdmin().Run("create").Args("-f", egFwYaml).Execute()
o.Expect(err).NotTo(o.HaveOccurred(), "created egress-firewall object")

g.By("waiting for egressfirewall rules to be applied successfully")
// Fetch the name of the egressfirewall object. As there can be only
// one egressfirewall object per namespace, we can use the first one.
egfwName, err := oc.AsAdmin().Run("get").Args("egressfirewall", "-o", "jsonpath={.items[0].metadata.name}").Output()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't egfwName refers to egress firewall name created from manifest ? this command just retrieves first egFw object from the namespace, right ?
or is it going to be only one egFw object in the namespace which is created from manifest file ? may be adding a comment here would clarify it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There can be only one egress firewall object in a namespace: https://ovn-kubernetes.io/features/network-security-controls/egress-firewall/#introduction

I'll add a comment to clarify this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment for the clarification.

o.Expect(err).NotTo(o.HaveOccurred(), "failed to get egressfirewall object")

err = wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 30*time.Second, true, func(ctx context.Context) (bool, error) {
out, err := oc.AsAdmin().Run("get").Args("egressfirewall", egfwName, "-o", "jsonpath={.status.status}").Output()
if err != nil {
return false, nil
}
return strings.Contains(out, "EgressFirewall Rules applied"), nil
})
o.Expect(err).NotTo(o.HaveOccurred(), "failed to wait for egressfirewall rules to be applied successfully")

o.Expect(sendEgressFwTraffic(f, mgmtFw, oc, egressFWTestPod, nodeSelectorSupport, checkWildcard)).To(o.Succeed())

g.By("deleting test pod")
Expand Down