@@ -12,6 +12,7 @@ import (
1212 "github.com/Azure/azure-container-networking/store"
1313)
1414
15+ // getMockStore creates a mock KeyValueStore with some endpoint state
1516func getMockStore () store.KeyValueStore {
1617 mockStore := store .NewMockStore ("" )
1718 endpointState := map [string ]* restserver.EndpointInfo {
@@ -67,13 +68,15 @@ func (m *MockCNIConflistGenerator) Close() error {
6768 return nil
6869}
6970
71+ // TestNodeSubnet tests initialization of NodeSubnet with endpoint info, and verfies that
72+ // the conflist is generated after fetching secondary IPs
7073func TestNodeSubnet (t * testing.T ) {
7174 podInfoByIPProvider , err := cnireconciler .NewCNSPodInfoProvider (getMockStore ())
7275 if err != nil {
7376 t .Fatalf ("NewCNSPodInfoProvider returned an error: %v" , err )
7477 }
7578
76- // Create a real HTTPRestService object
79+ // create a real HTTPRestService object
7780 mockCNIConflistGenerator := & MockCNIConflistGenerator {
7881 GenerateCalled : make (chan struct {}),
7982 }
@@ -111,6 +114,7 @@ func TestNodeSubnet(t *testing.T) {
111114 checkIPassignment (t , service , expectedIPs )
112115}
113116
117+ // checkIPassignment checks whether the IP assignment state in the HTTPRestService object matches expectation
114118func checkIPassignment (t * testing.T , service * restserver.HTTPRestService , expectedIPs map [string ]types.IPState ) {
115119 if len (service .PodIPConfigState ) != len (expectedIPs ) {
116120 t .Fatalf ("expected 2 entries in PodIPConfigState, got %d" , len (service .PodIPConfigState ))
0 commit comments