@@ -121,12 +121,14 @@ func TestTransparentVlanAddEndpoints(t *testing.T) {
121
121
nl := netlink .NewMockNetlink (false , "" )
122
122
plc := platform .NewMockExecClient (false )
123
123
124
- tests := []struct {
125
- name string
126
- client * TransparentVlanEndpointClient
127
- epInfo * EndpointInfo
128
- wantErr bool
129
- wantErrMsg string
124
+ setLinkNetNSTests := []struct {
125
+ name string
126
+ client * TransparentVlanEndpointClient
127
+ epInfo * EndpointInfo
128
+ moveInterface string
129
+ moveNS string
130
+ wantErr bool
131
+ wantErrMsg string
130
132
}{
131
133
// Set the link network namespace and confirm that it was moved inside
132
134
{
@@ -143,8 +145,10 @@ func TestTransparentVlanAddEndpoints(t *testing.T) {
143
145
netioshim : netio .NewMockNetIO (false , 0 ),
144
146
nsClient : NewMockNamespaceClient (),
145
147
},
146
- epInfo : & EndpointInfo {},
147
- wantErr : false ,
148
+ moveInterface : "eth0.1" ,
149
+ moveNS : "az_ns_1" ,
150
+ epInfo : & EndpointInfo {},
151
+ wantErr : false ,
148
152
},
149
153
{
150
154
name : "Set link netns fail to set" ,
@@ -160,9 +164,11 @@ func TestTransparentVlanAddEndpoints(t *testing.T) {
160
164
netioshim : netio .NewMockNetIO (false , 0 ),
161
165
nsClient : NewMockNamespaceClient (),
162
166
},
163
- epInfo : & EndpointInfo {},
164
- wantErr : true ,
165
- wantErrMsg : "failed to set eth0.1" ,
167
+ moveInterface : "A1veth0" ,
168
+ moveNS : "az_ns_2" ,
169
+ epInfo : & EndpointInfo {},
170
+ wantErr : true ,
171
+ wantErrMsg : "failed to set A1veth0 inside namespace 1 (az_ns_2)" ,
166
172
},
167
173
{
168
174
name : "Set link netns fail to detect" ,
@@ -181,15 +187,17 @@ func TestTransparentVlanAddEndpoints(t *testing.T) {
181
187
},
182
188
nsClient : NewMockNamespaceClient (),
183
189
},
184
- epInfo : & EndpointInfo {},
185
- wantErr : true ,
186
- wantErrMsg : "failed to detect eth0.1" ,
190
+ moveInterface : "eth0.1" ,
191
+ moveNS : "az_ns_1" ,
192
+ epInfo : & EndpointInfo {},
193
+ wantErr : true ,
194
+ wantErrMsg : "failed to detect eth0.1 inside namespace 1 (az_ns_1)" ,
187
195
},
188
196
}
189
- for _ , tt := range tests {
197
+ for _ , tt := range setLinkNetNSTests {
190
198
tt := tt
191
199
t .Run (tt .name , func (t * testing.T ) {
192
- err := tt .client .setLinkNetNSAndConfirm (tt .client . vlanIfName , 1 , tt .client . vnetNSName )
200
+ err := tt .client .setLinkNetNSAndConfirm (tt .moveInterface , 1 , tt .moveNS )
193
201
if tt .wantErr {
194
202
require .Error (t , err )
195
203
require .Contains (t , err .Error (), tt .wantErrMsg , "Expected:%v actual:%v" , tt .wantErrMsg , err .Error ())
@@ -199,7 +207,7 @@ func TestTransparentVlanAddEndpoints(t *testing.T) {
199
207
})
200
208
}
201
209
202
- tests = []struct {
210
+ tests : = []struct {
203
211
name string
204
212
client * TransparentVlanEndpointClient
205
213
epInfo * EndpointInfo
@@ -256,7 +264,7 @@ func TestTransparentVlanAddEndpoints(t *testing.T) {
256
264
},
257
265
epInfo : & EndpointInfo {},
258
266
wantErr : true ,
259
- wantErrMsg : "failed to cleanup/delete ns after noticing vlan veth does not exist: netns failure: " + errNetnsMock .Error (),
267
+ wantErrMsg : "failed to cleanup/delete ns after noticing vlan interface does not exist: netns failure: " + errNetnsMock .Error (),
260
268
},
261
269
{
262
270
name : "Ensure clean populate VM cleanup straggling vlan if in vm ns" ,
@@ -380,7 +388,7 @@ func TestTransparentVlanAddEndpoints(t *testing.T) {
380
388
},
381
389
epInfo : & EndpointInfo {},
382
390
wantErr : true ,
383
- wantErrMsg : "failed to move or detect vnetVethName in vnet ns, deleting: failed to set A1veth0 inside namespace 1: " + netlink .ErrorMockNetlink .Error () + " : netlink fail" ,
391
+ wantErrMsg : "failed to move or detect vnetVethName in vnet ns, deleting: failed to set A1veth0 inside namespace 1 (az_ns_1) : " + netlink .ErrorMockNetlink .Error () + " : netlink fail" ,
384
392
},
385
393
{
386
394
name : "Add endpoints get interface fail for primary interface (eth0)" ,
@@ -528,7 +536,7 @@ func TestTransparentVlanAddEndpoints(t *testing.T) {
528
536
wantErr : false ,
529
537
},
530
538
{
531
- name : "Add endpoints fail check vlan veth exists" ,
539
+ name : "Add endpoints fail check vlan interface exists" ,
532
540
client : & TransparentVlanEndpointClient {
533
541
primaryHostIfName : "eth0" ,
534
542
vlanIfName : "eth0.1" ,
@@ -542,7 +550,7 @@ func TestTransparentVlanAddEndpoints(t *testing.T) {
542
550
},
543
551
epInfo : & EndpointInfo {},
544
552
wantErr : true ,
545
- wantErrMsg : "vlan veth doesn't exist: " + netio .ErrMockNetIOFail .Error () + ":eth0.1" ,
553
+ wantErrMsg : "vlan interface doesn't exist: " + netio .ErrMockNetIOFail .Error () + ":eth0.1" ,
546
554
},
547
555
{
548
556
name : "Add endpoints fail check vnet veth exists" ,
0 commit comments