Skip to content

Commit

Permalink
add fail nb client ut case in ovn-nb-logical_switch_port_test.go (#4685)
Browse files Browse the repository at this point in the history
* add fail nb client ut case in ovn-nb-logical_switch_port_test.go
---------

Signed-off-by: dolibali <[email protected]>
  • Loading branch information
dolibali authored and bobz965 committed Nov 26, 2024
1 parent 66e90c0 commit 55166cb
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pkg/ovs/ovn-nb-logical_switch_port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ func (suite *OvnClientTestSuite) testCreateVirtualLogicalSwitchPorts() {
t.Parallel()

nbClient := suite.ovnNBClient
failedNbClient := suite.faiedOvnNBClient
lsName := "test-create-virtual-port-ls"
vips := []string{"192.168.33.10", "192.168.33.12"}

Expand Down Expand Up @@ -341,13 +342,19 @@ func (suite *OvnClientTestSuite) testCreateVirtualLogicalSwitchPorts() {
err = nbClient.CreateVirtualLogicalSwitchPorts("", vips...)
require.Error(t, err)
})

t.Run("fail nb client should log err", func(t *testing.T) {
err = failedNbClient.CreateVirtualLogicalSwitchPorts(lsName, vips...)
require.Error(t, err)
})
}

func (suite *OvnClientTestSuite) testCreateVirtualLogicalSwitchPort() {
t := suite.T()
t.Parallel()

nbClient := suite.ovnNBClient
failedNbClient := suite.faiedOvnNBClient
lspName := "test-create-one-virtual-port-lsp"
lsName := "test-create-one-virtual-port-ls"
lsName2 := "test-create-one-virtual-port-ls2"
Expand Down Expand Up @@ -382,6 +389,11 @@ func (suite *OvnClientTestSuite) testCreateVirtualLogicalSwitchPort() {
err = nbClient.CreateVirtualLogicalSwitchPort("", "", "")
require.Error(t, err)
})

t.Run("fail nb client should log err", func(t *testing.T) {
err = failedNbClient.CreateVirtualLogicalSwitchPort(lspName, lsName, vip)
require.Error(t, err)
})
}

func (suite *OvnClientTestSuite) testCreateBareLogicalSwitchPort() {
Expand Down Expand Up @@ -473,6 +485,11 @@ func (suite *OvnClientTestSuite) testSetLogicalSwitchPortVirtualParents() {
require.Empty(t, lsp.Options["virtual-parents"])
}
})

t.Run("fail nb client should log err", func(t *testing.T) {
err = failedNbClient.SetLogicalSwitchPortVirtualParents(lsName, "virt-parents-ls-2,virt-parents-ls-3", ips...)
require.Error(t, err)
})
}

func (suite *OvnClientTestSuite) testSetVirtualLogicalSwitchPortVirtualParents() {
Expand Down Expand Up @@ -536,13 +553,19 @@ func (suite *OvnClientTestSuite) testSetVirtualLogicalSwitchPortVirtualParents()
_, exists := lsp.Options["virtual-parents"]
require.False(t, exists)
})

t.Run("fail nb client should log err", func(t *testing.T) {
err = failedNbClient.SetVirtualLogicalSwitchPortVirtualParents(lspName, "virt-parents-ls-2,virt-parents-ls-3")
require.Error(t, err)
})
}

func (suite *OvnClientTestSuite) testSetLogicalSwitchPortArpProxy() {
t := suite.T()
t.Parallel()

nbClient := suite.ovnNBClient
failedNbClient := suite.faiedOvnNBClient
lsName := "test-set-lsp-arp-proxy-ls"
ips := "10.244.0.37,fc00::af4:25"
mac := "00:00:00:AB:B4:65"
Expand Down Expand Up @@ -580,6 +603,12 @@ func (suite *OvnClientTestSuite) testSetLogicalSwitchPortArpProxy() {
err = nbClient.SetLogicalSwitchPortArpProxy("test-nonexistent-lsp", enableArpProxy)
require.Error(t, err)
})

t.Run("fail nb client should log err", func(t *testing.T) {
enableArpProxy := true
err = failedNbClient.SetLogicalSwitchPortArpProxy(lspName, enableArpProxy)
require.Error(t, err)
})
}

func (suite *OvnClientTestSuite) testSetLogicalSwitchPortSecurity() {
Expand Down Expand Up @@ -1142,6 +1171,7 @@ func (suite *OvnClientTestSuite) testEnablePortLayer2forward() {
t.Parallel()

nbClient := suite.ovnNBClient
failedNbClient := suite.faiedOvnNBClient
lsName := "test-enable-port-l2-ls"
lspName := "test-enable-port-l2-lsp"
ns := "test-enable-port-l2-ns"
Expand Down Expand Up @@ -1200,6 +1230,11 @@ func (suite *OvnClientTestSuite) testEnablePortLayer2forward() {
}
require.Equal(t, 1, addressCount)
})

t.Run("fail nb client should log err", func(t *testing.T) {
err = failedNbClient.EnablePortLayer2forward(lspName)
require.Error(t, err)
})
}

func (suite *OvnClientTestSuite) testSetLogicalSwitchPortVlanTag() {
Expand Down

0 comments on commit 55166cb

Please sign in to comment.