Skip to content

Commit 383045c

Browse files
update set registry keys
1 parent 15e66d7 commit 383045c

File tree

10 files changed

+443
-272
lines changed

10 files changed

+443
-272
lines changed

cns/kubecontroller/nodenetworkconfig/conversion_linux_test.go

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,115 @@ var validVNETBlockRequest = &cns.CreateNetworkContainerRequest{
101101
},
102102
},
103103
}
104+
105+
var validVNETBlockRequestSwiftV2 = &cns.CreateNetworkContainerRequest{
106+
Version: strconv.FormatInt(version, 10),
107+
HostPrimaryIP: vnetBlockNodeIP,
108+
IPConfiguration: cns.IPConfiguration{
109+
GatewayIPAddress: vnetBlockDefaultGateway,
110+
IPSubnet: cns.IPSubnet{
111+
PrefixLength: uint8(vnetBlockSubnetPrefixLen),
112+
IPAddress: vnetBlockNodeIP,
113+
},
114+
},
115+
NetworkContainerid: ncID,
116+
NetworkContainerType: cns.Docker,
117+
SecondaryIPConfigs: map[string]cns.SecondaryIPConfig{
118+
"10.224.0.8": {
119+
IPAddress: "10.224.0.8",
120+
NCVersion: version,
121+
},
122+
"10.224.0.9": {
123+
IPAddress: "10.224.0.9",
124+
NCVersion: version,
125+
},
126+
"10.224.0.10": {
127+
IPAddress: "10.224.0.10",
128+
NCVersion: version,
129+
},
130+
"10.224.0.11": {
131+
IPAddress: "10.224.0.11",
132+
NCVersion: version,
133+
},
134+
"10.224.0.12": {
135+
IPAddress: "10.224.0.12",
136+
NCVersion: version,
137+
},
138+
"10.224.0.13": {
139+
IPAddress: "10.224.0.13",
140+
NCVersion: version,
141+
},
142+
"10.224.0.14": {
143+
IPAddress: "10.224.0.14",
144+
NCVersion: version,
145+
},
146+
"10.224.0.15": {
147+
IPAddress: "10.224.0.15",
148+
NCVersion: version,
149+
},
150+
},
151+
SwiftV2PrefixOnNic: true,
152+
}
153+
154+
var swiftV2EnabledVNETBlockRequest = &cns.CreateNetworkContainerRequest{
155+
NetworkContainerid: ncID,
156+
NetworkContainerType: cns.Docker,
157+
Version: "1",
158+
HostPrimaryIP: "10.0.0.1",
159+
IPConfiguration: cns.IPConfiguration{
160+
IPSubnet: cns.IPSubnet{
161+
IPAddress: "10.0.0.1",
162+
PrefixLength: 24,
163+
},
164+
GatewayIPAddress: "10.0.0.1",
165+
},
166+
SecondaryIPConfigs: map[string]cns.SecondaryIPConfig{},
167+
SwiftV2PrefixOnNic: true,
168+
NCStatus: "Available",
169+
}
170+
171+
var swiftV2DisabledVNETBlockRequest = &cns.CreateNetworkContainerRequest{
172+
NetworkContainerid: ncID,
173+
NetworkContainerType: cns.Docker,
174+
Version: "1",
175+
HostPrimaryIP: "10.0.0.1",
176+
IPConfiguration: cns.IPConfiguration{
177+
IPSubnet: cns.IPSubnet{
178+
IPAddress: "10.0.0.1",
179+
PrefixLength: 24,
180+
},
181+
GatewayIPAddress: "10.0.0.1",
182+
},
183+
SecondaryIPConfigs: map[string]cns.SecondaryIPConfig{
184+
"10.0.0.0": {
185+
IPAddress: "10.0.0.0",
186+
NCVersion: 1,
187+
},
188+
"10.0.0.10": {
189+
IPAddress: "10.0.0.10",
190+
NCVersion: 1,
191+
},
192+
},
193+
NCStatus: "Available",
194+
}
195+
196+
var swiftV2DisabledNonVNETBlockRequest = &cns.CreateNetworkContainerRequest{
197+
NetworkContainerid: ncID,
198+
NetworkContainerType: cns.Docker,
199+
Version: "0",
200+
HostPrimaryIP: "10.0.0.1",
201+
IPConfiguration: cns.IPConfiguration{
202+
IPSubnet: cns.IPSubnet{
203+
IPAddress: "10.0.0.0",
204+
PrefixLength: 24,
205+
},
206+
GatewayIPAddress: "10.0.0.1",
207+
},
208+
SecondaryIPConfigs: map[string]cns.SecondaryIPConfig{
209+
"10.0.0.0": {
210+
IPAddress: "10.0.0.0",
211+
NCVersion: 0,
212+
},
213+
},
214+
NCStatus: "Available",
215+
}

cns/kubecontroller/nodenetworkconfig/conversion_test.go

Lines changed: 29 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,18 @@ func TestCreateNCRequestFromDynamicNC(t *testing.T) {
229229

230230
func TestCreateNCRequestFromStaticNC(t *testing.T) {
231231
tests := []struct {
232-
name string
233-
input v1alpha.NetworkContainer
234-
want *cns.CreateNetworkContainerRequest
235-
wantErr bool
232+
name string
233+
input v1alpha.NetworkContainer
234+
isSwiftV2 bool
235+
want *cns.CreateNetworkContainerRequest
236+
wantErr bool
236237
}{
237238
{
238-
name: "valid overlay",
239-
input: validOverlayNC,
240-
wantErr: false,
241-
want: validOverlayRequest,
239+
name: "valid overlay",
240+
input: validOverlayNC,
241+
isSwiftV2: false,
242+
wantErr: false,
243+
want: validOverlayRequest,
242244
},
243245
{
244246
name: "malformed primary IP",
@@ -303,10 +305,18 @@ func TestCreateNCRequestFromStaticNC(t *testing.T) {
303305
},
304306
// VNET Block test cases
305307
{
306-
name: "valid VNET Block",
307-
input: validVNETBlockNC,
308-
wantErr: false,
309-
want: validVNETBlockRequest,
308+
name: "valid VNET Block",
309+
input: validVNETBlockNC,
310+
isSwiftV2: false,
311+
wantErr: false,
312+
want: validVNETBlockRequest,
313+
},
314+
{
315+
name: "valid VNET Block with SwiftV2",
316+
input: validVNETBlockNC,
317+
isSwiftV2: true,
318+
wantErr: false,
319+
want: validVNETBlockRequestSwiftV2,
310320
},
311321
{
312322
name: "PrimaryIP is not CIDR",
@@ -340,7 +350,7 @@ func TestCreateNCRequestFromStaticNC(t *testing.T) {
340350
for _, tt := range tests {
341351
tt := tt
342352
t.Run(tt.name, func(t *testing.T) {
343-
got, err := CreateNCRequestFromStaticNC(tt.input, false)
353+
got, err := CreateNCRequestFromStaticNC(tt.input, tt.isSwiftV2)
344354
if tt.wantErr {
345355
assert.Error(t, err)
346356
return
@@ -372,25 +382,8 @@ func TestCreateNCRequestFromStaticNCWithConfig(t *testing.T) {
372382
Status: "Available",
373383
},
374384
isSwiftV2: true,
375-
want: &cns.CreateNetworkContainerRequest{
376-
NetworkContainerid: ncID,
377-
NetworkContainerType: cns.Docker,
378-
Version: "1",
379-
HostPrimaryIP: "10.0.0.1",
380-
IPConfiguration: cns.IPConfiguration{
381-
IPSubnet: cns.IPSubnet{
382-
IPAddress: "10.0.0.1",
383-
PrefixLength: 24,
384-
},
385-
GatewayIPAddress: "10.0.0.1",
386-
},
387-
SecondaryIPConfigs: map[string]cns.SecondaryIPConfig{
388-
// No IPs from primary prefix
389-
},
390-
SwiftV2PrefixOnNic: true,
391-
NCStatus: "Available",
392-
},
393-
wantErr: false,
385+
want: swiftV2EnabledVNETBlockRequest,
386+
wantErr: false,
394387
},
395388
{
396389
name: "SwiftV2 disabled with VNETBlock - should process all IP in prefix",
@@ -411,26 +404,8 @@ func TestCreateNCRequestFromStaticNCWithConfig(t *testing.T) {
411404
},
412405
},
413406
isSwiftV2: false,
414-
want: &cns.CreateNetworkContainerRequest{
415-
NetworkContainerid: ncID,
416-
NetworkContainerType: cns.Docker,
417-
Version: "1",
418-
HostPrimaryIP: "10.0.0.1",
419-
IPConfiguration: cns.IPConfiguration{
420-
IPSubnet: cns.IPSubnet{
421-
IPAddress: "10.0.0.1",
422-
PrefixLength: 24,
423-
},
424-
GatewayIPAddress: "10.0.0.1",
425-
},
426-
SecondaryIPConfigs: map[string]cns.SecondaryIPConfig{
427-
"10.0.0.0": {IPAddress: "10.0.0.0", NCVersion: 1},
428-
// IP assignments
429-
"10.0.0.10": {IPAddress: "10.0.0.10", NCVersion: 1},
430-
},
431-
NCStatus: "Available",
432-
},
433-
wantErr: false,
407+
want: swiftV2DisabledVNETBlockRequest,
408+
wantErr: false,
434409
},
435410
{
436411
name: "SwiftV2 disabled with non-VNETBlock type - should process IP in prefix",
@@ -451,24 +426,8 @@ func TestCreateNCRequestFromStaticNCWithConfig(t *testing.T) {
451426
},
452427
},
453428
isSwiftV2: false,
454-
want: &cns.CreateNetworkContainerRequest{
455-
NetworkContainerid: ncID,
456-
NetworkContainerType: cns.Docker,
457-
Version: "0",
458-
HostPrimaryIP: "10.0.0.1",
459-
IPConfiguration: cns.IPConfiguration{
460-
IPSubnet: cns.IPSubnet{
461-
IPAddress: "10.0.0.0",
462-
PrefixLength: 24,
463-
},
464-
GatewayIPAddress: "10.0.0.1",
465-
},
466-
SecondaryIPConfigs: map[string]cns.SecondaryIPConfig{
467-
"10.0.0.0": {IPAddress: "10.0.0.0", NCVersion: 0},
468-
},
469-
NCStatus: "Available",
470-
},
471-
wantErr: false,
429+
want: swiftV2DisabledNonVNETBlockRequest,
430+
wantErr: false,
472431
},
473432
}
474433

cns/kubecontroller/nodenetworkconfig/conversion_windows_test.go

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var validVNETBlockRequest = &cns.CreateNetworkContainerRequest{
3232
GatewayIPAddress: vnetBlockDefaultGateway,
3333
IPSubnet: cns.IPSubnet{
3434
PrefixLength: uint8(vnetBlockSubnetPrefixLen),
35-
IPAddress: vnetBlockPrimaryIP,
35+
IPAddress: vnetBlockNodeIP,
3636
},
3737
},
3838
NetworkContainerid: ncID,
@@ -80,5 +80,95 @@ var validVNETBlockRequest = &cns.CreateNetworkContainerRequest{
8080
NCVersion: version,
8181
},
8282
},
83+
SwiftV2PrefixOnNic: false,
84+
}
85+
86+
var validVNETBlockRequestSwiftV2 = &cns.CreateNetworkContainerRequest{
87+
Version: strconv.FormatInt(version, 10),
88+
IPConfiguration: cns.IPConfiguration{
89+
GatewayIPAddress: vnetBlockDefaultGateway,
90+
IPSubnet: cns.IPSubnet{
91+
PrefixLength: uint8(vnetBlockSubnetPrefixLen),
92+
IPAddress: vnetBlockNodeIP,
93+
},
94+
},
95+
NetworkContainerid: ncID,
96+
NetworkContainerType: cns.Docker,
97+
SecondaryIPConfigs: map[string]cns.SecondaryIPConfig{
98+
"10.224.0.8": {
99+
IPAddress: "10.224.0.8",
100+
NCVersion: version,
101+
},
102+
"10.224.0.9": {
103+
IPAddress: "10.224.0.9",
104+
NCVersion: version,
105+
},
106+
"10.224.0.10": {
107+
IPAddress: "10.224.0.10",
108+
NCVersion: version,
109+
},
110+
"10.224.0.11": {
111+
IPAddress: "10.224.0.11",
112+
NCVersion: version,
113+
},
114+
"10.224.0.12": {
115+
IPAddress: "10.224.0.12",
116+
NCVersion: version,
117+
},
118+
"10.224.0.13": {
119+
IPAddress: "10.224.0.13",
120+
NCVersion: version,
121+
},
122+
"10.224.0.14": {
123+
IPAddress: "10.224.0.14",
124+
NCVersion: version,
125+
},
126+
},
127+
SwiftV2PrefixOnNic: true,
128+
}
129+
130+
var swiftV2EnabledVNETBlockRequest = &cns.CreateNetworkContainerRequest{
131+
NetworkContainerid: ncID,
132+
NetworkContainerType: cns.Docker,
133+
Version: "1",
134+
IPConfiguration: cns.IPConfiguration{
135+
IPSubnet: cns.IPSubnet{
136+
IPAddress: "10.0.0.1",
137+
PrefixLength: 24,
138+
},
139+
GatewayIPAddress: "10.0.0.1",
140+
},
141+
SecondaryIPConfigs: map[string]cns.SecondaryIPConfig{},
83142
SwiftV2PrefixOnNic: true,
143+
NCStatus: "Available",
144+
}
145+
146+
var swiftV2DisabledVNETBlockRequest = &cns.CreateNetworkContainerRequest{
147+
NetworkContainerid: ncID,
148+
NetworkContainerType: cns.Docker,
149+
Version: "1",
150+
IPConfiguration: cns.IPConfiguration{
151+
IPSubnet: cns.IPSubnet{
152+
IPAddress: "10.0.0.1",
153+
PrefixLength: 24,
154+
},
155+
GatewayIPAddress: "10.0.0.1",
156+
},
157+
SecondaryIPConfigs: map[string]cns.SecondaryIPConfig{},
158+
NCStatus: "Available",
159+
}
160+
161+
var swiftV2DisabledNonVNETBlockRequest = &cns.CreateNetworkContainerRequest{
162+
NetworkContainerid: ncID,
163+
NetworkContainerType: cns.Docker,
164+
Version: "0",
165+
IPConfiguration: cns.IPConfiguration{
166+
IPSubnet: cns.IPSubnet{
167+
IPAddress: "10.0.0.0",
168+
PrefixLength: 24,
169+
},
170+
GatewayIPAddress: "10.0.0.1",
171+
},
172+
SecondaryIPConfigs: map[string]cns.SecondaryIPConfig{},
173+
NCStatus: "Available",
84174
}

0 commit comments

Comments
 (0)