@@ -304,7 +304,7 @@ func TestCreateAndUpdateNCWithSecondaryIPNCVersion(t *testing.T) {
304304 }
305305}
306306
307- func TestSyncHostNCVersion (t * testing.T ) {
307+ func TestStartSyncHostNCVersionLoop (t * testing.T ) {
308308 // cns.KubernetesCRD has one more logic compared to other orchestrator type, so test both of them
309309 orchestratorTypes := []string {cns .Kubernetes , cns .KubernetesCRD }
310310 for _ , orchestratorType := range orchestratorTypes {
@@ -349,7 +349,12 @@ func TestSyncHostNCVersion(t *testing.T) {
349349 defer cleanupIMDS ()
350350
351351 // When syncing the host NC version, it will use the orchestratorType passed in.
352- svc .SyncHostNCVersion (context .Background (), orchestratorType )
352+ cnsconf := configuration.CNSConfig {
353+ SyncHostNCVersionIntervalMs : 100 ,
354+ ChannelMode : orchestratorType ,
355+ }
356+ svc .StartSyncHostNCVersionLoop (t .Context (), cnsconf )
357+ svc .ncSyncState .Wait (t .Context ()) // wait for at leat one run
353358 containerStatus = svc .state .ContainerStatus [req .NetworkContainerid ]
354359 if containerStatus .HostVersion != "0" {
355360 t .Errorf ("Unexpected containerStatus.HostVersion %s, expected host version should be 0 in string" , containerStatus .HostVersion )
@@ -400,7 +405,8 @@ func TestPendingIPsGotUpdatedWhenSyncHostNCVersion(t *testing.T) {
400405 cleanup := setMockNMAgent (svc , mnma )
401406 defer cleanup ()
402407
403- svc .SyncHostNCVersion (context .Background (), cns .CRD )
408+ svc .StartSyncHostNCVersionLoop (t .Context (), fastcnsconf )
409+ svc .ncSyncState .Wait (t .Context ()) // wait for at leat one run
404410 containerStatus = svc .state .ContainerStatus [req .NetworkContainerid ]
405411
406412 receivedSecondaryIPConfigs = containerStatus .CreateNetworkContainerRequest .SecondaryIPConfigs
0 commit comments