Skip to content

Commit

Permalink
e2e, handler, ovs: Use secondary interfaces vars. (#1275)
Browse files Browse the repository at this point in the history
There are some e2e test for the handler that try to discover the
secondary interfaces stating "ipv4.enabled==false" this is wrong since
those interfaces could part of a primary interface ovs bridge and that
will match.

This change just use the e2e passed env var that state those interfaces.

Signed-off-by: Enrique Llorente <[email protected]>
  • Loading branch information
qinqon authored Dec 2, 2024
1 parent 2e791f9 commit 55f0b03
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions test/e2e/handler/simple_ovs_bridge_and_bond_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
. "github.com/onsi/gomega"

nmstate "github.com/nmstate/kubernetes-nmstate/api/shared"
"github.com/nmstate/kubernetes-nmstate/test/e2e/policy"
)

func ovsBrUpLAGEth1AndEth2(bridgeName, bondName, port1Name, port2Name string) nmstate.State {
Expand Down Expand Up @@ -146,20 +147,21 @@ var _ = Describe("OVS Bridge", func() {
Context("with capture", func() {
BeforeEach(func() {
capture := map[string]string{
"ethernet-ifaces": `interfaces.type=="ethernet"`,
"ethernet-not-ignored-ifaces": `capture.ethernet-ifaces | interfaces.state!="ignore"`,
"secondary-ifaces": `capture.ethernet-not-ignored-ifaces | interfaces.ipv4.enabled==false`,
"first-secondary-nic": fmt.Sprintf(`interfaces.name=="%s"`, firstSecondaryNic),
"second-secondary-nic": fmt.Sprintf(`interfaces.name=="%s"`, secondSecondaryNic),
}
updateDesiredStateWithCaptureAndWait(
setDesiredStateWithPolicyAndCapture(bridge1,
ovsBrUpLAGEth1AndEth2(
bridge1,
bond1,
`"{{ capture.secondary-ifaces.interfaces.0.name }}"`,
`"{{ capture.secondary-ifaces.interfaces.1.name }}"`,
`"{{ capture.first-secondary-nic.interfaces.0.name }}"`,
`"{{ capture.second-secondary-nic.interfaces.0.name }}"`,
),
capture,
)
deletePolicy(TestPolicy)

policy.WaitForAvailablePolicy(bridge1)
deletePolicy(bridge1)
})

It("should have the ovs-bridge at currentState", func() {
Expand Down Expand Up @@ -255,22 +257,21 @@ var _ = Describe("OVS Bridge", func() {
BeforeEach(func() {
By("Creating policy with desiredState")
capture := map[string]string{
"first-secondary-iface": fmt.Sprintf(`interfaces.name=="%s"`, firstSecondaryNic),
"ethernet-ifaces": `interfaces.type=="ethernet"`,
"ethernet-not-ignored-ifaces": `capture.ethernet-ifaces | interfaces.state!="ignore"`,
"secondary-ifaces": `capture.ethernet-not-ignored-ifaces | interfaces.ipv4.enabled==false`,
"first-secondary-iface": fmt.Sprintf(`interfaces.name=="%s"`, firstSecondaryNic),
"second-secondary-iface": fmt.Sprintf(`interfaces.name=="%s"`, secondSecondaryNic),
}

macAddr = `"{{ capture.first-secondary-iface.interfaces.0.mac-address }}"`
port1 := `"{{ capture.secondary-ifaces.interfaces.0.name }}"`
port2 := `"{{ capture.secondary-ifaces.interfaces.1.name }}"`
port1 := `"{{ capture.first-secondary-iface.interfaces.0.name }}"`
port2 := `"{{ capture.second-secondary-iface.interfaces.0.name }}"`

updateDesiredStateWithCaptureAtNodeAndWait(
designatedNode,
setDesiredStateWithPolicyAndCaptureAndNodeSelectorEventually(bridge1,
ovsBrUpLAGEth1Eth2WithInternalPort(bridge1, ovsPortName, macAddr, port1, port2),
capture,
map[string]string{"kubernetes.io/hostname": designatedNode},
)
deletePolicy(TestPolicy)
policy.WaitForAvailablePolicy(bridge1)
deletePolicy(bridge1)
})

It("should have the ovs-bridge and internal port at currentState", func() {
Expand Down

0 comments on commit 55f0b03

Please sign in to comment.