From 1c8ff10573b583fadf9d4ec87157f5a73f45b612 Mon Sep 17 00:00:00 2001 From: dolibali Date: Thu, 31 Oct 2024 08:38:56 +0000 Subject: [PATCH 1/2] add fail nb client ut case in ovn-nb-logical_switch_port_test.go Signed-off-by: dolibali --- pkg/ovs/ovn-nb-logical_switch_port_test.go | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/pkg/ovs/ovn-nb-logical_switch_port_test.go b/pkg/ovs/ovn-nb-logical_switch_port_test.go index 7e9c4eac7f2..fcb98806ab2 100644 --- a/pkg/ovs/ovn-nb-logical_switch_port_test.go +++ b/pkg/ovs/ovn-nb-logical_switch_port_test.go @@ -308,6 +308,7 @@ func (suite *OvnClientTestSuite) testCreateVirtualLogicalSwitchPorts() { t.Parallel() nbClient := suite.ovnNBClient + failnbclient := suite.faiedOvnNBClient lsName := "test-create-virtual-port-ls" vips := []string{"192.168.33.10", "192.168.33.12"} @@ -341,6 +342,11 @@ 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 = failnbclient.CreateVirtualLogicalSwitchPorts(lsName, vips...) + require.Error(t, err) + }) } func (suite *OvnClientTestSuite) testCreateVirtualLogicalSwitchPort() { @@ -348,6 +354,7 @@ func (suite *OvnClientTestSuite) testCreateVirtualLogicalSwitchPort() { t.Parallel() nbClient := suite.ovnNBClient + failnbclient := suite.faiedOvnNBClient lspName := "test-create-one-virtual-port-lsp" lsName := "test-create-one-virtual-port-ls" lsName2 := "test-create-one-virtual-port-ls2" @@ -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 = failnbclient.CreateVirtualLogicalSwitchPort(lspName, lsName, vip) + require.Error(t, err) + }) } func (suite *OvnClientTestSuite) testCreateBareLogicalSwitchPort() { @@ -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() { @@ -536,6 +553,11 @@ 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() { @@ -543,6 +565,7 @@ func (suite *OvnClientTestSuite) testSetLogicalSwitchPortArpProxy() { 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" @@ -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() { @@ -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" @@ -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() { From b2e726ceb2e38cb1408a78b2d6ea5554ebae8d8c Mon Sep 17 00:00:00 2001 From: dolibali Date: Thu, 31 Oct 2024 08:58:19 +0000 Subject: [PATCH 2/2] fix hump problem Signed-off-by: dolibali --- pkg/ovs/ovn-nb-logical_switch_port_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/ovs/ovn-nb-logical_switch_port_test.go b/pkg/ovs/ovn-nb-logical_switch_port_test.go index fcb98806ab2..284f73f209a 100644 --- a/pkg/ovs/ovn-nb-logical_switch_port_test.go +++ b/pkg/ovs/ovn-nb-logical_switch_port_test.go @@ -308,7 +308,7 @@ func (suite *OvnClientTestSuite) testCreateVirtualLogicalSwitchPorts() { t.Parallel() nbClient := suite.ovnNBClient - failnbclient := suite.faiedOvnNBClient + failedNbClient := suite.faiedOvnNBClient lsName := "test-create-virtual-port-ls" vips := []string{"192.168.33.10", "192.168.33.12"} @@ -344,7 +344,7 @@ func (suite *OvnClientTestSuite) testCreateVirtualLogicalSwitchPorts() { }) t.Run("fail nb client should log err", func(t *testing.T) { - err = failnbclient.CreateVirtualLogicalSwitchPorts(lsName, vips...) + err = failedNbClient.CreateVirtualLogicalSwitchPorts(lsName, vips...) require.Error(t, err) }) } @@ -354,7 +354,7 @@ func (suite *OvnClientTestSuite) testCreateVirtualLogicalSwitchPort() { t.Parallel() nbClient := suite.ovnNBClient - failnbclient := suite.faiedOvnNBClient + failedNbClient := suite.faiedOvnNBClient lspName := "test-create-one-virtual-port-lsp" lsName := "test-create-one-virtual-port-ls" lsName2 := "test-create-one-virtual-port-ls2" @@ -391,7 +391,7 @@ func (suite *OvnClientTestSuite) testCreateVirtualLogicalSwitchPort() { }) t.Run("fail nb client should log err", func(t *testing.T) { - err = failnbclient.CreateVirtualLogicalSwitchPort(lspName, lsName, vip) + err = failedNbClient.CreateVirtualLogicalSwitchPort(lspName, lsName, vip) require.Error(t, err) }) }