@@ -67,16 +67,16 @@ func TestReconcileNCStatePrimaryIPChangeShouldFail(t *testing.T) {
6767 svc .state .ContainerStatus = make (map [string ]containerstatus )
6868
6969 testCases := []struct {
70- existingIPAddress string
71- requestIPAddress string
70+ reqIPAddress string
71+ reqPrefixLength uint8
72+ existingIPAddress string
73+ existingPrefixLength uint8
7274 }{
73- {"" , "10.240.0.0/16" },
74- {"10.240.0.0" , "2001:db8::/64" },
75- {"2001:db8::/64" , "10.240.0.0/16" },
76- {"10.0.1.0/22" , "10.0.2.0/24" },
77- {"10.0.1.0/21" , "10.0.1.0/23" },
78- {"10.0.1.0" , "10.0.0.0/15" },
79- {"10.0.1.0/15" , "10.0.0.0" },
75+ {"10.240.1.0" , 16 , "10.240.0.0" , 16 },
76+ {"10.240.0.0" , 64 , "2001:db8::" , 64 },
77+ {"2001:db8::" , 64 , "10.240.0.0" , 16 },
78+ {"10.0.1.0" , 24 , "10.0.2.0" , 22 },
79+ {"10.0.1.0" , 23 , "10.0.1.0" , 21 },
8080 }
8181
8282 // Run test cases
@@ -92,7 +92,7 @@ func TestReconcileNCStatePrimaryIPChangeShouldFail(t *testing.T) {
9292 IPConfiguration : cns.IPConfiguration {
9393 IPSubnet : cns.IPSubnet {
9494 IPAddress : tc .existingIPAddress ,
95- PrefixLength : 24 ,
95+ PrefixLength : tc . existingPrefixLength ,
9696 },
9797 },
9898 },
@@ -103,8 +103,8 @@ func TestReconcileNCStatePrimaryIPChangeShouldFail(t *testing.T) {
103103 NetworkContainerid : ncID ,
104104 IPConfiguration : cns.IPConfiguration {
105105 IPSubnet : cns.IPSubnet {
106- IPAddress : tc .requestIPAddress ,
107- PrefixLength : 24 ,
106+ IPAddress : tc .reqIPAddress ,
107+ PrefixLength : tc . reqPrefixLength ,
108108 },
109109 },
110110 },
@@ -127,13 +127,17 @@ func TestReconcileNCStatePrimaryIPChangeShouldNotFail(t *testing.T) {
127127 svc .state .ContainerStatus = make (map [string ]containerstatus )
128128
129129 testCases := []struct {
130- existingIPAddress string
131- requestIPAddress string
130+ reqIPAddress string
131+ reqPrefixLength uint8
132+ existingIPAddress string
133+ existingPrefixLength uint8
132134 }{
133- {"10.0.1.0/24" , "10.0.2.0/22" },
134- {"10.0.1.0/20" , "10.0.1.0/18" },
135- {"10.0.1.0/19" , "10.0.0.0/15" },
136- {"10.0.1.0/18" , "10.0.1.0/18" },
135+ {"10.240.0.0" , 20 , "10.240.0.0" , 24 },
136+
137+ {"10.0.1.0" , 22 , "10.0.2.0" , 24 },
138+ {"10.0.1.0" , 18 , "10.0.1.0" , 20 },
139+ {"10.0.1.0" , 15 , "10.0.0.0" , 19 },
140+ {"10.0.1.0" , 18 , "10.0.1.0" , 18 },
137141 }
138142
139143 // Run test cases
@@ -149,7 +153,7 @@ func TestReconcileNCStatePrimaryIPChangeShouldNotFail(t *testing.T) {
149153 IPConfiguration : cns.IPConfiguration {
150154 IPSubnet : cns.IPSubnet {
151155 IPAddress : tc .existingIPAddress ,
152- PrefixLength : 24 ,
156+ PrefixLength : tc . existingPrefixLength ,
153157 },
154158 },
155159 },
@@ -160,8 +164,8 @@ func TestReconcileNCStatePrimaryIPChangeShouldNotFail(t *testing.T) {
160164 NetworkContainerid : ncID ,
161165 IPConfiguration : cns.IPConfiguration {
162166 IPSubnet : cns.IPSubnet {
163- IPAddress : tc .requestIPAddress ,
164- PrefixLength : 24 ,
167+ IPAddress : tc .reqIPAddress ,
168+ PrefixLength : tc . reqPrefixLength ,
165169 },
166170 },
167171 NetworkContainerType : cns .Kubernetes ,
0 commit comments