|
1 | | -// Copyright (c) 2020, 2022, Oracle and/or its affiliates. |
| 1 | +// Copyright (c) 2020, 2023, 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; |
|
28 | 28 | import org.junit.jupiter.api.DisplayName; |
29 | 29 | import org.junit.jupiter.api.Tag; |
30 | 30 | import org.junit.jupiter.api.Test; |
31 | | -import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; |
32 | 31 |
|
33 | | -import static oracle.weblogic.kubernetes.TestConstants.COPY_WLS_LOGGING_EXPORTER_FILE_NAME; |
34 | 32 | import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_HTTPS_PORT; |
35 | 33 | import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_HTTP_PORT; |
36 | 34 | import static oracle.weblogic.kubernetes.TestConstants.ELASTICSEARCH_IMAGE; |
|
47 | 45 | import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_CHART_DIR; |
48 | 46 | import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_RELEASE_NAME; |
49 | 47 | import static oracle.weblogic.kubernetes.TestConstants.SKIP_CLEANUP; |
50 | | -import static oracle.weblogic.kubernetes.TestConstants.WEBLOGIC_INDEX_KEY; |
51 | | -import static oracle.weblogic.kubernetes.TestConstants.WLS_LOGGING_EXPORTER_YAML_FILE_NAME; |
52 | | -import static oracle.weblogic.kubernetes.actions.ActionConstants.DOWNLOAD_DIR; |
53 | 48 | import static oracle.weblogic.kubernetes.actions.ActionConstants.ITTESTS_DIR; |
54 | 49 | import static oracle.weblogic.kubernetes.actions.ActionConstants.MODEL_DIR; |
55 | 50 | import static oracle.weblogic.kubernetes.actions.ActionConstants.RESOURCE_DIR; |
56 | | -import static oracle.weblogic.kubernetes.actions.ActionConstants.SNAKE_DOWNLOADED_FILENAME; |
57 | | -import static oracle.weblogic.kubernetes.actions.ActionConstants.WLE_DOWNLOAD_FILENAME_DEFAULT; |
58 | 51 | import static oracle.weblogic.kubernetes.actions.ActionConstants.WORK_DIR; |
59 | 52 | import static oracle.weblogic.kubernetes.actions.TestActions.execCommand; |
60 | 53 | import static oracle.weblogic.kubernetes.actions.TestActions.getOperatorPodName; |
|
75 | 68 | import static oracle.weblogic.kubernetes.utils.ImageUtils.imageRepoLoginAndPushImageToRegistry; |
76 | 69 | import static oracle.weblogic.kubernetes.utils.LoggingExporterUtils.installAndVerifyElasticsearch; |
77 | 70 | import static oracle.weblogic.kubernetes.utils.LoggingExporterUtils.installAndVerifyKibana; |
78 | | -import static oracle.weblogic.kubernetes.utils.LoggingExporterUtils.installAndVerifyWlsLoggingExporter; |
79 | 71 | import static oracle.weblogic.kubernetes.utils.LoggingExporterUtils.uninstallAndVerifyElasticsearch; |
80 | 72 | import static oracle.weblogic.kubernetes.utils.LoggingExporterUtils.uninstallAndVerifyKibana; |
81 | 73 | import static oracle.weblogic.kubernetes.utils.LoggingExporterUtils.verifyLoggingExporterReady; |
|
97 | 89 | * test createLogStashConfigMap = false. |
98 | 90 | * 3. Verify that ELK Stack is ready to use by checking the index status of |
99 | 91 | * Kibana and Logstash created in the Operator pod successfully. |
100 | | - * 4. Install WebLogic Logging Exporter in all WebLogic server pods by |
101 | | - * adding WebLogic Logging Exporter binary to the image builder process |
102 | | - * so that it will be available in the domain image via |
103 | | - * --additionalBuildCommands and --additionalBuildFiles. |
104 | | - * 5. Create and start the WebLogic domain. |
105 | | - * 6. Verify that |
| 92 | + * 4. Create and start the WebLogic domain. |
| 93 | + * 5. Verify that |
106 | 94 | * 1) Elasticsearch collects data from WebLogic logs and |
107 | 95 | * stores them in its repository correctly. |
108 | | - * 2) Using WebLogic Logging Exporter, WebLogic server Logs can be integrated to |
109 | | - * ELK Stack in the same pod that the domain is running on. |
110 | | - * 3) Users can update logstash configuration by updating the configmap |
| 96 | + * 2) Users can update logstash configuration by updating the configmap |
111 | 97 | * weblogic-operator-logstash-cm instead of rebuilding operator image |
112 | 98 | */ |
113 | 99 | @DisplayName("Test to use Elasticsearch API to query WebLogic logs") |
|
119 | 105 | class ItElasticLogging { |
120 | 106 |
|
121 | 107 | // constants for creating domain image using model in image |
122 | | - private static final String WLS_LOGGING_MODEL_FILE = "model.wlslogging.yaml"; |
123 | | - private static final String WLS_LOGGING_IMAGE_NAME = "wls-logging-image"; |
| 108 | + private static final String WLS_ELK_LOGGING_MODEL_FILE = "model.wlslogging.yaml"; |
| 109 | + private static final String WLS_ELK_LOGGING_IMAGE_NAME = "wls-logging-image"; |
124 | 110 |
|
125 | 111 | // constants for testing WebLogic Logging Exporter |
126 | 112 | private static final String wlsLoggingExporterYamlFileLoc = RESOURCE_DIR + "/loggingexporter"; |
@@ -226,11 +212,6 @@ public static void init(@Namespaces(4) List<String> namespaces) { |
226 | 212 | "operator to be running in namespace {0}", |
227 | 213 | opNamespace); |
228 | 214 |
|
229 | | - // install WebLogic Logging Exporter if in non-OKD env |
230 | | - if (!OKD) { |
231 | | - installAndVerifyWlsLoggingExporter(managedServerFilter, wlsLoggingExporterYamlFileLoc, elasticSearchNs); |
232 | | - } |
233 | | - |
234 | 215 | // create and verify WebLogic domain image using model in image with model files |
235 | 216 | String imageName = createAndVerifyDomainImage(); |
236 | 217 |
|
@@ -338,46 +319,6 @@ void testWebLogicLogSearch() { |
338 | 319 | logger.info("Query Operator log for WebLogic server status info succeeded"); |
339 | 320 | } |
340 | 321 |
|
341 | | - /** |
342 | | - * Use Elasticsearch Search APIs to query WebLogic log info pushed to Elasticsearch repository |
343 | | - * by WebLogic Logging Exporter. Verify that log occurrence for WebLogic servers are not empty. |
344 | | - */ |
345 | | - @Test |
346 | | - @DisplayName("Use Elasticsearch Search APIs to query WebLogic log info in WLS server pod and verify") |
347 | | - @DisabledIfEnvironmentVariable(named = "OKD", matches = "true") |
348 | | - void testWlsLoggingExporter() throws Exception { |
349 | | - Map<String, String> wlsMap = verifyLoggingExporterReady(opNamespace, elasticSearchNs, null, WEBLOGIC_INDEX_KEY); |
350 | | - // merge testVarMap and wlsMap |
351 | | - testVarMap.putAll(wlsMap); |
352 | | - |
353 | | - // Verify that occurrence of log level = Notice are not empty |
354 | | - String regex = ".*took\":(\\d+),.*hits\":\\{(.+)\\}"; |
355 | | - String queryCriteria = "/_search?q=level:Notice"; |
356 | | - verifyCountsHitsInSearchResults(queryCriteria, regex, WEBLOGIC_INDEX_KEY, false); |
357 | | - |
358 | | - // Verify that occurrence of loggerName = WebLogicServer are not empty |
359 | | - queryCriteria = "/_search?q=loggerName:WebLogicServer"; |
360 | | - verifyCountsHitsInSearchResults(queryCriteria, regex, WEBLOGIC_INDEX_KEY, false); |
361 | | - |
362 | | - // Verify that occurrence of _type:doc are not empty |
363 | | - queryCriteria = "/_search?q=_type:doc"; |
364 | | - verifyCountsHitsInSearchResults(queryCriteria, regex, WEBLOGIC_INDEX_KEY, false); |
365 | | - |
366 | | - // Verify that serverName:managed-server1 is filtered out |
367 | | - // by checking the count of logs from serverName:managed-server1 is zero and no failures |
368 | | - regex = "(?m).*\\s*.*count\"\\s*:\\s*(\\d+),.*failed\"\\s*:\\s*(\\d+)"; |
369 | | - StringBuffer queryCriteriaBuff = new StringBuffer("/doc/_count?pretty") |
370 | | - .append(" -H 'Content-Type: application/json'") |
371 | | - .append(" -d'{\"query\":{\"query_string\":{\"query\":\"") |
372 | | - .append(managedServerFilter) |
373 | | - .append("\",\"fields\":[\"serverName\"],\"default_operator\": \"AND\"}}}'"); |
374 | | - |
375 | | - queryCriteria = queryCriteriaBuff.toString(); |
376 | | - verifyCountsHitsInSearchResults(queryCriteria, regex, WEBLOGIC_INDEX_KEY, true, "notExist"); |
377 | | - |
378 | | - logger.info("Query WebLogic log info succeeded"); |
379 | | - } |
380 | | - |
381 | 322 | /** |
382 | 323 | * Test when variable createLogStashConfigMap sets to true, a configMap named weblogic-operator-logstash-cm |
383 | 324 | * is created and users can update logstash configuration by updating the configmap |
@@ -447,33 +388,18 @@ private static String createAndVerifyDomainImage() { |
447 | 388 |
|
448 | 389 | // create image with model files |
449 | 390 | if (!OKD) { |
450 | | - String additionalBuildCommands = WORK_DIR + "/" + COPY_WLS_LOGGING_EXPORTER_FILE_NAME; |
451 | | - StringBuffer additionalBuildFilesVarargsBuff = new StringBuffer() |
452 | | - .append(WORK_DIR) |
453 | | - .append("/") |
454 | | - .append(WLS_LOGGING_EXPORTER_YAML_FILE_NAME) |
455 | | - .append(",") |
456 | | - .append(DOWNLOAD_DIR) |
457 | | - .append("/") |
458 | | - .append(WLE_DOWNLOAD_FILENAME_DEFAULT) |
459 | | - .append(",") |
460 | | - .append(DOWNLOAD_DIR) |
461 | | - .append("/") |
462 | | - .append(SNAKE_DOWNLOADED_FILENAME); |
463 | | - |
464 | 391 | logger.info("Create image with model file and verify"); |
465 | | - miiImage = createMiiImageAndVerify(WLS_LOGGING_IMAGE_NAME, WLS_LOGGING_MODEL_FILE, |
466 | | - MII_BASIC_APP_NAME, additionalBuildCommands, additionalBuildFilesVarargsBuff.toString()); |
| 392 | + miiImage = createMiiImageAndVerify(WLS_ELK_LOGGING_IMAGE_NAME, WLS_ELK_LOGGING_MODEL_FILE,MII_BASIC_APP_NAME); |
467 | 393 | } else { |
468 | 394 | List<String> appList = new ArrayList<>(); |
469 | 395 | appList.add(MII_BASIC_APP_NAME); |
470 | 396 |
|
471 | 397 | // build the model file list |
472 | | - final List<String> modelList = Collections.singletonList(MODEL_DIR + "/" + WLS_LOGGING_MODEL_FILE); |
| 398 | + final List<String> modelList = Collections.singletonList(MODEL_DIR + "/" + WLS_ELK_LOGGING_MODEL_FILE); |
473 | 399 |
|
474 | 400 | // create image with model files |
475 | 401 | logger.info("Create image with model file and verify"); |
476 | | - miiImage = createMiiImageAndVerify(WLS_LOGGING_IMAGE_NAME, modelList, appList); |
| 402 | + miiImage = createMiiImageAndVerify(WLS_ELK_LOGGING_IMAGE_NAME, modelList, appList); |
477 | 403 | } |
478 | 404 |
|
479 | 405 | // repo login and push image to registry if necessary |
|
0 commit comments