@@ -2,6 +2,7 @@ package dataplane
22
33import (
44 "testing"
5+ "time"
56
67 "github.com/Azure/azure-container-networking/common"
78 "github.com/Azure/azure-container-networking/npm/metrics"
@@ -79,8 +80,13 @@ func TestNewDataPlane(t *testing.T) {
7980 calls := getBootupTestCalls ()
8081 ioshim := common .NewMockIOShim (calls )
8182 defer ioshim .VerifyCalls (t , calls )
82- dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , nil )
83+ stopCh := make (chan struct {}, 1 )
84+ dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , stopCh )
8385 require .NoError (t , err )
86+ defer func () {
87+ stopCh <- struct {}{}
88+ time .Sleep (100 * time .Millisecond )
89+ }()
8490 assert .NotNil (t , dp )
8591}
8692
@@ -90,8 +96,13 @@ func TestCreateAndDeleteIpSets(t *testing.T) {
9096 calls := getBootupTestCalls ()
9197 ioshim := common .NewMockIOShim (calls )
9298 defer ioshim .VerifyCalls (t , calls )
93- dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , nil )
99+ stopCh := make (chan struct {}, 1 )
100+ dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , stopCh )
94101 require .NoError (t , err )
102+ defer func () {
103+ stopCh <- struct {}{}
104+ time .Sleep (100 * time .Millisecond )
105+ }()
95106 assert .NotNil (t , dp )
96107 setsTocreate := []* ipsets.IPSetMetadata {
97108 {
@@ -132,8 +143,13 @@ func TestAddToSet(t *testing.T) {
132143 calls := getBootupTestCalls ()
133144 ioshim := common .NewMockIOShim (calls )
134145 defer ioshim .VerifyCalls (t , calls )
135- dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , nil )
146+ stopCh := make (chan struct {}, 1 )
147+ dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , stopCh )
136148 require .NoError (t , err )
149+ defer func () {
150+ stopCh <- struct {}{}
151+ time .Sleep (100 * time .Millisecond )
152+ }()
137153
138154 setsTocreate := []* ipsets.IPSetMetadata {
139155 {
@@ -196,8 +212,13 @@ func TestApplyPolicy(t *testing.T) {
196212 calls := append (getBootupTestCalls (), getAddPolicyTestCallsForDP (& testPolicyobj )... )
197213 ioshim := common .NewMockIOShim (calls )
198214 defer ioshim .VerifyCalls (t , calls )
199- dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , nil )
215+ stopCh := make (chan struct {}, 1 )
216+ dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , stopCh )
200217 require .NoError (t , err )
218+ defer func () {
219+ stopCh <- struct {}{}
220+ time .Sleep (100 * time .Millisecond )
221+ }()
201222
202223 err = dp .AddPolicy (& testPolicyobj )
203224 require .NoError (t , err )
@@ -210,8 +231,13 @@ func TestRemovePolicy(t *testing.T) {
210231 calls = append (calls , getRemovePolicyTestCallsForDP (& testPolicyobj )... )
211232 ioshim := common .NewMockIOShim (calls )
212233 defer ioshim .VerifyCalls (t , calls )
213- dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , nil )
234+ stopCh := make (chan struct {}, 1 )
235+ dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , stopCh )
214236 require .NoError (t , err )
237+ defer func () {
238+ stopCh <- struct {}{}
239+ time .Sleep (100 * time .Millisecond )
240+ }()
215241
216242 err = dp .AddPolicy (& testPolicyobj )
217243 require .NoError (t , err )
@@ -234,8 +260,13 @@ func TestHandle2977(t *testing.T) {
234260 calls = append (calls , getAddPolicyTestCallsForDP (& testPolicyobj )... )
235261 ioshim := common .NewMockIOShim (calls )
236262 defer ioshim .VerifyCalls (t , calls )
237- dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , nil )
263+ stopCh := make (chan struct {}, 1 )
264+ dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , stopCh )
238265 require .NoError (t , err )
266+ defer func () {
267+ stopCh <- struct {}{}
268+ time .Sleep (100 * time .Millisecond )
269+ }()
239270
240271 err = dp .AddPolicy (& testPolicyobj )
241272 require .NoError (t , err )
@@ -263,8 +294,13 @@ func TestUpdatePolicy(t *testing.T) {
263294 calls = append (calls , getAddPolicyTestCallsForDP (& updatedTestPolicyobj )... )
264295 ioshim := common .NewMockIOShim (calls )
265296 defer ioshim .VerifyCalls (t , calls )
266- dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , nil )
297+ stopCh := make (chan struct {}, 1 )
298+ dp , err := NewDataPlane ("testnode" , ioshim , dpCfg , stopCh )
267299 require .NoError (t , err )
300+ defer func () {
301+ stopCh <- struct {}{}
302+ time .Sleep (100 * time .Millisecond )
303+ }()
268304
269305 err = dp .AddPolicy (& testPolicyobj )
270306 require .NoError (t , err )
0 commit comments