@@ -21,18 +21,20 @@ import (
2121 "github.com/Azure/azure-container-networking/common"
2222)
2323
24- var ipamQueryUrl = "localhost:42424"
25- var ipamQueryResponse = "" +
26- "<Interfaces>" +
27- " <Interface MacAddress=\" *\" IsPrimary=\" true\" >" +
28- " <IPSubnet Prefix=\" 10.0.0.0/16\" >" +
29- " <IPAddress Address=\" 10.0.0.4\" IsPrimary=\" true\" />" +
30- " <IPAddress Address=\" 10.0.0.5\" IsPrimary=\" false\" />" +
31- " <IPAddress Address=\" 10.0.0.6\" IsPrimary=\" false\" />" +
32- " <IPAddress Address=\" 10.0.0.7\" IsPrimary=\" false\" />" +
33- " </IPSubnet>" +
34- " </Interface>" +
35- "</Interfaces>"
24+ var (
25+ ipamQueryUrl = "localhost:42424"
26+ ipamQueryResponse = "" +
27+ "<Interfaces>" +
28+ " <Interface MacAddress=\" *\" IsPrimary=\" true\" >" +
29+ " <IPSubnet Prefix=\" 10.0.0.0/16\" >" +
30+ " <IPAddress Address=\" 10.0.0.4\" IsPrimary=\" true\" />" +
31+ " <IPAddress Address=\" 10.0.0.5\" IsPrimary=\" false\" />" +
32+ " <IPAddress Address=\" 10.0.0.6\" IsPrimary=\" false\" />" +
33+ " <IPAddress Address=\" 10.0.0.7\" IsPrimary=\" false\" />" +
34+ " </IPSubnet>" +
35+ " </Interface>" +
36+ "</Interfaces>"
37+ )
3638
3739func TestIpam (t * testing.T ) {
3840 RegisterFailHandler (Fail )
@@ -73,11 +75,11 @@ var (
7375 err error
7476 endpointID1 = uuid .New ().String ()
7577
76- //this usedAddresses map is to test not duplicate IP's
78+ // this usedAddresses map is to test not duplicate IP's
7779 // have been provided throughout this test execution
7880 UsedAddresses = map [string ]string {}
7981
80- //below is the network,used to test if the IP's provided by IPAM
82+ // below is the network,used to test if the IP's provided by IPAM
8183 // is in the the space requested.
8284 network = net.IPNet {IP : net .ParseIP ("10.0.0.0" ), Mask : net .CIDRMask (16 , 32 )}
8385
@@ -104,9 +106,7 @@ var (
104106 })
105107
106108 _ = Describe ("Test IPAM" , func () {
107-
108109 Context ("IPAM start" , func () {
109-
110110 var config common.PluginConfig
111111
112112 It ("Create IPAM plugin" , func () {
@@ -127,7 +127,6 @@ var (
127127 })
128128
129129 Describe ("Test IPAM ADD and DELETE pool" , func () {
130-
131130 var result * cniTypesCurr.Result
132131
133132 Context ("When ADD with nothing, call for ipam triggering request pool and address" , func () {
@@ -153,7 +152,6 @@ var (
153152 Expect (err ).ShouldNot (HaveOccurred ())
154153
155154 delete (UsedAddresses , result .IPs [0 ].Address .IP .String ())
156-
157155 })
158156 })
159157
@@ -167,7 +165,6 @@ var (
167165 })
168166
169167 Describe ("Test IPAM ADD and DELETE address" , func () {
170-
171168 Context ("When address is given" , func () {
172169 It ("Request pool and address successfully" , func () {
173170 arg .StdinData = getStdinData ("0.4.0" , "" , "10.0.0.6" )
@@ -217,14 +214,13 @@ var (
217214
218215 AssertProperAddressSpace (result .IPs [0 ].Address )
219216
220- //release the container ID for next test
217+ // release the container ID for next test
221218 arg .ContainerID = ""
222219 })
223220 })
224221 })
225222
226223 Describe ("Test IPAM DELETE" , func () {
227-
228224 Context ("Delete when only container id is given" , func () {
229225 It ("Deleted" , func () {
230226 arg .StdinData = getStdinData ("0.4.0" , "10.0.0.0/16" , "" )
@@ -236,13 +232,11 @@ var (
236232 address := UsedAddresses [arg .ContainerID ]
237233
238234 RemoveAddressUsage (address , arg .ContainerID )
239-
240235 })
241236 })
242237
243238 Context ("When address and subnet is given" , func () {
244239 It ("Release address successfully" , func () {
245-
246240 nextAddress := GetNextAddress ()
247241 arg .StdinData = getStdinData ("0.4.0" , "10.0.0.0/16" , nextAddress )
248242 err = plugin .Delete (arg )
@@ -291,15 +285,15 @@ var (
291285)
292286
293287func GetNextAddress () string {
294- //return first value
288+ // return first value
295289 for a := range UsedAddresses {
296290 return a
297291 }
298292 return ""
299293}
300294
301295func AssertAddressNotInUse (address string ) {
302- //confirm if IP is in use by other invocation
296+ // confirm if IP is in use by other invocation
303297 _ , exists := UsedAddresses [address ]
304298
305299 Expect (exists ).Should (BeFalse ())
@@ -325,7 +319,7 @@ func RemoveAddressUsage(address, containerId string) {
325319}
326320
327321func AssertProperAddressSpace (address net.IPNet ) {
328- //validate the IP is part of this network IP space
322+ // validate the IP is part of this network IP space
329323 Expect (network .Contains (address .IP )).Should (Equal (true ))
330324 Expect (address .Mask ).Should (Equal (network .Mask ))
331325}
0 commit comments