1
- // Copyright (c) 2020, 2021 , Oracle and/or its affiliates.
1
+ // Copyright (c) 2020, 2022 , Oracle and/or its affiliates.
2
2
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3
3
4
4
package oracle .weblogic .kubernetes ;
@@ -153,37 +153,37 @@ public static void init(@Namespaces(3) List<String> namespaces) {
153
153
// install and verify Kibana
154
154
logger .info ("install and verify Kibana" );
155
155
kibanaParams = assertDoesNotThrow (() -> installAndVerifyKibana (elasticSearchNs ),
156
- String .format ("Failed to install Kibana" ));
156
+ String .format ("Failed to install Kibana" ));
157
157
assertTrue (kibanaParams != null , "Failed to install Kibana" );
158
158
159
159
// install and verify Operator
160
160
installAndVerifyOperator (opNamespace , opNamespace + "-sa" ,
161
- false , 0 , true , domainNamespace );
161
+ false , 0 , true , domainNamespace );
162
162
163
163
elasticSearchHost = "elasticsearch." + elasticSearchNs + ".svc.cluster.local" ;
164
164
// upgrade to latest operator
165
165
HelmParams upgradeHelmParams = new HelmParams ()
166
- .releaseName (OPERATOR_RELEASE_NAME )
167
- .namespace (opNamespace )
168
- .chartDir (OPERATOR_CHART_DIR );
166
+ .releaseName (OPERATOR_RELEASE_NAME )
167
+ .namespace (opNamespace )
168
+ .chartDir (OPERATOR_CHART_DIR );
169
169
170
170
// build operator chart values
171
171
OperatorParams opParams = new OperatorParams ()
172
- .helmParams (upgradeHelmParams )
173
- .elkIntegrationEnabled (true )
174
- .elasticSearchHost (elasticSearchHost );
172
+ .helmParams (upgradeHelmParams )
173
+ .elkIntegrationEnabled (true )
174
+ .elasticSearchHost (elasticSearchHost );
175
175
176
176
assertTrue (upgradeAndVerifyOperator (opNamespace , opParams ),
177
- String .format ("Failed to upgrade operator in namespace %s" , opNamespace ));
177
+ String .format ("Failed to upgrade operator in namespace %s" , opNamespace ));
178
178
179
179
// wait for the operator to be ready
180
180
logger .info ("Wait for the operator pod is ready in namespace {0}" , opNamespace );
181
181
testUntil (
182
- assertDoesNotThrow (() -> operatorIsReady (opNamespace ),
183
- "operatorIsReady failed with ApiException" ),
184
- logger ,
185
- "operator to be running in namespace {0}" ,
186
- opNamespace );
182
+ assertDoesNotThrow (() -> operatorIsReady (opNamespace ),
183
+ "operatorIsReady failed with ApiException" ),
184
+ logger ,
185
+ "operator to be running in namespace {0}" ,
186
+ opNamespace );
187
187
188
188
// install WebLogic Logging Exporter if in non-OKD env
189
189
if (!OKD ) {
@@ -201,10 +201,10 @@ public static void init(@Namespaces(3) List<String> namespaces) {
201
201
202
202
elasticSearchHost = "elasticsearch." + elasticSearchNs + ".svc.cluster.local" ;
203
203
StringBuffer elasticsearchUrlBuff =
204
- new StringBuffer ("curl http://" )
205
- .append (elasticSearchHost )
206
- .append (":" )
207
- .append (ELASTICSEARCH_HTTP_PORT );
204
+ new StringBuffer ("curl http://" )
205
+ .append (elasticSearchHost )
206
+ .append (":" )
207
+ .append (ELASTICSEARCH_HTTP_PORT );
208
208
k8sExecCmdPrefix = elasticsearchUrlBuff .toString ();
209
209
logger .info ("Elasticsearch URL {0}" , k8sExecCmdPrefix );
210
210
@@ -222,31 +222,31 @@ public static void init(@Namespaces(3) List<String> namespaces) {
222
222
@ AfterAll
223
223
void tearDown () {
224
224
if (System .getenv ("SKIP_CLEANUP" ) == null
225
- || (System .getenv ("SKIP_CLEANUP" ) != null
226
- && System .getenv ("SKIP_CLEANUP" ).equalsIgnoreCase ("false" ))) {
225
+ || (System .getenv ("SKIP_CLEANUP" ) != null
226
+ && System .getenv ("SKIP_CLEANUP" ).equalsIgnoreCase ("false" ))) {
227
227
228
228
// uninstall ELK Stack
229
229
elasticsearchParams = new LoggingExporterParams ()
230
- .elasticsearchName (ELASTICSEARCH_NAME )
231
- .elasticsearchImage (ELASTICSEARCH_IMAGE )
232
- .elasticsearchHttpPort (ELASTICSEARCH_HTTP_PORT )
233
- .elasticsearchHttpsPort (ELASTICSEARCH_HTTPS_PORT )
234
- .loggingExporterNamespace (elasticSearchNs );
230
+ .elasticsearchName (ELASTICSEARCH_NAME )
231
+ .elasticsearchImage (ELASTICSEARCH_IMAGE )
232
+ .elasticsearchHttpPort (ELASTICSEARCH_HTTP_PORT )
233
+ .elasticsearchHttpsPort (ELASTICSEARCH_HTTPS_PORT )
234
+ .loggingExporterNamespace (elasticSearchNs );
235
235
236
236
kibanaParams = new LoggingExporterParams ()
237
- .kibanaName (KIBANA_NAME )
238
- .kibanaImage (KIBANA_IMAGE )
239
- .kibanaType (KIBANA_TYPE )
240
- .loggingExporterNamespace (elasticSearchNs )
241
- .kibanaContainerPort (KIBANA_PORT );
237
+ .kibanaName (KIBANA_NAME )
238
+ .kibanaImage (KIBANA_IMAGE )
239
+ .kibanaType (KIBANA_TYPE )
240
+ .loggingExporterNamespace (elasticSearchNs )
241
+ .kibanaContainerPort (KIBANA_PORT );
242
242
243
243
logger .info ("Uninstall Elasticsearch pod" );
244
244
assertDoesNotThrow (() -> uninstallAndVerifyElasticsearch (elasticsearchParams ),
245
- "uninstallAndVerifyElasticsearch failed with ApiException" );
245
+ "uninstallAndVerifyElasticsearch failed with ApiException" );
246
246
247
247
logger .info ("Uninstall Kibana pod" );
248
248
assertDoesNotThrow (() -> uninstallAndVerifyKibana (kibanaParams ),
249
- "uninstallAndVerifyKibana failed with ApiException" );
249
+ "uninstallAndVerifyKibana failed with ApiException" );
250
250
}
251
251
}
252
252
@@ -328,10 +328,10 @@ void testWlsLoggingExporter() throws Exception {
328
328
// by checking the count of logs from serverName:managed-server1 is zero and no failures
329
329
regex = "(?m).*\\ s*.*count\" \\ s*:\\ s*(\\ d+),.*failed\" \\ s*:\\ s*(\\ d+)" ;
330
330
StringBuffer queryCriteriaBuff = new StringBuffer ("/doc/_count?pretty" )
331
- .append (" -H 'Content-Type: application/json'" )
332
- .append (" -d'{\" query\" :{\" query_string\" :{\" query\" :\" " )
333
- .append (managedServerFilter )
334
- .append ("\" ,\" fields\" :[\" serverName\" ],\" default_operator\" : \" AND\" }}}'" );
331
+ .append (" -H 'Content-Type: application/json'" )
332
+ .append (" -d'{\" query\" :{\" query_string\" :{\" query\" :\" " )
333
+ .append (managedServerFilter )
334
+ .append ("\" ,\" fields\" :[\" serverName\" ],\" default_operator\" : \" AND\" }}}'" );
335
335
336
336
queryCriteria = queryCriteriaBuff .toString ();
337
337
verifyCountsHitsInSearchResults (queryCriteria , regex , WEBLOGIC_INDEX_KEY , true , "notExist" );
@@ -346,21 +346,21 @@ private static String createAndVerifyDomainImage() {
346
346
if (!OKD ) {
347
347
String additionalBuildCommands = WORK_DIR + "/" + COPY_WLS_LOGGING_EXPORTER_FILE_NAME ;
348
348
StringBuffer additionalBuildFilesVarargsBuff = new StringBuffer ()
349
- .append (WORK_DIR )
350
- .append ("/" )
351
- .append (WLS_LOGGING_EXPORTER_YAML_FILE_NAME )
352
- .append ("," )
353
- .append (DOWNLOAD_DIR )
354
- .append ("/" )
355
- .append (WLE_DOWNLOAD_FILENAME_DEFAULT )
356
- .append ("," )
357
- .append (DOWNLOAD_DIR )
358
- .append ("/" )
359
- .append (SNAKE_DOWNLOADED_FILENAME );
349
+ .append (WORK_DIR )
350
+ .append ("/" )
351
+ .append (WLS_LOGGING_EXPORTER_YAML_FILE_NAME )
352
+ .append ("," )
353
+ .append (DOWNLOAD_DIR )
354
+ .append ("/" )
355
+ .append (WLE_DOWNLOAD_FILENAME_DEFAULT )
356
+ .append ("," )
357
+ .append (DOWNLOAD_DIR )
358
+ .append ("/" )
359
+ .append (SNAKE_DOWNLOADED_FILENAME );
360
360
361
361
logger .info ("Create image with model file and verify" );
362
362
miiImage = createMiiImageAndVerify (WLS_LOGGING_IMAGE_NAME , WLS_LOGGING_MODEL_FILE ,
363
- MII_BASIC_APP_NAME , additionalBuildCommands , additionalBuildFilesVarargsBuff .toString ());
363
+ MII_BASIC_APP_NAME , additionalBuildCommands , additionalBuildFilesVarargsBuff .toString ());
364
364
} else {
365
365
List <String > appList = new ArrayList ();
366
366
appList .add (MII_BASIC_APP_NAME );
@@ -387,21 +387,21 @@ private static String createAndVerifyDomainImage() {
387
387
private static void createAndVerifyDomain (String miiImage ) {
388
388
// create a domain resource
389
389
logger .info ("Create model-in-image domain {0} in namespace {1}, and wait until it comes up" ,
390
- domainUid , domainNamespace );
390
+ domainUid , domainNamespace );
391
391
createMiiDomainAndVerify (
392
- domainNamespace ,
393
- domainUid ,
394
- miiImage ,
395
- adminServerPodName ,
396
- managedServerPodPrefix ,
397
- replicaCount );
392
+ domainNamespace ,
393
+ domainUid ,
394
+ miiImage ,
395
+ adminServerPodName ,
396
+ managedServerPodPrefix ,
397
+ replicaCount );
398
398
}
399
399
400
400
private void verifyServerRunningInSearchResults (String serverName ) {
401
401
String queryCriteria = "/_search?q=log:" + serverName ;
402
402
withStandardRetryPolicy .untilAsserted (
403
- () -> assertTrue (execSearchQuery (queryCriteria , LOGSTASH_INDEX_KEY ).contains ("RUNNING" ),
404
- String .format ("serverName %s is not RUNNING" , serverName )));
403
+ () -> assertTrue (execSearchQuery (queryCriteria , LOGSTASH_INDEX_KEY ).contains ("RUNNING" ),
404
+ String .format ("serverName %s is not RUNNING" , serverName )));
405
405
406
406
String queryResult = execSearchQuery (queryCriteria , LOGSTASH_INDEX_KEY );
407
407
logger .info ("query result is {0}" , queryResult );
@@ -442,28 +442,28 @@ private void verifyCountsHitsInSearchResults(String queryCriteria, String regex,
442
442
443
443
private String execSearchQuery (String queryCriteria , String index ) {
444
444
String operatorPodName = assertDoesNotThrow (
445
- () -> getOperatorPodName (OPERATOR_RELEASE_NAME , opNamespace ));
445
+ () -> getOperatorPodName (OPERATOR_RELEASE_NAME , opNamespace ));
446
446
assertTrue (operatorPodName != null && !operatorPodName .isEmpty (), "Failed to get Operator pad name" );
447
447
logger .info ("Operator pod name " + operatorPodName );
448
448
449
449
int waittime = 5 ;
450
450
String indexName = (String ) testVarMap .get (index );
451
451
StringBuffer curlOptions = new StringBuffer (" --connect-timeout " + waittime )
452
- .append (" --max-time " + waittime )
453
- .append (" -X GET " );
452
+ .append (" --max-time " + waittime )
453
+ .append (" -X GET " );
454
454
StringBuffer k8sExecCmdPrefixBuff = new StringBuffer (k8sExecCmdPrefix );
455
455
int offset = k8sExecCmdPrefixBuff .indexOf ("http" );
456
456
k8sExecCmdPrefixBuff .insert (offset , curlOptions );
457
457
String cmd = k8sExecCmdPrefixBuff
458
- .append ("/" )
459
- .append (indexName )
460
- .append (queryCriteria )
461
- .toString ();
458
+ .append ("/" )
459
+ .append (indexName )
460
+ .append (queryCriteria )
461
+ .toString ();
462
462
logger .info ("Exec command {0} in Operator pod {1}" , cmd , operatorPodName );
463
463
464
464
ExecResult execResult = assertDoesNotThrow (
465
- () -> execCommand (opNamespace , operatorPodName , null , true ,
466
- "/bin/sh" , "-c" , cmd ));
465
+ () -> execCommand (opNamespace , operatorPodName , null , true ,
466
+ "/bin/sh" , "-c" , cmd ));
467
467
assertNotNull (execResult , "curl command returns null" );
468
468
logger .info ("Search query returns " + execResult .stdout ());
469
469
0 commit comments