@@ -307,26 +307,22 @@ func TestAddMultipleNetworkPolicies(t *testing.T) {
307307
308308 if util .IsWindowsDP () {
309309 dp .EXPECT ().UpdatePolicy (gomock .Any ()).Times (0 )
310- addNetPol (f , netPolObj1 )
311- addNetPol (f , netPolObj2 )
312-
313- // already exists (will be a no-op)
314- addNetPol (f , netPolObj1 )
315310 // named ports are not allowed on windows
316311 testCases = []expectedNetPolValues {
317312 {0 , 0 , netPolPromVals {0 , 0 , 0 , 0 }},
318313 }
319314 } else {
320315 dp .EXPECT ().UpdatePolicy (gomock .Any ()).Times (2 )
321- addNetPol (f , netPolObj1 )
322- addNetPol (f , netPolObj2 )
323316
324- // already exists (will be a no-op)
325- addNetPol (f , netPolObj1 )
326317 testCases = []expectedNetPolValues {
327318 {2 , 0 , netPolPromVals {2 , 2 , 0 , 0 }},
328319 }
329320 }
321+ addNetPol (f , netPolObj1 )
322+ addNetPol (f , netPolObj2 )
323+
324+ // already exists (will be a no-op)
325+ addNetPol (f , netPolObj1 )
330326
331327 checkNetPolTestResult ("TestAddMultipleNetPols" , f , testCases )
332328}
@@ -349,19 +345,19 @@ func TestAddNetworkPolicy(t *testing.T) {
349345
350346 if util .IsWindowsDP () {
351347 dp .EXPECT ().UpdatePolicy (gomock .Any ()).Times (0 )
352- addNetPol (f , netPolObj )
353348 // named ports are not allowed on windows
354349 testCases = []expectedNetPolValues {
355350 {0 , 0 , netPolPromVals {0 , 0 , 0 , 0 }},
356351 }
357352 } else {
358353 dp .EXPECT ().UpdatePolicy (gomock .Any ()).Times (1 )
359354
360- addNetPol (f , netPolObj )
361355 testCases = []expectedNetPolValues {
362356 {1 , 0 , netPolPromVals {1 , 1 , 0 , 0 }},
363357 }
364358 }
359+ addNetPol (f , netPolObj )
360+
365361 checkNetPolTestResult ("TestAddNetPol" , f , testCases )
366362}
367363
@@ -459,19 +455,18 @@ func TestDeleteNetworkPolicy(t *testing.T) {
459455 dp .EXPECT ().UpdatePolicy (gomock .Any ()).Times (0 )
460456 dp .EXPECT ().RemovePolicy (gomock .Any ()).Times (0 )
461457
462- deleteNetPol (t , f , netPolObj , DeletedFinalStateknownObject )
463458 testCases = []expectedNetPolValues {
464459 {0 , 0 , netPolPromVals {0 , 0 , 0 , 0 }},
465460 }
466461 } else {
467462 dp .EXPECT ().UpdatePolicy (gomock .Any ()).Times (1 )
468463 dp .EXPECT ().RemovePolicy (gomock .Any ()).Times (1 )
469464
470- deleteNetPol (t , f , netPolObj , DeletedFinalStateknownObject )
471465 testCases = []expectedNetPolValues {
472466 {0 , 0 , netPolPromVals {0 , 1 , 0 , 1 }},
473467 }
474468 }
469+ deleteNetPol (t , f , netPolObj , DeletedFinalStateknownObject )
475470 checkNetPolTestResult ("TestDelNetPol" , f , testCases )
476471}
477472
@@ -522,19 +517,19 @@ func TestDeleteNetworkPolicyWithTombstoneAfterAddingNetworkPolicy(t *testing.T)
522517 dp .EXPECT ().UpdatePolicy (gomock .Any ()).Times (0 )
523518 dp .EXPECT ().RemovePolicy (gomock .Any ()).Times (0 )
524519
525- deleteNetPol (t , f , netPolObj , DeletedFinalStateUnknownObject )
526520 testCases = []expectedNetPolValues {
527521 {0 , 0 , netPolPromVals {0 , 0 , 0 , 0 }},
528522 }
529523 } else {
530524 dp .EXPECT ().UpdatePolicy (gomock .Any ()).Times (1 )
531525 dp .EXPECT ().RemovePolicy (gomock .Any ()).Times (1 )
532526
533- deleteNetPol (t , f , netPolObj , DeletedFinalStateUnknownObject )
534527 testCases = []expectedNetPolValues {
535528 {0 , 0 , netPolPromVals {0 , 1 , 0 , 1 }},
536529 }
537530 }
531+ deleteNetPol (t , f , netPolObj , DeletedFinalStateUnknownObject )
532+
538533 checkNetPolTestResult ("TestDeleteNetworkPolicyWithTombstoneAfterAddingNetworkPolicy" , f , testCases )
539534}
540535
@@ -563,18 +558,18 @@ func TestUpdateNetworkPolicy(t *testing.T) {
563558 if util .IsWindowsDP () {
564559 dp .EXPECT ().UpdatePolicy (gomock .Any ()).Times (0 )
565560
566- updateNetPol (t , f , oldNetPolObj , newNetPolObj )
567561 testCases = []expectedNetPolValues {
568562 {0 , 0 , netPolPromVals {0 , 0 , 0 , 0 }},
569563 }
570564 } else {
571565 dp .EXPECT ().UpdatePolicy (gomock .Any ()).Times (1 )
572566
573- updateNetPol (t , f , oldNetPolObj , newNetPolObj )
574567 testCases = []expectedNetPolValues {
575568 {1 , 0 , netPolPromVals {1 , 1 , 0 , 0 }},
576569 }
577570 }
571+ updateNetPol (t , f , oldNetPolObj , newNetPolObj )
572+
578573 checkNetPolTestResult ("TestUpdateNetPol" , f , testCases )
579574}
580575
@@ -609,19 +604,17 @@ func TestLabelUpdateNetworkPolicy(t *testing.T) {
609604 if util .IsWindowsDP () {
610605 dp .EXPECT ().UpdatePolicy (gomock .Any ()).Times (0 )
611606
612- updateNetPol (t , f , oldNetPolObj , newNetPolObj )
613-
614607 testCases = []expectedNetPolValues {
615608 {0 , 0 , netPolPromVals {0 , 0 , 0 , 0 }},
616609 }
617610 } else {
618611 dp .EXPECT ().UpdatePolicy (gomock .Any ()).Times (2 )
619612
620- updateNetPol (t , f , oldNetPolObj , newNetPolObj )
621-
622613 testCases = []expectedNetPolValues {
623614 {1 , 0 , netPolPromVals {1 , 1 , 1 , 0 }},
624615 }
625616 }
617+ updateNetPol (t , f , oldNetPolObj , newNetPolObj )
618+
626619 checkNetPolTestResult ("TestUpdateNetPol" , f , testCases )
627620}
0 commit comments