diff --git a/go-controller/hybrid-overlay/pkg/controller/node_linux_test.go b/go-controller/hybrid-overlay/pkg/controller/node_linux_test.go index 7979fff9413..95a565478ce 100644 --- a/go-controller/hybrid-overlay/pkg/controller/node_linux_test.go +++ b/go-controller/hybrid-overlay/pkg/controller/node_linux_test.go @@ -111,18 +111,18 @@ func addNodeSetupCmds(fexec *ovntest.FakeExec, nodeName string) { Output: thisNodeSubnet, }) fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --may-exist add-br br-ext -- set Bridge br-ext fail_mode=secure -- set Interface br-ext mtu_request=1400", + "ovs-vsctl --timeout=15 --retry --may-exist add-br br-ext -- set Bridge br-ext fail_mode=secure -- set Interface br-ext mtu_request=1400", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface br-ext mac_in_use", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface br-ext mac_in_use", Output: "10:11:12:13:14:15", }) fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 set bridge br-ext other-config:hwaddr=10:11:12:13:14:15", - "ovs-vsctl --timeout=15 --may-exist add-port br-int int -- --may-exist add-port br-ext ext -- set Interface int type=patch options:peer=ext external-ids:iface-id=int-" + nodeName + " -- set Interface ext type=patch options:peer=int", + "ovs-vsctl --timeout=15 --retry set bridge br-ext other-config:hwaddr=10:11:12:13:14:15", + "ovs-vsctl --timeout=15 --retry --may-exist add-port br-int int -- --may-exist add-port br-ext ext -- set Interface int type=patch options:peer=ext external-ids:iface-id=int-" + nodeName + " -- set Interface ext type=patch options:peer=int", }) fexec.AddFakeCmdsNoOutputNoError([]string{ - `ovs-vsctl --timeout=15 --may-exist add-port br-ext ext-vxlan -- set interface ext-vxlan type=vxlan options:remote_ip="flow" options:key="flow" options:dst_port=4789`, + `ovs-vsctl --timeout=15 --retry --may-exist add-port br-ext ext-vxlan -- set interface ext-vxlan type=vxlan options:remote_ip="flow" options:key="flow" options:dst_port=4789`, }) } diff --git a/go-controller/pkg/cni/bandwidth_test.go b/go-controller/pkg/cni/bandwidth_test.go index 26ae4a68926..f9d87bae33b 100644 --- a/go-controller/pkg/cni/bandwidth_test.go +++ b/go-controller/pkg/cni/bandwidth_test.go @@ -27,7 +27,7 @@ func TestClearPodBandwidth(t *testing.T) { desc: "Test error code path when ovsFind attempts to retrieve interfaces", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, fmt.Errorf("mock: failed to run ovsFind")}}, @@ -38,8 +38,8 @@ func TestClearPodBandwidth(t *testing.T) { desc: "Test code path when ovsClear returns an error", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{[]byte{1}, nil}}, @@ -51,8 +51,8 @@ func TestClearPodBandwidth(t *testing.T) { desc: "Test error code path when ovsFind attempts to retrieve qos instances", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, @@ -64,10 +64,10 @@ func TestClearPodBandwidth(t *testing.T) { desc: "Test code path when ovsDestroy returns an error", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{[]byte{1}, nil}}, @@ -80,10 +80,10 @@ func TestClearPodBandwidth(t *testing.T) { { desc: "Positive test code path", onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{[]byte{1}, nil}}, @@ -135,7 +135,7 @@ func TestSetPodBandwidth(t *testing.T) { desc: "Test code path when both ingressBPS is greater than zero and ovsCreate returns an error", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}}, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, fmt.Errorf("mock: failed to run ovsCreate")}}}, runnerInstance: mockKexecIface, @@ -145,8 +145,8 @@ func TestSetPodBandwidth(t *testing.T) { desc: "Test code path when inressBPS is greater than zero and ovsSet returns an error", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, @@ -158,8 +158,8 @@ func TestSetPodBandwidth(t *testing.T) { { desc: "Positive test code path when ingressBPS is greater than zero", onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, @@ -172,9 +172,9 @@ func TestSetPodBandwidth(t *testing.T) { desc: "Negative test code path when setting ingress_policing_rate", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, @@ -188,10 +188,10 @@ func TestSetPodBandwidth(t *testing.T) { desc: "Negative test code path when setting ingress_policing_burst", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, @@ -205,10 +205,10 @@ func TestSetPodBandwidth(t *testing.T) { { desc: "Positive test code path when both ingressBPS and egressBPS are greater than zero", onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, @@ -262,8 +262,8 @@ func TestGetIngressPodBandwidth(t *testing.T) { { desc: "Positive test code path when ingressBPS is correctly set", onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{[]byte{1}, nil}}, @@ -275,7 +275,7 @@ func TestGetIngressPodBandwidth(t *testing.T) { { desc: "Positive test code path when ingressBPS is not set", onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, @@ -286,8 +286,8 @@ func TestGetIngressPodBandwidth(t *testing.T) { { desc: "Positive test code path when ingressBPS is not set (no max-rate)", onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{[]byte{1}, nil}}, @@ -300,7 +300,7 @@ func TestGetIngressPodBandwidth(t *testing.T) { desc: "Negative test code path when ovsGet 'port' returns error", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, fmt.Errorf("mock: failed to run ovsSet")}}, @@ -311,8 +311,8 @@ func TestGetIngressPodBandwidth(t *testing.T) { desc: "Negative test code path when ovsGet 'qos' returns error", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{[]byte{1}, nil}}, @@ -324,8 +324,8 @@ func TestGetIngressPodBandwidth(t *testing.T) { desc: "Negative test code path when max-rate value cannot be transfer to integer", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{[]byte{1}, nil}}, @@ -395,7 +395,7 @@ func TestGetEgressPodBandwidth(t *testing.T) { { desc: "Positive test code path when egressBPS is correctly set", onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{[]byte("10000"), nil}}, @@ -406,7 +406,7 @@ func TestGetEgressPodBandwidth(t *testing.T) { { desc: "Positive test code path when egressBPS is not set (no ingress_policing_rate)", onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, @@ -417,7 +417,7 @@ func TestGetEgressPodBandwidth(t *testing.T) { { desc: "Positive test code path when egressBPS is not set", onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{[]byte("0"), nil}}, @@ -429,7 +429,7 @@ func TestGetEgressPodBandwidth(t *testing.T) { desc: "Negative test code path when ovsGet 'interface' returns error", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, fmt.Errorf("mock: failed to run ovsSet")}}, @@ -440,7 +440,7 @@ func TestGetEgressPodBandwidth(t *testing.T) { desc: "Negative test code path when ingress_policing_rate cannot be transfer to integer ", expectedErr: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{[]byte("test"), nil}}, diff --git a/go-controller/pkg/cni/helper_linux_test.go b/go-controller/pkg/cni/helper_linux_test.go index 7e7d29dffca..e7b58f6fd8f 100644 --- a/go-controller/pkg/cni/helper_linux_test.go +++ b/go-controller/pkg/cni/helper_linux_test.go @@ -483,7 +483,7 @@ func TestSetupSriovInterface(t *testing.T) { inpPCIAddrs: "0000:03:00.1", errExp: true, sriovOpsMockHelper: []ovntest.TestifyMockHelper{}, - onRetArgsKexecIface: []ovntest.TestifyMockHelper{{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string"}, RetArgList: []interface{}{mockCmd}}}, + onRetArgsKexecIface: []ovntest.TestifyMockHelper{{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string"}, RetArgList: []interface{}{mockCmd}}}, onRetArgsCmdList: []ovntest.TestifyMockHelper{{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, fmt.Errorf("failed to run 'ovs-vsctl")}}}, netLinkOpsMockHelper: []ovntest.TestifyMockHelper{ {OnCallMethodName: "LinkByName", OnCallMethodArgType: []string{"string"}, RetArgList: []interface{}{nil, fmt.Errorf("mock error")}}, @@ -503,7 +503,7 @@ func TestSetupSriovInterface(t *testing.T) { inpPCIAddrs: "0000:03:00.1", errExp: true, sriovOpsMockHelper: []ovntest.TestifyMockHelper{}, - onRetArgsKexecIface: []ovntest.TestifyMockHelper{{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string"}, RetArgList: []interface{}{mockCmd}}}, + onRetArgsKexecIface: []ovntest.TestifyMockHelper{{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string"}, RetArgList: []interface{}{mockCmd}}}, onRetArgsCmdList: []ovntest.TestifyMockHelper{{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}}, netLinkOpsMockHelper: []ovntest.TestifyMockHelper{ {OnCallMethodName: "LinkByName", OnCallMethodArgType: []string{"string"}, RetArgList: []interface{}{mockLink, nil}}, @@ -529,7 +529,7 @@ func TestSetupSriovInterface(t *testing.T) { }, inpPCIAddrs: "0000:03:00.1", errExp: true, - onRetArgsKexecIface: []ovntest.TestifyMockHelper{{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string"}, RetArgList: []interface{}{mockCmd}}}, + onRetArgsKexecIface: []ovntest.TestifyMockHelper{{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string"}, RetArgList: []interface{}{mockCmd}}}, onRetArgsCmdList: []ovntest.TestifyMockHelper{{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, fmt.Errorf("failed to run 'ovs-vsctl")}}}, runnerInstance: mockKexecIface, sriovOpsMockHelper: []ovntest.TestifyMockHelper{ @@ -591,7 +591,7 @@ func TestSetupSriovInterface(t *testing.T) { inpPCIAddrs: "0000:03:00.1", errExp: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}}, runnerInstance: mockKexecIface, @@ -624,8 +624,8 @@ func TestSetupSriovInterface(t *testing.T) { inpPCIAddrs: "0000:03:00.1", errMatch: fmt.Errorf("failed to rename"), onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, @@ -664,8 +664,8 @@ func TestSetupSriovInterface(t *testing.T) { inpPCIAddrs: "0000:03:00.1", errExp: true, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, @@ -709,8 +709,8 @@ func TestSetupSriovInterface(t *testing.T) { inpPCIAddrs: "0000:03:00.1", errMatch: fmt.Errorf("failed to set MTU on"), onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsCmdList: []ovntest.TestifyMockHelper{ {OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, diff --git a/go-controller/pkg/cni/ovs.go b/go-controller/pkg/cni/ovs.go index a25413c9559..f1ade323a47 100644 --- a/go-controller/pkg/cni/ovs.go +++ b/go-controller/pkg/cni/ovs.go @@ -43,7 +43,7 @@ func ovsExec(args ...string) (string, error) { return "", fmt.Errorf("OVS exec runner not initialized") } - args = append([]string{"--timeout=30"}, args...) + args = append([]string{"--timeout=30", "--retry"}, args...) output, err := runner.Command(vsctlPath, args...).CombinedOutput() if err != nil { return "", fmt.Errorf("failed to run 'ovs-vsctl %s': %v\n %q", strings.Join(args, " "), err, string(output)) diff --git a/go-controller/pkg/cni/ovs_test.go b/go-controller/pkg/cni/ovs_test.go index b09e5c117e9..74d7dbf8fb2 100644 --- a/go-controller/pkg/cni/ovs_test.go +++ b/go-controller/pkg/cni/ovs_test.go @@ -19,7 +19,7 @@ var _ = Describe("CNI OVS tests", func() { It("returns non-empty elements from ovsFind", func() { fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=30 --no-heading --format=csv --data=bare --columns=_uuid find Interface external-ids:iface-id=foobar", + Cmd: "ovs-vsctl --timeout=30 --retry --no-heading --format=csv --data=bare --columns=_uuid find Interface external-ids:iface-id=foobar", Output: `75419b50-ec6e-4989-b769-164488f53375 4609184a-cb69-46ed-880f-807b6a4e99f5 d9af11aa-37c3-4ea9-8ba3-a74843cc0f47 @@ -37,7 +37,7 @@ d9af11aa-37c3-4ea9-8ba3-a74843cc0f47 It("returns nil if no element is returned from ovsFind", func() { fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=30 --no-heading --format=csv --data=bare --columns=_uuid find Interface external-ids:iface-id=foobar", + Cmd: "ovs-vsctl --timeout=30 --retry --no-heading --format=csv --data=bare --columns=_uuid find Interface external-ids:iface-id=foobar", Output: "", }) @@ -48,7 +48,7 @@ d9af11aa-37c3-4ea9-8ba3-a74843cc0f47 It("returns empty values if the elements themselves are empty from ovsFind", func() { fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=30 --no-heading --format=csv --data=bare --columns=_uuid find Interface external-ids:iface-id=foobar", + Cmd: "ovs-vsctl --timeout=30 --retry --no-heading --format=csv --data=bare --columns=_uuid find Interface external-ids:iface-id=foobar", Output: ` `, @@ -63,7 +63,7 @@ d9af11aa-37c3-4ea9-8ba3-a74843cc0f47 It("returns quoted empty values if the elements themselves are empty from ovsFind", func() { fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=30 --no-heading --format=csv --data=bare --columns=_uuid find Interface external-ids:iface-id=foobar", + Cmd: "ovs-vsctl --timeout=30 --retry --no-heading --format=csv --data=bare --columns=_uuid find Interface external-ids:iface-id=foobar", Output: `"" "" `, @@ -78,7 +78,7 @@ d9af11aa-37c3-4ea9-8ba3-a74843cc0f47 It("returns unquoted value if the elements themselves are quoted from ovsGet", func() { fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=30 --if-exists get Interface blah external-ids:iface-id", + Cmd: "ovs-vsctl --timeout=30 --retry --if-exists get Interface blah external-ids:iface-id", Output: `"1234" `, }) diff --git a/go-controller/pkg/cni/ovs_unit_test.go b/go-controller/pkg/cni/ovs_unit_test.go index d968b642b5d..b0a794b122a 100644 --- a/go-controller/pkg/cni/ovs_unit_test.go +++ b/go-controller/pkg/cni/ovs_unit_test.go @@ -61,14 +61,14 @@ func TestOvsExec(t *testing.T) { { desc: "Test codepath when runner is non nil and returns error", expectedErr: fmt.Errorf("failed to run ovs-vsctl"), - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, onRetArgsCmdList: &ovntest.TestifyMockHelper{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, fmt.Errorf("failed to run 'ovs-vsctl")}}, runnerInstance: mockKexecIface, }, { desc: "Test codepath when runner is not nil and does not return an error", expectedErr: nil, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, onRetArgsCmdList: &ovntest.TestifyMockHelper{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, runnerInstance: mockKexecIface, }, @@ -112,7 +112,7 @@ func TestOvsCreate(t *testing.T) { { desc: "Positive test codepath for ovsCreate", expectedErr: nil, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, onRetArgsCmdList: &ovntest.TestifyMockHelper{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, runnerInstance: mockKexecIface, }, @@ -152,7 +152,7 @@ func TestOvsDestroy(t *testing.T) { { desc: "Positive test codepath for ovsDestroy", expectedErr: nil, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, onRetArgsCmdList: &ovntest.TestifyMockHelper{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, runnerInstance: mockKexecIface, }, @@ -192,7 +192,7 @@ func TestOvsSet(t *testing.T) { { desc: "Positive test codepath for ovsSet", expectedErr: nil, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, onRetArgsCmdList: &ovntest.TestifyMockHelper{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, runnerInstance: mockKexecIface, }, @@ -232,21 +232,21 @@ func TestOvsFind(t *testing.T) { { desc: "Test codepath when ovsExec returns an error", expectedErr: fmt.Errorf("failed to run ovsFind"), - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, onRetArgsCmdList: &ovntest.TestifyMockHelper{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, fmt.Errorf("failed to run ovsFind")}}, runnerInstance: mockKexecIface, }, { desc: "Test codepath when ovsExec output is nil", expectedErr: nil, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, onRetArgsCmdList: &ovntest.TestifyMockHelper{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, runnerInstance: mockKexecIface, }, { desc: "Positive test codepath for ovsFind; ovsExec output is not nil", expectedErr: nil, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, onRetArgsCmdList: &ovntest.TestifyMockHelper{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{[]byte{}, nil}}, runnerInstance: mockKexecIface, }, @@ -286,7 +286,7 @@ func TestOvsClear(t *testing.T) { { desc: "Positive test codepath for ovsClear", expectedErr: nil, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, onRetArgsCmdList: &ovntest.TestifyMockHelper{OnCallMethodName: "CombinedOutput", OnCallMethodArgType: []string{}, RetArgList: []interface{}{nil, nil}}, runnerInstance: mockKexecIface, }, diff --git a/go-controller/pkg/config/config.go b/go-controller/pkg/config/config.go index e4b5730ed4c..b4a2d3cbf89 100644 --- a/go-controller/pkg/config/config.go +++ b/go-controller/pkg/config/config.go @@ -1474,7 +1474,7 @@ func rawExec(exec kexec.Interface, cmd string, args ...string) (string, error) { // Can't use pkg/ovs or pkg/util here because those package import this one func runOVSVsctl(exec kexec.Interface, args ...string) (string, error) { - newArgs := append([]string{"--timeout=15"}, args...) + newArgs := append([]string{"--timeout=15", "--retry"}, args...) out, err := rawExec(exec, ovsVsctlCommand, newArgs...) if err != nil { return "", err diff --git a/go-controller/pkg/config/config_test.go b/go-controller/pkg/config/config_test.go index ecf904f3bf4..b3b2f744814 100644 --- a/go-controller/pkg/config/config_test.go +++ b/go-controller/pkg/config/config_test.go @@ -340,30 +340,30 @@ var _ = Describe("Config Operations", func() { // k8s-api-server fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:k8s-api-server", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:k8s-api-server", Output: "https://somewhere.com:8081", }) // k8s-api-token fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:k8s-api-token", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:k8s-api-token", Output: "asadfasdfasrw3atr3r3rf33fasdaa3233", }) // k8s-api-token-file fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:k8s-api-token-file", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:k8s-api-token-file", Output: "/new/path/to/token", }) // k8s-ca-certificate fname, fdata, err := createTempFile("ca.crt") gomega.Expect(err).NotTo(gomega.HaveOccurred()) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:k8s-ca-certificate", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:k8s-ca-certificate", Output: fname, }) // ovn-nb address fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:ovn-nb", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:ovn-nb", Output: "tcp:1.1.1.1:6441", }) @@ -409,30 +409,30 @@ var _ = Describe("Config Operations", func() { // k8s-api-server fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:k8s-api-server", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:k8s-api-server", Output: "https://somewhere.com:8081", }) // k8s-api-token fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:k8s-api-token", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:k8s-api-token", Output: "asadfasdfasrw3atr3r3rf33fasdaa3233", }) // k8s-api-token-file fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:k8s-api-token-file", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:k8s-api-token-file", Output: "/new/path/to/token", }) // k8s-ca-certificate fname, fdata, err := createTempFile("kube-cacert.pem") gomega.Expect(err).NotTo(gomega.HaveOccurred()) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:k8s-ca-certificate", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:k8s-ca-certificate", Output: fname, }) // ovn-nb address fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:ovn-nb", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:ovn-nb", Output: "tcp:1.1.1.1:6441,tcp:1.1.1.2:6641,tcp:1.1.1.3:6641", }) @@ -1480,9 +1480,9 @@ foo=bar fexec := ovntest.NewFakeExec() fexec.AddFakeCmdsNoOutputNoError([]string{ "ovn-nbctl --db=" + sbURL + " --timeout=5 --private-key=" + keyFile + " --certificate=" + certFile + " --bootstrap-ca-cert=" + caFile + " list nb_global", - "ovs-vsctl --timeout=15 del-ssl", - "ovs-vsctl --timeout=15 set-ssl " + keyFile + " " + certFile + " " + caFile, - "ovs-vsctl --timeout=15 set Open_vSwitch . external_ids:ovn-remote=\"" + sbURL + "\"", + "ovs-vsctl --timeout=15 --retry del-ssl", + "ovs-vsctl --timeout=15 --retry set-ssl " + keyFile + " " + certFile + " " + caFile, + "ovs-vsctl --timeout=15 --retry set Open_vSwitch . external_ids:ovn-remote=\"" + sbURL + "\"", }) cliConfig := &OvnAuthConfig{ @@ -1516,7 +1516,7 @@ foo=bar It("configures client southbound TCP legacy address correctly", func() { fexec := ovntest.NewFakeExec() fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 set Open_vSwitch . external_ids:ovn-remote=\"" + sbURLConverted + "\"", + "ovs-vsctl --timeout=15 --retry set Open_vSwitch . external_ids:ovn-remote=\"" + sbURLConverted + "\"", }) cliConfig := &OvnAuthConfig{Address: sbURLLegacy} diff --git a/go-controller/pkg/network-controller-manager/node_network_controller_manager_test.go b/go-controller/pkg/network-controller-manager/node_network_controller_manager_test.go index 2162a6fcf5c..29345c55388 100644 --- a/go-controller/pkg/network-controller-manager/node_network_controller_manager_test.go +++ b/go-controller/pkg/network-controller-manager/node_network_controller_manager_test.go @@ -17,7 +17,7 @@ import ( ) func genListStalePortsCmd() string { - return fmt.Sprintf("ovs-vsctl --timeout=15 --data=bare --no-headings --columns=name find interface ofport=-1") + return fmt.Sprintf("ovs-vsctl --timeout=15 --retry --data=bare --no-headings --columns=name find interface ofport=-1") } func genDeleteStalePortCmd(ifaces ...string) string { @@ -26,18 +26,18 @@ func genDeleteStalePortCmd(ifaces ...string) string { if len(staleIfacesCmd) > 0 { staleIfacesCmd += fmt.Sprintf(" -- --if-exists --with-iface del-port %s", iface) } else { - staleIfacesCmd += fmt.Sprintf("ovs-vsctl --timeout=15 --if-exists --with-iface del-port %s", iface) + staleIfacesCmd += fmt.Sprintf("ovs-vsctl --timeout=15 --retry --if-exists --with-iface del-port %s", iface) } } return staleIfacesCmd } func genDeleteStaleRepPortCmd(iface string) string { - return fmt.Sprintf("ovs-vsctl --timeout=15 --if-exists --with-iface del-port %s", iface) + return fmt.Sprintf("ovs-vsctl --timeout=15 --retry --if-exists --with-iface del-port %s", iface) } func genFindInterfaceWithSandboxCmd() string { - return fmt.Sprintf("ovs-vsctl --timeout=15 --columns=name,external_ids --data=bare --no-headings " + + return fmt.Sprintf("ovs-vsctl --timeout=15 --retry --columns=name,external_ids --data=bare --no-headings " + "--format=csv find Interface external_ids:sandbox!=\"\" external_ids:vf-netdev-name!=\"\"") } diff --git a/go-controller/pkg/node/base_node_network_controller_dpu_test.go b/go-controller/pkg/node/base_node_network_controller_dpu_test.go index 9d72c5d3af7..0885112a918 100644 --- a/go-controller/pkg/node/base_node_network_controller_dpu_test.go +++ b/go-controller/pkg/node/base_node_network_controller_dpu_test.go @@ -25,7 +25,7 @@ import ( ) func genOVSFindCmd(timeout, table, column, condition string) string { - return fmt.Sprintf("ovs-vsctl --timeout=%s --no-heading --format=csv --data=bare --columns=%s find %s %s", + return fmt.Sprintf("ovs-vsctl --timeout=%s --retry --no-heading --format=csv --data=bare --columns=%s find %s %s", timeout, column, table, condition) } @@ -34,7 +34,7 @@ func genOVSAddPortCmd(hostIfaceName, ifaceID, mac, ip, sandboxID, podUID string) if ip != "" { ipAddrExtID = fmt.Sprintf("external_ids:ip_addresses=%s ", ip) } - return fmt.Sprintf("ovs-vsctl --timeout=30 --may-exist add-port br-int %s other_config:transient=true "+ + return fmt.Sprintf("ovs-vsctl --timeout=30 --retry --may-exist add-port br-int %s other_config:transient=true "+ "-- set interface %s external_ids:attached_mac=%s external_ids:iface-id=%s external_ids:iface-id-ver=%s "+ "%sexternal_ids:sandbox=%s external_ids:vf-netdev-name=%s "+ "-- --if-exists remove interface %s external_ids k8s.ovn.org/network "+ @@ -43,14 +43,14 @@ func genOVSAddPortCmd(hostIfaceName, ifaceID, mac, ip, sandboxID, podUID string) } func genOVSDelPortCmd(portName string) string { - return fmt.Sprintf("ovs-vsctl --timeout=15 --if-exists del-port br-int %s", portName) + return fmt.Sprintf("ovs-vsctl --timeout=15 --retry --if-exists del-port br-int %s", portName) } func genOVSGetCmd(table, record, column, key string) string { if key != "" { column = column + ":" + key } - return fmt.Sprintf("ovs-vsctl --timeout=30 --if-exists get %s %s %s", table, record, column) + return fmt.Sprintf("ovs-vsctl --timeout=30 --retry --if-exists get %s %s %s", table, record, column) } func genOfctlDumpFlowsCmd(queryStr string) string { @@ -397,7 +397,7 @@ var _ = Describe("Node DPU tests", func() { netlinkOpsMock.On("LinkByName", vfRep).Return(vfLink, nil) netlinkOpsMock.On("LinkSetDown", vfLink).Return(nil) execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --if-exists del-port br-int %s", "pf0vf9"), + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry --if-exists del-port br-int %s", "pf0vf9"), }) err := dnnc.delRepPort(&pod, &scd, vfRep, types.DefaultNetworkName) Expect(err).ToNot(HaveOccurred()) diff --git a/go-controller/pkg/node/default_node_network_controller_test.go b/go-controller/pkg/node/default_node_network_controller_test.go index a139d05bb91..47c2489e27a 100644 --- a/go-controller/pkg/node/default_node_network_controller_test.go +++ b/go-controller/pkg/node/default_node_network_controller_test.go @@ -245,7 +245,7 @@ var _ = Describe("Node", func() { fexec := ovntest.NewFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 set Open_vSwitch . "+ + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry set Open_vSwitch . "+ "external_ids:ovn-encap-type=geneve "+ "external_ids:ovn-encap-ip=%s "+ "external_ids:ovn-remote-probe-interval=%d "+ @@ -259,7 +259,7 @@ var _ = Describe("Node", func() { nodeIP, interval, ofintval, ofintval, nodeName), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 -- clear bridge br-int netflow" + + Cmd: "ovs-vsctl --timeout=15 --retry -- clear bridge br-int netflow" + " -- " + "clear bridge br-int sflow" + " -- " + @@ -308,7 +308,7 @@ var _ = Describe("Node", func() { fexec := ovntest.NewFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 set Open_vSwitch . "+ + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry set Open_vSwitch . "+ "external_ids:ovn-encap-type=geneve "+ "external_ids:ovn-encap-ip=%s "+ "external_ids:ovn-remote-probe-interval=%d "+ @@ -322,7 +322,7 @@ var _ = Describe("Node", func() { nodeIP, interval, ofintval, ofintval, nodeName), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 " + + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry " + "--if-exists get Open_vSwitch . external_ids:system-id"), Output: chassisUUID, }) @@ -336,7 +336,7 @@ var _ = Describe("Node", func() { "%s options:dst_port=%d", encapUUID, encapPort), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 -- clear bridge br-int netflow" + + Cmd: "ovs-vsctl --timeout=15 --retry -- clear bridge br-int netflow" + " -- " + "clear bridge br-int sflow" + " -- " + @@ -384,7 +384,7 @@ var _ = Describe("Node", func() { fexec := ovntest.NewFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 set Open_vSwitch . "+ + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry set Open_vSwitch . "+ "external_ids:ovn-encap-type=geneve "+ "external_ids:ovn-encap-ip=%s "+ "external_ids:ovn-remote-probe-interval=%d "+ @@ -400,7 +400,7 @@ var _ = Describe("Node", func() { nodeIP, interval, ofintval, ofintval, nodeName), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 -- clear bridge br-int netflow" + + Cmd: "ovs-vsctl --timeout=15 --retry -- clear bridge br-int netflow" + " -- " + "clear bridge br-int sflow" + " -- " + @@ -452,7 +452,7 @@ var _ = Describe("Node", func() { fexec := ovntest.NewFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 set Open_vSwitch . "+ + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry set Open_vSwitch . "+ "external_ids:ovn-encap-type=geneve "+ "external_ids:ovn-encap-ip=%s "+ "external_ids:ovn-remote-probe-interval=%d "+ @@ -467,14 +467,14 @@ var _ = Describe("Node", func() { }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 -- clear bridge br-int netflow" + + Cmd: "ovs-vsctl --timeout=15 --retry -- clear bridge br-int netflow" + " -- " + "clear bridge br-int sflow" + " -- " + "clear bridge br-int ipfix", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15"+ + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry"+ " -- "+ "--id=@ipfix create ipfix "+ "targets=[\"%s:%d\"] cache_active_timeout=60 sampling=400"+ @@ -526,7 +526,7 @@ var _ = Describe("Node", func() { fexec := ovntest.NewFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 set Open_vSwitch . "+ + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry set Open_vSwitch . "+ "external_ids:ovn-encap-type=geneve "+ "external_ids:ovn-encap-ip=%s "+ "external_ids:ovn-remote-probe-interval=%d "+ @@ -541,14 +541,14 @@ var _ = Describe("Node", func() { }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 -- clear bridge br-int netflow" + + Cmd: "ovs-vsctl --timeout=15 --retry -- clear bridge br-int netflow" + " -- " + "clear bridge br-int sflow" + " -- " + "clear bridge br-int ipfix", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15"+ + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry"+ " -- "+ "--id=@ipfix create ipfix "+ "targets=[\"%s:%d\"] cache_active_timeout=123 cache_max_flows=456 sampling=789"+ @@ -600,7 +600,7 @@ var _ = Describe("Node", func() { fexec := ovntest.NewFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 set Open_vSwitch . "+ + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry set Open_vSwitch . "+ "external_ids:ovn-encap-type=geneve "+ "external_ids:ovn-encap-ip=%s "+ "external_ids:ovn-remote-probe-interval=%d "+ @@ -615,14 +615,14 @@ var _ = Describe("Node", func() { }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 -- clear bridge br-int netflow" + + Cmd: "ovs-vsctl --timeout=15 --retry -- clear bridge br-int netflow" + " -- " + "clear bridge br-int sflow" + " -- " + "clear bridge br-int ipfix", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15" + + Cmd: "ovs-vsctl --timeout=15 --retry" + " -- " + "--id=@ipfix create ipfix " + // verify that the 1.2.5.6 IP has been attached to the :8888 target below diff --git a/go-controller/pkg/node/gateway_init_linux_test.go b/go-controller/pkg/node/gateway_init_linux_test.go index 3e1a5b9218e..c31c4bfbe5e 100644 --- a/go-controller/pkg/node/gateway_init_linux_test.go +++ b/go-controller/pkg/node/gateway_init_linux_test.go @@ -71,19 +71,19 @@ func shareGatewayInterfaceTest(app *cli.App, testNS ns.NetNS, fexec := ovntest.NewLooseCompareFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 port-to-br eth0", + Cmd: "ovs-vsctl --timeout=15 --retry port-to-br eth0", Err: fmt.Errorf(""), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 port-to-br eth0", + Cmd: "ovs-vsctl --timeout=15 --retry port-to-br eth0", Err: fmt.Errorf(""), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 br-exists eth0", + Cmd: "ovs-vsctl --timeout=15 --retry br-exists eth0", Err: fmt.Errorf(""), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 -- --may-exist add-br breth0 -- br-set-external-id breth0 bridge-id breth0 -- br-set-external-id breth0 bridge-uplink eth0 -- set bridge breth0 fail-mode=standalone other_config:hwaddr=" + eth0MAC + " -- --may-exist add-port breth0 eth0 -- set port eth0 other-config:transient=true", + Cmd: "ovs-vsctl --timeout=15 --retry -- --may-exist add-br breth0 -- br-set-external-id breth0 bridge-id breth0 -- br-set-external-id breth0 bridge-uplink eth0 -- set bridge breth0 fail-mode=standalone other_config:hwaddr=" + eth0MAC + " -- --may-exist add-port breth0 eth0 -- set port eth0 other-config:transient=true", Action: func() error { return testNS.Do(func(ns.NetNS) error { defer GinkgoRecover() @@ -115,22 +115,22 @@ func shareGatewayInterfaceTest(app *cli.App, testNS ns.NetNS, }) } fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface breth0 mac_in_use", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface breth0 mac_in_use", Output: eth0MAC, }) fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 set bridge breth0 other-config:hwaddr=" + eth0MAC, + "ovs-vsctl --timeout=15 --retry set bridge breth0 other-config:hwaddr=" + eth0MAC, }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:ovn-bridge-mappings", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:ovn-bridge-mappings", Output: "", }) fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 set Open_vSwitch . external_ids:ovn-bridge-mappings=" + types.PhysicalNetworkName + ":breth0", + "ovs-vsctl --timeout=15 --retry set Open_vSwitch . external_ids:ovn-bridge-mappings=" + types.PhysicalNetworkName + ":breth0", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:system-id", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:system-id", Output: systemID, }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ @@ -138,23 +138,23 @@ func shareGatewayInterfaceTest(app *cli.App, testNS ns.NetNS, Output: "Check pkt length action: Yes", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . other_config:hw-offload", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . other_config:hw-offload", Output: fmt.Sprintf("%t", hwOffload), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get Interface patch-breth0_node1-to-br-int ofport", + Cmd: "ovs-vsctl --timeout=15 --retry get Interface patch-breth0_node1-to-br-int ofport", Output: "5", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get interface eth0 ofport", + Cmd: "ovs-vsctl --timeout=15 --retry get interface eth0 ofport", Output: "7", }) if setNodeIP { fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 get Open_vSwitch . external_ids:ovn-encap-ip", + "ovs-vsctl --timeout=15 --retry get Open_vSwitch . external_ids:ovn-encap-ip", }) fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 set Open_vSwitch . external_ids:ovn-encap-ip=192.168.1.10", + "ovs-vsctl --timeout=15 --retry set Open_vSwitch . external_ids:ovn-encap-ip=192.168.1.10", }) fexec.AddFakeCmdsNoOutputNoError([]string{ "ovn-appctl --timeout=5 -t ovn-controller exit --restart", @@ -181,11 +181,11 @@ func shareGatewayInterfaceTest(app *cli.App, testNS ns.NetNS, }) // nodePortWatcher() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface patch-breth0_" + nodeName + "-to-br-int ofport", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface patch-breth0_" + nodeName + "-to-br-int ofport", Output: "5", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface eth0 ofport", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface eth0 ofport", Output: "7", }) // syncServices() @@ -426,35 +426,35 @@ func shareGatewayInterfaceDPUTest(app *cli.App, testNS ns.NetNS, // gatewayInitInternal // bridgeForInterface fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 port-to-br " + brphys, + Cmd: "ovs-vsctl --timeout=15 --retry port-to-br " + brphys, Err: fmt.Errorf(""), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 port-to-br " + brphys, + Cmd: "ovs-vsctl --timeout=15 --retry port-to-br " + brphys, Err: fmt.Errorf(""), Output: brphys, }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 br-exists " + brphys, + Cmd: "ovs-vsctl --timeout=15 --retry br-exists " + brphys, Err: nil, }) // getIntfName // GetNicName fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 list-ports " + brphys, + Cmd: "ovs-vsctl --timeout=15 --retry list-ports " + brphys, Output: "p0", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get Port " + uplinkPort + " Interfaces", + Cmd: "ovs-vsctl --timeout=15 --retry get Port " + uplinkPort + " Interfaces", Output: "p0", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get Interface " + uplinkPort + " Type", + Cmd: "ovs-vsctl --timeout=15 --retry get Interface " + uplinkPort + " Type", Output: "system", }) // getIntfName fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get interface p0 ofport", + Cmd: "ovs-vsctl --timeout=15 --retry get interface p0 ofport", }) if config.IPv4Mode { fexec.AddFakeCmd(&ovntest.ExpectedCmd{ @@ -471,19 +471,19 @@ func shareGatewayInterfaceDPUTest(app *cli.App, testNS ns.NetNS, // bridgedGatewayNodeSetup // GetOVSPortMACAddress fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface " + brphys + " mac_in_use", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface " + brphys + " mac_in_use", Output: uplinkMAC, }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:ovn-bridge-mappings", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:ovn-bridge-mappings", Output: "", }) fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 set Open_vSwitch . external_ids:ovn-bridge-mappings=" + types.PhysicalNetworkName + ":" + brphys, + "ovs-vsctl --timeout=15 --retry set Open_vSwitch . external_ids:ovn-bridge-mappings=" + types.PhysicalNetworkName + ":" + brphys, }) // GetNodeChassisID fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:system-id", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:system-id", Output: systemID, }) // DetectCheckPktLengthSupport @@ -493,54 +493,54 @@ func shareGatewayInterfaceDPUTest(app *cli.App, testNS ns.NetNS, }) // IsOvsHwOffloadEnabled fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . other_config:hw-offload", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . other_config:hw-offload", Output: "false", }) // GetDPUHostInterface fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 list-ports " + brphys, + Cmd: "ovs-vsctl --timeout=15 --retry list-ports " + brphys, Output: hostRep, }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get Port " + hostRep + " Interfaces", + Cmd: "ovs-vsctl --timeout=15 --retry get Port " + hostRep + " Interfaces", Output: hostRep, }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get Interface " + hostRep + " Name", + Cmd: "ovs-vsctl --timeout=15 --retry get Interface " + hostRep + " Name", Output: hostRep, }) // newGatewayOpenFlowManager fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get Interface patch-" + brphys + "_node1-to-br-int ofport", + Cmd: "ovs-vsctl --timeout=15 --retry get Interface patch-" + brphys + "_node1-to-br-int ofport", Output: "5", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get interface " + uplinkPort + " ofport", + Cmd: "ovs-vsctl --timeout=15 --retry get interface " + uplinkPort + " ofport", Output: "7", }) // GetDPUHostInterface fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 list-ports " + brphys, + Cmd: "ovs-vsctl --timeout=15 --retry list-ports " + brphys, Output: hostRep, }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get Port pf0hpf Interfaces", + Cmd: "ovs-vsctl --timeout=15 --retry get Port pf0hpf Interfaces", Output: hostRep, }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get Interface pf0hpf Name", + Cmd: "ovs-vsctl --timeout=15 --retry get Interface pf0hpf Name", Output: hostRep, }) // newGatewayOpenFlowManager fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get interface " + hostRep + " ofport", + Cmd: "ovs-vsctl --timeout=15 --retry get interface " + hostRep + " ofport", Output: "9", }) fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 get Open_vSwitch . external_ids:ovn-encap-ip", + "ovs-vsctl --timeout=15 --retry get Open_vSwitch . external_ids:ovn-encap-ip", }) fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 set Open_vSwitch . external_ids:ovn-encap-ip=192.168.1.101", + "ovs-vsctl --timeout=15 --retry set Open_vSwitch . external_ids:ovn-encap-ip=192.168.1.101", }) fexec.AddFakeCmdsNoOutputNoError([]string{ "ovn-appctl --timeout=5 -t ovn-controller exit --restart", @@ -551,11 +551,11 @@ func shareGatewayInterfaceDPUTest(app *cli.App, testNS ns.NetNS, }) // nodePortWatcher() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface patch-" + brphys + "_" + nodeName + "-to-br-int ofport", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface patch-" + brphys + "_" + nodeName + "-to-br-int ofport", Output: "5", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface " + uplinkPort + " ofport", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface " + uplinkPort + " ofport", Output: "7", }) // syncServices() @@ -838,19 +838,19 @@ func localGatewayInterfaceTest(app *cli.App, testNS ns.NetNS, fexec := ovntest.NewLooseCompareFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 port-to-br eth0", + Cmd: "ovs-vsctl --timeout=15 --retry port-to-br eth0", Err: fmt.Errorf(""), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 port-to-br eth0", + Cmd: "ovs-vsctl --timeout=15 --retry port-to-br eth0", Err: fmt.Errorf(""), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 br-exists eth0", + Cmd: "ovs-vsctl --timeout=15 --retry br-exists eth0", Err: fmt.Errorf(""), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 -- --may-exist add-br breth0 -- br-set-external-id breth0 bridge-id breth0 -- br-set-external-id breth0 bridge-uplink eth0 -- set bridge breth0 fail-mode=standalone other_config:hwaddr=" + eth0MAC + " -- --may-exist add-port breth0 eth0 -- set port eth0 other-config:transient=true", + Cmd: "ovs-vsctl --timeout=15 --retry -- --may-exist add-br breth0 -- br-set-external-id breth0 bridge-id breth0 -- br-set-external-id breth0 bridge-uplink eth0 -- set bridge breth0 fail-mode=standalone other_config:hwaddr=" + eth0MAC + " -- --may-exist add-port breth0 eth0 -- set port eth0 other-config:transient=true", Action: func() error { return testNS.Do(func(ns.NetNS) error { defer GinkgoRecover() @@ -882,22 +882,22 @@ func localGatewayInterfaceTest(app *cli.App, testNS ns.NetNS, }) } fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface breth0 mac_in_use", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface breth0 mac_in_use", Output: eth0MAC, }) fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 set bridge breth0 other-config:hwaddr=" + eth0MAC, + "ovs-vsctl --timeout=15 --retry set bridge breth0 other-config:hwaddr=" + eth0MAC, }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:ovn-bridge-mappings", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:ovn-bridge-mappings", Output: "", }) fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 set Open_vSwitch . external_ids:ovn-bridge-mappings=" + types.PhysicalNetworkName + ":breth0", + "ovs-vsctl --timeout=15 --retry set Open_vSwitch . external_ids:ovn-bridge-mappings=" + types.PhysicalNetworkName + ":breth0", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external_ids:system-id", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external_ids:system-id", Output: systemID, }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ @@ -905,20 +905,20 @@ func localGatewayInterfaceTest(app *cli.App, testNS ns.NetNS, Output: "Check pkt length action: Yes", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . other_config:hw-offload", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . other_config:hw-offload", Output: "false", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get Interface patch-breth0_node1-to-br-int ofport", + Cmd: "ovs-vsctl --timeout=15 --retry get Interface patch-breth0_node1-to-br-int ofport", Output: "5", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get interface eth0 ofport", + Cmd: "ovs-vsctl --timeout=15 --retry get interface eth0 ofport", Output: "7", }) // IP already configured, do not try to set it or restart ovn-controller fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 get Open_vSwitch . external_ids:ovn-encap-ip", + Cmd: "ovs-vsctl --timeout=15 --retry get Open_vSwitch . external_ids:ovn-encap-ip", Output: "192.168.1.10", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ @@ -964,11 +964,11 @@ OFPT_GET_CONFIG_REPLY (xid=0x4): frags=normal miss_send_len=0`, }) // nodePortWatcher() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface patch-breth0_" + nodeName + "-to-br-int ofport", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface patch-breth0_" + nodeName + "-to-br-int ofport", Output: "5", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface eth0 ofport", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface eth0 ofport", Output: "7", }) // syncServices() @@ -1693,7 +1693,7 @@ var _ = Describe("Gateway unit tests", func() { fexec := ovntest.NewLooseCompareFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 port-to-br %s", ifName), + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry port-to-br %s", ifName), Err: fmt.Errorf(""), }) err := util.SetExec(fexec) @@ -1715,7 +1715,7 @@ var _ = Describe("Gateway unit tests", func() { fexec := ovntest.NewLooseCompareFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 port-to-br %s", ifName), + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry port-to-br %s", ifName), Err: fmt.Errorf(""), }) err := util.SetExec(fexec) @@ -1740,7 +1740,7 @@ var _ = Describe("Gateway unit tests", func() { fexec := ovntest.NewLooseCompareFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 port-to-br %s", ifName), + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry port-to-br %s", ifName), Err: fmt.Errorf(""), Output: "br" + ifName, }) @@ -1783,7 +1783,7 @@ var _ = Describe("Gateway unit tests", func() { fexec := ovntest.NewLooseCompareFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 port-to-br %s", ifName), + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry port-to-br %s", ifName), Err: fmt.Errorf(""), Output: "", }) @@ -1817,7 +1817,7 @@ var _ = Describe("Gateway unit tests", func() { fexec := ovntest.NewLooseCompareFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 port-to-br %s", ifName), + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry port-to-br %s", ifName), Err: fmt.Errorf(""), Output: "", }) @@ -1860,7 +1860,7 @@ var _ = Describe("Gateway unit tests", func() { fexec := ovntest.NewLooseCompareFakeExec() fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 port-to-br %s", ifName), + Cmd: fmt.Sprintf("ovs-vsctl --timeout=15 --retry port-to-br %s", ifName), Err: fmt.Errorf(""), Output: "", }) diff --git a/go-controller/pkg/node/management-port_dpu_test.go b/go-controller/pkg/node/management-port_dpu_test.go index e1a1db0881a..6cff09958cc 100644 --- a/go-controller/pkg/node/management-port_dpu_test.go +++ b/go-controller/pkg/node/management-port_dpu_test.go @@ -18,14 +18,14 @@ import ( ) func genOVSAddMgmtPortCmd(nodeName, repName string) string { - return fmt.Sprintf("ovs-vsctl --timeout=15 -- --may-exist add-port br-int %s -- set interface %s external-ids:iface-id=%s"+ + return fmt.Sprintf("ovs-vsctl --timeout=15 --retry -- --may-exist add-port br-int %s -- set interface %s external-ids:iface-id=%s"+ " external-ids:ovn-orig-mgmt-port-rep-name=%s", types.K8sMgmtIntfName+"_0", types.K8sMgmtIntfName+"_0", types.K8sPrefix+nodeName, repName) } func mockOVSListInterfaceMgmtPortNotExistCmd(execMock *ovntest.FakeExec, mgmtPortName string) { execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, }) } @@ -214,7 +214,7 @@ var _ = Describe("Mananagement port DPU tests", func() { netlinkOpsMock.On("LinkSetUp", linkMock).Return(nil, nil) mockOVSListInterfaceMgmtPortNotExistCmd(execMock, types.K8sMgmtIntfName) execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 set Open_vSwitch . external-ids:ovn-orig-mgmt-port-netdev-name=" + mgmtPortDpuHost.netdevName, + "ovs-vsctl --timeout=15 --retry set Open_vSwitch . external-ids:ovn-orig-mgmt-port-netdev-name=" + mgmtPortDpuHost.netdevName, }) // mock createPlatformManagementPort, we fail it as it covers what we want to test without the diff --git a/go-controller/pkg/node/management-port_linux_test.go b/go-controller/pkg/node/management-port_linux_test.go index 7147c3ee204..8710732cafd 100644 --- a/go-controller/pkg/node/management-port_linux_test.go +++ b/go-controller/pkg/node/management-port_linux_test.go @@ -201,22 +201,22 @@ func testManagementPort(ctx *cli.Context, fexec *ovntest.FakeExec, testNS ns.Net // generic setup fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgtPort, + Cmd: "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgtPort, Output: "internal," + mgtPort, }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgtPort + "_0", + Cmd: "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgtPort + "_0", Output: "internal," + mgtPort + "_0", }) fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 -- --if-exists del-port br-int " + legacyMgtPort + " -- --may-exist add-port br-int " + mgtPort + " -- set interface " + mgtPort + " type=internal mtu_request=" + mtu + " external-ids:iface-id=" + legacyMgtPort, + "ovs-vsctl --timeout=15 --retry -- --if-exists del-port br-int " + legacyMgtPort + " -- --may-exist add-port br-int " + mgtPort + " -- set interface " + mgtPort + " type=internal mtu_request=" + mtu + " external-ids:iface-id=" + legacyMgtPort, }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface " + mgtPort + " mac_in_use", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface " + mgtPort + " mac_in_use", Output: mgtPortMAC, }) fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 set interface " + mgtPort + " " + fmt.Sprintf("mac=%s", strings.ReplaceAll(mgtPortMAC, ":", "\\:")), + "ovs-vsctl --timeout=15 --retry set interface " + mgtPort + " " + fmt.Sprintf("mac=%s", strings.ReplaceAll(mgtPortMAC, ":", "\\:")), }) for _, cfg := range configs { if cfg.family == netlink.FAMILY_V4 { @@ -232,7 +232,7 @@ func testManagementPort(ctx *cli.Context, fexec *ovntest.FakeExec, testNS ns.Net } } fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface " + mgtPort + " ofport", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface " + mgtPort + " ofport", Output: "1", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ @@ -323,14 +323,14 @@ func testManagementPortDPU(ctx *cli.Context, fexec *ovntest.FakeExec, testNS ns. // OVS cmd setup fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgtPort, - fmt.Sprintf("ovs-vsctl --timeout=15 -- --may-exist add-port br-int %s -- set interface %s "+ + "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgtPort, + fmt.Sprintf("ovs-vsctl --timeout=15 --retry -- --may-exist add-port br-int %s -- set interface %s "+ "external-ids:iface-id=%s external-ids:ovn-orig-mgmt-port-rep-name=%s", mgtPort, mgtPort, "k8s-"+nodeName, mgmtPortNetdev), }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get interface " + mgtPort + " ofport", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get interface " + mgtPort + " ofport", Output: "1", }) fexec.AddFakeCmd(&ovntest.ExpectedCmd{ @@ -416,7 +416,7 @@ func testManagementPortDPUHost(ctx *cli.Context, fexec *ovntest.FakeExec, testNS // OVS cmd setup fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgtPort, + "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgtPort, }) for _, cfg := range configs { @@ -525,7 +525,7 @@ var _ = Describe("Management Port Operations", func() { Context("Syncing netdevice interface", func() { It("Fails to lookup netdevice link", func() { execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, }) netlinkOpsMock.On("LinkByName", mgmtPortName).Return(nil, netlinkMockErr) netlinkOpsMock.On("IsLinkNotFoundError", mock.Anything).Return(false) @@ -536,7 +536,7 @@ var _ = Describe("Management Port Operations", func() { It("Fails to teardown IP configuration", func() { execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, }) netlinkOpsMock.On("LinkByName", mgmtPortName).Return(linkMock, nil) netlinkOpsMock.On("AddrList", linkMock, netlink.FAMILY_ALL).Return([]netlink.Addr{}, netlinkMockErr) @@ -548,7 +548,7 @@ var _ = Describe("Management Port Operations", func() { It("Fails to set netdevice link down", func() { execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, }) netlinkOpsMock.On("LinkByName", mgmtPortName).Return(linkMock, nil) netlinkOpsMock.On("AddrList", linkMock, netlink.FAMILY_ALL).Return([]netlink.Addr{}, nil) @@ -561,10 +561,10 @@ var _ = Describe("Management Port Operations", func() { It("Fails to rename netdevice link", func() { execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, }) execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external-ids:ovn-orig-mgmt-port-netdev-name", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external-ids:ovn-orig-mgmt-port-netdev-name", Output: netdevName, }) netlinkOpsMock.On("LinkByName", mgmtPortName).Return(linkMock, nil) @@ -578,10 +578,10 @@ var _ = Describe("Management Port Operations", func() { }) It("Unconfigures old management port netdevice", func() { execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, }) execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Open_vSwitch . external-ids:ovn-orig-mgmt-port-netdev-name", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Open_vSwitch . external-ids:ovn-orig-mgmt-port-netdev-name", Output: netdevName, }) netlinkOpsMock.On("LinkByName", mgmtPortName).Return(linkMock, nil) @@ -598,7 +598,7 @@ var _ = Describe("Management Port Operations", func() { Context("Syncing when old management port is OVS internal port", func() { It("Internal port found, but new one supposed to be an internal port", func() { execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + Cmd: "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, Output: "internal," + mgmtPortName, }) @@ -607,11 +607,11 @@ var _ = Describe("Management Port Operations", func() { }) It("Fails to remove port from the bridge", func() { execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + Cmd: "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, Output: "internal," + mgmtPortName, }) execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 del-port br-int " + mgmtPortName, + Cmd: "ovs-vsctl --timeout=15 --retry del-port br-int " + mgmtPortName, Err: fakeExecErr, }) @@ -621,11 +621,11 @@ var _ = Describe("Management Port Operations", func() { It("Removes internal port from the bridge", func() { execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + Cmd: "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, Output: "internal," + mgmtPortName, }) execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 del-port br-int " + mgmtPortName, + "ovs-vsctl --timeout=15 --retry del-port br-int " + mgmtPortName, }) err := syncMgmtPortInterface(hostSubnets, mgmtPortName, false) @@ -636,14 +636,14 @@ var _ = Describe("Management Port Operations", func() { Context("Syncing representor interface", func() { It("Fails to delete representor from the bridge", func() { execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + Cmd: "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, Output: "," + mgmtPortName, }) execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --if-exists get Interface " + mgmtPortName + " external-ids:ovn-orig-mgmt-port-rep-name", + "ovs-vsctl --timeout=15 --retry --if-exists get Interface " + mgmtPortName + " external-ids:ovn-orig-mgmt-port-rep-name", }) execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists del-port br-int " + mgmtPortName, + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists del-port br-int " + mgmtPortName, Err: fakeExecErr, }) @@ -653,15 +653,15 @@ var _ = Describe("Management Port Operations", func() { It("Fails to get representor original name and fallback to generic one", func() { execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + Cmd: "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, Output: "," + mgmtPortName, }) execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Interface " + mgmtPortName + " external-ids:ovn-orig-mgmt-port-rep-name", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Interface " + mgmtPortName + " external-ids:ovn-orig-mgmt-port-rep-name", Err: fakeExecErr, }) execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --if-exists del-port br-int " + mgmtPortName, + "ovs-vsctl --timeout=15 --retry --if-exists del-port br-int " + mgmtPortName, }) // Return error here, so we know that function didn't returned earlier @@ -672,12 +672,12 @@ var _ = Describe("Management Port Operations", func() { It("Fails to get representor link", func() { execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + Cmd: "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, Output: "," + mgmtPortName, }) execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --if-exists get Interface " + mgmtPortName + " external-ids:ovn-orig-mgmt-port-rep-name", - "ovs-vsctl --timeout=15 --if-exists del-port br-int " + mgmtPortName, + "ovs-vsctl --timeout=15 --retry --if-exists get Interface " + mgmtPortName + " external-ids:ovn-orig-mgmt-port-rep-name", + "ovs-vsctl --timeout=15 --retry --if-exists del-port br-int " + mgmtPortName, }) netlinkOpsMock.On("LinkByName", mgmtPortName).Return(nil, netlinkMockErr) @@ -687,12 +687,12 @@ var _ = Describe("Management Port Operations", func() { It("Fails to set representor link down", func() { execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + Cmd: "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, Output: "," + mgmtPortName, }) execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --if-exists get Interface " + mgmtPortName + " external-ids:ovn-orig-mgmt-port-rep-name", - "ovs-vsctl --timeout=15 --if-exists del-port br-int " + mgmtPortName, + "ovs-vsctl --timeout=15 --retry --if-exists get Interface " + mgmtPortName + " external-ids:ovn-orig-mgmt-port-rep-name", + "ovs-vsctl --timeout=15 --retry --if-exists del-port br-int " + mgmtPortName, }) netlinkOpsMock.On("LinkByName", mgmtPortName).Return(linkMock, nil) netlinkOpsMock.On("LinkSetDown", linkMock).Return(netlinkMockErr) @@ -703,15 +703,15 @@ var _ = Describe("Management Port Operations", func() { It("Fails to rename representor link", func() { execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + Cmd: "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, Output: "," + mgmtPortName, }) execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Interface " + mgmtPortName + " external-ids:ovn-orig-mgmt-port-rep-name", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Interface " + mgmtPortName + " external-ids:ovn-orig-mgmt-port-rep-name", Output: repName, }) execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --if-exists del-port br-int " + mgmtPortName, + "ovs-vsctl --timeout=15 --retry --if-exists del-port br-int " + mgmtPortName, }) netlinkOpsMock.On("LinkByName", mgmtPortName).Return(linkMock, nil) netlinkOpsMock.On("LinkSetDown", linkMock).Return(nil) @@ -723,15 +723,15 @@ var _ = Describe("Management Port Operations", func() { It("Removes representor from the bridge", func() { execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, + Cmd: "ovs-vsctl --timeout=15 --retry --no-headings --data bare --format csv --columns type,name find Interface name=" + mgmtPortName, Output: "," + mgmtPortName, }) execMock.AddFakeCmd(&ovntest.ExpectedCmd{ - Cmd: "ovs-vsctl --timeout=15 --if-exists get Interface " + mgmtPortName + " external-ids:ovn-orig-mgmt-port-rep-name", + Cmd: "ovs-vsctl --timeout=15 --retry --if-exists get Interface " + mgmtPortName + " external-ids:ovn-orig-mgmt-port-rep-name", Output: repName, }) execMock.AddFakeCmdsNoOutputNoError([]string{ - "ovs-vsctl --timeout=15 --if-exists del-port br-int " + mgmtPortName, + "ovs-vsctl --timeout=15 --retry --if-exists del-port br-int " + mgmtPortName, }) netlinkOpsMock.On("LinkByName", mgmtPortName).Return(linkMock, nil) netlinkOpsMock.On("LinkSetDown", linkMock).Return(nil) diff --git a/go-controller/pkg/util/net_unit_test.go b/go-controller/pkg/util/net_unit_test.go index a7992a73845..82b879b630c 100644 --- a/go-controller/pkg/util/net_unit_test.go +++ b/go-controller/pkg/util/net_unit_test.go @@ -177,21 +177,21 @@ func TestGetOVSPortMACAddress(t *testing.T) { desc: "tests code path when RunOVSVsctl returns error", input: "TEST_PORT", errExpected: true, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{nil, nil, fmt.Errorf("executable file not found in $PATH")}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{nil, nil, fmt.Errorf("executable file not found in $PATH")}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, { desc: "tests code path when MAC address returned is []", input: "TEST_PORT", errExpected: true, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[]")), nil, nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[]")), nil, nil}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, { desc: "tests code path when Valid MAC address is returned", input: "TEST_PORT", - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("00:00:a9:fe:21:01")), nil, nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("00:00:a9:fe:21:01")), nil, nil}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, } for i, tc := range tests { diff --git a/go-controller/pkg/util/nicstobridge_test.go b/go-controller/pkg/util/nicstobridge_test.go index 7ecfedefe29..366313745c6 100644 --- a/go-controller/pkg/util/nicstobridge_test.go +++ b/go-controller/pkg/util/nicstobridge_test.go @@ -49,12 +49,12 @@ func TestGetNicName(t *testing.T) { outputExp: "", inpBrName: "testPortName", onRetArgsExecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("port1\nport2")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("port1\nport2")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, }, { @@ -63,14 +63,14 @@ func TestGetNicName(t *testing.T) { outputExp: "", inpBrName: "testPortName", onRetArgsExecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("port1")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("port1")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, }, { @@ -78,14 +78,14 @@ func TestGetNicName(t *testing.T) { outputExp: "port1", inpBrName: "testPortName", onRetArgsExecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("port1")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("port1")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, }, { @@ -94,16 +94,16 @@ func TestGetNicName(t *testing.T) { outputExp: "", inpBrName: "testPortName", onRetArgsExecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("port1")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("internal")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("port1")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("internal")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, }, { @@ -111,16 +111,16 @@ func TestGetNicName(t *testing.T) { outputExp: "Name", inpBrName: "brName", onRetArgsExecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("port1")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("internal")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("port1")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("internal")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, }, { @@ -128,16 +128,16 @@ func TestGetNicName(t *testing.T) { outputExp: "someoutput", inpBrName: "testName", onRetArgsExecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("port1")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("internal")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("someoutput")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("port1")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("internal")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("someoutput")), bytes.NewBuffer([]byte("")), nil}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, }, } @@ -438,8 +438,8 @@ func TestNicToBridge(t *testing.T) { desc: "RunOVSVsctl fails to create OVS bridge", inpIface: "eth0", errExp: true, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 31, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("RunOVSVsctl error")}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("RunOVSVsctl error")}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 33, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ {OnCallMethodName: "LinkByName", OnCallMethodArgType: []string{"string"}, RetArgList: []interface{}{mockLink, nil}}, }, @@ -451,8 +451,8 @@ func TestNicToBridge(t *testing.T) { desc: "IP address retrieval for link fails", inpIface: "eth0", errExp: true, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 31, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 33, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ {OnCallMethodName: "LinkByName", OnCallMethodArgType: []string{"string"}, RetArgList: []interface{}{mockLink, nil}}, {OnCallMethodName: "AddrList", OnCallMethodArgType: []string{"*mocks.Link", "int"}, RetArgList: []interface{}{nil, fmt.Errorf("mock error")}}, @@ -465,8 +465,8 @@ func TestNicToBridge(t *testing.T) { desc: "Route retrieval for link fails", inpIface: "eth0", errExp: true, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 31, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 33, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ {OnCallMethodName: "LinkByName", OnCallMethodArgType: []string{"string"}, RetArgList: []interface{}{mockLink, nil}}, {OnCallMethodName: "AddrList", OnCallMethodArgType: []string{"*mocks.Link", "int"}, RetArgList: []interface{}{[]netlink.Addr{{IPNet: ovntest.MustParseIPNet("192.168.1.15/24")}}, nil}}, @@ -479,8 +479,8 @@ func TestNicToBridge(t *testing.T) { { desc: "Retrieving link by bridge name fails", errExp: true, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 31, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 33, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ {OnCallMethodName: "LinkByName", OnCallMethodArgType: []string{"string"}, RetArgList: []interface{}{mockLink, nil}}, {OnCallMethodName: "AddrList", OnCallMethodArgType: []string{"*mocks.Link", "int"}, RetArgList: []interface{}{[]netlink.Addr{{IPNet: ovntest.MustParseIPNet("192.168.1.15/24")}}, nil}}, @@ -494,8 +494,8 @@ func TestNicToBridge(t *testing.T) { { desc: "Saving IP address to bridge fails", errExp: true, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 31, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 33, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ {OnCallMethodName: "LinkByName", OnCallMethodArgType: []string{"string"}, RetArgList: []interface{}{mockLink, nil}}, {OnCallMethodName: "AddrList", OnCallMethodArgType: []string{"*mocks.Link", "int"}, RetArgList: []interface{}{[]netlink.Addr{}, nil}}, @@ -510,8 +510,8 @@ func TestNicToBridge(t *testing.T) { { desc: "Saving routes to bridge fails", errExp: true, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 31, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 33, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ {OnCallMethodName: "LinkByName", OnCallMethodArgType: []string{"string"}, RetArgList: []interface{}{mockLink, nil}}, {OnCallMethodName: "AddrList", OnCallMethodArgType: []string{"*mocks.Link", "int"}, RetArgList: []interface{}{[]netlink.Addr{}, nil}}, @@ -527,8 +527,8 @@ func TestNicToBridge(t *testing.T) { }, { desc: "IP address and Routes of interface to OVS bridge succeeds", - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 31, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 32, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 33, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ {OnCallMethodName: "LinkByName", OnCallMethodArgType: []string{"string"}, RetArgList: []interface{}{mockLink, nil}}, {OnCallMethodName: "AddrList", OnCallMethodArgType: []string{"*mocks.Link", "int"}, RetArgList: []interface{}{[]netlink.Addr{}, nil}}, @@ -634,11 +634,11 @@ func TestBridgeToNic(t *testing.T) { // Below two entries are for mocking the `nicName, err := GetNicName(bridge)` code path onRetArgsExecUtilsIface: []ovntest.TestifyMockHelper{ //Below entry is for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ //Below entry is for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ // Below row entry is for mocking the `bridgeLink, err := netlink.LinkByName(bridge)` code path @@ -655,15 +655,15 @@ func TestBridgeToNic(t *testing.T) { errExp: true, onRetArgsExecUtilsIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ // Below row entry is for mocking the `bridgeLink, err := netlink.LinkByName(bridge)` code path @@ -683,14 +683,14 @@ func TestBridgeToNic(t *testing.T) { // Below two entries are for mocking the `nicName, err := GetNicName(bridge)` code path onRetArgsExecUtilsIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}}, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ // Below row entry is for mocking the `bridgeLink, err := netlink.LinkByName(bridge)` code path @@ -718,15 +718,15 @@ func TestBridgeToNic(t *testing.T) { // Below two entries are for mocking the `nicName, err := GetNicName(bridge)` code path onRetArgsExecUtilsIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ // Below row entry is for mocking the `bridgeLink, err := netlink.LinkByName(bridge)` code path @@ -761,19 +761,19 @@ func TestBridgeToNic(t *testing.T) { // Below two entries are for mocking the `nicName, err := GetNicName(bridge)` code path onRetArgsExecUtilsIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, //Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 3, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ // Below row entry is for mocking the `bridgeLink, err := netlink.LinkByName(bridge)` code path @@ -806,27 +806,27 @@ func TestBridgeToNic(t *testing.T) { errExp: true, onRetArgsExecUtilsIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 3, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("9d2bc35689fa975")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("9d2bc35689fa975")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "type")` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("--", "--if-exists", "del-br", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below rows are for mocking the three RunOVSVsctl executed inside the for loop that processes the interface list returned - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("--", "--if-exists", "del-br", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ // Below row entry is for mocking the `bridgeLink, err := netlink.LinkByName(bridge)` code path @@ -859,27 +859,27 @@ func TestBridgeToNic(t *testing.T) { errExp: true, onRetArgsExecUtilsIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 3, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("9d2bc35689fa975")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("9d2bc35689fa975")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "type")` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("internal")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("internal")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("--", "--if-exists", "del-br", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below rows are for mocking the three RunOVSVsctl executed inside the for loop that processes the interface list returned - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("--", "--if-exists", "del-br", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ // Below row entry is for mocking the `bridgeLink, err := netlink.LinkByName(bridge)` code path @@ -912,31 +912,31 @@ func TestBridgeToNic(t *testing.T) { errExp: true, onRetArgsExecUtilsIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 3, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("ovn-3e22f4-0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("ovn-3e22f4-0")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "type")` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("patch")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("patch")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "options:peer")` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("--", "--if-exists", "del-br", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below rows are for mocking the three RunOVSVsctl executed inside the for loop that processes the interface list returned - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "options:peer")` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("--", "--if-exists", "del-br", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ // Below row entry is for mocking the `bridgeLink, err := netlink.LinkByName(bridge)` code path @@ -969,35 +969,35 @@ func TestBridgeToNic(t *testing.T) { errExp: true, onRetArgsExecUtilsIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 3, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("ovn-3e22f4-0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("ovn-3e22f4-0")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "type")` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("patch")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("patch")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "options:peer")` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `_, stderr, err = RunOVSVsctl("--if-exists", "del-port", "br-int", peer)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("--", "--if-exists", "del-br", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below rows are for mocking the three RunOVSVsctl executed inside the for loop that processes the interface list returned - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "options:peer")` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `_, stderr, err = RunOVSVsctl("--if-exists", "del-port", "br-int", peer)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("--", "--if-exists", "del-br", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ // Below row entry is for mocking the `bridgeLink, err := netlink.LinkByName(bridge)` code path @@ -1030,35 +1030,35 @@ func TestBridgeToNic(t *testing.T) { errExp: true, onRetArgsExecUtilsIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 3, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("ovn-3e22f4-0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("ovn-3e22f4-0")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "type")` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("patch")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("patch")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "options:peer")` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `_, stderr, err = RunOVSVsctl("--if-exists", "del-port", "br-int", peer)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("--", "--if-exists", "del-br", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("mock error")}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below rows are for mocking the three RunOVSVsctl executed inside the for loop that processes the interface list returned - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "options:peer")` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `_, stderr, err = RunOVSVsctl("--if-exists", "del-port", "br-int", peer)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("--", "--if-exists", "del-br", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ // Below row entry is for mocking the `bridgeLink, err := netlink.LinkByName(bridge)` code path @@ -1090,35 +1090,35 @@ func TestBridgeToNic(t *testing.T) { inpBridge: "breth0", onRetArgsExecUtilsIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("eth0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("[080841d8-4e12-4003-b0ac-36fefd63bae1]")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("system")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 3, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("ovn-3e22f4-0")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("ovn-3e22f4-0")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "type")` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("patch")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("patch")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "options:peer")` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `_, stderr, err = RunOVSVsctl("--if-exists", "del-port", "br-int", peer)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("--", "--if-exists", "del-br", bridge)` code path - {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + {OnCallMethodName: "RunCmd", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, }, onRetArgsKexecIface: []ovntest.TestifyMockHelper{ //Below three entries are for mocking the `nicName, err := GetNicName(bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err := RunOVSVsctl("list-ifaces", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 4, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 5, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below rows are for mocking the three RunOVSVsctl executed inside the for loop that processes the interface list returned - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("get", "interface", iface, "options:peer")` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `_, stderr, err = RunOVSVsctl("--if-exists", "del-port", "br-int", peer)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, // Below row is for mocking the `stdout, stderr, err = RunOVSVsctl("--", "--if-exists", "del-br", bridge)` code path - {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 6, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, + {OnCallMethodName: "Command", OnCallMethodsArgsStrTypeAppendCount: 7, OnCallMethodArgType: []string{}, RetArgList: []interface{}{mockCmd}}, }, onRetArgsNetLinkLibOpers: []ovntest.TestifyMockHelper{ // Below row entry is for mocking the `bridgeLink, err := netlink.LinkByName(bridge)` code path diff --git a/go-controller/pkg/util/ovs.go b/go-controller/pkg/util/ovs.go index b0e9fb0daca..54081859e6e 100644 --- a/go-controller/pkg/util/ovs.go +++ b/go-controller/pkg/util/ovs.go @@ -318,7 +318,7 @@ func RunOVSOfctl(args ...string) (string, string, error) { // RunOVSVsctl runs a command via ovs-vsctl. func RunOVSVsctl(args ...string) (string, string, error) { - cmdArgs := []string{fmt.Sprintf("--timeout=%d", ovsCommandTimeout)} + cmdArgs := []string{fmt.Sprintf("--timeout=%d", ovsCommandTimeout), "--retry"} cmdArgs = append(cmdArgs, args...) stdout, stderr, err := run(runner.vsctlPath, cmdArgs...) return strings.Trim(strings.TrimSpace(stdout.String()), "\""), stderr.String(), err diff --git a/go-controller/pkg/util/ovs_unit_test.go b/go-controller/pkg/util/ovs_unit_test.go index 4c12563abca..8ba35be9a3f 100644 --- a/go-controller/pkg/util/ovs_unit_test.go +++ b/go-controller/pkg/util/ovs_unit_test.go @@ -977,14 +977,14 @@ func TestRunOVSVsctl(t *testing.T) { { desc: "negative: run `ovs-vsctl` command", expectedErr: fmt.Errorf("failed to execute ovs-vsctl command"), - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string"}, RetArgList: []interface{}{nil, nil, fmt.Errorf("failed to execute ovs-vsctl command")}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string"}, RetArgList: []interface{}{nil, nil, fmt.Errorf("failed to execute ovs-vsctl command")}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, { desc: "positive: run `ovs-vsctl` ", expectedErr: nil, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("testblah")), bytes.NewBuffer([]byte("")), nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("testblah")), bytes.NewBuffer([]byte("")), nil}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, } for i, tc := range tests { diff --git a/go-controller/pkg/util/util_unit_test.go b/go-controller/pkg/util/util_unit_test.go index 4e8437aa7aa..eaa508b790f 100644 --- a/go-controller/pkg/util/util_unit_test.go +++ b/go-controller/pkg/util/util_unit_test.go @@ -65,26 +65,26 @@ func TestGetNodeChassisID(t *testing.T) { { desc: "ovs-vsctl command returns error", errExpected: true, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("test error")}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("test error")}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, { desc: "ovs-vsctl command returns empty chassisID along with error", errExpected: true, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("test error")}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), fmt.Errorf("test error")}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, { desc: "ovs-vsctl command returns empty chassisID with NO error", errExpected: true, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("")), bytes.NewBuffer([]byte("")), nil}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, { desc: "ovs-vsctl command returns valid chassisID", errExpected: false, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("4e98c281-f12b-4601-ab5a-a3d759fcb493")), bytes.NewBuffer([]byte("")), nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, + onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("4e98c281-f12b-4601-ab5a-a3d759fcb493")), bytes.NewBuffer([]byte("")), nil}}, + onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string", "string", "string", "string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, }, }