Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fail nb client ut case in ovn-nb-logical_switch_port_test.go #4685

Merged
merged 2 commits into from
Oct 31, 2024
Merged
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
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
Loading