3
3
4
4
package oracle .weblogic .kubernetes ;
5
5
6
+ import java .io .IOException ;
6
7
import java .net .InetAddress ;
8
+ import java .net .UnknownHostException ;
7
9
import java .net .http .HttpResponse ;
8
10
import java .nio .file .Path ;
9
11
import java .nio .file .Paths ;
24
26
import oracle .weblogic .domain .Model ;
25
27
import oracle .weblogic .domain .OnlineUpdate ;
26
28
import oracle .weblogic .domain .ServerPod ;
27
- import oracle .weblogic .kubernetes .annotations .DisabledOn12213Image ;
28
29
import oracle .weblogic .kubernetes .annotations .IntegrationTest ;
29
30
import oracle .weblogic .kubernetes .annotations .Namespaces ;
30
31
import oracle .weblogic .kubernetes .logging .LoggingFacade ;
43
44
import static oracle .weblogic .kubernetes .TestConstants .ISTIO_HTTP_HOSTPORT ;
44
45
import static oracle .weblogic .kubernetes .TestConstants .K8S_NODEPORT_HOST ;
45
46
import static oracle .weblogic .kubernetes .TestConstants .KUBERNETES_CLI ;
47
+ import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_APP_DEPLOYMENT_NAME ;
46
48
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_NAME ;
47
49
import static oracle .weblogic .kubernetes .TestConstants .MII_BASIC_IMAGE_TAG ;
48
50
import static oracle .weblogic .kubernetes .TestConstants .OKE_CLUSTER ;
52
54
import static oracle .weblogic .kubernetes .actions .ActionConstants .WORK_DIR ;
53
55
import static oracle .weblogic .kubernetes .actions .TestActions .addLabelsToNamespace ;
54
56
import static oracle .weblogic .kubernetes .actions .TestActions .patchDomainResourceWithNewIntrospectVersion ;
55
- import static oracle .weblogic .kubernetes .utils .ApplicationUtils .checkAppUsingHostHeader ;
56
57
import static oracle .weblogic .kubernetes .utils .ClusterUtils .createClusterResourceAndAddReferenceToDomain ;
57
58
import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .replaceConfigMapWithModelFiles ;
58
59
import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .verifyIntrospectorRuns ;
59
60
import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .verifyPodIntrospectVersionUpdated ;
60
61
import static oracle .weblogic .kubernetes .utils .CommonMiiTestUtils .verifyPodsNotRolled ;
61
62
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .checkPodReadyAndServiceExists ;
62
- import static oracle .weblogic .kubernetes .utils .CommonTestUtils .createTestWebAppWarFile ;
63
63
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .formatIPv6Host ;
64
64
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .getServiceExtIPAddrtOke ;
65
- import static oracle .weblogic .kubernetes .utils .CommonTestUtils .isAppInServerPodReady ;
66
65
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .testUntil ;
67
66
import static oracle .weblogic .kubernetes .utils .CommonTestUtils .withStandardRetryPolicy ;
68
67
import static oracle .weblogic .kubernetes .utils .ConfigMapUtils .createConfigMapAndVerify ;
69
- import static oracle .weblogic .kubernetes .utils .DeployUtil .deployUsingRest ;
70
68
import static oracle .weblogic .kubernetes .utils .DomainUtils .createDomainAndVerify ;
71
69
import static oracle .weblogic .kubernetes .utils .FileUtils .generateFileFromTemplate ;
72
70
import static oracle .weblogic .kubernetes .utils .FileUtils .replaceStringInFile ;
@@ -133,10 +131,7 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
133
131
labelMap .put ("istio-injection" , "enabled" );
134
132
assertDoesNotThrow (() -> addLabelsToNamespace (domainNamespace ,labelMap ));
135
133
assertDoesNotThrow (() -> addLabelsToNamespace (opNamespace ,labelMap ));
136
-
137
- // create testwebapp.war
138
- testWebAppWarLoc = createTestWebAppWarFile (domainNamespace );
139
-
134
+
140
135
// install and verify operator
141
136
installAndVerifyOperator (opNamespace , domainNamespace );
142
137
@@ -150,24 +145,20 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
150
145
* Deploy istio gateways and virtual service.
151
146
*
152
147
* Verify server pods are in ready state and services are created.
153
- * Verify WebLogic console is accessible thru istio ingress port.
154
- * Deploy a web application thru istio http ingress port using REST api.
155
- * Access web application thru istio http ingress port using curl.
148
+ * Verify WebLogic REST interface is accessible thru istio ingress port.
156
149
*
157
150
* Create a configmap with a sparse model file to add a new workmanager
158
151
* with custom min threads constraint and a max threads constraint
159
152
* Patch the domain resource with the configmap.
160
153
* Update the introspect version of the domain resource.
161
- * Verify rolling restart of the domain by comparing PodCreationTimestamp
162
- * before and after rolling restart.
154
+ * Verify the changes are applied without rolling restart of the domain by comparing PodCreationTimestamp
163
155
* Verify new work manager is configured.
164
156
*/
165
157
@ Test
166
158
@ DisplayName ("Create WebLogic Domain with mii model with istio" )
167
159
@ Tag ("gate" )
168
160
@ Tag ("crio" )
169
- @ DisabledOn12213Image
170
- void testIstioModelInImageDomainModified () {
161
+ void testIstioModelInImageDomain () throws UnknownHostException , IOException , InterruptedException {
171
162
172
163
// Create the repo secret to pull the image
173
164
// this secret is used only for non-kind cluster
@@ -177,21 +168,21 @@ void testIstioModelInImageDomainModified() {
177
168
logger .info ("Create secret for admin credentials" );
178
169
String adminSecretName = "weblogic-credentials" ;
179
170
assertDoesNotThrow (() -> createSecretWithUsernamePassword (
180
- adminSecretName ,
181
- domainNamespace ,
182
- ADMIN_USERNAME_DEFAULT ,
183
- ADMIN_PASSWORD_DEFAULT ),
171
+ adminSecretName ,
172
+ domainNamespace ,
173
+ ADMIN_USERNAME_DEFAULT ,
174
+ ADMIN_PASSWORD_DEFAULT ),
184
175
String .format ("createSecret failed for %s" , adminSecretName ));
185
176
186
177
// create encryption secret
187
178
logger .info ("Create encryption secret" );
188
179
String encryptionSecretName = "encryptionsecret" ;
189
180
assertDoesNotThrow (() -> createSecretWithUsernamePassword (
190
- encryptionSecretName ,
191
- domainNamespace ,
192
- "weblogicenc" ,
193
- "weblogicenc" ),
194
- String .format ("createSecret failed for %s" , encryptionSecretName ));
181
+ encryptionSecretName ,
182
+ domainNamespace ,
183
+ "weblogicenc" ,
184
+ "weblogicenc" ),
185
+ String .format ("createSecret failed for %s" , encryptionSecretName ));
195
186
196
187
// create WDT config map without any files
197
188
createConfigMapAndVerify (configMapName , domainUid , domainNamespace , Collections .emptyList ());
@@ -200,9 +191,7 @@ void testIstioModelInImageDomainModified() {
200
191
DomainResource domain = createDomainResource (domainUid , domainNamespace , adminSecretName ,
201
192
TEST_IMAGES_REPO_SECRET_NAME , encryptionSecretName ,
202
193
MII_BASIC_IMAGE_NAME + ":" + MII_BASIC_IMAGE_TAG , configMapName );
203
- domain = createClusterResourceAndAddReferenceToDomain (
204
- domainUid + "-" + clusterName , clusterName , domainNamespace , domain , replicaCount );
205
-
194
+
206
195
// create model in image domain
207
196
createDomainAndVerify (domain , domainNamespace );
208
197
@@ -215,20 +204,20 @@ void testIstioModelInImageDomainModified() {
215
204
managedServerPrefix + i , domainNamespace );
216
205
checkPodReadyAndServiceExists (managedServerPrefix + i , domainUid , domainNamespace );
217
206
}
218
-
207
+
219
208
// delete the mTLS mode
220
209
ExecResult result = assertDoesNotThrow (() -> ExecCommand .exec (KUBERNETES_CLI + " delete -f "
221
210
+ Paths .get (WORK_DIR , "istio-tls-mode.yaml" ).toString (), true ));
222
211
assertEquals (0 , result .exitValue (), "Got expected exit value" );
223
212
logger .info (result .stdout ());
224
- logger .info (result .stderr ());
213
+ logger .info (result .stderr ());
225
214
226
215
String clusterService = domainUid + "-cluster-" + clusterName + "." + domainNamespace + ".svc.cluster.local" ;
227
216
228
- Map <String , String > templateMap = new HashMap <>();
217
+ Map <String , String > templateMap = new HashMap <>();
229
218
templateMap .put ("NAMESPACE" , domainNamespace );
230
219
templateMap .put ("DUID" , domainUid );
231
- templateMap .put ("ADMIN_SERVICE" ,adminServerPodName );
220
+ templateMap .put ("ADMIN_SERVICE" , adminServerPodName );
232
221
templateMap .put ("CLUSTER_SERVICE" , clusterService );
233
222
234
223
Path srcHttpFile = Paths .get (RESOURCE_DIR , "istio" , "istio-http-template.yaml" );
@@ -248,60 +237,34 @@ void testIstioModelInImageDomainModified() {
248
237
deployRes = assertDoesNotThrow (() -> deployIstioDestinationRule (targetDrFile ));
249
238
assertTrue (deployRes , "Failed to deploy Istio DestinationRule" );
250
239
251
- int istioIngressPort = getIstioHttpIngressPort ();
240
+ int istioIngressPort = getIstioHttpIngressPort ();
252
241
String host = formatIPv6Host (K8S_NODEPORT_HOST );
253
242
logger .info ("Istio Ingress Port is {0}" , istioIngressPort );
254
- logger .info ("host {0}" , host );
243
+ logger .info ("host {0}" , host );
255
244
256
245
// In internal OKE env, use Istio EXTERNAL-IP; in non-OKE env, use K8S_NODEPORT_HOST + ":" + istioIngressPort
257
246
String hostAndPort = getServiceExtIPAddrtOke (istioIngressServiceName , istioNamespace ) != null
258
247
? getServiceExtIPAddrtOke (istioIngressServiceName , istioNamespace ) : host + ":" + istioIngressPort ;
259
-
260
- try {
261
- if (!TestConstants .WLSIMG_BUILDER .equals (TestConstants .WLSIMG_BUILDER_DEFAULT )) {
262
- istioIngressPort = ISTIO_HTTP_HOSTPORT ;
263
- hostAndPort = InetAddress .getLocalHost ().getHostAddress () + ":" + istioIngressPort ;
264
- }
265
- Map <String , String > headers = new HashMap <>();
266
- headers .put ("host" , domainNamespace + ".org" );
267
- headers .put ("Authorization" , ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT );
268
- String url = "http://" + hostAndPort + "/management/tenant-monitoring/servers/" ;
269
- HttpResponse <String > response ;
270
- response = OracleHttpClient .get (url , headers , true );
271
- assertEquals (200 , response .statusCode ());
272
- assertTrue (response .body ().contains ("RUNNING" ));
273
- } catch (Exception ex ) {
274
- logger .severe (ex .getMessage ());
275
- }
276
248
277
- if (OKE_CLUSTER ) {
278
- // create secret for internal OKE cluster
279
- createBaseRepoSecret (domainNamespace );
280
- }
249
+ Map <String , String > headers = new HashMap <>();
250
+ headers .put ("host" , domainNamespace + ".org" );
251
+ headers .put ("Authorization" , ADMIN_USERNAME_DEFAULT + ":" + ADMIN_PASSWORD_DEFAULT );
281
252
282
- Path archivePath = Paths . get ( testWebAppWarLoc );
283
- String target = "{identity: [clusters,'" + clusterName + "']}" ;
284
- ExecResult deployUsingRest = deployUsingRest ( hostAndPort , ADMIN_USERNAME_DEFAULT , ADMIN_PASSWORD_DEFAULT ,
285
- target , archivePath , domainNamespace + ".org" , "testwebapp" );
253
+ if (! TestConstants . WLSIMG_BUILDER . equals ( TestConstants . WLSIMG_BUILDER_DEFAULT )) {
254
+ istioIngressPort = ISTIO_HTTP_HOSTPORT ;
255
+ hostAndPort = InetAddress . getLocalHost (). getHostAddress () + ":" + istioIngressPort ;
256
+ }
286
257
287
- assertNotNull (deployUsingRest , "Application deployment failed" );
288
- logger .info ("Application deployment returned {0}" , deployUsingRest .toString ());
289
- assertEquals ("202" , deployUsingRest .stdout (), "Deployment didn't return HTTP status code 202" );
290
- logger .info ("Application {0} deployed successfully at {1}" , "testwebapp.war" , domainUid + "-" + clusterName );
258
+ String url = "http://" + hostAndPort + "/management/tenant-monitoring/servers/" ;
259
+ HttpResponse <String > response ;
260
+ response = OracleHttpClient .get (url , headers , true );
261
+ assertEquals (200 , response .statusCode ());
262
+ assertTrue (response .body ().contains ("RUNNING" ));
291
263
292
264
if (OKE_CLUSTER ) {
293
- testUntil (isAppInServerPodReady (domainNamespace ,
294
- managedServerPrefix + 1 , 8001 , "/testwebapp/index.jsp" , "testwebapp" ),
295
- logger , "Check Deployed App {0} in server {1}" ,
296
- archivePath ,
297
- target );
298
- } else {
299
- String url = "http://" + hostAndPort + "/testwebapp/index.jsp" ;
300
- logger .info ("Application Access URL {0}" , url );
301
- boolean checkApp = checkAppUsingHostHeader (url , domainNamespace + ".org" );
302
- assertTrue (checkApp , "Failed to access WebLogic application" );
265
+ // create secret for internal OKE cluster
266
+ createBaseRepoSecret (domainNamespace );
303
267
}
304
- logger .info ("Application /testwebapp/index.jsp is accessble to {0}" , domainUid );
305
268
306
269
//Verify the dynamic configuration update
307
270
LinkedHashMap <String , OffsetDateTime > pods = new LinkedHashMap <>();
@@ -319,17 +282,13 @@ void testIstioModelInImageDomainModified() {
319
282
Arrays .asList (MODEL_DIR + "/model.config.wm.yaml" ), withStandardRetryPolicy );
320
283
321
284
String introspectVersion = patchDomainResourceWithNewIntrospectVersion (domainUid , domainNamespace );
322
-
323
285
verifyIntrospectorRuns (domainUid , domainNamespace );
324
286
325
287
String resourcePath = "/management/weblogic/latest/domainRuntime"
326
- + "/serverRuntimes/managed-server1/applicationRuntimes"
327
- + "/testwebapp/workManagerRuntimes/newWM/"
328
- + "maxThreadsConstraintRuntime " ;
329
- String wmRuntimeUrl = "http://" + hostAndPort + resourcePath ;
330
-
331
- boolean checkWm = checkAppUsingHostHeader (wmRuntimeUrl , domainNamespace + ".org" );
332
- assertTrue (checkWm , "Failed to access WorkManagerRuntime" );
288
+ + "/serverRuntimes/managed-server1/applicationRuntimes/"
289
+ + MII_BASIC_APP_DEPLOYMENT_NAME + "/workManagerRuntimes/newWM/" ;
290
+ String wmRuntimeUrl = "http://" + hostAndPort + resourcePath ;
291
+ checkApp (wmRuntimeUrl , headers );
333
292
logger .info ("Found new work manager runtime" );
334
293
335
294
verifyPodsNotRolled (domainNamespace , pods );
@@ -368,14 +327,16 @@ private DomainResource createDomainResource(String domainUid, String domNamespac
368
327
.value ("-Djava.security.egd=file:/dev/./urandom " )))
369
328
.adminServer (createAdminServer ())
370
329
.configuration (new Configuration ()
371
- .model (new Model ()
372
- .domainType ("WLS" )
373
- .configMap (configmapName )
374
- .onlineUpdate (new OnlineUpdate ().enabled (true ))
375
- .runtimeEncryptionSecret (encryptionSecretName ))
330
+ .model (new Model ()
331
+ .domainType ("WLS" )
332
+ .configMap (configmapName )
333
+ .onlineUpdate (new OnlineUpdate ()
334
+ .enabled (true ))
335
+ .runtimeEncryptionSecret (encryptionSecretName ))
376
336
.introspectorJobActiveDeadlineSeconds (300L )));
377
337
setPodAntiAffinity (domain );
378
- return domain ;
338
+ return createClusterResourceAndAddReferenceToDomain (
339
+ domainUid + "-" + clusterName , clusterName , domainNamespace , domain , replicaCount );
379
340
}
380
341
381
342
private static void enableStrictMode (String namespace ) {
@@ -392,4 +353,15 @@ private static void enableStrictMode(String namespace) {
392
353
logger .info (result .stderr ());
393
354
});
394
355
}
356
+
357
+ private void checkApp (String url , Map <String , String > headers ) {
358
+ testUntil (
359
+ () -> {
360
+ HttpResponse <String > response = OracleHttpClient .get (url , headers , true );
361
+ return response .statusCode () == 200 ;
362
+ },
363
+ logger ,
364
+ "application to be ready {0}" ,
365
+ url );
366
+ }
395
367
}
0 commit comments