@@ -23,23 +23,53 @@ func (vcd *TestVCD) Test_AlbVirtualService(check *C) {
23
23
// Setup Org user and connection
24
24
adminOrg , err := vcd .client .GetAdminOrgByName (vcd .config .VCD .Org )
25
25
check .Assert (err , IsNil )
26
- orgUserVcdClient , err := newOrgUserConnection (adminOrg , "alb-virtual-service-testing" , "CHANGE-ME" , vcd .config .Provider .Url , true )
26
+ orgUserVcdClient , orgUser , err := newOrgUserConnection (adminOrg , "alb-virtual-service-testing" , "CHANGE-ME" , vcd .config .Provider .Url , true )
27
27
check .Assert (err , IsNil )
28
28
29
+ printVerbose ("# Running tests as Sysadmin user\n " )
29
30
// Run tests with System user
30
31
testMinimalVirtualServiceConfigHTTP (check , edge , albPool , seGroup , vcd , vcd .client )
31
32
testVirtualServiceConfigWithCertHTTPS (check , edge , albPool , seGroup , vcd , vcd .client )
32
33
testMinimalVirtualServiceConfigL4 (check , edge , albPool , seGroup , vcd , vcd .client )
33
34
testMinimalVirtualServiceConfigL4TLS (check , edge , albPool , seGroup , vcd , vcd .client )
34
35
36
+ printVerbose ("# Running tests as Org user\n " )
35
37
// Run tests with Org admin user
36
38
testMinimalVirtualServiceConfigHTTP (check , edge , albPool , seGroup , vcd , orgUserVcdClient )
37
39
testVirtualServiceConfigWithCertHTTPS (check , edge , albPool , seGroup , vcd , orgUserVcdClient )
38
40
testMinimalVirtualServiceConfigL4 (check , edge , albPool , seGroup , vcd , orgUserVcdClient )
39
41
testMinimalVirtualServiceConfigL4TLS (check , edge , albPool , seGroup , vcd , orgUserVcdClient )
40
42
43
+ // Test 10.4.1 Transparent mode on VCD >= 10.4.1
44
+ if vcd .client .Client .APIVCDMaxVersionIs (">= 37.1" ) {
45
+ printVerbose ("# Running 10.4.1+ tests as Sysadmin user\n " )
46
+
47
+ printVerbose ("## Creating ALB Pool with Member Group (VCD 10.4.1+) as Sysadmin\n " )
48
+ ipSet , poolWithMemberGroup := setupAlbPoolFirewallGroupMembers (check , vcd , edge )
49
+
50
+ testMinimalVirtualServiceConfigHTTPTransparent (check , edge , poolWithMemberGroup , seGroup , vcd , vcd .client , true )
51
+ testMinimalVirtualServiceConfigHTTPTransparent (check , edge , poolWithMemberGroup , seGroup , vcd , vcd .client , false )
52
+
53
+ printVerbose ("# Running 10.4.1+ tests as Org user\n " )
54
+
55
+ printVerbose ("## Creating ALB Pool with Member Group (VCD 10.4.1+) as Org user\n " )
56
+ testMinimalVirtualServiceConfigHTTPTransparent (check , edge , poolWithMemberGroup , seGroup , vcd , orgUserVcdClient , true )
57
+ testMinimalVirtualServiceConfigHTTPTransparent (check , edge , poolWithMemberGroup , seGroup , vcd , orgUserVcdClient , false )
58
+
59
+ // cleanup ipset and pool membership
60
+ err = poolWithMemberGroup .Delete ()
61
+ check .Assert (err , IsNil )
62
+
63
+ err = ipSet .Delete ()
64
+ check .Assert (err , IsNil )
65
+ }
66
+
41
67
// teardown prerequisites
42
68
tearDownAlbVirtualServicePrerequisites (check , albPool , seGroupAssignment , edge , seGroup , cloud , controller )
69
+
70
+ // cleanup Org user
71
+ err = orgUser .Delete (true )
72
+ check .Assert (err , IsNil )
43
73
}
44
74
45
75
func testMinimalVirtualServiceConfigHTTP (check * C , edge * NsxtEdgeGateway , pool * NsxtAlbPool , seGroup * NsxtAlbServiceEngineGroup , vcd * TestVCD , client * VCDClient ) {
@@ -94,6 +124,63 @@ func testMinimalVirtualServiceConfigHTTP(check *C, edge *NsxtEdgeGateway, pool *
94
124
testAlbVirtualServiceConfig (check , vcd , "MinimalHTTP" , virtualServiceConfig , virtualServiceConfigUpdated , client )
95
125
}
96
126
127
+ func testMinimalVirtualServiceConfigHTTPTransparent (check * C , edge * NsxtEdgeGateway , poolWithMemberGroup * NsxtAlbPool , seGroup * NsxtAlbServiceEngineGroup , vcd * TestVCD , client * VCDClient , trueOnCreate bool ) {
128
+ createTransparentMode := trueOnCreate
129
+ updateTransparentMode := ! createTransparentMode
130
+
131
+ virtualServiceConfig := & types.NsxtAlbVirtualService {
132
+ Name : check .TestName (),
133
+ Enabled : addrOf (true ),
134
+ TransparentModeEnabled : & createTransparentMode ,
135
+ ApplicationProfile : types.NsxtAlbVirtualServiceApplicationProfile {
136
+ SystemDefined : true ,
137
+ Type : "HTTP" ,
138
+ },
139
+ GatewayRef : types.OpenApiReference {ID : edge .EdgeGateway .ID },
140
+ LoadBalancerPoolRef : types.OpenApiReference {ID : poolWithMemberGroup .NsxtAlbPool .ID },
141
+ ServiceEngineGroupRef : types.OpenApiReference {ID : seGroup .NsxtAlbServiceEngineGroup .ID },
142
+ ServicePorts : []types.NsxtAlbVirtualServicePort {
143
+ {
144
+ PortStart : addrOf (80 ),
145
+ },
146
+ },
147
+ VirtualIpAddress : edge .EdgeGateway .EdgeGatewayUplinks [0 ].Subnets .Values [0 ].PrimaryIP ,
148
+ }
149
+
150
+ virtualServiceConfigUpdated := & types.NsxtAlbVirtualService {
151
+ Name : check .TestName (),
152
+ Description : "Updated" ,
153
+ Enabled : addrOf (true ),
154
+ TransparentModeEnabled : & updateTransparentMode ,
155
+ ApplicationProfile : types.NsxtAlbVirtualServiceApplicationProfile {
156
+ SystemDefined : true ,
157
+ Type : "HTTP" ,
158
+ },
159
+ GatewayRef : types.OpenApiReference {ID : edge .EdgeGateway .ID },
160
+ LoadBalancerPoolRef : types.OpenApiReference {ID : poolWithMemberGroup .NsxtAlbPool .ID },
161
+ ServiceEngineGroupRef : types.OpenApiReference {ID : seGroup .NsxtAlbServiceEngineGroup .ID },
162
+ ServicePorts : []types.NsxtAlbVirtualServicePort {
163
+ {
164
+ PortStart : addrOf (443 ),
165
+ PortEnd : addrOf (449 ),
166
+ SslEnabled : addrOf (false ),
167
+ },
168
+ {
169
+ PortStart : addrOf (2000 ),
170
+ PortEnd : addrOf (2010 ),
171
+ SslEnabled : addrOf (false ),
172
+ },
173
+ },
174
+ // Use Primary IP of Edge Gateway as virtual service IP
175
+ VirtualIpAddress : edge .EdgeGateway .EdgeGatewayUplinks [0 ].Subnets .Values [0 ].PrimaryIP ,
176
+ //HealthStatus: "",
177
+ //HealthMessage: "",
178
+ //DetailedHealthMessage: "",
179
+ }
180
+
181
+ testAlbVirtualServiceConfig (check , vcd , fmt .Sprintf ("MinimalHTTPWithTransparentModeOnCreate%t" , createTransparentMode ), virtualServiceConfig , virtualServiceConfigUpdated , client )
182
+ }
183
+
97
184
func testMinimalVirtualServiceConfigL4 (check * C , edge * NsxtEdgeGateway , pool * NsxtAlbPool , seGroup * NsxtAlbServiceEngineGroup , vcd * TestVCD , client * VCDClient ) {
98
185
virtualServiceConfig := & types.NsxtAlbVirtualService {
99
186
Name : check .TestName (),
@@ -363,6 +450,41 @@ func setupAlbVirtualServicePrerequisites(check *C, vcd *TestVCD) (*NsxtAlbContro
363
450
return controller , cloud , seGroup , edge , assignedSeGroup , albPool
364
451
}
365
452
453
+ func setupAlbPoolFirewallGroupMembers (check * C , vcd * TestVCD , edge * NsxtEdgeGateway ) (* NsxtFirewallGroup , * NsxtAlbPool ) {
454
+ // creates ip set
455
+ ipSetConfig := & types.NsxtFirewallGroup {
456
+ Name : check .TestName (),
457
+ OwnerRef : & types.OpenApiReference {ID : edge .EdgeGateway .ID },
458
+ Description : "Test IP Set" ,
459
+ Type : "IP_SET" ,
460
+ IpAddresses : []string {"1.1.1.1" },
461
+ }
462
+
463
+ ipSet , err := vcd .nsxtVdc .CreateNsxtFirewallGroup (ipSetConfig )
464
+ check .Assert (err , IsNil )
465
+
466
+ // add ip set to cleanup list
467
+ openApiEndpoint := types .OpenApiPathVersion1_0_0 + types .OpenApiEndpointFirewallGroups + ipSet .NsxtFirewallGroup .ID
468
+ PrependToCleanupListOpenApi (ipSet .NsxtFirewallGroup .Name , check .TestName (), openApiEndpoint )
469
+
470
+ poolConfig := & types.NsxtAlbPool {
471
+ Name : check .TestName () + "-member-group" ,
472
+ Enabled : takeBoolPointer (true ),
473
+ GatewayRef : types.OpenApiReference {ID : edge .EdgeGateway .ID },
474
+ MemberGroupRef : & types.OpenApiReference {
475
+ ID : ipSet .NsxtFirewallGroup .ID ,
476
+ },
477
+ }
478
+
479
+ albPool , err := vcd .client .CreateNsxtAlbPool (poolConfig )
480
+ check .Assert (err , IsNil )
481
+
482
+ openApiEndpoint = types .OpenApiPathVersion1_0_0 + types .OpenApiEndpointAlbPools + albPool .NsxtAlbPool .ID
483
+ PrependToCleanupListOpenApi (albPool .NsxtAlbPool .Name , check .TestName (), openApiEndpoint )
484
+
485
+ return ipSet , albPool
486
+ }
487
+
366
488
func tearDownAlbVirtualServicePrerequisites (check * C , albPool * NsxtAlbPool , assignment * NsxtAlbServiceEngineGroupAssignment , edge * NsxtEdgeGateway , seGroup * NsxtAlbServiceEngineGroup , cloud * NsxtAlbCloud , controller * NsxtAlbController ) {
367
489
err := albPool .Delete ()
368
490
check .Assert (err , IsNil )
0 commit comments