From 7e1b7d0f058037079fdb405c4bac332131c0ad75 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Tue, 31 Jan 2023 13:17:47 -0600 Subject: [PATCH 01/20] add wallet collection logic --- .../discover/common_resources_discoverer.py | 36 +++++++++++++++++++ .../category_modules/JDBCSystemResource.json | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py index c8301e634c..2e220b77f1 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py +++ b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py @@ -2,6 +2,7 @@ Copyright (c) 2017, 2023, Oracle Corporation and/or its affiliates. All rights reserved. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. """ +import os.path from java.lang import IllegalArgumentException from oracle.weblogic.deploy.util import PyOrderedDict as OrderedDict @@ -91,6 +92,7 @@ def get_datasources(self): location = LocationContext(self._base_location) location.append_location(model_top_folder_name) datasources = self._find_names_in_folder(location) + collected_wallet = {} if datasources is not None: _logger.info('WLSDPLY-06340', len(datasources), class_name=_class_name, method_name=_method_name) typedef = self._model_context.get_domain_typedef() @@ -112,11 +114,45 @@ def get_datasources(self): resource_result = result[datasource][model_second_folder] self._populate_model_parameters(resource_result, location) self._discover_subfolders(resource_result, location) + self._collect_jdbc_driver_wallet(datasource, collected_wallet, + result[datasource][model_constants.JDBC_RESOURCE][model_constants.JDBC_DRIVER_PARAMS]) location.remove_name_token(name_token) location.pop_location() _logger.exiting(class_name=_class_name, method_name=_method_name, result=result) return model_top_folder_name, result + def _collect_jdbc_driver_wallet(self, datasource, collected_wallet, driver_params): + if model_constants.JDBC_DRIVER_PARAMS_PROPERTIES in driver_params: + properties = driver_params[model_constants.JDBC_DRIVER_PARAMS_PROPERTIES] + for connection_property in ["javax.net.ssl.keyStore", + "javax.net.ssl.trustStore", + "oracle.net.tns_admin" ]: + if connection_property in properties: + property_value = properties[connection_property]['Value'] + if property_value: + if os.path.exists(property_value): + fixed_path = self._add_wallet_directory_to_archive(datasource, collected_wallet, + property_value) + # update the property value with the updated path into the archive + if os.path.isdir(property_value): + properties[connection_property]['Value'] = fixed_path + else: + properties[connection_property]['Value'] = fixed_path + os.path.basename(property_value) + + def _add_wallet_directory_to_archive(self, datasource, collected_wallet, property_value): + if self._model_context.skip_archive() or self._model_context.is_remote(): + return property_value + if os.path.isdir(property_value): + path = os.path.abspath(property_value) + else: + path = os.path.dirname(os.path.abspath(property_value)) + archive_file = self._model_context.get_archive_file() + if not path in collected_wallet: + ds = datasource.replace(' ','').replace('(', '').replace(')','') + path_into_archive = archive_file.addDatabaseWallet(datasource, path) + collected_wallet[path] = { 'wallet_name' : ds, 'path_into_archive': path_into_archive} + return collected_wallet[path]['path_into_archive'] + def get_foreign_jndi_providers(self): """ Discover Foreign JNDI providers from the domain. diff --git a/core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/JDBCSystemResource.json b/core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/JDBCSystemResource.json index 3680dd9ce4..caf1ddacf4 100644 --- a/core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/JDBCSystemResource.json +++ b/core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/JDBCSystemResource.json @@ -109,7 +109,7 @@ "folders": { }, "attributes": { "EncryptedValueEncrypted": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "EncryptedValueEncrypted", "wlst_path": "WP001", "default_value": null, "wlst_type": "password", "get_method": "GET"} ], - "Value": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Value", "wlst_path": "WP001", "default_value": "", "wlst_type": "string" } ], + "Value": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Value", "wlst_path": "WP001", "default_value": "", "wlst_type": "string", "uses_path_tokens": "true" } ], "SysPropValue": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SysPropValue", "wlst_path": "WP001", "default_value": "", "wlst_type": "string" } ] }, "wlst_attributes_path": "WP001", From 1493bae80bda0e55249de6d760591fdeae42445b Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Tue, 31 Jan 2023 13:25:22 -0600 Subject: [PATCH 02/20] undo unnecessary changes --- .../deploy/aliases/category_modules/JDBCSystemResource.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/JDBCSystemResource.json b/core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/JDBCSystemResource.json index caf1ddacf4..3680dd9ce4 100644 --- a/core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/JDBCSystemResource.json +++ b/core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/JDBCSystemResource.json @@ -109,7 +109,7 @@ "folders": { }, "attributes": { "EncryptedValueEncrypted": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "EncryptedValueEncrypted", "wlst_path": "WP001", "default_value": null, "wlst_type": "password", "get_method": "GET"} ], - "Value": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Value", "wlst_path": "WP001", "default_value": "", "wlst_type": "string", "uses_path_tokens": "true" } ], + "Value": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Value", "wlst_path": "WP001", "default_value": "", "wlst_type": "string" } ], "SysPropValue": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "SysPropValue", "wlst_path": "WP001", "default_value": "", "wlst_type": "string" } ] }, "wlst_attributes_path": "WP001", From c76f496d1043ecb14f47e417637ce86f9aefc202 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Wed, 1 Feb 2023 16:34:38 -0600 Subject: [PATCH 03/20] refactor --- .../discover/common_resources_discoverer.py | 98 +++++++++++++++---- .../deploy/messages/wlsdeploy_rb.properties | 6 ++ 2 files changed, 83 insertions(+), 21 deletions(-) diff --git a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py index 2e220b77f1..19ed3612c8 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py +++ b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py @@ -122,36 +122,92 @@ def get_datasources(self): return model_top_folder_name, result def _collect_jdbc_driver_wallet(self, datasource, collected_wallet, driver_params): + _method_name = '_collect_jdbc_driver_wallet' if model_constants.JDBC_DRIVER_PARAMS_PROPERTIES in driver_params: properties = driver_params[model_constants.JDBC_DRIVER_PARAMS_PROPERTIES] - for connection_property in ["javax.net.ssl.keyStore", - "javax.net.ssl.trustStore", - "oracle.net.tns_admin" ]: + for connection_property in [model_constants.DRIVER_PARAMS_KEYSTORE_PROPERTY, + model_constants.DRIVER_PARAMS_TRUSTSTORE_PROPERTY, + model_constants.DRIVER_PARAMS_NET_TNS_ADMIN]: if connection_property in properties: property_value = properties[connection_property]['Value'] - if property_value: - if os.path.exists(property_value): - fixed_path = self._add_wallet_directory_to_archive(datasource, collected_wallet, - property_value) - # update the property value with the updated path into the archive - if os.path.isdir(property_value): - properties[connection_property]['Value'] = fixed_path - else: - properties[connection_property]['Value'] = fixed_path + os.path.basename(property_value) - - def _add_wallet_directory_to_archive(self, datasource, collected_wallet, property_value): + if property_value and os.path.exists(property_value): + fixed_path = self._add_wallet_directory_to_archive(datasource, collected_wallet, + property_value) + _logger.info('WLSDPLY-06367', connection_property, fixed_path, + class_name=_class_name, method_name=_method_name) + properties[connection_property]['Value'] = fixed_path + + + def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictionary, property_value): + _method_name = '_add_wallet_directory_to_archive' if self._model_context.skip_archive() or self._model_context.is_remote(): return property_value if os.path.isdir(property_value): - path = os.path.abspath(property_value) + onprem_wallet_parent_path = os.path.abspath(property_value) else: - path = os.path.dirname(os.path.abspath(property_value)) + onprem_wallet_parent_path = os.path.dirname(os.path.abspath(property_value)) + + # error if wallet parent path is at oracle home + if self._model_context.get_oracle_home() == onprem_wallet_parent_path: + _logger.severe('WLSDPLY-06368', property_value, self._model_context.get_oracle_home()) + de = exception_helper.create_discover_exception('WLSDPLY-06368', property_value, + self._model_context.get_oracle_home()) + _logger.throwing(class_name=_class_name, method_name=_method_name, error=de) + raise de + + onprem_wallet_dir_is_not_flat = self._is_on_prem_wallet_dir_flat(onprem_wallet_parent_path, property_value) archive_file = self._model_context.get_archive_file() - if not path in collected_wallet: - ds = datasource.replace(' ','').replace('(', '').replace(')','') - path_into_archive = archive_file.addDatabaseWallet(datasource, path) - collected_wallet[path] = { 'wallet_name' : ds, 'path_into_archive': path_into_archive} - return collected_wallet[path]['path_into_archive'] + # fix up name just in case + wallet_name = datasource.replace(' ','').replace('(', '').replace(')','') + + # keep track of the wallet name and from where it is collected + # { 'onprem_wallet_parentpath' : { 'wallet_name': , 'path_into_archive': , + # }, + # .... } + # + + if not onprem_wallet_parent_path in collected_wallet_dictionary: + if onprem_wallet_dir_is_not_flat: + fixed_path = archive_file.addDatabaseWallet(wallet_name, os.path.abspath(property_value)) + path_into_archive = os.path.dirname(fixed_path) + else: + fixed_path = archive_file.addDatabaseWallet(wallet_name, onprem_wallet_parent_path) + path_into_archive = fixed_path + fixed_path = os.path.join(fixed_path, os.path.basename(property_value)) + + collected_wallet_dictionary[onprem_wallet_parent_path] = \ + {'wallet_name' : wallet_name, 'path_into_archive': path_into_archive} + else: + # if the directory has already been visited before + # check for the wallet to see if the file has already been collected on prem and add only the file + if not archive_file.isPathIntoArchive(os.path.join( + collected_wallet_dictionary[onprem_wallet_parent_path]['path_into_archive'], + os.path.basename(property_value))): + # only case is it is not flat directory if the particular file has not been collected + fixed_path = archive_file.addDatabaseWallet(wallet_name, os.path.abspath(property_value)) + else: + # already in archive just figure out the path + if (os.path.isdir(property_value)): + fixed_path = collected_wallet_dictionary[onprem_wallet_parent_path]['path_into_archive'] + else: + fixed_path = os.path.join(collected_wallet_dictionary[onprem_wallet_parent_path]['path_into_archive'], + os.path.basename(property_value)) + + + return fixed_path + + def _is_on_prem_wallet_dir_flat(self, onprem_wallet_parent_path, property_value): + # info if wallet parent is not flat and only collect the particular file and not the entire directory + dir_list = os.listdir(onprem_wallet_parent_path) + onprem_wallet_dir_is_not_flat = False + for item in dir_list: + if os.path.isdir(os.path.join(onprem_wallet_parent_path, item)): + onprem_wallet_dir_is_not_flat = True + break + # put out info for user only particular file is collected and not the entire wallet directory + if onprem_wallet_dir_is_not_flat: + _logger.info('WLSDPLY-06369', property_value) + return onprem_wallet_dir_is_not_flat def get_foreign_jndi_providers(self): """ diff --git a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties index 45191654f0..f2069857a3 100644 --- a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties +++ b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties @@ -740,6 +740,12 @@ WLSDPLY-06363=Skipping {0} File Store {1} WLSDPLY-06364=Discovering {0} {1} elements WLSDPLY-06365=Adding {0} {1} WLSDPLY-06366={0} configuration for {1} {2} will not be discovered in online mode +WLSDPLY-06367=Add JDBC Datasource DriverParams wallet based on property {0} into archive entry path {1} +WLSDPLY-06368=Unable to collect wallet directory because the JDBC Datasource DriverParams connection property value {0} \ + is at ORACLE_HOME directory {1}. +WLSDPLY-06369=Parent directory of JDBC Datasource DriverParams property value {0} is not a flat structure, only \ + individual file will be added to the wallet, other files that may exists in the original database wallet will not be \ + collected. # deployments_discoverer.py WLSDPLY-06380=Discovering domain model deployments From 5f078dbada4ff297df8895c8e4df045b67a546d3 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Wed, 1 Feb 2023 16:44:03 -0600 Subject: [PATCH 04/20] fix bug --- .../tool/discover/common_resources_discoverer.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py index 19ed3612c8..95bed7c7fc 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py +++ b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py @@ -161,7 +161,7 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona wallet_name = datasource.replace(' ','').replace('(', '').replace(')','') # keep track of the wallet name and from where it is collected - # { 'onprem_wallet_parentpath' : { 'wallet_name': , 'path_into_archive': , + # { : { 'wallet_name': , 'path_into_archive': , # }, # .... } # @@ -183,8 +183,10 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona if not archive_file.isPathIntoArchive(os.path.join( collected_wallet_dictionary[onprem_wallet_parent_path]['path_into_archive'], os.path.basename(property_value))): - # only case is it is not flat directory if the particular file has not been collected - fixed_path = archive_file.addDatabaseWallet(wallet_name, os.path.abspath(property_value)) + # only case is it is not flat directory if the particular file has not been collected before, add + # it to the previous wallet + fixed_path = archive_file.addDatabaseWallet(collected_wallet_dictionary[onprem_wallet_parent_path]['wallet_name'], + os.path.abspath(property_value)) else: # already in archive just figure out the path if (os.path.isdir(property_value)): @@ -193,7 +195,6 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona fixed_path = os.path.join(collected_wallet_dictionary[onprem_wallet_parent_path]['path_into_archive'], os.path.basename(property_value)) - return fixed_path def _is_on_prem_wallet_dir_flat(self, onprem_wallet_parent_path, property_value): From 67583a7371fc3ea4f11eec73216458d7e0dc90dd Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Wed, 1 Feb 2023 17:40:30 -0600 Subject: [PATCH 05/20] fix bug --- .../tool/discover/common_resources_discoverer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py index 95bed7c7fc..7f90095341 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py +++ b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py @@ -165,7 +165,6 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona # }, # .... } # - if not onprem_wallet_parent_path in collected_wallet_dictionary: if onprem_wallet_dir_is_not_flat: fixed_path = archive_file.addDatabaseWallet(wallet_name, os.path.abspath(property_value)) @@ -180,9 +179,10 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona else: # if the directory has already been visited before # check for the wallet to see if the file has already been collected on prem and add only the file - if not archive_file.isPathIntoArchive(os.path.join( - collected_wallet_dictionary[onprem_wallet_parent_path]['path_into_archive'], - os.path.basename(property_value))): + check_path = os.path.join( + collected_wallet_dictionary[onprem_wallet_parent_path]['path_into_archive'], + os.path.basename(property_value)) + if not check_path in archive_file.getArchiveEntries() and os.path.isfile(property_value): # only case is it is not flat directory if the particular file has not been collected before, add # it to the previous wallet fixed_path = archive_file.addDatabaseWallet(collected_wallet_dictionary[onprem_wallet_parent_path]['wallet_name'], From 826f163cd82cd92cb6131288eb87154e2d17b449 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Thu, 2 Feb 2023 14:26:24 -0600 Subject: [PATCH 06/20] add integration test --- core/src/main/python/create.py | 7 +- .../discover/common_resources_discoverer.py | 24 +- .../wlsdeploy/tool/util/archive_helper.py | 16 +- .../weblogic/deploy/integration/BaseTest.java | 11 + .../weblogic/deploy/integration/ITWdt.java | 2124 +++++++++-------- .../src/test/resources/cwallet.sso | 0 .../resources/simple-topology-jdbcwallet.yaml | 40 + 7 files changed, 1197 insertions(+), 1025 deletions(-) create mode 100644 integration-tests/system-test/src/test/resources/cwallet.sso create mode 100644 integration-tests/system-test/src/test/resources/simple-topology-jdbcwallet.yaml diff --git a/core/src/main/python/create.py b/core/src/main/python/create.py index 007dd555d2..6b655ae97f 100644 --- a/core/src/main/python/create.py +++ b/core/src/main/python/create.py @@ -322,8 +322,11 @@ def main(model_context): has_atp, has_ssl = validate_rcu_args_and_model(model_context, model_dictionary, archive_helper, aliases) # check if there is an atpwallet and extract in the domain dir # it is to support non JRF domain but user wants to use ATP database - if has_atp and archive_helper: - archive_helper.extract_database_wallet() + # if (has_atp or has_ssl) and archive_helper: + # archive_helper.extract_database_wallet() + + if archive_helper: + archive_helper.extract_all_database_wallets() creator = DomainCreator(model_dictionary, model_context, aliases) creator.create() diff --git a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py index 7f90095341..596d421f31 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py +++ b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py @@ -129,19 +129,25 @@ def _collect_jdbc_driver_wallet(self, datasource, collected_wallet, driver_param model_constants.DRIVER_PARAMS_TRUSTSTORE_PROPERTY, model_constants.DRIVER_PARAMS_NET_TNS_ADMIN]: if connection_property in properties: - property_value = properties[connection_property]['Value'] - if property_value and os.path.exists(property_value): - fixed_path = self._add_wallet_directory_to_archive(datasource, collected_wallet, - property_value) - _logger.info('WLSDPLY-06367', connection_property, fixed_path, - class_name=_class_name, method_name=_method_name) - properties[connection_property]['Value'] = fixed_path + qualified_property_value = properties[connection_property]['Value'] + if qualified_property_value: + if qualified_property_value.startswith(WLSDeployArchive.WLSDPLY_ARCHIVE_BINARY_DIR + + WLSDeployArchive.ZIP_SEP): + qualified_property_value = os.path.join(self._model_context.get_domain_home() + ,qualified_property_value) + if os.path.exists(qualified_property_value): + fixed_path = self._add_wallet_directory_to_archive(datasource, collected_wallet, + qualified_property_value) + _logger.info('WLSDPLY-06367', connection_property, fixed_path, + class_name=_class_name, method_name=_method_name) + properties[connection_property]['Value'] = fixed_path def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictionary, property_value): _method_name = '_add_wallet_directory_to_archive' if self._model_context.skip_archive() or self._model_context.is_remote(): return property_value + if os.path.isdir(property_value): onprem_wallet_parent_path = os.path.abspath(property_value) else: @@ -151,7 +157,7 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona if self._model_context.get_oracle_home() == onprem_wallet_parent_path: _logger.severe('WLSDPLY-06368', property_value, self._model_context.get_oracle_home()) de = exception_helper.create_discover_exception('WLSDPLY-06368', property_value, - self._model_context.get_oracle_home()) + self._model_context.get_oracle_home()) _logger.throwing(class_name=_class_name, method_name=_method_name, error=de) raise de @@ -193,7 +199,7 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona fixed_path = collected_wallet_dictionary[onprem_wallet_parent_path]['path_into_archive'] else: fixed_path = os.path.join(collected_wallet_dictionary[onprem_wallet_parent_path]['path_into_archive'], - os.path.basename(property_value)) + os.path.basename(property_value)) return fixed_path diff --git a/core/src/main/python/wlsdeploy/tool/util/archive_helper.py b/core/src/main/python/wlsdeploy/tool/util/archive_helper.py index 624324e837..580a28b398 100644 --- a/core/src/main/python/wlsdeploy/tool/util/archive_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/archive_helper.py @@ -2,7 +2,7 @@ Copyright (c) 2017, 2023, Oracle Corporation and/or its affiliates. All rights reserved. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. """ -import os +import os, sets import shutil from java.io import File @@ -401,6 +401,20 @@ def extract_database_wallet(self, wallet_name=WLSDeployArchive.DEFAULT_RCU_WALLE self.__logger.exiting(class_name=self.__class_name, method_name=_method_name, result=resulting_wallet_path) return resulting_wallet_path + def extract_all_database_wallets(self): + archive_entries = self.get_archive_entries() + wallet_names = sets.Set() + for entry in archive_entries: + if entry.startswith(WLSDeployArchive.ARCHIVE_DB_WALLETS_DIR): + if os.path.isdir(entry): + name = wallet_names.add(os.path.basename(entry)) + else: + name = os.path.basename(os.path.dirname(entry)) + + wallet_names.add(name) + for wallet_name in wallet_names: + self.extract_database_wallet(wallet_name) + def extract_opss_wallet(self): """ Extract the and unzip the OPSS wallet, if present, and return the path to the wallet directory. diff --git a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java index f2064090ab..57d5a3f86b 100644 --- a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java +++ b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java @@ -33,6 +33,7 @@ public class BaseTest { protected static final String FS = File.separator; private static final String SAMPLE_ARCHIVE_FILE = "archive.zip"; private static final String UPDATED_SAMPLE_ARCHIVE_FILE = "archive2.zip"; + private static final String WALLET_SAMPLE_ARCHIVE_FILE = "archive-jdbc.zip"; private static final String WDT_ZIPFILE = "weblogic-deploy.zip"; private static final String WDT_HOME_DIR = "weblogic-deploy"; protected static final String SAMPLE_MODEL_FILE_PREFIX = "simple-topology"; @@ -49,6 +50,7 @@ public class BaseTest { protected static String validateModelScript = ""; protected static String domainParentDir = ""; protected static String prepareModelScript = ""; + protected static String archiveHelperScript = ""; protected static final String ORACLE_DB_IMG = "phx.ocir.io/weblogick8s/database/enterprise"; protected static final String ORACLE_DB_IMG_TAG = "12.2.0.1-slim"; private static final String DB_CONTAINER_NAME = generateDatabaseContainerName(); @@ -90,6 +92,7 @@ protected static void initialize() { validateModelScript = getWDTScriptsHome() + FS + "validateModel.sh"; compareModelScript = getWDTScriptsHome() + FS + "compareModel.sh"; prepareModelScript = getWDTScriptsHome() + FS + "prepareModel.sh"; + archiveHelperScript = getWDTScriptsHome() + FS + "archiveHelper.sh"; domainParentDir = "." + FS + "target" + FS + "domains"; } @@ -208,6 +211,10 @@ protected static String getSampleArchiveFile() { return getTargetDir() + FS + SAMPLE_ARCHIVE_FILE; } + protected static String getSampleArchiveFileWithWallet() { + return getTargetDir() + FS + WALLET_SAMPLE_ARCHIVE_FILE; + } + protected static String getUpdatedSampleArchiveFile() { return getTargetDir() + FS + UPDATED_SAMPLE_ARCHIVE_FILE; } @@ -216,6 +223,10 @@ protected static String getSampleModelFile(String suffix) { return getResourcePath() + FS + SAMPLE_MODEL_FILE_PREFIX + suffix + ".yaml"; } + protected static String getSampleKeyStoreFile() { + return getResourcePath() + FS + "cwallet.sso"; + } + protected static Path getInstallerTargetDir() { return Paths.get("..", "installer", "target"); } diff --git a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java index ca028b4c18..1147698533 100644 --- a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java +++ b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java @@ -114,1051 +114,1149 @@ private static PrintWriter getTestMethodWriter(TestInfo testInfo, String suffixN new FileOutputStream(outputPath.resolve(Paths.get(methodName + suffixName + ".out")).toString()))), true); } - - /** - * test createDomain.sh with only -oracle_home argument - * @throws Exception - if any error occurs - */ - @DisplayName("Test 1: createDomain bad arguments") - @Order(1) - @Tag("gate") - @Test - void test01CreateDomainNoDomainHome(TestInfo testInfo) throws Exception { - String cmd = createDomainScript + " -oracle_home " + mwhome_12213; - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(99, result.exitValue(), "Unexpected return code"); - assertTrue(result.stdout().contains("WLSDPLY-20008"), "Output did not contain expected WLSDPLY-20008"); - } - } - - /** - * test createDomain.sh with only -oracle_home and -domain_type arguments - * @throws Exception - if any error occurs - */ - @DisplayName("Test 2: createDomain bad arguments") - @Order(2) - @Tag("gate") - @Test - void test02CreateDomainNoDomainHome(TestInfo testInfo) throws Exception { - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_type WLS"; - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(99, result.exitValue(), "Unexpected return code"); - // command should fail because of invalid arguments - assertTrue(result.stdout().contains("WLSDPLY-20008"), "Output did not contain expected WLSDPLY-20008"); - } - } - - /** - * test createDomain.sh without model file - * @throws Exception - if any error occurs - */ - @DisplayName("Test 3: createDomain bad arguments") - @Order(3) - @Tag("gate") - @Test - void test03CreateDomainNoModelfile(TestInfo testInfo) throws Exception { - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir; - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(99, result.exitValue(), "Unexpected return code"); - // command should fail because of invalid arguments - assertTrue(result.stdout().contains("WLSDPLY-20008"), "Output did not contain expected WLSDPLY-20008"); - } - } - - /** - * test createDomain.sh without archive file - * @throws Exception - if output file could not be created or written - */ - @DisplayName("Test 4: createDomain without archive file") - @Order(4) - @Tag("gate") - @Test - void test04CreateDomainNoArchivefile(TestInfo testInfo) throws Exception { - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir + - " -model_file " + getSampleModelFile("-constant") ; - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(2, result.exitValue(), "Unexpected return code"); - // command should fail because of invalid arguments - assertTrue(result.stdout().contains("WLSDPLY-05025"), "Output did not contain expected WLSDPLY-05025"); - } - } - - /** - * test createDomain.sh with required arguments using simple-topology-constant.yaml (domain = domain1) - * @throws Exception - if any error occurs - */ - @DisplayName("Test 5: createDomain with domain_parent") - @Order(5) - @Tag("gate") - @Test - void test05CreateDomain(TestInfo testInfo) throws Exception { - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir + - " -model_file " + getSampleModelFile("-constant") + - " -archive_file " + getSampleArchiveFile(); - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result.exitValue(), "Unexpected return code"); - assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); - } - } - - /** - * test createDomain.sh using simple-topology-constant.yaml with different domain name in - * -domain_home and model file in model file, it specifies the domain name as 'domain1' - * in -domain_home argument, it specifies the domain home as 'domain2' - * @throws Exception - if any error occurs - */ - @DisplayName("Test 6: createDomain with domain_home") - @Order(6) - @Tag("gate") - @Test - void test06CreateDomainDifferentDomainName(TestInfo testInfo) throws Exception { - String cmd = createDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + "domain2" - + " -model_file " + getSampleModelFile("-constant") - + " -archive_file " + getSampleArchiveFile(); - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result.exitValue(), "Unexpected return code"); - assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); - } - } - - /** - * test createDomain.sh with WLS domain_type using simple-topology-constant.yaml (domain = domain2) - * @throws Exception -if any error occurs - */ - @Order(7) - @Tag("gate") - @Test - void test07CreateDomainWLSType(TestInfo testInfo) throws Exception { - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainParentDir + FS + "domain2 -model_file " + - getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + - " -domain_type WLS"; - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result.exitValue(), "Unexpected return code"); - assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); - } - } - - /** - * test createDomain.sh, model file contains variables but no variable_file specified - * @throws Exception - if any error occurs - */ - @DisplayName("Test 8: createDomain but needs variable file") - @Order(8) - @Tag("gate") - @Test - void test08CreateDomainNoVariableFile(TestInfo testInfo) throws Exception { - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir + - " -model_file " + getSampleModelFile("1") + - " -archive_file " + getSampleArchiveFile() ; - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(2, result.exitValue(), "Unexpected return code"); - // command should fail because of invalid arguments - assertTrue(result.stdout().contains("WLSDPLY-20004"), "Output did not contain expected WLSDPLY-20004"); - } - } - - /** - * test createDomain.sh with variable_file argument using simple-topology1.yaml (domain = domain2) - * @throws Exception - if any error occurs - */ - @DisplayName("Test 9: createDomain with variable file") - @Order(9) - @Tag("gate") - @Test - void test09CreateDomainWithVariableFile(TestInfo testInfo) throws Exception { - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainParentDir + FS + "domain2 -model_file " + - getSampleModelFile("1") + " -archive_file " + getSampleArchiveFile() + - " -domain_type WLS -variable_file " + getSampleVariableFile(); - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result.exitValue(), "Unexpected return code"); - assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); - } - } - - /** - * test createDomain.sh with wlst_path set to mwhome/wlserver using simple-topology1.yaml (domain = domain2) - * @throws Exception - if any error occurs - */ - @DisplayName("Test 10: createDomain with WLS wlst_path") - @Order(10) - @Tag("gate") - @Test - void test10CreateDomainWithWlstPath(TestInfo testInfo) throws Exception { - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainParentDir + FS + "domain2 -model_file " + - getSampleModelFile("1") + " -archive_file " + getSampleArchiveFile() + - " -domain_type WLS -variable_file " + getSampleVariableFile() + " -wlst_path " + - mwhome_12213 + FS + "wlserver"; - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result.exitValue(), "Unexpected return code"); - assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); - } - } - - /** - * test createDomain.sh with -wlst_path set to mwhome/oracle_common using simple-topology1.yaml (domain = domain2) - * @throws Exception - if any error occurs - */ - @DisplayName("Test 11: createDomain with oracle_commmon wlst_path") - @Order(11) - @Tag("gate") - @Test - void test11CreateDomainWithOracleCommonWlstPath(TestInfo testInfo) throws Exception { - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainParentDir + FS + "domain2 -model_file " + - getSampleModelFile("1") + " -archive_file " + getSampleArchiveFile() + - " -domain_type WLS -variable_file " + getSampleVariableFile() + " -wlst_path " + - mwhome_12213 + FS + "oracle_common"; - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result.exitValue(), "Unexpected return code"); - assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); - test11DomainCreated = true; - } - } - - /** - * test createDomain.sh, create JRF domain without -run_rcu argument - * @throws Exception - if any error occurs - */ - @DisplayName("Test 12: createDomain JRF domain without DB") - @Order(12) - @Tag("gate") - @Test - void test12CreateJRFDomainNoRunRCU(TestInfo testInfo) throws Exception { - assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); - try (PrintWriter out = getTestMethodWriter(testInfo)) { - Path source = Paths.get(getSampleModelFile("2")); - Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); - // create wdt model file to use in create, after substitution of DB host/ip - replaceStringInFile(source, modelOut, "%DB_HOST%", getDBContainerIP()); - - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainParentDir + FS + "domain2 -model_file " + - modelOut + " -archive_file " + getSampleArchiveFile() + " -domain_type JRF"; - - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(2, result.exitValue(), "Unexpected return code"); - assertTrue(result.stdout().contains("WLSDPLY-12409"), "Output did not contain expected WLSDPLY-12409"); - } - } - - /** - * test createDomain.sh, create JRF domain with -run_rcu argument - * @throws Exception - if any error occurs - */ - @DisplayName("Test 13: createDomain JRF domain and run RCU") - @Order(13) - @Tag("gate") - @Test - void test13CreateJRFDomainRunRCU(TestInfo testInfo) throws Exception { - assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); - waitForDatabase(); - try (PrintWriter out = getTestMethodWriter(testInfo)) { - Path source = Paths.get(getSampleModelFile("2")); - Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); - // create wdt model file to use in create, after substitution of DB host/ip - replaceStringInFile(source, modelOut, "%DB_HOST%", getDBContainerIP()); - - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainParentDir + FS + "jrfDomain1 -model_file " + - modelOut + " -archive_file " + getSampleArchiveFile() + " -domain_type JRF -run_rcu"; - - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result.exitValue(), "Unexpected return code"); - // command should fail because of invalid arguments - assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); - rcuDomainCreated = true; - } - } - - - /** - * testDOnlineUpdate1 check for 103 return code if an update requires restart. - * @throws Exception - if any error occurs - */ - @DisplayName("Test 14: Update JRF domain that requires restart") - @Order(14) - @Tag("gate") - @Test - void test14OnlineUpdate1(TestInfo testInfo) throws Exception { - assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); - assumeTrue(rcuDomainCreated, "testDOnlineUpdate skipped because testDCreateJRFDomainRunRCU failed"); - - // Setup boot.properties - // domainParent12213 - is relative ! - String domainHome = domainParentDir + FS + "jrfDomain1"; - setUpBootProperties(domainHome, "admin-server", "weblogic", "welcome1"); - Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); - boolean isServerUp = startAdminServer(domainHome, adminServerOut); - - if (isServerUp) { - try (PrintWriter out = getTestMethodWriter(testInfo)) { - // update wdt model file - Path source = Paths.get(getSampleModelFile("-onlineUpdate")); - Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); - Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); - - String cmd = "echo welcome1 | " - + updateDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + "jrfDomain1" - + " -model_file " + model - + " -domain_type JRF" - + " -admin_url t3://localhost:7001 -admin_user weblogic"; - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - - stopAdminServer(domainHome); - assertEquals(103, result.exitValue(), "onlineUpdate is expecting return code of 103"); - } - - } else { - // Best effort to clean up server - tryKillTheAdminServer(domainHome, "admin-server"); - throw new Exception("testDOnlineUpdate failed - cannot bring up server"); - } - } - - - /** - * testDOnlineUpdate2 check for 104 return code if an update cancel changes. - * @throws Exception - if any error occurs - */ - @DisplayName("Test 15: Update JRF domain that requires restart, but cancel changes") - @Order(15) - @Tag("gate") - @Test - void test15OnlineUpdate2(TestInfo testInfo) throws Exception { - assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); - assumeTrue(rcuDomainCreated, "testDOnlineUpdate2 skipped because testDCreateJRFDomainRunRCU failed"); - - String domainHome = domainParentDir + FS + "jrfDomain1"; - Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); - boolean isServerUp = startAdminServer(domainHome, adminServerOut); - - if (isServerUp) { - try (PrintWriter out = getTestMethodWriter(testInfo)) { - Path source = Paths.get(getSampleModelFile("-onlineUpdate2")); - Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate2.yaml"); - Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); - - String cmd = "echo welcome1 | " - + updateDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + "jrfDomain1" - + " -model_file " + model - + " -domain_type JRF" - + " -admin_url t3://localhost:7001 -admin_user weblogic" - + " -cancel_changes_if_restart_required"; - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - - stopAdminServer(domainHome); - assertEquals(104, result.exitValue(), "onlineUpdate2 is expecting return code of 104"); - } - } else { - // Best effort to clean up server - tryKillTheAdminServer(domainHome, "admin-server"); - throw new Exception("testDOnlineUpdate2 failed - cannot bring up WLS server"); - } - } - - +// +// /** +// * test createDomain.sh with only -oracle_home argument +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 1: createDomain bad arguments") +// @Order(1) +// @Tag("gate") +// @Test +// void test01CreateDomainNoDomainHome(TestInfo testInfo) throws Exception { +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213; +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(99, result.exitValue(), "Unexpected return code"); +// assertTrue(result.stdout().contains("WLSDPLY-20008"), "Output did not contain expected WLSDPLY-20008"); +// } +// } +// +// /** +// * test createDomain.sh with only -oracle_home and -domain_type arguments +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 2: createDomain bad arguments") +// @Order(2) +// @Tag("gate") +// @Test +// void test02CreateDomainNoDomainHome(TestInfo testInfo) throws Exception { +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_type WLS"; +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(99, result.exitValue(), "Unexpected return code"); +// // command should fail because of invalid arguments +// assertTrue(result.stdout().contains("WLSDPLY-20008"), "Output did not contain expected WLSDPLY-20008"); +// } +// } +// +// /** +// * test createDomain.sh without model file +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 3: createDomain bad arguments") +// @Order(3) +// @Tag("gate") +// @Test +// void test03CreateDomainNoModelfile(TestInfo testInfo) throws Exception { +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir; +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(99, result.exitValue(), "Unexpected return code"); +// // command should fail because of invalid arguments +// assertTrue(result.stdout().contains("WLSDPLY-20008"), "Output did not contain expected WLSDPLY-20008"); +// } +// } +// +// /** +// * test createDomain.sh without archive file +// * @throws Exception - if output file could not be created or written +// */ +// @DisplayName("Test 4: createDomain without archive file") +// @Order(4) +// @Tag("gate") +// @Test +// void test04CreateDomainNoArchivefile(TestInfo testInfo) throws Exception { +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir + +// " -model_file " + getSampleModelFile("-constant") ; +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(2, result.exitValue(), "Unexpected return code"); +// // command should fail because of invalid arguments +// assertTrue(result.stdout().contains("WLSDPLY-05025"), "Output did not contain expected WLSDPLY-05025"); +// } +// } +// +// /** +// * test createDomain.sh with required arguments using simple-topology-constant.yaml (domain = domain1) +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 5: createDomain with domain_parent") +// @Order(5) +// @Tag("gate") +// @Test +// void test05CreateDomain(TestInfo testInfo) throws Exception { +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir + +// " -model_file " + getSampleModelFile("-constant") + +// " -archive_file " + getSampleArchiveFile(); +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); +// } +// } +// +// /** +// * test createDomain.sh using simple-topology-constant.yaml with different domain name in +// * -domain_home and model file in model file, it specifies the domain name as 'domain1' +// * in -domain_home argument, it specifies the domain home as 'domain2' +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 6: createDomain with domain_home") +// @Order(6) +// @Tag("gate") +// @Test +// void test06CreateDomainDifferentDomainName(TestInfo testInfo) throws Exception { +// String cmd = createDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + "domain2" +// + " -model_file " + getSampleModelFile("-constant") +// + " -archive_file " + getSampleArchiveFile(); +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); +// } +// } +// +// /** +// * test createDomain.sh with WLS domain_type using simple-topology-constant.yaml (domain = domain2) +// * @throws Exception -if any error occurs +// */ +// @Order(7) +// @Tag("gate") +// @Test +// void test07CreateDomainWLSType(TestInfo testInfo) throws Exception { +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainParentDir + FS + "domain2 -model_file " + +// getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + +// " -domain_type WLS"; +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); +// } +// } +// +// /** +// * test createDomain.sh, model file contains variables but no variable_file specified +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 8: createDomain but needs variable file") +// @Order(8) +// @Tag("gate") +// @Test +// void test08CreateDomainNoVariableFile(TestInfo testInfo) throws Exception { +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir + +// " -model_file " + getSampleModelFile("1") + +// " -archive_file " + getSampleArchiveFile() ; +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(2, result.exitValue(), "Unexpected return code"); +// // command should fail because of invalid arguments +// assertTrue(result.stdout().contains("WLSDPLY-20004"), "Output did not contain expected WLSDPLY-20004"); +// } +// } +// +// /** +// * test createDomain.sh with variable_file argument using simple-topology1.yaml (domain = domain2) +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 9: createDomain with variable file") +// @Order(9) +// @Tag("gate") +// @Test +// void test09CreateDomainWithVariableFile(TestInfo testInfo) throws Exception { +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainParentDir + FS + "domain2 -model_file " + +// getSampleModelFile("1") + " -archive_file " + getSampleArchiveFile() + +// " -domain_type WLS -variable_file " + getSampleVariableFile(); +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); +// } +// } +// +// /** +// * test createDomain.sh with wlst_path set to mwhome/wlserver using simple-topology1.yaml (domain = domain2) +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 10: createDomain with WLS wlst_path") +// @Order(10) +// @Tag("gate") +// @Test +// void test10CreateDomainWithWlstPath(TestInfo testInfo) throws Exception { +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainParentDir + FS + "domain2 -model_file " + +// getSampleModelFile("1") + " -archive_file " + getSampleArchiveFile() + +// " -domain_type WLS -variable_file " + getSampleVariableFile() + " -wlst_path " + +// mwhome_12213 + FS + "wlserver"; +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); +// } +// } +// +// /** +// * test createDomain.sh with -wlst_path set to mwhome/oracle_common using simple-topology1.yaml (domain = domain2) +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 11: createDomain with oracle_commmon wlst_path") +// @Order(11) +// @Tag("gate") +// @Test +// void test11CreateDomainWithOracleCommonWlstPath(TestInfo testInfo) throws Exception { +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainParentDir + FS + "domain2 -model_file " + +// getSampleModelFile("1") + " -archive_file " + getSampleArchiveFile() + +// " -domain_type WLS -variable_file " + getSampleVariableFile() + " -wlst_path " + +// mwhome_12213 + FS + "oracle_common"; +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); +// test11DomainCreated = true; +// } +// } +// +// /** +// * test createDomain.sh, create JRF domain without -run_rcu argument +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 12: createDomain JRF domain without DB") +// @Order(12) +// @Tag("gate") +// @Test +// void test12CreateJRFDomainNoRunRCU(TestInfo testInfo) throws Exception { +// assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// Path source = Paths.get(getSampleModelFile("2")); +// Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); +// // create wdt model file to use in create, after substitution of DB host/ip +// replaceStringInFile(source, modelOut, "%DB_HOST%", getDBContainerIP()); +// +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainParentDir + FS + "domain2 -model_file " + +// modelOut + " -archive_file " + getSampleArchiveFile() + " -domain_type JRF"; +// +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(2, result.exitValue(), "Unexpected return code"); +// assertTrue(result.stdout().contains("WLSDPLY-12409"), "Output did not contain expected WLSDPLY-12409"); +// } +// } +// +// /** +// * test createDomain.sh, create JRF domain with -run_rcu argument +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 13: createDomain JRF domain and run RCU") +// @Order(13) +// @Tag("gate") +// @Test +// void test13CreateJRFDomainRunRCU(TestInfo testInfo) throws Exception { +// assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); +// waitForDatabase(); +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// Path source = Paths.get(getSampleModelFile("2")); +// Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); +// // create wdt model file to use in create, after substitution of DB host/ip +// replaceStringInFile(source, modelOut, "%DB_HOST%", getDBContainerIP()); +// +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainParentDir + FS + "jrfDomain1 -model_file " + +// modelOut + " -archive_file " + getSampleArchiveFile() + " -domain_type JRF -run_rcu"; +// +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// // command should fail because of invalid arguments +// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); +// rcuDomainCreated = true; +// } +// } +// +// +// /** +// * testDOnlineUpdate1 check for 103 return code if an update requires restart. +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 14: Update JRF domain that requires restart") +// @Order(14) +// @Tag("gate") +// @Test +// void test14OnlineUpdate1(TestInfo testInfo) throws Exception { +// assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); +// assumeTrue(rcuDomainCreated, "testDOnlineUpdate skipped because testDCreateJRFDomainRunRCU failed"); +// +// // Setup boot.properties +// // domainParent12213 - is relative ! +// String domainHome = domainParentDir + FS + "jrfDomain1"; +// setUpBootProperties(domainHome, "admin-server", "weblogic", "welcome1"); +// Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); +// boolean isServerUp = startAdminServer(domainHome, adminServerOut); +// +// if (isServerUp) { +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// // update wdt model file +// Path source = Paths.get(getSampleModelFile("-onlineUpdate")); +// Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); +// Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); +// +// String cmd = "echo welcome1 | " +// + updateDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + "jrfDomain1" +// + " -model_file " + model +// + " -domain_type JRF" +// + " -admin_url t3://localhost:7001 -admin_user weblogic"; +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// +// stopAdminServer(domainHome); +// assertEquals(103, result.exitValue(), "onlineUpdate is expecting return code of 103"); +// } +// +// } else { +// // Best effort to clean up server +// tryKillTheAdminServer(domainHome, "admin-server"); +// throw new Exception("testDOnlineUpdate failed - cannot bring up server"); +// } +// } +// +// +// /** +// * testDOnlineUpdate2 check for 104 return code if an update cancel changes. +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 15: Update JRF domain that requires restart, but cancel changes") +// @Order(15) +// @Tag("gate") +// @Test +// void test15OnlineUpdate2(TestInfo testInfo) throws Exception { +// assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); +// assumeTrue(rcuDomainCreated, "testDOnlineUpdate2 skipped because testDCreateJRFDomainRunRCU failed"); +// +// String domainHome = domainParentDir + FS + "jrfDomain1"; +// Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); +// boolean isServerUp = startAdminServer(domainHome, adminServerOut); +// +// if (isServerUp) { +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// Path source = Paths.get(getSampleModelFile("-onlineUpdate2")); +// Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate2.yaml"); +// Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); +// +// String cmd = "echo welcome1 | " +// + updateDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + "jrfDomain1" +// + " -model_file " + model +// + " -domain_type JRF" +// + " -admin_url t3://localhost:7001 -admin_user weblogic" +// + " -cancel_changes_if_restart_required"; +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// +// stopAdminServer(domainHome); +// assertEquals(104, result.exitValue(), "onlineUpdate2 is expecting return code of 104"); +// } +// } else { +// // Best effort to clean up server +// tryKillTheAdminServer(domainHome, "admin-server"); +// throw new Exception("testDOnlineUpdate2 failed - cannot bring up WLS server"); +// } +// } +// +// +// /** +// * test createDomain.sh, create restrictedJRF domain +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 16: create restricted JRF domain") +// @Order(16) +// @Tag("gate") +// @Test +// void test16CreateRestrictedJRFDomain(TestInfo testInfo) throws Exception { +// assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainParentDir + FS + "restrictedJRFD1 -model_file " + +// getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + +// " -domain_type RestrictedJRF"; +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// // command should fail because of invalid arguments +// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); +// } +// } +// +// /** +// * test discoverDomain.sh with required arguments +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 17: Discover domain restrictedJRFD1") +// @Order(17) +// @Tag("gate") +// @Test +// void test17DiscoverDomainWithRequiredArgument(TestInfo testInfo) throws Exception { +// assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainParentDir + FS + "restrictedJRFD1-discover17-18-19 -model_file " + +// getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + +// " -domain_type RestrictedJRF"; +// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// discover17DomainCreated = true; +// } +// +// try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { +// Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); +// Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); +// cmd = discoverDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + "restrictedJRFD1-discover17-18-19" +// + " -model_file " + discoveredModel +// + " -archive_file " + discoveredArchive +// + " -domain_type RestrictedJRF"; +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// // SecurityConfiguration warning +// assertEquals(1, result.exitValue(), "Unexpected return code"); +// +// // verify model file +// verifyModelFile(discoveredModel.toString()); +// verifyFDiscoverDomainWithRequiredArgument(discoveredModel.toString()); +// } +// } +// +// private void verifyFDiscoverDomainWithRequiredArgument(String expectedModelFile) throws Exception { +// List checkContents = new ArrayList<>(); +// checkContents.add("domainInfo:"); +// checkContents.add("AdminUserName: --FIX ME--"); +// checkContents.add("CoherenceClusterSystemResource: defaultCoherenceCluster"); +// checkContents.add("PublicAddress: kubernetes"); +// checkContents.add("Trust Service Identity Asserter:"); +// checkContents.add("appDeployments:"); +// checkContents.add("SourcePath: wlsdeploy/applications/simple-app.war"); +// verifyModelFileContents(expectedModelFile, checkContents); +// } +// /** +// * test discoverDomain.sh with -model_file argument +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 18: Discover domain restrictedJRFD1 using model_file arg") +// @Order(18) +// @Tag("gate") +// @Test +// void test18DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { +// assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); +// assertTrue(discover17DomainCreated, "Domain not created cannot run test"); +// +// Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); +// Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.yaml"); +// String cmd = discoverDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainParentDir + FS + "restrictedJRFD1-discover17-18-19 -archive_file " + discoveredArchive + +// " -model_file " + discoveredModelFile; +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// // SecurityConfiguration warning +// assertEquals(1, result.exitValue(), "Unexpected return code"); +// +// // verify model file +// verifyModelFile(discoveredModelFile.toString()); +// } +// } +// +// /** +// * test discoverDomain.sh with -variable_file argument +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 19: Discover domain restrictedJRFD1 using variable file") +// @Order(19) +// @Tag("gate") +// @Test +// void test19DiscoverDomainWithVariableFile(TestInfo testInfo) throws Exception { +// assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); +// assertTrue(discover17DomainCreated, "Domain not created and cannot be discovered"); +// Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); +// Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.yaml"); +// Path discoveredVariableFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.properties"); +// +// String cmd = discoverDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + "restrictedJRFD1-discover17-18-19" +// + " -archive_file " + discoveredArchive +// + " -model_file " + discoveredModelFile +// + " -variable_file " + discoveredVariableFile; +// +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// // SecurityConfiguration warning +// assertEquals(1, result.exitValue(), "Unexpected return code"); +// +// // verify model file and variable file +// verifyModelFile(discoveredModelFile.toString()); +// verifyModelFile(discoveredVariableFile.toString()); +// verifyGDiscoverDomainWithVariableFile(discoveredModelFile.toString()); +// } +// } +// +// private void verifyGDiscoverDomainWithVariableFile(String expectedModelFile) throws Exception { +// List checkContents = new ArrayList<>(); +// checkContents.add("AdminUserName: '@@PROP:AdminUserName@@'"); +// verifyModelFileContents(expectedModelFile, checkContents); +// } +// +// /** +// * test discoverDomain.sh with -domain_type as JRF +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 20: Discover domain domain_type JRF") +// @Order(20) +// @Tag("gate") +// @Test +// void test20DiscoverDomainJRFDomainType(TestInfo testInfo) throws Exception { +// assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); +// waitForDatabase(); +// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { +// Path source = Paths.get(getSampleModelFile("2")); +// Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); +// // create wdt model file to use in create, after substitution of DB host/ip +// replaceStringInFile(source, modelOut, "%DB_HOST%", getDBContainerIP()); +// +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainParentDir + FS + "jrfDomain1-discover20 -model_file " + +// modelOut + " -archive_file " + getSampleArchiveFile() + " -domain_type JRF -run_rcu"; +// +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// } +// try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { +// Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); +// Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredJRFD1.yaml"); +// String cmd = discoverDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + "jrfDomain1-discover20" +// + " -archive_file " + discoveredArchive +// + " -model_file " + discoveredModelFile +// + " -domain_type JRF"; +// +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// // SecurityConfiguration warning +// assertEquals(1, result.exitValue(), "Unexpected return code"); +// +// // verify model file +// verifyModelFile(discoveredModelFile.toString()); +// verifyHDiscoverDomainJRFDomainType(discoveredModelFile.toString()); +// } +// } +// +// private void verifyHDiscoverDomainJRFDomainType(String expectedModelFile) { +// List checkContents = new ArrayList<>(); +// checkContents.add("AWT Application Context Startup Class"); +// try { +// verifyModelFileContents(expectedModelFile, checkContents); +// throw new Exception("JRF blacklist components found in model file"); +// } catch (Exception e) { +// // empty this is expected result +// } +// } +// +// /** +// * test updateDomain.sh, update the domain to set the number of dynamic servers to 4 +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 21: Update domain dynamic server count") +// @Order(21) +// @Tag("gate") +// @Test +// void test21UpdateDomain(TestInfo testInfo) throws Exception { +// assumeTrue(test11DomainCreated, "Skipping test 21 because dependent domain was not created"); +// try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain")) { +// Path source = Paths.get(getSampleVariableFile()); +// Path variableFile = getTestOutputPath(testInfo).resolve(SAMPLE_VARIABLE_FILE); +// +// replaceStringInFile(source, variableFile, "CONFIGURED_MANAGED_SERVER_COUNT=2", +// "CONFIGURED_MANAGED_SERVER_COUNT=4"); +// +// String cmd = updateDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + "domain2" +// + " -model_file " + getSampleModelFile("1") +// + " -archive_file " + getSampleArchiveFile() +// + " -domain_type WLS" +// + " -variable_file " + variableFile; +// +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// verifyResult(result, "updateDomain.sh completed successfully"); +// } +// try (PrintWriter out = getTestMethodWriter(testInfo, "GrepResults")) { +// // Expecting grep return code of 0. Grep will return 0 if found, and 1 if the requested text is not found. +// String cmd = "grep -q '4' " + domainParentDir + FS + +// "domain2" + FS + "config" + FS + "config.xml"; +// CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result2.exitValue(), "config.xml does not appear to reflect the update"); +// } +// } +// +// /** +// * Test deployApp with missing model in archive. +// * Negative test, expects error message. +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 22: Deploy App negative test") +// @Order(22) +// @Tag("gate") +// @Test +// void test22DeployAppWithoutModelFile(TestInfo testInfo) throws Exception { +// assumeTrue(test11DomainCreated, "Skipping test 22 because dependent domain was not created"); +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// String cmd = deployAppScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + "domain2" +// + " -archive_file " + getSampleArchiveFile(); +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// verifyErrorMsg(result, "deployApps invoked with missing required argument: -model_file"); +// } +// } +// +// /** +// * Test deployApps. +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 23: Deploy App") +// @Order(23) +// @Tag("gate") +// @Test +// void test23DeployAppWithModelfile(TestInfo testInfo) throws Exception { +// assumeTrue(test11DomainCreated, "Skipping test 23 because dependent domain was not created"); +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// String cmd = deployAppScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + "domain2" +// + " -archive_file " + getSampleArchiveFile() +// + " -model_file " + getSampleModelFile("-constant"); +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// verifyResult(result, "deployApps.sh completed successfully"); +// } +// } +// +// /** +// * test validateModel.sh with -oracle_home only +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 24: Validate model negative (no model)") +// @Order(24) +// @Tag("gate") +// @Test +// void test24ValidateModelWithOracleHomeOnly(TestInfo testInfo) throws Exception { +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// String cmd = validateModelScript + " -oracle_home " + mwhome_12213; +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// verifyErrorMsg(result, "validateModel requires a model file to run"); +// } +// } +// +// /** +// * test validateModel.sh with -oracle_home and -model_file +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 25: Validate model negative (no archive)") +// @Order(25) +// @Tag("gate") +// @Test +// void test25ValidateModelWithOracleHomeModelFile(TestInfo testInfo) throws Exception { +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// String cmd = validateModelScript + " -oracle_home " + mwhome_12213 + " -model_file " + +// getSampleModelFile("-constant"); +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// verifyErrorMsg(result, "the archive file was not provided"); +// } +// } +// +// /** +// * test validateModel.sh without -variable_file +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 26: Validate model negative (no variable file)") +// @Order(26) +// @Tag("gate") +// @Test +// void test26ValidateModelWithoutVariableFile(TestInfo testInfo) throws Exception { +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// String cmd = validateModelScript +// + " -oracle_home " + mwhome_12213 +// + " -model_file " + getSampleModelFile("1"); +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// verifyErrorMsg(result, " and no properties file was provided"); +// } +// } +// +// /** +// * test compareModel.sh with only attribute difference. The files existences test whether it impacts WKO operation +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 27: Compare model") +// @Order(27) +// @Tag("gate") +// @Test +// void test27CompareModelRemoveAttribute(TestInfo testInfo) throws Exception { +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// Path outputDir = getTestOutputPath(testInfo).resolve("wdt_temp_output"); +// Files.createDirectories(outputDir); +// String cmd = compareModelScript +// + " -oracle_home " + mwhome_12213 +// + " -output_dir " + outputDir +// + " " + getSampleModelFile("1-lessattribute") +// + " " + getSampleModelFile("1"); +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// verifyResult(result, "compareModel.sh completed successfully"); +// +// verifyFileExists(outputDir.resolve("compare_model_stdout").toString()); +// verifyFileDoesNotExists(outputDir.resolve("diffed_model.yaml").toString()); +// } +// } +// +// /** +// * test validateModel.sh with invalid model file +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 28: Validate model negative (invalid model)") +// @Order(28) +// @Tag("gate") +// @Test +// void test28ValidateModelWithInvalidModelfile(TestInfo testInfo) throws Exception { +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// String cmd = validateModelScript +// + " -oracle_home " + mwhome_12213 +// + " -model_file " + getSampleModelFile("-invalid") +// + " -variable_file " + getSampleVariableFile(); +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// verifyErrorMsg(result, "exit code = 2"); +// } +// } +// +// @DisplayName("Test 29: Encrypt model") +// @Order(29) +// @Tag("gate") +// @Test +// void test29EncryptModel(TestInfo testInfo) throws Exception { +// Path source = Paths.get(getSampleModelFile("-constant")); +// Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-constant.yaml"); +// try (PrintWriter out = getTestMethodWriter(testInfo, "EncryptModel")) { +// Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); +// +// String cmd = encryptModelScript +// + " -oracle_home " + mwhome_12213 +// + " -model_file " + model + " < " + getResourcePath().resolve("passphrase.txt"); +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// verifyResult(result, "encryptModel.sh completed successfully"); +// } +// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { +// // create the domain using -use_encryption +// String cmd = createDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + "domain10" +// + " -model_file " + model +// + " -archive_file " + getSampleArchiveFile() +// + " -domain_type WLS" +// + " -use_encryption < " + getResourcePath().resolve("passphrase.txt"); +// CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// verifyResult(result2, "createDomain.sh completed successfully"); +// } +// } +// +// /** +// * test updateDomain.sh online with untargeting, deploy, and app update +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 30: createDomain and run updateDomain online for application") +// @Order(30) +// @Tag("gate") +// @Test +// void test30OnlineUpdateApp(TestInfo testInfo) throws Exception { +// String domainDir = "domain2-test30"; +// String cmd = createDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + domainDir +// + " -model_file " + getSampleModelFile("-onlinebase") +// + " -archive_file " + getSampleArchiveFile(); +// +// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); +// } +// +// String domainHome = domainParentDir + FS + domainDir; +// setUpBootProperties(domainHome, "admin-server", "weblogic", "welcome1"); +// Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); +// boolean isServerUp = startAdminServer(domainHome, adminServerOut); +// +// Path source = Paths.get(getSampleModelFile("-untargetapp")); +// Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); +// if (isServerUp) { +// try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-1")) { +// // update wdt model file +// Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); +// +// cmd = "echo welcome1 | " +// + updateDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + domainDir +// + " -model_file " + model +// + " -archive_file " + getSampleArchiveFile() +// + " -admin_url t3://localhost:7001 -admin_user weblogic"; +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// +// assertEquals(0, result.exitValue(), "Unexpected return code for untargeting app"); +// assertTrue(result.stdout().contains(" "), +// "Update does not contains expected message WLSDPLY-09339"); +// } +// try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-2")) { +// // Check result +// source = Paths.get(getSampleModelFile("-targetapp")); +// model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); +// Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); +// +// cmd = "echo welcome1 | " +// + updateDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + domainDir +// + " -model_file " + model +// + " -archive_file " + getSampleArchiveFile() +// + " -admin_url t3://localhost:7001 -admin_user weblogic"; +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// +// assertEquals(0, result.exitValue(), "Unexpected return code for targeting app"); +// assertTrue(result.stdout().contains("<__deploy_app_online> "), +// "Update does not contains expected message WLSDPLY-09316"); +// assertTrue(result.stdout().contains("<__start_app> "), +// "Update does not contains expected message WLSDPLY-09313"); +// } +// try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-online")) { +// source = Paths.get(getSampleModelFile("-targetapp")); +// model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); +// Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); +// +// cmd = "echo welcome1 | " +// + updateDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + domainDir +// + " -model_file " + model +// + " -archive_file " + getUpdatedSampleArchiveFile() +// + " -admin_url t3://localhost:7001 -admin_user weblogic"; +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// +// assertEquals(0, result.exitValue(), "Unexpected return code for updating domain with new archive"); +// assertTrue(result.stdout().contains("<__stop_app> "), +// "Update does not contains expected message WLSDPLY-09312"); +// assertTrue(result.stdout().contains("<__undeploy_app> "), +// "Update does not contains expected message WLSDPLY-09314"); +// assertTrue(result.stdout().contains("<__deploy_app_online> "), +// "Update does not contains expected message WLSDPLY-09316"); +// assertTrue(result.stdout().contains("<__start_app> "), +// "Update does not contains expected message WLSDPLY-09313"); +// +// cmd = "echo welcome1 | " +// + updateDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + domainDir +// + " -model_file " + model +// + " -remote" +// + " -archive_file " + getUpdatedSampleArchiveFile() +// + " -admin_url t3://localhost:7001 -admin_user weblogic"; +// result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// +// assertEquals(0, result.exitValue(), "Unexpected return code for remote updating domain with new archive"); +// +// Path sourcePyfile = Paths.get(getResourcePath() + FS + SAMPLE_MODEL_FILE_PREFIX + "-chk-srcpath.py"); +// Path testPyFile = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-chk-srcpath.py"); +// Files.copy(sourcePyfile, testPyFile, StandardCopyOption.REPLACE_EXISTING); +// cmd = mwhome_12213 + "/oracle_common/common/bin/wlst.sh " + testPyFile + " " + domainParentDir + FS + +// domainDir; +// result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code for running wlst to find app sourcepath"); +// Pattern pattern = Pattern.compile("SRCPATH=(.*)"); +// Matcher matcher = pattern.matcher(result.stdout()); +// String srcPath = "Unknown"; +// if (matcher.find()) { +// srcPath = matcher.group(1); +// } +// assertTrue(srcPath.equals("servers/admin-server/upload/simple-app/app/simple-app.war"), +// "App SourcePath returned " + srcPath + " does not match the expected value"); +// +// stopAdminServer(domainHome); +// } +// } else { +// // Best effort to clean up server +// tryKillTheAdminServer(domainHome, "admin-server"); +// throw new Exception("testDOnlineUpdate failed - cannot bring up server"); +// } +// } +// +// /** +// * test discoverDomain.sh that model can create a working domain +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 31: Discover domain and then create a new domain from the model") +// @Order(31) +// @Tag("gate") +// @Test +// void test31DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { +// String domainDir = "domain2-discover31"; +// String cmd = createDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + domainDir +// + " -model_file " + getSampleModelFile("-onlinebase") +// + " -archive_file " + getSampleArchiveFile(); +// +// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// } +// Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); +// Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); +// Path discoveredVariableFile = getTestOutputPath(testInfo).resolve("discoveredVariable.properties"); +// cmd = discoverDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainParentDir + FS + "domain2-discover31 -archive_file " + discoveredArchive + +// " -model_file " + discoveredModelFile + " -variable_file " + discoveredVariableFile; +// try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// +// verifyResult(result, "discoverDomain.sh completed successfully"); +// +// // verify model file +// verifyModelFile(discoveredModelFile.toString()); +// +// } +// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomainFromDiscover")) { +// String domainHome = domainParentDir + FS + "createDomainFromDiscover"; +// cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainHome + " -archive_file " + discoveredArchive + +// " -model_file " + discoveredModelFile + " -variable_file " + getSampleVariableFile(); +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// +// verifyResult(result, "createDomain.sh completed successfully"); +// +// setUpBootProperties(domainHome, "AdminServer", "weblogic", "welcome1"); +// Path adminServerOut = getTestOutputPath(testInfo).resolve("AdminServer.out"); +// boolean isServerUp = startAdminServer(domainHome, adminServerOut ); +// if (!isServerUp) { +// throw new Exception("Admin server did not come up after createDomain from discoverDomain"); +// } +// stopAdminServer(domainHome); +// } +// } +// +// /** +// * test prepareModel.sh with -target as wko +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 32: Prepare model") +// @Order(32) +// @Tag("gate") +// @Test +// void test32PrepareModel(TestInfo testInfo) throws Exception { +// +// Path outputFiles = getTestOutputPath(testInfo); +// try (PrintWriter out = getTestMethodWriter(testInfo, "PrepareModel")) { +// String wkoModelFile = getSampleModelFile("-targetwko"); +// String cmd = prepareModelScript +// + " -oracle_home " + mwhome_12213 +// + " -output_dir " + outputFiles +// + " -model_file " + wkoModelFile +// + " -target " + "wko"; +// +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// // ListenPort differences warning +// assertEquals(1, result.exitValue(), "Unexpected return code"); +// } +// try (PrintWriter out = getTestMethodWriter(testInfo, "GrepResults")) { +// // verify model file +// String tempWkoModel = outputFiles + FS + "simple-topology-targetwko.yaml"; +// String cmd = "grep \"PasswordEncrypted: '@@SECRET\" " + tempWkoModel; +// CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result2.exitValue(), "Missing JDBC Secret"); +// cmd = "grep -c 'Machine' " + tempWkoModel; +// CommandResult result3 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertNotEquals(0, result3.exitValue(), "Machine section was not removed from model"); +// } +// } +// +// /** +// * Test Discover Domain using the -skip_archive argument +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 33: Skip archive") +// @Order(33) +// @Tag("gate") +// @Test +// void test33DiscoverSkipArchive(TestInfo testInfo) throws Exception { +// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + +// domainParentDir + FS + "discoverDomainSkipArchive-33-34 -model_file " + +// getSampleModelFile("-onlinebase") + " -archive_file " + getSampleArchiveFile(); +// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// discover33DomainCreated = true; +// } +// +// try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { +// Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); +// cmd = discoverDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainParentDir + FS + "discoverDomainSkipArchive-33-34" +// + " -model_file " + discoveredModel +// + " -skip_archive " ; +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// // SecurityConfiguration warning +// assertEquals(0, result.exitValue(), "Unexpected return code"); +// } +// } +// +// /** +// * Test Discover Domain using the -run_remote argument +// * @throws Exception - if any error occurs +// */ +// @DisplayName("Test 34: remote discovery") +// @Order(34) +// @Tag("gate") +// @Test +// void test34DiscoverRemote(TestInfo testInfo) throws Exception { +// assertTrue(discover33DomainCreated, "step skipped because Domain creation failed in step test33DiscoverSkipArchive"); +// String domainHome = domainParentDir + FS + "discoverDomainSkipArchive-33-34"; +// setUpBootProperties(domainHome, "admin-server", "weblogic", "welcome1"); +// Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); +// boolean isServerUp = startAdminServer(domainHome, adminServerOut); +// +// if (isServerUp) { +// try (PrintWriter out = getTestMethodWriter(testInfo)) { +// Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); +// String cmd = discoverDomainScript +// + " -oracle_home " + mwhome_12213 +// + " -domain_home " + domainHome +// + " -model_file " + discoveredModel +// + " -admin_user weblogic -admin_pass welcome1 -admin_url t3://localhost:7001" +// + " -remote"; +// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); +// // SecurityConfiguration warning +// verifyResult(result, "Remote discovery created a model that references files or directories" + +// " on the remote machine"); +// } +// } else { +// // Best effort to clean up server +// tryKillTheAdminServer(domainHome, "admin-server"); +// throw new Exception("test34DiscoverRemote failed - cannot bring up server"); +// } +// +// } +// /** - * test createDomain.sh, create restrictedJRF domain - * @throws Exception - if any error occurs - */ - @DisplayName("Test 16: create restricted JRF domain") - @Order(16) - @Tag("gate") - @Test - void test16CreateRestrictedJRFDomain(TestInfo testInfo) throws Exception { - assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainParentDir + FS + "restrictedJRFD1 -model_file " + - getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + - " -domain_type RestrictedJRF"; - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result.exitValue(), "Unexpected return code"); - // command should fail because of invalid arguments - assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); - } - } - - /** - * test discoverDomain.sh with required arguments - * @throws Exception - if any error occurs - */ - @DisplayName("Test 17: Discover domain restrictedJRFD1") - @Order(17) - @Tag("gate") - @Test - void test17DiscoverDomainWithRequiredArgument(TestInfo testInfo) throws Exception { - assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainParentDir + FS + "restrictedJRFD1-discover17-18-19 -model_file " + - getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + - " -domain_type RestrictedJRF"; - try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result.exitValue(), "Unexpected return code"); - discover17DomainCreated = true; - } - - try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { - Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); - Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); - cmd = discoverDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + "restrictedJRFD1-discover17-18-19" - + " -model_file " + discoveredModel - + " -archive_file " + discoveredArchive - + " -domain_type RestrictedJRF"; - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - // SecurityConfiguration warning - assertEquals(1, result.exitValue(), "Unexpected return code"); - - // verify model file - verifyModelFile(discoveredModel.toString()); - verifyFDiscoverDomainWithRequiredArgument(discoveredModel.toString()); - } - } - - private void verifyFDiscoverDomainWithRequiredArgument(String expectedModelFile) throws Exception { - List checkContents = new ArrayList<>(); - checkContents.add("domainInfo:"); - checkContents.add("AdminUserName: --FIX ME--"); - checkContents.add("CoherenceClusterSystemResource: defaultCoherenceCluster"); - checkContents.add("PublicAddress: kubernetes"); - checkContents.add("Trust Service Identity Asserter:"); - checkContents.add("appDeployments:"); - checkContents.add("SourcePath: wlsdeploy/applications/simple-app.war"); - verifyModelFileContents(expectedModelFile, checkContents); - } - /** - * test discoverDomain.sh with -model_file argument - * @throws Exception - if any error occurs - */ - @DisplayName("Test 18: Discover domain restrictedJRFD1 using model_file arg") - @Order(18) - @Tag("gate") - @Test - void test18DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { - assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); - assertTrue(discover17DomainCreated, "Domain not created cannot run test"); - - Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); - Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.yaml"); - String cmd = discoverDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainParentDir + FS + "restrictedJRFD1-discover17-18-19 -archive_file " + discoveredArchive + - " -model_file " + discoveredModelFile; - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - // SecurityConfiguration warning - assertEquals(1, result.exitValue(), "Unexpected return code"); - - // verify model file - verifyModelFile(discoveredModelFile.toString()); - } - } - - /** - * test discoverDomain.sh with -variable_file argument - * @throws Exception - if any error occurs - */ - @DisplayName("Test 19: Discover domain restrictedJRFD1 using variable file") - @Order(19) - @Tag("gate") - @Test - void test19DiscoverDomainWithVariableFile(TestInfo testInfo) throws Exception { - assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); - assertTrue(discover17DomainCreated, "Domain not created and cannot be discovered"); - Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); - Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.yaml"); - Path discoveredVariableFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.properties"); - - String cmd = discoverDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + "restrictedJRFD1-discover17-18-19" - + " -archive_file " + discoveredArchive - + " -model_file " + discoveredModelFile - + " -variable_file " + discoveredVariableFile; - - try (PrintWriter out = getTestMethodWriter(testInfo)) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - // SecurityConfiguration warning - assertEquals(1, result.exitValue(), "Unexpected return code"); - - // verify model file and variable file - verifyModelFile(discoveredModelFile.toString()); - verifyModelFile(discoveredVariableFile.toString()); - verifyGDiscoverDomainWithVariableFile(discoveredModelFile.toString()); - } - } - - private void verifyGDiscoverDomainWithVariableFile(String expectedModelFile) throws Exception { - List checkContents = new ArrayList<>(); - checkContents.add("AdminUserName: '@@PROP:AdminUserName@@'"); - verifyModelFileContents(expectedModelFile, checkContents); - } - - /** - * test discoverDomain.sh with -domain_type as JRF + * test discoverDomain.sh that model can create a working domain * @throws Exception - if any error occurs */ - @DisplayName("Test 20: Discover domain domain_type JRF") - @Order(20) + @DisplayName("Test 35: Discover domain and then create a new domain from the model") + @Order(35) @Tag("gate") @Test - void test20DiscoverDomainJRFDomainType(TestInfo testInfo) throws Exception { - assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); - waitForDatabase(); - try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { - Path source = Paths.get(getSampleModelFile("2")); - Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); - // create wdt model file to use in create, after substitution of DB host/ip - replaceStringInFile(source, modelOut, "%DB_HOST%", getDBContainerIP()); - - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainParentDir + FS + "jrfDomain1-discover20 -model_file " + - modelOut + " -archive_file " + getSampleArchiveFile() + " -domain_type JRF -run_rcu"; - + void test35DiscoverDomainWithJDBCWallet(TestInfo testInfo) throws Exception { + String domainDir = "domain2-discover35"; + Path genJDBCArchive = getTestOutputPath(testInfo).resolve("gen-wallet-archive.zip"); + String cmd = archiveHelperScript + + " add databaseWallet " + + " -source " + getSampleKeyStoreFile() + + " -wallet_name acmeWallet " + + " -archive_file " + genJDBCArchive; + + try (PrintWriter out = getTestMethodWriter(testInfo, "archiveHelper")) { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); assertEquals(0, result.exitValue(), "Unexpected return code"); } - try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { - Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); - Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredJRFD1.yaml"); - String cmd = discoverDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + "jrfDomain1-discover20" - + " -archive_file " + discoveredArchive - + " -model_file " + discoveredModelFile - + " -domain_type JRF"; - - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - // SecurityConfiguration warning - assertEquals(1, result.exitValue(), "Unexpected return code"); - - // verify model file - verifyModelFile(discoveredModelFile.toString()); - verifyHDiscoverDomainJRFDomainType(discoveredModelFile.toString()); - } - } - - private void verifyHDiscoverDomainJRFDomainType(String expectedModelFile) { - List checkContents = new ArrayList<>(); - checkContents.add("AWT Application Context Startup Class"); - try { - verifyModelFileContents(expectedModelFile, checkContents); - throw new Exception("JRF blacklist components found in model file"); - } catch (Exception e) { - // empty this is expected result - } - } - - /** - * test updateDomain.sh, update the domain to set the number of dynamic servers to 4 - * @throws Exception - if any error occurs - */ - @DisplayName("Test 21: Update domain dynamic server count") - @Order(21) - @Tag("gate") - @Test - void test21UpdateDomain(TestInfo testInfo) throws Exception { - assumeTrue(test11DomainCreated, "Skipping test 21 because dependent domain was not created"); - try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain")) { - Path source = Paths.get(getSampleVariableFile()); - Path variableFile = getTestOutputPath(testInfo).resolve(SAMPLE_VARIABLE_FILE); - - replaceStringInFile(source, variableFile, "CONFIGURED_MANAGED_SERVER_COUNT=2", - "CONFIGURED_MANAGED_SERVER_COUNT=4"); - - String cmd = updateDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + "domain2" - + " -model_file " + getSampleModelFile("1") - + " -archive_file " + getSampleArchiveFile() - + " -domain_type WLS" - + " -variable_file " + variableFile; - - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - verifyResult(result, "updateDomain.sh completed successfully"); - } - try (PrintWriter out = getTestMethodWriter(testInfo, "GrepResults")) { - // Expecting grep return code of 0. Grep will return 0 if found, and 1 if the requested text is not found. - String cmd = "grep -q '4' " + domainParentDir + FS + - "domain2" + FS + "config" + FS + "config.xml"; - CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result2.exitValue(), "config.xml does not appear to reflect the update"); - } - } - - /** - * Test deployApp with missing model in archive. - * Negative test, expects error message. - * @throws Exception - if any error occurs - */ - @DisplayName("Test 22: Deploy App negative test") - @Order(22) - @Tag("gate") - @Test - void test22DeployAppWithoutModelFile(TestInfo testInfo) throws Exception { - assumeTrue(test11DomainCreated, "Skipping test 22 because dependent domain was not created"); - try (PrintWriter out = getTestMethodWriter(testInfo)) { - String cmd = deployAppScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + "domain2" - + " -archive_file " + getSampleArchiveFile(); - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - verifyErrorMsg(result, "deployApps invoked with missing required argument: -model_file"); - } - } - - /** - * Test deployApps. - * @throws Exception - if any error occurs - */ - @DisplayName("Test 23: Deploy App") - @Order(23) - @Tag("gate") - @Test - void test23DeployAppWithModelfile(TestInfo testInfo) throws Exception { - assumeTrue(test11DomainCreated, "Skipping test 23 because dependent domain was not created"); - try (PrintWriter out = getTestMethodWriter(testInfo)) { - String cmd = deployAppScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + "domain2" - + " -archive_file " + getSampleArchiveFile() - + " -model_file " + getSampleModelFile("-constant"); - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - verifyResult(result, "deployApps.sh completed successfully"); - } - } - /** - * test validateModel.sh with -oracle_home only - * @throws Exception - if any error occurs - */ - @DisplayName("Test 24: Validate model negative (no model)") - @Order(24) - @Tag("gate") - @Test - void test24ValidateModelWithOracleHomeOnly(TestInfo testInfo) throws Exception { - try (PrintWriter out = getTestMethodWriter(testInfo)) { - String cmd = validateModelScript + " -oracle_home " + mwhome_12213; - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - verifyErrorMsg(result, "validateModel requires a model file to run"); - } - } - - /** - * test validateModel.sh with -oracle_home and -model_file - * @throws Exception - if any error occurs - */ - @DisplayName("Test 25: Validate model negative (no archive)") - @Order(25) - @Tag("gate") - @Test - void test25ValidateModelWithOracleHomeModelFile(TestInfo testInfo) throws Exception { - try (PrintWriter out = getTestMethodWriter(testInfo)) { - String cmd = validateModelScript + " -oracle_home " + mwhome_12213 + " -model_file " + - getSampleModelFile("-constant"); - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - verifyErrorMsg(result, "the archive file was not provided"); - } - } - - /** - * test validateModel.sh without -variable_file - * @throws Exception - if any error occurs - */ - @DisplayName("Test 26: Validate model negative (no variable file)") - @Order(26) - @Tag("gate") - @Test - void test26ValidateModelWithoutVariableFile(TestInfo testInfo) throws Exception { - try (PrintWriter out = getTestMethodWriter(testInfo)) { - String cmd = validateModelScript - + " -oracle_home " + mwhome_12213 - + " -model_file " + getSampleModelFile("1"); - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - verifyErrorMsg(result, " and no properties file was provided"); - } - } - - /** - * test compareModel.sh with only attribute difference. The files existences test whether it impacts WKO operation - * @throws Exception - if any error occurs - */ - @DisplayName("Test 27: Compare model") - @Order(27) - @Tag("gate") - @Test - void test27CompareModelRemoveAttribute(TestInfo testInfo) throws Exception { - try (PrintWriter out = getTestMethodWriter(testInfo)) { - Path outputDir = getTestOutputPath(testInfo).resolve("wdt_temp_output"); - Files.createDirectories(outputDir); - String cmd = compareModelScript - + " -oracle_home " + mwhome_12213 - + " -output_dir " + outputDir - + " " + getSampleModelFile("1-lessattribute") - + " " + getSampleModelFile("1"); - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - verifyResult(result, "compareModel.sh completed successfully"); - - verifyFileExists(outputDir.resolve("compare_model_stdout").toString()); - verifyFileDoesNotExists(outputDir.resolve("diffed_model.yaml").toString()); - } - } - - /** - * test validateModel.sh with invalid model file - * @throws Exception - if any error occurs - */ - @DisplayName("Test 28: Validate model negative (invalid model)") - @Order(28) - @Tag("gate") - @Test - void test28ValidateModelWithInvalidModelfile(TestInfo testInfo) throws Exception { - try (PrintWriter out = getTestMethodWriter(testInfo)) { - String cmd = validateModelScript - + " -oracle_home " + mwhome_12213 - + " -model_file " + getSampleModelFile("-invalid") - + " -variable_file " + getSampleVariableFile(); - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - verifyErrorMsg(result, "exit code = 2"); - } - } - - @DisplayName("Test 29: Encrypt model") - @Order(29) - @Tag("gate") - @Test - void test29EncryptModel(TestInfo testInfo) throws Exception { - Path source = Paths.get(getSampleModelFile("-constant")); - Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-constant.yaml"); - try (PrintWriter out = getTestMethodWriter(testInfo, "EncryptModel")) { - Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); - - String cmd = encryptModelScript - + " -oracle_home " + mwhome_12213 - + " -model_file " + model + " < " + getResourcePath().resolve("passphrase.txt"); - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - verifyResult(result, "encryptModel.sh completed successfully"); - } - try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { - // create the domain using -use_encryption - String cmd = createDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + "domain10" - + " -model_file " + model - + " -archive_file " + getSampleArchiveFile() - + " -domain_type WLS" - + " -use_encryption < " + getResourcePath().resolve("passphrase.txt"); - CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - verifyResult(result2, "createDomain.sh completed successfully"); - } - } - - /** - * test updateDomain.sh online with untargeting, deploy, and app update - * @throws Exception - if any error occurs - */ - @DisplayName("Test 30: createDomain and run updateDomain online for application") - @Order(30) - @Tag("gate") - @Test - void test30OnlineUpdateApp(TestInfo testInfo) throws Exception { - String domainDir = "domain2-test30"; - String cmd = createDomainScript + cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + domainParentDir + FS + domainDir - + " -model_file " + getSampleModelFile("-onlinebase") - + " -archive_file " + getSampleArchiveFile(); + + " -model_file " + getSampleModelFile("-jdbcwallet") + + " -archive_file " + genJDBCArchive; try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); assertEquals(0, result.exitValue(), "Unexpected return code"); - assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); } - String domainHome = domainParentDir + FS + domainDir; - setUpBootProperties(domainHome, "admin-server", "weblogic", "welcome1"); - Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); - boolean isServerUp = startAdminServer(domainHome, adminServerOut); - - Path source = Paths.get(getSampleModelFile("-untargetapp")); - Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); - if (isServerUp) { - try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-1")) { - // update wdt model file - Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); - - cmd = "echo welcome1 | " - + updateDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + domainDir - + " -model_file " + model - + " -archive_file " + getSampleArchiveFile() - + " -admin_url t3://localhost:7001 -admin_user weblogic"; - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - - assertEquals(0, result.exitValue(), "Unexpected return code for untargeting app"); - assertTrue(result.stdout().contains(" "), - "Update does not contains expected message WLSDPLY-09339"); - } - try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-2")) { - // Check result - source = Paths.get(getSampleModelFile("-targetapp")); - model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); - Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); - - cmd = "echo welcome1 | " - + updateDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + domainDir - + " -model_file " + model - + " -archive_file " + getSampleArchiveFile() - + " -admin_url t3://localhost:7001 -admin_user weblogic"; - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - - assertEquals(0, result.exitValue(), "Unexpected return code for targeting app"); - assertTrue(result.stdout().contains("<__deploy_app_online> "), - "Update does not contains expected message WLSDPLY-09316"); - assertTrue(result.stdout().contains("<__start_app> "), - "Update does not contains expected message WLSDPLY-09313"); - } - try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-online")) { - source = Paths.get(getSampleModelFile("-targetapp")); - model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); - Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); - - cmd = "echo welcome1 | " - + updateDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + domainDir - + " -model_file " + model - + " -archive_file " + getUpdatedSampleArchiveFile() - + " -admin_url t3://localhost:7001 -admin_user weblogic"; - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - - assertEquals(0, result.exitValue(), "Unexpected return code for updating domain with new archive"); - assertTrue(result.stdout().contains("<__stop_app> "), - "Update does not contains expected message WLSDPLY-09312"); - assertTrue(result.stdout().contains("<__undeploy_app> "), - "Update does not contains expected message WLSDPLY-09314"); - assertTrue(result.stdout().contains("<__deploy_app_online> "), - "Update does not contains expected message WLSDPLY-09316"); - assertTrue(result.stdout().contains("<__start_app> "), - "Update does not contains expected message WLSDPLY-09313"); - - cmd = "echo welcome1 | " - + updateDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + domainDir - + " -model_file " + model - + " -remote" - + " -archive_file " + getUpdatedSampleArchiveFile() - + " -admin_url t3://localhost:7001 -admin_user weblogic"; - result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - - assertEquals(0, result.exitValue(), "Unexpected return code for remote updating domain with new archive"); - - Path sourcePyfile = Paths.get(getResourcePath() + FS + SAMPLE_MODEL_FILE_PREFIX + "-chk-srcpath.py"); - Path testPyFile = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-chk-srcpath.py"); - Files.copy(sourcePyfile, testPyFile, StandardCopyOption.REPLACE_EXISTING); - cmd = mwhome_12213 + "/oracle_common/common/bin/wlst.sh " + testPyFile + " " + domainParentDir + FS + - domainDir; - result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result.exitValue(), "Unexpected return code for running wlst to find app sourcepath"); - Pattern pattern = Pattern.compile("SRCPATH=(.*)"); - Matcher matcher = pattern.matcher(result.stdout()); - String srcPath = "Unknown"; - if (matcher.find()) { - srcPath = matcher.group(1); - } - assertTrue(srcPath.equals("servers/admin-server/upload/simple-app/app/simple-app.war"), - "App SourcePath returned " + srcPath + " does not match the expected value"); - - stopAdminServer(domainHome); - } - } else { - // Best effort to clean up server - tryKillTheAdminServer(domainHome, "admin-server"); - throw new Exception("testDOnlineUpdate failed - cannot bring up server"); - } - } - - /** - * test discoverDomain.sh that model can create a working domain - * @throws Exception - if any error occurs - */ - @DisplayName("Test 31: Discover domain and then create a new domain from the model") - @Order(31) - @Tag("gate") - @Test - void test31DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { - String domainDir = "domain2-discover31"; - String cmd = createDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + domainDir - + " -model_file " + getSampleModelFile("-onlinebase") - + " -archive_file " + getSampleArchiveFile(); - - try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result.exitValue(), "Unexpected return code"); - } Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); Path discoveredVariableFile = getTestOutputPath(testInfo).resolve("discoveredVariable.properties"); cmd = discoverDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainParentDir + FS + "domain2-discover31 -archive_file " + discoveredArchive + - " -model_file " + discoveredModelFile + " -variable_file " + discoveredVariableFile; + domainParentDir + FS + domainDir + " -archive_file " + discoveredArchive + + " -model_file " + discoveredModelFile + " -variable_file " + discoveredVariableFile; try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); verifyResult(result, "discoverDomain.sh completed successfully"); - // verify model file - verifyModelFile(discoveredModelFile.toString()); - - } - try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomainFromDiscover")) { - String domainHome = domainParentDir + FS + "createDomainFromDiscover"; - cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainHome + " -archive_file " + discoveredArchive + - " -model_file " + discoveredModelFile + " -variable_file " + getSampleVariableFile(); - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - - verifyResult(result, "createDomain.sh completed successfully"); - - setUpBootProperties(domainHome, "AdminServer", "weblogic", "welcome1"); - Path adminServerOut = getTestOutputPath(testInfo).resolve("AdminServer.out"); - boolean isServerUp = startAdminServer(domainHome, adminServerOut ); - if (!isServerUp) { - throw new Exception("Admin server did not come up after createDomain from discoverDomain"); - } - stopAdminServer(domainHome); - } - } - - /** - * test prepareModel.sh with -target as wko - * @throws Exception - if any error occurs - */ - @DisplayName("Test 32: Prepare model") - @Order(32) - @Tag("gate") - @Test - void test32PrepareModel(TestInfo testInfo) throws Exception { - - Path outputFiles = getTestOutputPath(testInfo); - try (PrintWriter out = getTestMethodWriter(testInfo, "PrepareModel")) { - String wkoModelFile = getSampleModelFile("-targetwko"); - String cmd = prepareModelScript - + " -oracle_home " + mwhome_12213 - + " -output_dir " + outputFiles - + " -model_file " + wkoModelFile - + " -target " + "wko"; - - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - // ListenPort differences warning - assertEquals(1, result.exitValue(), "Unexpected return code"); - } - try (PrintWriter out = getTestMethodWriter(testInfo, "GrepResults")) { - // verify model file - String tempWkoModel = outputFiles + FS + "simple-topology-targetwko.yaml"; - String cmd = "grep \"PasswordEncrypted: '@@SECRET\" " + tempWkoModel; - CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result2.exitValue(), "Missing JDBC Secret"); - cmd = "grep -c 'Machine' " + tempWkoModel; - CommandResult result3 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertNotEquals(0, result3.exitValue(), "Machine section was not removed from model"); - } - } - - /** - * Test Discover Domain using the -skip_archive argument - * @throws Exception - if any error occurs - */ - @DisplayName("Test 33: Skip archive") - @Order(33) - @Tag("gate") - @Test - void test33DiscoverSkipArchive(TestInfo testInfo) throws Exception { - String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + - domainParentDir + FS + "discoverDomainSkipArchive-33-34 -model_file " + - getSampleModelFile("-onlinebase") + " -archive_file " + getSampleArchiveFile(); - try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - assertEquals(0, result.exitValue(), "Unexpected return code"); - discover33DomainCreated = true; - } + verifyDiscoveredJDBCWalletModelFile(discoveredModelFile.toString()); - try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { - Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); - cmd = discoverDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainParentDir + FS + "discoverDomainSkipArchive-33-34" - + " -model_file " + discoveredModel - + " -skip_archive " ; - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - // SecurityConfiguration warning - assertEquals(0, result.exitValue(), "Unexpected return code"); } } - /** - * Test Discover Domain using the -run_remote argument - * @throws Exception - if any error occurs - */ - @DisplayName("Test 34: remote discovery") - @Order(34) - @Tag("gate") - @Test - void test34DiscoverRemote(TestInfo testInfo) throws Exception { - assertTrue(discover33DomainCreated, "step skipped because Domain creation failed in step test33DiscoverSkipArchive"); - String domainHome = domainParentDir + FS + "discoverDomainSkipArchive-33-34"; - setUpBootProperties(domainHome, "admin-server", "weblogic", "welcome1"); - Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); - boolean isServerUp = startAdminServer(domainHome, adminServerOut); + private void verifyDiscoveredJDBCWalletModelFile(String expectedModelFile) throws Exception { + List checkContents = new ArrayList<>(); - if (isServerUp) { - try (PrintWriter out = getTestMethodWriter(testInfo)) { - Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); - String cmd = discoverDomainScript - + " -oracle_home " + mwhome_12213 - + " -domain_home " + domainHome - + " -model_file " + discoveredModel - + " -admin_user weblogic -admin_pass welcome1 -admin_url t3://localhost:7001" - + " -remote"; - CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); - // SecurityConfiguration warning - verifyResult(result, "Remote discovery created a model that references files or directories" + - " on the remote machine"); - } - } else { - // Best effort to clean up server - tryKillTheAdminServer(domainHome, "admin-server"); - throw new Exception("test34DiscoverRemote failed - cannot bring up server"); - } + checkContents.add("domainInfo:"); + checkContents.add(" AdminUserName: '@@PROP:AdminUserName@@'"); + checkContents.add(" AdminPassword: '@@PROP:AdminPassword@@'"); + checkContents.add("topology:"); + checkContents.add(" Name: domain2"); + checkContents.add(" AdminServerName: admin-server"); + checkContents.add(" DomainVersion: 12.2.1.4.0"); + checkContents.add(" ProductionModeEnabled: true"); + checkContents.add(" NMProperties:"); + checkContents.add(" JavaHome: /home/johnny/jdk1.8.0_201"); + checkContents.add(" Server:"); + checkContents.add(" admin-server: {}"); + checkContents.add(" SecurityConfiguration:"); + checkContents.add(" NodeManagerUsername: '@@PROP:SecurityConfig.NodeManagerUsername@@'"); + checkContents.add("resources:"); + checkContents.add(" JDBCSystemResource:"); + checkContents.add(" testds:"); + checkContents.add(" Target: admin-server"); + checkContents.add(" JdbcResource:"); + checkContents.add(" DatasourceType: GENERIC"); + checkContents.add(" JDBCConnectionPoolParams:"); + checkContents.add(" TestTableName: SQL ISVALID"); + checkContents.add(" JDBCDataSourceParams:"); + checkContents.add(" GlobalTransactionsProtocol: OnePhaseCommit"); + checkContents.add(" JNDIName: testds"); + checkContents.add(" JDBCDriverParams:"); + checkContents.add(" URL: jdbc:oracle:thin:@//localhost:1522/orclpdb1.localdomain"); + checkContents.add(" PasswordEncrypted: '@@PROP:JDBC.testds.PasswordEncrypted@@'"); + checkContents.add(" DriverName: oracle.jdbc.OracleDriver"); + checkContents.add(" Properties:"); + checkContents.add(" user:"); + checkContents.add(" Value: '@@PROP:JDBC.testds.user.Value@@'"); + checkContents.add(" javax.net.ssl.trustStore:"); + checkContents.add(" Value: wlsdeploy/dbWallets/testds/cwallet.sso"); + checkContents.add(" javax.net.ssl.trustStoreType:"); + checkContents.add(" Value: SSO"); + checkContents.add(" javax.net.ssl.keyStore:"); + checkContents.add(" Value: wlsdeploy/dbWallets/testds/cwallet.sso"); + checkContents.add(" javax.net.ssl.keyStoreType:"); + checkContents.add(" Value: SSO"); + checkContents.add(" oracle.net.tns_admin:"); + checkContents.add(" Value: wlsdeploy/dbWallets/testds/"); + verifyModelFileContents(expectedModelFile, checkContents); } private boolean startAdminServer(String domainHome, Path outputFile) throws Exception { diff --git a/integration-tests/system-test/src/test/resources/cwallet.sso b/integration-tests/system-test/src/test/resources/cwallet.sso new file mode 100644 index 0000000000..e69de29bb2 diff --git a/integration-tests/system-test/src/test/resources/simple-topology-jdbcwallet.yaml b/integration-tests/system-test/src/test/resources/simple-topology-jdbcwallet.yaml new file mode 100644 index 0000000000..d14ce44e1e --- /dev/null +++ b/integration-tests/system-test/src/test/resources/simple-topology-jdbcwallet.yaml @@ -0,0 +1,40 @@ +domainInfo: + AdminUserName: weblogic + AdminPassword: welcome1 + ServerStartMode: prod +topology: + Name: domain2 + AdminServerName: admin-server + ProductionModeEnabled: true + Server: + admin-server: + ListenPort: 7001 +resources: + JDBCSystemResource: + testds: + Target: admin-server + JdbcResource: + DatasourceType: GENERIC + JDBCConnectionPoolParams: + TestTableName: SQL ISVALID + JDBCDataSourceParams: + GlobalTransactionsProtocol: OnePhaseCommit + JNDIName: testds + JDBCDriverParams: + URL: jdbc:oracle:thin:@//localhost:1522/orclpdb1.localdomain + PasswordEncrypted: welcome1 + DriverName: oracle.jdbc.OracleDriver + Properties: + user: + Value: NY_IAU_APPEND + javax.net.ssl.trustStore: + Value: wlsdeploy/dbWallets/acmeWallet/cwallet.sso + javax.net.ssl.trustStoreType: + Value: SSO + javax.net.ssl.keyStore: + Value: wlsdeploy/dbWallets/acmeWallet/cwallet.sso + javax.net.ssl.keyStoreType: + Value: SSO + oracle.net.tns_admin: + Value: wlsdeploy/dbWallets/acmeWallet + From 3b1cdd150efd0b98cf988a0a7b04b38c347bf131 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Thu, 2 Feb 2023 14:50:58 -0600 Subject: [PATCH 07/20] make sure wallet available when updating ds --- .../main/python/wlsdeploy/tool/deploy/datasource_deployer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/python/wlsdeploy/tool/deploy/datasource_deployer.py b/core/src/main/python/wlsdeploy/tool/deploy/datasource_deployer.py index bebb5f06ee..daf398050d 100644 --- a/core/src/main/python/wlsdeploy/tool/deploy/datasource_deployer.py +++ b/core/src/main/python/wlsdeploy/tool/deploy/datasource_deployer.py @@ -18,6 +18,8 @@ class DatasourceDeployer(Deployer): def __init__(self, model, model_context, aliases, wlst_mode=WlstModes.OFFLINE): Deployer.__init__(self, model, model_context, aliases, wlst_mode) + if not model_context.is_remote(): + self.archive_helper.extract_all_database_wallets() def add_data_sources(self, parent_dict, location): """ From 1bbed2be3fac3324a1c7f21a1fd4f1e8211824d5 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Thu, 2 Feb 2023 15:18:21 -0600 Subject: [PATCH 08/20] restore integration tests --- .../weblogic/deploy/integration/ITWdt.java | 2094 ++++++++--------- 1 file changed, 1047 insertions(+), 1047 deletions(-) diff --git a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java index 1147698533..911cdf7aa1 100644 --- a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java +++ b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java @@ -114,1053 +114,1053 @@ private static PrintWriter getTestMethodWriter(TestInfo testInfo, String suffixN new FileOutputStream(outputPath.resolve(Paths.get(methodName + suffixName + ".out")).toString()))), true); } -// -// /** -// * test createDomain.sh with only -oracle_home argument -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 1: createDomain bad arguments") -// @Order(1) -// @Tag("gate") -// @Test -// void test01CreateDomainNoDomainHome(TestInfo testInfo) throws Exception { -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213; -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(99, result.exitValue(), "Unexpected return code"); -// assertTrue(result.stdout().contains("WLSDPLY-20008"), "Output did not contain expected WLSDPLY-20008"); -// } -// } -// -// /** -// * test createDomain.sh with only -oracle_home and -domain_type arguments -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 2: createDomain bad arguments") -// @Order(2) -// @Tag("gate") -// @Test -// void test02CreateDomainNoDomainHome(TestInfo testInfo) throws Exception { -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_type WLS"; -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(99, result.exitValue(), "Unexpected return code"); -// // command should fail because of invalid arguments -// assertTrue(result.stdout().contains("WLSDPLY-20008"), "Output did not contain expected WLSDPLY-20008"); -// } -// } -// -// /** -// * test createDomain.sh without model file -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 3: createDomain bad arguments") -// @Order(3) -// @Tag("gate") -// @Test -// void test03CreateDomainNoModelfile(TestInfo testInfo) throws Exception { -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir; -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(99, result.exitValue(), "Unexpected return code"); -// // command should fail because of invalid arguments -// assertTrue(result.stdout().contains("WLSDPLY-20008"), "Output did not contain expected WLSDPLY-20008"); -// } -// } -// -// /** -// * test createDomain.sh without archive file -// * @throws Exception - if output file could not be created or written -// */ -// @DisplayName("Test 4: createDomain without archive file") -// @Order(4) -// @Tag("gate") -// @Test -// void test04CreateDomainNoArchivefile(TestInfo testInfo) throws Exception { -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir + -// " -model_file " + getSampleModelFile("-constant") ; -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(2, result.exitValue(), "Unexpected return code"); -// // command should fail because of invalid arguments -// assertTrue(result.stdout().contains("WLSDPLY-05025"), "Output did not contain expected WLSDPLY-05025"); -// } -// } -// -// /** -// * test createDomain.sh with required arguments using simple-topology-constant.yaml (domain = domain1) -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 5: createDomain with domain_parent") -// @Order(5) -// @Tag("gate") -// @Test -// void test05CreateDomain(TestInfo testInfo) throws Exception { -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir + -// " -model_file " + getSampleModelFile("-constant") + -// " -archive_file " + getSampleArchiveFile(); -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); -// } -// } -// -// /** -// * test createDomain.sh using simple-topology-constant.yaml with different domain name in -// * -domain_home and model file in model file, it specifies the domain name as 'domain1' -// * in -domain_home argument, it specifies the domain home as 'domain2' -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 6: createDomain with domain_home") -// @Order(6) -// @Tag("gate") -// @Test -// void test06CreateDomainDifferentDomainName(TestInfo testInfo) throws Exception { -// String cmd = createDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + "domain2" -// + " -model_file " + getSampleModelFile("-constant") -// + " -archive_file " + getSampleArchiveFile(); -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); -// } -// } -// -// /** -// * test createDomain.sh with WLS domain_type using simple-topology-constant.yaml (domain = domain2) -// * @throws Exception -if any error occurs -// */ -// @Order(7) -// @Tag("gate") -// @Test -// void test07CreateDomainWLSType(TestInfo testInfo) throws Exception { -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainParentDir + FS + "domain2 -model_file " + -// getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + -// " -domain_type WLS"; -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); -// } -// } -// -// /** -// * test createDomain.sh, model file contains variables but no variable_file specified -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 8: createDomain but needs variable file") -// @Order(8) -// @Tag("gate") -// @Test -// void test08CreateDomainNoVariableFile(TestInfo testInfo) throws Exception { -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir + -// " -model_file " + getSampleModelFile("1") + -// " -archive_file " + getSampleArchiveFile() ; -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(2, result.exitValue(), "Unexpected return code"); -// // command should fail because of invalid arguments -// assertTrue(result.stdout().contains("WLSDPLY-20004"), "Output did not contain expected WLSDPLY-20004"); -// } -// } -// -// /** -// * test createDomain.sh with variable_file argument using simple-topology1.yaml (domain = domain2) -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 9: createDomain with variable file") -// @Order(9) -// @Tag("gate") -// @Test -// void test09CreateDomainWithVariableFile(TestInfo testInfo) throws Exception { -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainParentDir + FS + "domain2 -model_file " + -// getSampleModelFile("1") + " -archive_file " + getSampleArchiveFile() + -// " -domain_type WLS -variable_file " + getSampleVariableFile(); -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); -// } -// } -// -// /** -// * test createDomain.sh with wlst_path set to mwhome/wlserver using simple-topology1.yaml (domain = domain2) -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 10: createDomain with WLS wlst_path") -// @Order(10) -// @Tag("gate") -// @Test -// void test10CreateDomainWithWlstPath(TestInfo testInfo) throws Exception { -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainParentDir + FS + "domain2 -model_file " + -// getSampleModelFile("1") + " -archive_file " + getSampleArchiveFile() + -// " -domain_type WLS -variable_file " + getSampleVariableFile() + " -wlst_path " + -// mwhome_12213 + FS + "wlserver"; -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); -// } -// } -// -// /** -// * test createDomain.sh with -wlst_path set to mwhome/oracle_common using simple-topology1.yaml (domain = domain2) -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 11: createDomain with oracle_commmon wlst_path") -// @Order(11) -// @Tag("gate") -// @Test -// void test11CreateDomainWithOracleCommonWlstPath(TestInfo testInfo) throws Exception { -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainParentDir + FS + "domain2 -model_file " + -// getSampleModelFile("1") + " -archive_file " + getSampleArchiveFile() + -// " -domain_type WLS -variable_file " + getSampleVariableFile() + " -wlst_path " + -// mwhome_12213 + FS + "oracle_common"; -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); -// test11DomainCreated = true; -// } -// } -// -// /** -// * test createDomain.sh, create JRF domain without -run_rcu argument -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 12: createDomain JRF domain without DB") -// @Order(12) -// @Tag("gate") -// @Test -// void test12CreateJRFDomainNoRunRCU(TestInfo testInfo) throws Exception { -// assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// Path source = Paths.get(getSampleModelFile("2")); -// Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); -// // create wdt model file to use in create, after substitution of DB host/ip -// replaceStringInFile(source, modelOut, "%DB_HOST%", getDBContainerIP()); -// -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainParentDir + FS + "domain2 -model_file " + -// modelOut + " -archive_file " + getSampleArchiveFile() + " -domain_type JRF"; -// -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(2, result.exitValue(), "Unexpected return code"); -// assertTrue(result.stdout().contains("WLSDPLY-12409"), "Output did not contain expected WLSDPLY-12409"); -// } -// } -// -// /** -// * test createDomain.sh, create JRF domain with -run_rcu argument -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 13: createDomain JRF domain and run RCU") -// @Order(13) -// @Tag("gate") -// @Test -// void test13CreateJRFDomainRunRCU(TestInfo testInfo) throws Exception { -// assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); -// waitForDatabase(); -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// Path source = Paths.get(getSampleModelFile("2")); -// Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); -// // create wdt model file to use in create, after substitution of DB host/ip -// replaceStringInFile(source, modelOut, "%DB_HOST%", getDBContainerIP()); -// -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainParentDir + FS + "jrfDomain1 -model_file " + -// modelOut + " -archive_file " + getSampleArchiveFile() + " -domain_type JRF -run_rcu"; -// -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// // command should fail because of invalid arguments -// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); -// rcuDomainCreated = true; -// } -// } -// -// -// /** -// * testDOnlineUpdate1 check for 103 return code if an update requires restart. -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 14: Update JRF domain that requires restart") -// @Order(14) -// @Tag("gate") -// @Test -// void test14OnlineUpdate1(TestInfo testInfo) throws Exception { -// assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); -// assumeTrue(rcuDomainCreated, "testDOnlineUpdate skipped because testDCreateJRFDomainRunRCU failed"); -// -// // Setup boot.properties -// // domainParent12213 - is relative ! -// String domainHome = domainParentDir + FS + "jrfDomain1"; -// setUpBootProperties(domainHome, "admin-server", "weblogic", "welcome1"); -// Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); -// boolean isServerUp = startAdminServer(domainHome, adminServerOut); -// -// if (isServerUp) { -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// // update wdt model file -// Path source = Paths.get(getSampleModelFile("-onlineUpdate")); -// Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); -// Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); -// -// String cmd = "echo welcome1 | " -// + updateDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + "jrfDomain1" -// + " -model_file " + model -// + " -domain_type JRF" -// + " -admin_url t3://localhost:7001 -admin_user weblogic"; -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// -// stopAdminServer(domainHome); -// assertEquals(103, result.exitValue(), "onlineUpdate is expecting return code of 103"); -// } -// -// } else { -// // Best effort to clean up server -// tryKillTheAdminServer(domainHome, "admin-server"); -// throw new Exception("testDOnlineUpdate failed - cannot bring up server"); -// } -// } -// -// -// /** -// * testDOnlineUpdate2 check for 104 return code if an update cancel changes. -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 15: Update JRF domain that requires restart, but cancel changes") -// @Order(15) -// @Tag("gate") -// @Test -// void test15OnlineUpdate2(TestInfo testInfo) throws Exception { -// assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); -// assumeTrue(rcuDomainCreated, "testDOnlineUpdate2 skipped because testDCreateJRFDomainRunRCU failed"); -// -// String domainHome = domainParentDir + FS + "jrfDomain1"; -// Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); -// boolean isServerUp = startAdminServer(domainHome, adminServerOut); -// -// if (isServerUp) { -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// Path source = Paths.get(getSampleModelFile("-onlineUpdate2")); -// Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate2.yaml"); -// Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); -// -// String cmd = "echo welcome1 | " -// + updateDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + "jrfDomain1" -// + " -model_file " + model -// + " -domain_type JRF" -// + " -admin_url t3://localhost:7001 -admin_user weblogic" -// + " -cancel_changes_if_restart_required"; -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// -// stopAdminServer(domainHome); -// assertEquals(104, result.exitValue(), "onlineUpdate2 is expecting return code of 104"); -// } -// } else { -// // Best effort to clean up server -// tryKillTheAdminServer(domainHome, "admin-server"); -// throw new Exception("testDOnlineUpdate2 failed - cannot bring up WLS server"); -// } -// } -// -// -// /** -// * test createDomain.sh, create restrictedJRF domain -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 16: create restricted JRF domain") -// @Order(16) -// @Tag("gate") -// @Test -// void test16CreateRestrictedJRFDomain(TestInfo testInfo) throws Exception { -// assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainParentDir + FS + "restrictedJRFD1 -model_file " + -// getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + -// " -domain_type RestrictedJRF"; -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// // command should fail because of invalid arguments -// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); -// } -// } -// -// /** -// * test discoverDomain.sh with required arguments -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 17: Discover domain restrictedJRFD1") -// @Order(17) -// @Tag("gate") -// @Test -// void test17DiscoverDomainWithRequiredArgument(TestInfo testInfo) throws Exception { -// assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainParentDir + FS + "restrictedJRFD1-discover17-18-19 -model_file " + -// getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + -// " -domain_type RestrictedJRF"; -// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// discover17DomainCreated = true; -// } -// -// try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { -// Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); -// Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); -// cmd = discoverDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + "restrictedJRFD1-discover17-18-19" -// + " -model_file " + discoveredModel -// + " -archive_file " + discoveredArchive -// + " -domain_type RestrictedJRF"; -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// // SecurityConfiguration warning -// assertEquals(1, result.exitValue(), "Unexpected return code"); -// -// // verify model file -// verifyModelFile(discoveredModel.toString()); -// verifyFDiscoverDomainWithRequiredArgument(discoveredModel.toString()); -// } -// } -// -// private void verifyFDiscoverDomainWithRequiredArgument(String expectedModelFile) throws Exception { -// List checkContents = new ArrayList<>(); -// checkContents.add("domainInfo:"); -// checkContents.add("AdminUserName: --FIX ME--"); -// checkContents.add("CoherenceClusterSystemResource: defaultCoherenceCluster"); -// checkContents.add("PublicAddress: kubernetes"); -// checkContents.add("Trust Service Identity Asserter:"); -// checkContents.add("appDeployments:"); -// checkContents.add("SourcePath: wlsdeploy/applications/simple-app.war"); -// verifyModelFileContents(expectedModelFile, checkContents); -// } -// /** -// * test discoverDomain.sh with -model_file argument -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 18: Discover domain restrictedJRFD1 using model_file arg") -// @Order(18) -// @Tag("gate") -// @Test -// void test18DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { -// assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); -// assertTrue(discover17DomainCreated, "Domain not created cannot run test"); -// -// Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); -// Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.yaml"); -// String cmd = discoverDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainParentDir + FS + "restrictedJRFD1-discover17-18-19 -archive_file " + discoveredArchive + -// " -model_file " + discoveredModelFile; -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// // SecurityConfiguration warning -// assertEquals(1, result.exitValue(), "Unexpected return code"); -// -// // verify model file -// verifyModelFile(discoveredModelFile.toString()); -// } -// } -// -// /** -// * test discoverDomain.sh with -variable_file argument -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 19: Discover domain restrictedJRFD1 using variable file") -// @Order(19) -// @Tag("gate") -// @Test -// void test19DiscoverDomainWithVariableFile(TestInfo testInfo) throws Exception { -// assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); -// assertTrue(discover17DomainCreated, "Domain not created and cannot be discovered"); -// Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); -// Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.yaml"); -// Path discoveredVariableFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.properties"); -// -// String cmd = discoverDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + "restrictedJRFD1-discover17-18-19" -// + " -archive_file " + discoveredArchive -// + " -model_file " + discoveredModelFile -// + " -variable_file " + discoveredVariableFile; -// -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// // SecurityConfiguration warning -// assertEquals(1, result.exitValue(), "Unexpected return code"); -// -// // verify model file and variable file -// verifyModelFile(discoveredModelFile.toString()); -// verifyModelFile(discoveredVariableFile.toString()); -// verifyGDiscoverDomainWithVariableFile(discoveredModelFile.toString()); -// } -// } -// -// private void verifyGDiscoverDomainWithVariableFile(String expectedModelFile) throws Exception { -// List checkContents = new ArrayList<>(); -// checkContents.add("AdminUserName: '@@PROP:AdminUserName@@'"); -// verifyModelFileContents(expectedModelFile, checkContents); -// } -// -// /** -// * test discoverDomain.sh with -domain_type as JRF -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 20: Discover domain domain_type JRF") -// @Order(20) -// @Tag("gate") -// @Test -// void test20DiscoverDomainJRFDomainType(TestInfo testInfo) throws Exception { -// assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); -// waitForDatabase(); -// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { -// Path source = Paths.get(getSampleModelFile("2")); -// Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); -// // create wdt model file to use in create, after substitution of DB host/ip -// replaceStringInFile(source, modelOut, "%DB_HOST%", getDBContainerIP()); -// -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainParentDir + FS + "jrfDomain1-discover20 -model_file " + -// modelOut + " -archive_file " + getSampleArchiveFile() + " -domain_type JRF -run_rcu"; -// -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// } -// try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { -// Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); -// Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredJRFD1.yaml"); -// String cmd = discoverDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + "jrfDomain1-discover20" -// + " -archive_file " + discoveredArchive -// + " -model_file " + discoveredModelFile -// + " -domain_type JRF"; -// -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// // SecurityConfiguration warning -// assertEquals(1, result.exitValue(), "Unexpected return code"); -// -// // verify model file -// verifyModelFile(discoveredModelFile.toString()); -// verifyHDiscoverDomainJRFDomainType(discoveredModelFile.toString()); -// } -// } -// -// private void verifyHDiscoverDomainJRFDomainType(String expectedModelFile) { -// List checkContents = new ArrayList<>(); -// checkContents.add("AWT Application Context Startup Class"); -// try { -// verifyModelFileContents(expectedModelFile, checkContents); -// throw new Exception("JRF blacklist components found in model file"); -// } catch (Exception e) { -// // empty this is expected result -// } -// } -// -// /** -// * test updateDomain.sh, update the domain to set the number of dynamic servers to 4 -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 21: Update domain dynamic server count") -// @Order(21) -// @Tag("gate") -// @Test -// void test21UpdateDomain(TestInfo testInfo) throws Exception { -// assumeTrue(test11DomainCreated, "Skipping test 21 because dependent domain was not created"); -// try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain")) { -// Path source = Paths.get(getSampleVariableFile()); -// Path variableFile = getTestOutputPath(testInfo).resolve(SAMPLE_VARIABLE_FILE); -// -// replaceStringInFile(source, variableFile, "CONFIGURED_MANAGED_SERVER_COUNT=2", -// "CONFIGURED_MANAGED_SERVER_COUNT=4"); -// -// String cmd = updateDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + "domain2" -// + " -model_file " + getSampleModelFile("1") -// + " -archive_file " + getSampleArchiveFile() -// + " -domain_type WLS" -// + " -variable_file " + variableFile; -// -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// verifyResult(result, "updateDomain.sh completed successfully"); -// } -// try (PrintWriter out = getTestMethodWriter(testInfo, "GrepResults")) { -// // Expecting grep return code of 0. Grep will return 0 if found, and 1 if the requested text is not found. -// String cmd = "grep -q '4' " + domainParentDir + FS + -// "domain2" + FS + "config" + FS + "config.xml"; -// CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result2.exitValue(), "config.xml does not appear to reflect the update"); -// } -// } -// -// /** -// * Test deployApp with missing model in archive. -// * Negative test, expects error message. -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 22: Deploy App negative test") -// @Order(22) -// @Tag("gate") -// @Test -// void test22DeployAppWithoutModelFile(TestInfo testInfo) throws Exception { -// assumeTrue(test11DomainCreated, "Skipping test 22 because dependent domain was not created"); -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// String cmd = deployAppScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + "domain2" -// + " -archive_file " + getSampleArchiveFile(); -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// verifyErrorMsg(result, "deployApps invoked with missing required argument: -model_file"); -// } -// } -// -// /** -// * Test deployApps. -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 23: Deploy App") -// @Order(23) -// @Tag("gate") -// @Test -// void test23DeployAppWithModelfile(TestInfo testInfo) throws Exception { -// assumeTrue(test11DomainCreated, "Skipping test 23 because dependent domain was not created"); -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// String cmd = deployAppScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + "domain2" -// + " -archive_file " + getSampleArchiveFile() -// + " -model_file " + getSampleModelFile("-constant"); -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// verifyResult(result, "deployApps.sh completed successfully"); -// } -// } -// -// /** -// * test validateModel.sh with -oracle_home only -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 24: Validate model negative (no model)") -// @Order(24) -// @Tag("gate") -// @Test -// void test24ValidateModelWithOracleHomeOnly(TestInfo testInfo) throws Exception { -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// String cmd = validateModelScript + " -oracle_home " + mwhome_12213; -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// verifyErrorMsg(result, "validateModel requires a model file to run"); -// } -// } -// -// /** -// * test validateModel.sh with -oracle_home and -model_file -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 25: Validate model negative (no archive)") -// @Order(25) -// @Tag("gate") -// @Test -// void test25ValidateModelWithOracleHomeModelFile(TestInfo testInfo) throws Exception { -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// String cmd = validateModelScript + " -oracle_home " + mwhome_12213 + " -model_file " + -// getSampleModelFile("-constant"); -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// verifyErrorMsg(result, "the archive file was not provided"); -// } -// } -// -// /** -// * test validateModel.sh without -variable_file -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 26: Validate model negative (no variable file)") -// @Order(26) -// @Tag("gate") -// @Test -// void test26ValidateModelWithoutVariableFile(TestInfo testInfo) throws Exception { -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// String cmd = validateModelScript -// + " -oracle_home " + mwhome_12213 -// + " -model_file " + getSampleModelFile("1"); -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// verifyErrorMsg(result, " and no properties file was provided"); -// } -// } -// -// /** -// * test compareModel.sh with only attribute difference. The files existences test whether it impacts WKO operation -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 27: Compare model") -// @Order(27) -// @Tag("gate") -// @Test -// void test27CompareModelRemoveAttribute(TestInfo testInfo) throws Exception { -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// Path outputDir = getTestOutputPath(testInfo).resolve("wdt_temp_output"); -// Files.createDirectories(outputDir); -// String cmd = compareModelScript -// + " -oracle_home " + mwhome_12213 -// + " -output_dir " + outputDir -// + " " + getSampleModelFile("1-lessattribute") -// + " " + getSampleModelFile("1"); -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// verifyResult(result, "compareModel.sh completed successfully"); -// -// verifyFileExists(outputDir.resolve("compare_model_stdout").toString()); -// verifyFileDoesNotExists(outputDir.resolve("diffed_model.yaml").toString()); -// } -// } -// -// /** -// * test validateModel.sh with invalid model file -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 28: Validate model negative (invalid model)") -// @Order(28) -// @Tag("gate") -// @Test -// void test28ValidateModelWithInvalidModelfile(TestInfo testInfo) throws Exception { -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// String cmd = validateModelScript -// + " -oracle_home " + mwhome_12213 -// + " -model_file " + getSampleModelFile("-invalid") -// + " -variable_file " + getSampleVariableFile(); -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// verifyErrorMsg(result, "exit code = 2"); -// } -// } -// -// @DisplayName("Test 29: Encrypt model") -// @Order(29) -// @Tag("gate") -// @Test -// void test29EncryptModel(TestInfo testInfo) throws Exception { -// Path source = Paths.get(getSampleModelFile("-constant")); -// Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-constant.yaml"); -// try (PrintWriter out = getTestMethodWriter(testInfo, "EncryptModel")) { -// Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); -// -// String cmd = encryptModelScript -// + " -oracle_home " + mwhome_12213 -// + " -model_file " + model + " < " + getResourcePath().resolve("passphrase.txt"); -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// verifyResult(result, "encryptModel.sh completed successfully"); -// } -// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { -// // create the domain using -use_encryption -// String cmd = createDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + "domain10" -// + " -model_file " + model -// + " -archive_file " + getSampleArchiveFile() -// + " -domain_type WLS" -// + " -use_encryption < " + getResourcePath().resolve("passphrase.txt"); -// CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// verifyResult(result2, "createDomain.sh completed successfully"); -// } -// } -// -// /** -// * test updateDomain.sh online with untargeting, deploy, and app update -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 30: createDomain and run updateDomain online for application") -// @Order(30) -// @Tag("gate") -// @Test -// void test30OnlineUpdateApp(TestInfo testInfo) throws Exception { -// String domainDir = "domain2-test30"; -// String cmd = createDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + domainDir -// + " -model_file " + getSampleModelFile("-onlinebase") -// + " -archive_file " + getSampleArchiveFile(); -// -// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); -// } -// -// String domainHome = domainParentDir + FS + domainDir; -// setUpBootProperties(domainHome, "admin-server", "weblogic", "welcome1"); -// Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); -// boolean isServerUp = startAdminServer(domainHome, adminServerOut); -// -// Path source = Paths.get(getSampleModelFile("-untargetapp")); -// Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); -// if (isServerUp) { -// try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-1")) { -// // update wdt model file -// Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); -// -// cmd = "echo welcome1 | " -// + updateDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + domainDir -// + " -model_file " + model -// + " -archive_file " + getSampleArchiveFile() -// + " -admin_url t3://localhost:7001 -admin_user weblogic"; -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// -// assertEquals(0, result.exitValue(), "Unexpected return code for untargeting app"); -// assertTrue(result.stdout().contains(" "), -// "Update does not contains expected message WLSDPLY-09339"); -// } -// try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-2")) { -// // Check result -// source = Paths.get(getSampleModelFile("-targetapp")); -// model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); -// Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); -// -// cmd = "echo welcome1 | " -// + updateDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + domainDir -// + " -model_file " + model -// + " -archive_file " + getSampleArchiveFile() -// + " -admin_url t3://localhost:7001 -admin_user weblogic"; -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// -// assertEquals(0, result.exitValue(), "Unexpected return code for targeting app"); -// assertTrue(result.stdout().contains("<__deploy_app_online> "), -// "Update does not contains expected message WLSDPLY-09316"); -// assertTrue(result.stdout().contains("<__start_app> "), -// "Update does not contains expected message WLSDPLY-09313"); -// } -// try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-online")) { -// source = Paths.get(getSampleModelFile("-targetapp")); -// model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); -// Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); -// -// cmd = "echo welcome1 | " -// + updateDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + domainDir -// + " -model_file " + model -// + " -archive_file " + getUpdatedSampleArchiveFile() -// + " -admin_url t3://localhost:7001 -admin_user weblogic"; -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// -// assertEquals(0, result.exitValue(), "Unexpected return code for updating domain with new archive"); -// assertTrue(result.stdout().contains("<__stop_app> "), -// "Update does not contains expected message WLSDPLY-09312"); -// assertTrue(result.stdout().contains("<__undeploy_app> "), -// "Update does not contains expected message WLSDPLY-09314"); -// assertTrue(result.stdout().contains("<__deploy_app_online> "), -// "Update does not contains expected message WLSDPLY-09316"); -// assertTrue(result.stdout().contains("<__start_app> "), -// "Update does not contains expected message WLSDPLY-09313"); -// -// cmd = "echo welcome1 | " -// + updateDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + domainDir -// + " -model_file " + model -// + " -remote" -// + " -archive_file " + getUpdatedSampleArchiveFile() -// + " -admin_url t3://localhost:7001 -admin_user weblogic"; -// result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// -// assertEquals(0, result.exitValue(), "Unexpected return code for remote updating domain with new archive"); -// -// Path sourcePyfile = Paths.get(getResourcePath() + FS + SAMPLE_MODEL_FILE_PREFIX + "-chk-srcpath.py"); -// Path testPyFile = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-chk-srcpath.py"); -// Files.copy(sourcePyfile, testPyFile, StandardCopyOption.REPLACE_EXISTING); -// cmd = mwhome_12213 + "/oracle_common/common/bin/wlst.sh " + testPyFile + " " + domainParentDir + FS + -// domainDir; -// result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code for running wlst to find app sourcepath"); -// Pattern pattern = Pattern.compile("SRCPATH=(.*)"); -// Matcher matcher = pattern.matcher(result.stdout()); -// String srcPath = "Unknown"; -// if (matcher.find()) { -// srcPath = matcher.group(1); -// } -// assertTrue(srcPath.equals("servers/admin-server/upload/simple-app/app/simple-app.war"), -// "App SourcePath returned " + srcPath + " does not match the expected value"); -// -// stopAdminServer(domainHome); -// } -// } else { -// // Best effort to clean up server -// tryKillTheAdminServer(domainHome, "admin-server"); -// throw new Exception("testDOnlineUpdate failed - cannot bring up server"); -// } -// } -// -// /** -// * test discoverDomain.sh that model can create a working domain -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 31: Discover domain and then create a new domain from the model") -// @Order(31) -// @Tag("gate") -// @Test -// void test31DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { -// String domainDir = "domain2-discover31"; -// String cmd = createDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + domainDir -// + " -model_file " + getSampleModelFile("-onlinebase") -// + " -archive_file " + getSampleArchiveFile(); -// -// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// } -// Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); -// Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); -// Path discoveredVariableFile = getTestOutputPath(testInfo).resolve("discoveredVariable.properties"); -// cmd = discoverDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainParentDir + FS + "domain2-discover31 -archive_file " + discoveredArchive + -// " -model_file " + discoveredModelFile + " -variable_file " + discoveredVariableFile; -// try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// -// verifyResult(result, "discoverDomain.sh completed successfully"); -// -// // verify model file -// verifyModelFile(discoveredModelFile.toString()); -// -// } -// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomainFromDiscover")) { -// String domainHome = domainParentDir + FS + "createDomainFromDiscover"; -// cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainHome + " -archive_file " + discoveredArchive + -// " -model_file " + discoveredModelFile + " -variable_file " + getSampleVariableFile(); -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// -// verifyResult(result, "createDomain.sh completed successfully"); -// -// setUpBootProperties(domainHome, "AdminServer", "weblogic", "welcome1"); -// Path adminServerOut = getTestOutputPath(testInfo).resolve("AdminServer.out"); -// boolean isServerUp = startAdminServer(domainHome, adminServerOut ); -// if (!isServerUp) { -// throw new Exception("Admin server did not come up after createDomain from discoverDomain"); -// } -// stopAdminServer(domainHome); -// } -// } -// -// /** -// * test prepareModel.sh with -target as wko -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 32: Prepare model") -// @Order(32) -// @Tag("gate") -// @Test -// void test32PrepareModel(TestInfo testInfo) throws Exception { -// -// Path outputFiles = getTestOutputPath(testInfo); -// try (PrintWriter out = getTestMethodWriter(testInfo, "PrepareModel")) { -// String wkoModelFile = getSampleModelFile("-targetwko"); -// String cmd = prepareModelScript -// + " -oracle_home " + mwhome_12213 -// + " -output_dir " + outputFiles -// + " -model_file " + wkoModelFile -// + " -target " + "wko"; -// -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// // ListenPort differences warning -// assertEquals(1, result.exitValue(), "Unexpected return code"); -// } -// try (PrintWriter out = getTestMethodWriter(testInfo, "GrepResults")) { -// // verify model file -// String tempWkoModel = outputFiles + FS + "simple-topology-targetwko.yaml"; -// String cmd = "grep \"PasswordEncrypted: '@@SECRET\" " + tempWkoModel; -// CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result2.exitValue(), "Missing JDBC Secret"); -// cmd = "grep -c 'Machine' " + tempWkoModel; -// CommandResult result3 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertNotEquals(0, result3.exitValue(), "Machine section was not removed from model"); -// } -// } -// -// /** -// * Test Discover Domain using the -skip_archive argument -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 33: Skip archive") -// @Order(33) -// @Tag("gate") -// @Test -// void test33DiscoverSkipArchive(TestInfo testInfo) throws Exception { -// String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + -// domainParentDir + FS + "discoverDomainSkipArchive-33-34 -model_file " + -// getSampleModelFile("-onlinebase") + " -archive_file " + getSampleArchiveFile(); -// try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// discover33DomainCreated = true; -// } -// -// try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { -// Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); -// cmd = discoverDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainParentDir + FS + "discoverDomainSkipArchive-33-34" -// + " -model_file " + discoveredModel -// + " -skip_archive " ; -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// // SecurityConfiguration warning -// assertEquals(0, result.exitValue(), "Unexpected return code"); -// } -// } -// -// /** -// * Test Discover Domain using the -run_remote argument -// * @throws Exception - if any error occurs -// */ -// @DisplayName("Test 34: remote discovery") -// @Order(34) -// @Tag("gate") -// @Test -// void test34DiscoverRemote(TestInfo testInfo) throws Exception { -// assertTrue(discover33DomainCreated, "step skipped because Domain creation failed in step test33DiscoverSkipArchive"); -// String domainHome = domainParentDir + FS + "discoverDomainSkipArchive-33-34"; -// setUpBootProperties(domainHome, "admin-server", "weblogic", "welcome1"); -// Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); -// boolean isServerUp = startAdminServer(domainHome, adminServerOut); -// -// if (isServerUp) { -// try (PrintWriter out = getTestMethodWriter(testInfo)) { -// Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); -// String cmd = discoverDomainScript -// + " -oracle_home " + mwhome_12213 -// + " -domain_home " + domainHome -// + " -model_file " + discoveredModel -// + " -admin_user weblogic -admin_pass welcome1 -admin_url t3://localhost:7001" -// + " -remote"; -// CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); -// // SecurityConfiguration warning -// verifyResult(result, "Remote discovery created a model that references files or directories" + -// " on the remote machine"); -// } -// } else { -// // Best effort to clean up server -// tryKillTheAdminServer(domainHome, "admin-server"); -// throw new Exception("test34DiscoverRemote failed - cannot bring up server"); -// } -// -// } -// + + /** + * test createDomain.sh with only -oracle_home argument + * @throws Exception - if any error occurs + */ + @DisplayName("Test 1: createDomain bad arguments") + @Order(1) + @Tag("gate") + @Test + void test01CreateDomainNoDomainHome(TestInfo testInfo) throws Exception { + String cmd = createDomainScript + " -oracle_home " + mwhome_12213; + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(99, result.exitValue(), "Unexpected return code"); + assertTrue(result.stdout().contains("WLSDPLY-20008"), "Output did not contain expected WLSDPLY-20008"); + } + } + + /** + * test createDomain.sh with only -oracle_home and -domain_type arguments + * @throws Exception - if any error occurs + */ + @DisplayName("Test 2: createDomain bad arguments") + @Order(2) + @Tag("gate") + @Test + void test02CreateDomainNoDomainHome(TestInfo testInfo) throws Exception { + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_type WLS"; + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(99, result.exitValue(), "Unexpected return code"); + // command should fail because of invalid arguments + assertTrue(result.stdout().contains("WLSDPLY-20008"), "Output did not contain expected WLSDPLY-20008"); + } + } + + /** + * test createDomain.sh without model file + * @throws Exception - if any error occurs + */ + @DisplayName("Test 3: createDomain bad arguments") + @Order(3) + @Tag("gate") + @Test + void test03CreateDomainNoModelfile(TestInfo testInfo) throws Exception { + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir; + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(99, result.exitValue(), "Unexpected return code"); + // command should fail because of invalid arguments + assertTrue(result.stdout().contains("WLSDPLY-20008"), "Output did not contain expected WLSDPLY-20008"); + } + } + + /** + * test createDomain.sh without archive file + * @throws Exception - if output file could not be created or written + */ + @DisplayName("Test 4: createDomain without archive file") + @Order(4) + @Tag("gate") + @Test + void test04CreateDomainNoArchivefile(TestInfo testInfo) throws Exception { + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir + + " -model_file " + getSampleModelFile("-constant") ; + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(2, result.exitValue(), "Unexpected return code"); + // command should fail because of invalid arguments + assertTrue(result.stdout().contains("WLSDPLY-05025"), "Output did not contain expected WLSDPLY-05025"); + } + } + + /** + * test createDomain.sh with required arguments using simple-topology-constant.yaml (domain = domain1) + * @throws Exception - if any error occurs + */ + @DisplayName("Test 5: createDomain with domain_parent") + @Order(5) + @Tag("gate") + @Test + void test05CreateDomain(TestInfo testInfo) throws Exception { + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir + + " -model_file " + getSampleModelFile("-constant") + + " -archive_file " + getSampleArchiveFile(); + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); + } + } + + /** + * test createDomain.sh using simple-topology-constant.yaml with different domain name in + * -domain_home and model file in model file, it specifies the domain name as 'domain1' + * in -domain_home argument, it specifies the domain home as 'domain2' + * @throws Exception - if any error occurs + */ + @DisplayName("Test 6: createDomain with domain_home") + @Order(6) + @Tag("gate") + @Test + void test06CreateDomainDifferentDomainName(TestInfo testInfo) throws Exception { + String cmd = createDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + "domain2" + + " -model_file " + getSampleModelFile("-constant") + + " -archive_file " + getSampleArchiveFile(); + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); + } + } + + /** + * test createDomain.sh with WLS domain_type using simple-topology-constant.yaml (domain = domain2) + * @throws Exception -if any error occurs + */ + @Order(7) + @Tag("gate") + @Test + void test07CreateDomainWLSType(TestInfo testInfo) throws Exception { + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainParentDir + FS + "domain2 -model_file " + + getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + + " -domain_type WLS"; + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); + } + } + + /** + * test createDomain.sh, model file contains variables but no variable_file specified + * @throws Exception - if any error occurs + */ + @DisplayName("Test 8: createDomain but needs variable file") + @Order(8) + @Tag("gate") + @Test + void test08CreateDomainNoVariableFile(TestInfo testInfo) throws Exception { + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_parent " + domainParentDir + + " -model_file " + getSampleModelFile("1") + + " -archive_file " + getSampleArchiveFile() ; + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(2, result.exitValue(), "Unexpected return code"); + // command should fail because of invalid arguments + assertTrue(result.stdout().contains("WLSDPLY-20004"), "Output did not contain expected WLSDPLY-20004"); + } + } + + /** + * test createDomain.sh with variable_file argument using simple-topology1.yaml (domain = domain2) + * @throws Exception - if any error occurs + */ + @DisplayName("Test 9: createDomain with variable file") + @Order(9) + @Tag("gate") + @Test + void test09CreateDomainWithVariableFile(TestInfo testInfo) throws Exception { + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainParentDir + FS + "domain2 -model_file " + + getSampleModelFile("1") + " -archive_file " + getSampleArchiveFile() + + " -domain_type WLS -variable_file " + getSampleVariableFile(); + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); + } + } + + /** + * test createDomain.sh with wlst_path set to mwhome/wlserver using simple-topology1.yaml (domain = domain2) + * @throws Exception - if any error occurs + */ + @DisplayName("Test 10: createDomain with WLS wlst_path") + @Order(10) + @Tag("gate") + @Test + void test10CreateDomainWithWlstPath(TestInfo testInfo) throws Exception { + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainParentDir + FS + "domain2 -model_file " + + getSampleModelFile("1") + " -archive_file " + getSampleArchiveFile() + + " -domain_type WLS -variable_file " + getSampleVariableFile() + " -wlst_path " + + mwhome_12213 + FS + "wlserver"; + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); + } + } + + /** + * test createDomain.sh with -wlst_path set to mwhome/oracle_common using simple-topology1.yaml (domain = domain2) + * @throws Exception - if any error occurs + */ + @DisplayName("Test 11: createDomain with oracle_commmon wlst_path") + @Order(11) + @Tag("gate") + @Test + void test11CreateDomainWithOracleCommonWlstPath(TestInfo testInfo) throws Exception { + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainParentDir + FS + "domain2 -model_file " + + getSampleModelFile("1") + " -archive_file " + getSampleArchiveFile() + + " -domain_type WLS -variable_file " + getSampleVariableFile() + " -wlst_path " + + mwhome_12213 + FS + "oracle_common"; + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); + test11DomainCreated = true; + } + } + + /** + * test createDomain.sh, create JRF domain without -run_rcu argument + * @throws Exception - if any error occurs + */ + @DisplayName("Test 12: createDomain JRF domain without DB") + @Order(12) + @Tag("gate") + @Test + void test12CreateJRFDomainNoRunRCU(TestInfo testInfo) throws Exception { + assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); + try (PrintWriter out = getTestMethodWriter(testInfo)) { + Path source = Paths.get(getSampleModelFile("2")); + Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); + // create wdt model file to use in create, after substitution of DB host/ip + replaceStringInFile(source, modelOut, "%DB_HOST%", getDBContainerIP()); + + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainParentDir + FS + "domain2 -model_file " + + modelOut + " -archive_file " + getSampleArchiveFile() + " -domain_type JRF"; + + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(2, result.exitValue(), "Unexpected return code"); + assertTrue(result.stdout().contains("WLSDPLY-12409"), "Output did not contain expected WLSDPLY-12409"); + } + } + + /** + * test createDomain.sh, create JRF domain with -run_rcu argument + * @throws Exception - if any error occurs + */ + @DisplayName("Test 13: createDomain JRF domain and run RCU") + @Order(13) + @Tag("gate") + @Test + void test13CreateJRFDomainRunRCU(TestInfo testInfo) throws Exception { + assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); + waitForDatabase(); + try (PrintWriter out = getTestMethodWriter(testInfo)) { + Path source = Paths.get(getSampleModelFile("2")); + Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); + // create wdt model file to use in create, after substitution of DB host/ip + replaceStringInFile(source, modelOut, "%DB_HOST%", getDBContainerIP()); + + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainParentDir + FS + "jrfDomain1 -model_file " + + modelOut + " -archive_file " + getSampleArchiveFile() + " -domain_type JRF -run_rcu"; + + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + // command should fail because of invalid arguments + assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); + rcuDomainCreated = true; + } + } + + + /** + * testDOnlineUpdate1 check for 103 return code if an update requires restart. + * @throws Exception - if any error occurs + */ + @DisplayName("Test 14: Update JRF domain that requires restart") + @Order(14) + @Tag("gate") + @Test + void test14OnlineUpdate1(TestInfo testInfo) throws Exception { + assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); + assumeTrue(rcuDomainCreated, "testDOnlineUpdate skipped because testDCreateJRFDomainRunRCU failed"); + + // Setup boot.properties + // domainParent12213 - is relative ! + String domainHome = domainParentDir + FS + "jrfDomain1"; + setUpBootProperties(domainHome, "admin-server", "weblogic", "welcome1"); + Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); + boolean isServerUp = startAdminServer(domainHome, adminServerOut); + + if (isServerUp) { + try (PrintWriter out = getTestMethodWriter(testInfo)) { + // update wdt model file + Path source = Paths.get(getSampleModelFile("-onlineUpdate")); + Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); + Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); + + String cmd = "echo welcome1 | " + + updateDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + "jrfDomain1" + + " -model_file " + model + + " -domain_type JRF" + + " -admin_url t3://localhost:7001 -admin_user weblogic"; + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + + stopAdminServer(domainHome); + assertEquals(103, result.exitValue(), "onlineUpdate is expecting return code of 103"); + } + + } else { + // Best effort to clean up server + tryKillTheAdminServer(domainHome, "admin-server"); + throw new Exception("testDOnlineUpdate failed - cannot bring up server"); + } + } + + + /** + * testDOnlineUpdate2 check for 104 return code if an update cancel changes. + * @throws Exception - if any error occurs + */ + @DisplayName("Test 15: Update JRF domain that requires restart, but cancel changes") + @Order(15) + @Tag("gate") + @Test + void test15OnlineUpdate2(TestInfo testInfo) throws Exception { + assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); + assumeTrue(rcuDomainCreated, "testDOnlineUpdate2 skipped because testDCreateJRFDomainRunRCU failed"); + + String domainHome = domainParentDir + FS + "jrfDomain1"; + Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); + boolean isServerUp = startAdminServer(domainHome, adminServerOut); + + if (isServerUp) { + try (PrintWriter out = getTestMethodWriter(testInfo)) { + Path source = Paths.get(getSampleModelFile("-onlineUpdate2")); + Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate2.yaml"); + Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); + + String cmd = "echo welcome1 | " + + updateDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + "jrfDomain1" + + " -model_file " + model + + " -domain_type JRF" + + " -admin_url t3://localhost:7001 -admin_user weblogic" + + " -cancel_changes_if_restart_required"; + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + + stopAdminServer(domainHome); + assertEquals(104, result.exitValue(), "onlineUpdate2 is expecting return code of 104"); + } + } else { + // Best effort to clean up server + tryKillTheAdminServer(domainHome, "admin-server"); + throw new Exception("testDOnlineUpdate2 failed - cannot bring up WLS server"); + } + } + + + /** + * test createDomain.sh, create restrictedJRF domain + * @throws Exception - if any error occurs + */ + @DisplayName("Test 16: create restricted JRF domain") + @Order(16) + @Tag("gate") + @Test + void test16CreateRestrictedJRFDomain(TestInfo testInfo) throws Exception { + assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainParentDir + FS + "restrictedJRFD1 -model_file " + + getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + + " -domain_type RestrictedJRF"; + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + // command should fail because of invalid arguments + assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); + } + } + + /** + * test discoverDomain.sh with required arguments + * @throws Exception - if any error occurs + */ + @DisplayName("Test 17: Discover domain restrictedJRFD1") + @Order(17) + @Tag("gate") + @Test + void test17DiscoverDomainWithRequiredArgument(TestInfo testInfo) throws Exception { + assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainParentDir + FS + "restrictedJRFD1-discover17-18-19 -model_file " + + getSampleModelFile("-constant") + " -archive_file " + getSampleArchiveFile() + + " -domain_type RestrictedJRF"; + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + discover17DomainCreated = true; + } + + try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { + Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); + Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); + cmd = discoverDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + "restrictedJRFD1-discover17-18-19" + + " -model_file " + discoveredModel + + " -archive_file " + discoveredArchive + + " -domain_type RestrictedJRF"; + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + // SecurityConfiguration warning + assertEquals(1, result.exitValue(), "Unexpected return code"); + + // verify model file + verifyModelFile(discoveredModel.toString()); + verifyFDiscoverDomainWithRequiredArgument(discoveredModel.toString()); + } + } + + private void verifyFDiscoverDomainWithRequiredArgument(String expectedModelFile) throws Exception { + List checkContents = new ArrayList<>(); + checkContents.add("domainInfo:"); + checkContents.add("AdminUserName: --FIX ME--"); + checkContents.add("CoherenceClusterSystemResource: defaultCoherenceCluster"); + checkContents.add("PublicAddress: kubernetes"); + checkContents.add("Trust Service Identity Asserter:"); + checkContents.add("appDeployments:"); + checkContents.add("SourcePath: wlsdeploy/applications/simple-app.war"); + verifyModelFileContents(expectedModelFile, checkContents); + } + /** + * test discoverDomain.sh with -model_file argument + * @throws Exception - if any error occurs + */ + @DisplayName("Test 18: Discover domain restrictedJRFD1 using model_file arg") + @Order(18) + @Tag("gate") + @Test + void test18DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { + assumeTrue(new RestrictedJrfChecker(), "User specified skipping Restricted JRF tests"); + assertTrue(discover17DomainCreated, "Domain not created cannot run test"); + + Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); + Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.yaml"); + String cmd = discoverDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainParentDir + FS + "restrictedJRFD1-discover17-18-19 -archive_file " + discoveredArchive + + " -model_file " + discoveredModelFile; + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + // SecurityConfiguration warning + assertEquals(1, result.exitValue(), "Unexpected return code"); + + // verify model file + verifyModelFile(discoveredModelFile.toString()); + } + } + + /** + * test discoverDomain.sh with -variable_file argument + * @throws Exception - if any error occurs + */ + @DisplayName("Test 19: Discover domain restrictedJRFD1 using variable file") + @Order(19) + @Tag("gate") + @Test + void test19DiscoverDomainWithVariableFile(TestInfo testInfo) throws Exception { + assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); + assertTrue(discover17DomainCreated, "Domain not created and cannot be discovered"); + Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); + Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.yaml"); + Path discoveredVariableFile = getTestOutputPath(testInfo).resolve("discoveredRestrictedJRFD1.properties"); + + String cmd = discoverDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + "restrictedJRFD1-discover17-18-19" + + " -archive_file " + discoveredArchive + + " -model_file " + discoveredModelFile + + " -variable_file " + discoveredVariableFile; + + try (PrintWriter out = getTestMethodWriter(testInfo)) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + // SecurityConfiguration warning + assertEquals(1, result.exitValue(), "Unexpected return code"); + + // verify model file and variable file + verifyModelFile(discoveredModelFile.toString()); + verifyModelFile(discoveredVariableFile.toString()); + verifyGDiscoverDomainWithVariableFile(discoveredModelFile.toString()); + } + } + + private void verifyGDiscoverDomainWithVariableFile(String expectedModelFile) throws Exception { + List checkContents = new ArrayList<>(); + checkContents.add("AdminUserName: '@@PROP:AdminUserName@@'"); + verifyModelFileContents(expectedModelFile, checkContents); + } + + /** + * test discoverDomain.sh with -domain_type as JRF + * @throws Exception - if any error occurs + */ + @DisplayName("Test 20: Discover domain domain_type JRF") + @Order(20) + @Tag("gate") + @Test + void test20DiscoverDomainJRFDomainType(TestInfo testInfo) throws Exception { + assumeTrue(new JrfChecker(), "User specified skipping JRF tests"); + waitForDatabase(); + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { + Path source = Paths.get(getSampleModelFile("2")); + Path modelOut = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "2.yaml"); + // create wdt model file to use in create, after substitution of DB host/ip + replaceStringInFile(source, modelOut, "%DB_HOST%", getDBContainerIP()); + + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainParentDir + FS + "jrfDomain1-discover20 -model_file " + + modelOut + " -archive_file " + getSampleArchiveFile() + " -domain_type JRF -run_rcu"; + + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + } + try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { + Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); + Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredJRFD1.yaml"); + String cmd = discoverDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + "jrfDomain1-discover20" + + " -archive_file " + discoveredArchive + + " -model_file " + discoveredModelFile + + " -domain_type JRF"; + + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + // SecurityConfiguration warning + assertEquals(1, result.exitValue(), "Unexpected return code"); + + // verify model file + verifyModelFile(discoveredModelFile.toString()); + verifyHDiscoverDomainJRFDomainType(discoveredModelFile.toString()); + } + } + + private void verifyHDiscoverDomainJRFDomainType(String expectedModelFile) { + List checkContents = new ArrayList<>(); + checkContents.add("AWT Application Context Startup Class"); + try { + verifyModelFileContents(expectedModelFile, checkContents); + throw new Exception("JRF blacklist components found in model file"); + } catch (Exception e) { + // empty this is expected result + } + } + + /** + * test updateDomain.sh, update the domain to set the number of dynamic servers to 4 + * @throws Exception - if any error occurs + */ + @DisplayName("Test 21: Update domain dynamic server count") + @Order(21) + @Tag("gate") + @Test + void test21UpdateDomain(TestInfo testInfo) throws Exception { + assumeTrue(test11DomainCreated, "Skipping test 21 because dependent domain was not created"); + try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain")) { + Path source = Paths.get(getSampleVariableFile()); + Path variableFile = getTestOutputPath(testInfo).resolve(SAMPLE_VARIABLE_FILE); + + replaceStringInFile(source, variableFile, "CONFIGURED_MANAGED_SERVER_COUNT=2", + "CONFIGURED_MANAGED_SERVER_COUNT=4"); + + String cmd = updateDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + "domain2" + + " -model_file " + getSampleModelFile("1") + + " -archive_file " + getSampleArchiveFile() + + " -domain_type WLS" + + " -variable_file " + variableFile; + + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + verifyResult(result, "updateDomain.sh completed successfully"); + } + try (PrintWriter out = getTestMethodWriter(testInfo, "GrepResults")) { + // Expecting grep return code of 0. Grep will return 0 if found, and 1 if the requested text is not found. + String cmd = "grep -q '4' " + domainParentDir + FS + + "domain2" + FS + "config" + FS + "config.xml"; + CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result2.exitValue(), "config.xml does not appear to reflect the update"); + } + } + + /** + * Test deployApp with missing model in archive. + * Negative test, expects error message. + * @throws Exception - if any error occurs + */ + @DisplayName("Test 22: Deploy App negative test") + @Order(22) + @Tag("gate") + @Test + void test22DeployAppWithoutModelFile(TestInfo testInfo) throws Exception { + assumeTrue(test11DomainCreated, "Skipping test 22 because dependent domain was not created"); + try (PrintWriter out = getTestMethodWriter(testInfo)) { + String cmd = deployAppScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + "domain2" + + " -archive_file " + getSampleArchiveFile(); + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + verifyErrorMsg(result, "deployApps invoked with missing required argument: -model_file"); + } + } + + /** + * Test deployApps. + * @throws Exception - if any error occurs + */ + @DisplayName("Test 23: Deploy App") + @Order(23) + @Tag("gate") + @Test + void test23DeployAppWithModelfile(TestInfo testInfo) throws Exception { + assumeTrue(test11DomainCreated, "Skipping test 23 because dependent domain was not created"); + try (PrintWriter out = getTestMethodWriter(testInfo)) { + String cmd = deployAppScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + "domain2" + + " -archive_file " + getSampleArchiveFile() + + " -model_file " + getSampleModelFile("-constant"); + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + verifyResult(result, "deployApps.sh completed successfully"); + } + } + + /** + * test validateModel.sh with -oracle_home only + * @throws Exception - if any error occurs + */ + @DisplayName("Test 24: Validate model negative (no model)") + @Order(24) + @Tag("gate") + @Test + void test24ValidateModelWithOracleHomeOnly(TestInfo testInfo) throws Exception { + try (PrintWriter out = getTestMethodWriter(testInfo)) { + String cmd = validateModelScript + " -oracle_home " + mwhome_12213; + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + verifyErrorMsg(result, "validateModel requires a model file to run"); + } + } + + /** + * test validateModel.sh with -oracle_home and -model_file + * @throws Exception - if any error occurs + */ + @DisplayName("Test 25: Validate model negative (no archive)") + @Order(25) + @Tag("gate") + @Test + void test25ValidateModelWithOracleHomeModelFile(TestInfo testInfo) throws Exception { + try (PrintWriter out = getTestMethodWriter(testInfo)) { + String cmd = validateModelScript + " -oracle_home " + mwhome_12213 + " -model_file " + + getSampleModelFile("-constant"); + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + verifyErrorMsg(result, "the archive file was not provided"); + } + } + + /** + * test validateModel.sh without -variable_file + * @throws Exception - if any error occurs + */ + @DisplayName("Test 26: Validate model negative (no variable file)") + @Order(26) + @Tag("gate") + @Test + void test26ValidateModelWithoutVariableFile(TestInfo testInfo) throws Exception { + try (PrintWriter out = getTestMethodWriter(testInfo)) { + String cmd = validateModelScript + + " -oracle_home " + mwhome_12213 + + " -model_file " + getSampleModelFile("1"); + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + verifyErrorMsg(result, " and no properties file was provided"); + } + } + + /** + * test compareModel.sh with only attribute difference. The files existences test whether it impacts WKO operation + * @throws Exception - if any error occurs + */ + @DisplayName("Test 27: Compare model") + @Order(27) + @Tag("gate") + @Test + void test27CompareModelRemoveAttribute(TestInfo testInfo) throws Exception { + try (PrintWriter out = getTestMethodWriter(testInfo)) { + Path outputDir = getTestOutputPath(testInfo).resolve("wdt_temp_output"); + Files.createDirectories(outputDir); + String cmd = compareModelScript + + " -oracle_home " + mwhome_12213 + + " -output_dir " + outputDir + + " " + getSampleModelFile("1-lessattribute") + + " " + getSampleModelFile("1"); + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + verifyResult(result, "compareModel.sh completed successfully"); + + verifyFileExists(outputDir.resolve("compare_model_stdout").toString()); + verifyFileDoesNotExists(outputDir.resolve("diffed_model.yaml").toString()); + } + } + + /** + * test validateModel.sh with invalid model file + * @throws Exception - if any error occurs + */ + @DisplayName("Test 28: Validate model negative (invalid model)") + @Order(28) + @Tag("gate") + @Test + void test28ValidateModelWithInvalidModelfile(TestInfo testInfo) throws Exception { + try (PrintWriter out = getTestMethodWriter(testInfo)) { + String cmd = validateModelScript + + " -oracle_home " + mwhome_12213 + + " -model_file " + getSampleModelFile("-invalid") + + " -variable_file " + getSampleVariableFile(); + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + verifyErrorMsg(result, "exit code = 2"); + } + } + + @DisplayName("Test 29: Encrypt model") + @Order(29) + @Tag("gate") + @Test + void test29EncryptModel(TestInfo testInfo) throws Exception { + Path source = Paths.get(getSampleModelFile("-constant")); + Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-constant.yaml"); + try (PrintWriter out = getTestMethodWriter(testInfo, "EncryptModel")) { + Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); + + String cmd = encryptModelScript + + " -oracle_home " + mwhome_12213 + + " -model_file " + model + " < " + getResourcePath().resolve("passphrase.txt"); + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + verifyResult(result, "encryptModel.sh completed successfully"); + } + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { + // create the domain using -use_encryption + String cmd = createDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + "domain10" + + " -model_file " + model + + " -archive_file " + getSampleArchiveFile() + + " -domain_type WLS" + + " -use_encryption < " + getResourcePath().resolve("passphrase.txt"); + CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + verifyResult(result2, "createDomain.sh completed successfully"); + } + } + + /** + * test updateDomain.sh online with untargeting, deploy, and app update + * @throws Exception - if any error occurs + */ + @DisplayName("Test 30: createDomain and run updateDomain online for application") + @Order(30) + @Tag("gate") + @Test + void test30OnlineUpdateApp(TestInfo testInfo) throws Exception { + String domainDir = "domain2-test30"; + String cmd = createDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + domainDir + + " -model_file " + getSampleModelFile("-onlinebase") + + " -archive_file " + getSampleArchiveFile(); + + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + assertTrue(result.stdout().contains("createDomain.sh completed successfully"), "Create failed"); + } + + String domainHome = domainParentDir + FS + domainDir; + setUpBootProperties(domainHome, "admin-server", "weblogic", "welcome1"); + Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); + boolean isServerUp = startAdminServer(domainHome, adminServerOut); + + Path source = Paths.get(getSampleModelFile("-untargetapp")); + Path model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); + if (isServerUp) { + try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-1")) { + // update wdt model file + Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); + + cmd = "echo welcome1 | " + + updateDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + domainDir + + " -model_file " + model + + " -archive_file " + getSampleArchiveFile() + + " -admin_url t3://localhost:7001 -admin_user weblogic"; + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + + assertEquals(0, result.exitValue(), "Unexpected return code for untargeting app"); + assertTrue(result.stdout().contains(" "), + "Update does not contains expected message WLSDPLY-09339"); + } + try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-2")) { + // Check result + source = Paths.get(getSampleModelFile("-targetapp")); + model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); + Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); + + cmd = "echo welcome1 | " + + updateDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + domainDir + + " -model_file " + model + + " -archive_file " + getSampleArchiveFile() + + " -admin_url t3://localhost:7001 -admin_user weblogic"; + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + + assertEquals(0, result.exitValue(), "Unexpected return code for targeting app"); + assertTrue(result.stdout().contains("<__deploy_app_online> "), + "Update does not contains expected message WLSDPLY-09316"); + assertTrue(result.stdout().contains("<__start_app> "), + "Update does not contains expected message WLSDPLY-09313"); + } + try (PrintWriter out = getTestMethodWriter(testInfo, "UpdateDomain-online")) { + source = Paths.get(getSampleModelFile("-targetapp")); + model = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-onlineUpdate.yaml"); + Files.copy(source, model, StandardCopyOption.REPLACE_EXISTING); + + cmd = "echo welcome1 | " + + updateDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + domainDir + + " -model_file " + model + + " -archive_file " + getUpdatedSampleArchiveFile() + + " -admin_url t3://localhost:7001 -admin_user weblogic"; + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + + assertEquals(0, result.exitValue(), "Unexpected return code for updating domain with new archive"); + assertTrue(result.stdout().contains("<__stop_app> "), + "Update does not contains expected message WLSDPLY-09312"); + assertTrue(result.stdout().contains("<__undeploy_app> "), + "Update does not contains expected message WLSDPLY-09314"); + assertTrue(result.stdout().contains("<__deploy_app_online> "), + "Update does not contains expected message WLSDPLY-09316"); + assertTrue(result.stdout().contains("<__start_app> "), + "Update does not contains expected message WLSDPLY-09313"); + + cmd = "echo welcome1 | " + + updateDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + domainDir + + " -model_file " + model + + " -remote" + + " -archive_file " + getUpdatedSampleArchiveFile() + + " -admin_url t3://localhost:7001 -admin_user weblogic"; + result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + + assertEquals(0, result.exitValue(), "Unexpected return code for remote updating domain with new archive"); + + Path sourcePyfile = Paths.get(getResourcePath() + FS + SAMPLE_MODEL_FILE_PREFIX + "-chk-srcpath.py"); + Path testPyFile = getTestOutputPath(testInfo).resolve(SAMPLE_MODEL_FILE_PREFIX + "-chk-srcpath.py"); + Files.copy(sourcePyfile, testPyFile, StandardCopyOption.REPLACE_EXISTING); + cmd = mwhome_12213 + "/oracle_common/common/bin/wlst.sh " + testPyFile + " " + domainParentDir + FS + + domainDir; + result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code for running wlst to find app sourcepath"); + Pattern pattern = Pattern.compile("SRCPATH=(.*)"); + Matcher matcher = pattern.matcher(result.stdout()); + String srcPath = "Unknown"; + if (matcher.find()) { + srcPath = matcher.group(1); + } + assertTrue(srcPath.equals("servers/admin-server/upload/simple-app/app/simple-app.war"), + "App SourcePath returned " + srcPath + " does not match the expected value"); + + stopAdminServer(domainHome); + } + } else { + // Best effort to clean up server + tryKillTheAdminServer(domainHome, "admin-server"); + throw new Exception("testDOnlineUpdate failed - cannot bring up server"); + } + } + + /** + * test discoverDomain.sh that model can create a working domain + * @throws Exception - if any error occurs + */ + @DisplayName("Test 31: Discover domain and then create a new domain from the model") + @Order(31) + @Tag("gate") + @Test + void test31DiscoverDomainWithModelFile(TestInfo testInfo) throws Exception { + String domainDir = "domain2-discover31"; + String cmd = createDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + domainDir + + " -model_file " + getSampleModelFile("-onlinebase") + + " -archive_file " + getSampleArchiveFile(); + + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + } + Path discoveredArchive = getTestOutputPath(testInfo).resolve("discoveredArchive.zip"); + Path discoveredModelFile = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); + Path discoveredVariableFile = getTestOutputPath(testInfo).resolve("discoveredVariable.properties"); + cmd = discoverDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainParentDir + FS + "domain2-discover31 -archive_file " + discoveredArchive + + " -model_file " + discoveredModelFile + " -variable_file " + discoveredVariableFile; + try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + + verifyResult(result, "discoverDomain.sh completed successfully"); + + // verify model file + verifyModelFile(discoveredModelFile.toString()); + + } + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomainFromDiscover")) { + String domainHome = domainParentDir + FS + "createDomainFromDiscover"; + cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainHome + " -archive_file " + discoveredArchive + + " -model_file " + discoveredModelFile + " -variable_file " + getSampleVariableFile(); + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + + verifyResult(result, "createDomain.sh completed successfully"); + + setUpBootProperties(domainHome, "AdminServer", "weblogic", "welcome1"); + Path adminServerOut = getTestOutputPath(testInfo).resolve("AdminServer.out"); + boolean isServerUp = startAdminServer(domainHome, adminServerOut ); + if (!isServerUp) { + throw new Exception("Admin server did not come up after createDomain from discoverDomain"); + } + stopAdminServer(domainHome); + } + } + + /** + * test prepareModel.sh with -target as wko + * @throws Exception - if any error occurs + */ + @DisplayName("Test 32: Prepare model") + @Order(32) + @Tag("gate") + @Test + void test32PrepareModel(TestInfo testInfo) throws Exception { + + Path outputFiles = getTestOutputPath(testInfo); + try (PrintWriter out = getTestMethodWriter(testInfo, "PrepareModel")) { + String wkoModelFile = getSampleModelFile("-targetwko"); + String cmd = prepareModelScript + + " -oracle_home " + mwhome_12213 + + " -output_dir " + outputFiles + + " -model_file " + wkoModelFile + + " -target " + "wko"; + + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + // ListenPort differences warning + assertEquals(1, result.exitValue(), "Unexpected return code"); + } + try (PrintWriter out = getTestMethodWriter(testInfo, "GrepResults")) { + // verify model file + String tempWkoModel = outputFiles + FS + "simple-topology-targetwko.yaml"; + String cmd = "grep \"PasswordEncrypted: '@@SECRET\" " + tempWkoModel; + CommandResult result2 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result2.exitValue(), "Missing JDBC Secret"); + cmd = "grep -c 'Machine' " + tempWkoModel; + CommandResult result3 = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertNotEquals(0, result3.exitValue(), "Machine section was not removed from model"); + } + } + + /** + * Test Discover Domain using the -skip_archive argument + * @throws Exception - if any error occurs + */ + @DisplayName("Test 33: Skip archive") + @Order(33) + @Tag("gate") + @Test + void test33DiscoverSkipArchive(TestInfo testInfo) throws Exception { + String cmd = createDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " + + domainParentDir + FS + "discoverDomainSkipArchive-33-34 -model_file " + + getSampleModelFile("-onlinebase") + " -archive_file " + getSampleArchiveFile(); + try (PrintWriter out = getTestMethodWriter(testInfo, "CreateDomain")) { + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + assertEquals(0, result.exitValue(), "Unexpected return code"); + discover33DomainCreated = true; + } + + try (PrintWriter out = getTestMethodWriter(testInfo, "DiscoverDomain")) { + Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); + cmd = discoverDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainParentDir + FS + "discoverDomainSkipArchive-33-34" + + " -model_file " + discoveredModel + + " -skip_archive " ; + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + // SecurityConfiguration warning + assertEquals(0, result.exitValue(), "Unexpected return code"); + } + } + + /** + * Test Discover Domain using the -run_remote argument + * @throws Exception - if any error occurs + */ + @DisplayName("Test 34: remote discovery") + @Order(34) + @Tag("gate") + @Test + void test34DiscoverRemote(TestInfo testInfo) throws Exception { + assertTrue(discover33DomainCreated, "step skipped because Domain creation failed in step test33DiscoverSkipArchive"); + String domainHome = domainParentDir + FS + "discoverDomainSkipArchive-33-34"; + setUpBootProperties(domainHome, "admin-server", "weblogic", "welcome1"); + Path adminServerOut = getTestOutputPath(testInfo).resolve("admin-server.out"); + boolean isServerUp = startAdminServer(domainHome, adminServerOut); + + if (isServerUp) { + try (PrintWriter out = getTestMethodWriter(testInfo)) { + Path discoveredModel = getTestOutputPath(testInfo).resolve("discoveredModel.yaml"); + String cmd = discoverDomainScript + + " -oracle_home " + mwhome_12213 + + " -domain_home " + domainHome + + " -model_file " + discoveredModel + + " -admin_user weblogic -admin_pass welcome1 -admin_url t3://localhost:7001" + + " -remote"; + CommandResult result = Runner.run(cmd, getTestMethodEnvironment(testInfo), out); + // SecurityConfiguration warning + verifyResult(result, "Remote discovery created a model that references files or directories" + + " on the remote machine"); + } + } else { + // Best effort to clean up server + tryKillTheAdminServer(domainHome, "admin-server"); + throw new Exception("test34DiscoverRemote failed - cannot bring up server"); + } + + } + /** * test discoverDomain.sh that model can create a working domain * @throws Exception - if any error occurs From 778af855ec48ec14b12ecbc4b6f191bfa0354ebd Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Thu, 2 Feb 2023 15:47:48 -0600 Subject: [PATCH 09/20] Fix npe --- core/src/main/python/create.py | 4 ---- .../main/python/wlsdeploy/tool/deploy/datasource_deployer.py | 2 +- .../test/java/oracle/weblogic/deploy/integration/ITWdt.java | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/core/src/main/python/create.py b/core/src/main/python/create.py index 6b655ae97f..c446cd34e3 100644 --- a/core/src/main/python/create.py +++ b/core/src/main/python/create.py @@ -320,10 +320,6 @@ def main(model_context): archive_helper = ArchiveHelper(archive_file_name, domain_path, __logger, ExceptionType.CREATE) has_atp, has_ssl = validate_rcu_args_and_model(model_context, model_dictionary, archive_helper, aliases) - # check if there is an atpwallet and extract in the domain dir - # it is to support non JRF domain but user wants to use ATP database - # if (has_atp or has_ssl) and archive_helper: - # archive_helper.extract_database_wallet() if archive_helper: archive_helper.extract_all_database_wallets() diff --git a/core/src/main/python/wlsdeploy/tool/deploy/datasource_deployer.py b/core/src/main/python/wlsdeploy/tool/deploy/datasource_deployer.py index daf398050d..ad58067474 100644 --- a/core/src/main/python/wlsdeploy/tool/deploy/datasource_deployer.py +++ b/core/src/main/python/wlsdeploy/tool/deploy/datasource_deployer.py @@ -18,7 +18,7 @@ class DatasourceDeployer(Deployer): def __init__(self, model, model_context, aliases, wlst_mode=WlstModes.OFFLINE): Deployer.__init__(self, model, model_context, aliases, wlst_mode) - if not model_context.is_remote(): + if not model_context.is_remote() and self.archive_helper: self.archive_helper.extract_all_database_wallets() def add_data_sources(self, parent_dict, location): diff --git a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java index 911cdf7aa1..2ced5e8f1a 100644 --- a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java +++ b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java @@ -1162,10 +1162,10 @@ void test34DiscoverRemote(TestInfo testInfo) throws Exception { } /** - * test discoverDomain.sh that model can create a working domain + * test create and discover domain with jdbc wallet. * @throws Exception - if any error occurs */ - @DisplayName("Test 35: Discover domain and then create a new domain from the model") + @DisplayName("Test 35: test create and discover domain with jdbc wallet") @Order(35) @Tag("gate") @Test From a903c540e5379702418d2e7953875115cd966ee3 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Fri, 3 Feb 2023 12:03:54 -0600 Subject: [PATCH 10/20] add error when wallet file not found --- .../tool/discover/common_resources_discoverer.py | 9 ++++++++- .../weblogic/deploy/messages/wlsdeploy_rb.properties | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py index 596d421f31..c008f9e3dc 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py +++ b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py @@ -141,7 +141,14 @@ def _collect_jdbc_driver_wallet(self, datasource, collected_wallet, driver_param _logger.info('WLSDPLY-06367', connection_property, fixed_path, class_name=_class_name, method_name=_method_name) properties[connection_property]['Value'] = fixed_path - + else: + _logger.severe('WLSDPLY-06370', datasource, connection_property, + properties[connection_property]['Value']) + de = exception_helper.create_discover_exception('WLSDPLY-06370', datasource, + connection_property, + properties[connection_property]['Value']) + _logger.throwing(class_name=_class_name, method_name=_method_name, error=de) + raise de def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictionary, property_value): _method_name = '_add_wallet_directory_to_archive' diff --git a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties index f2069857a3..695367dbac 100644 --- a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties +++ b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties @@ -746,6 +746,7 @@ WLSDPLY-06368=Unable to collect wallet directory because the JDBC Datasource Dri WLSDPLY-06369=Parent directory of JDBC Datasource DriverParams property value {0} is not a flat structure, only \ individual file will be added to the wallet, other files that may exists in the original database wallet will not be \ collected. +WLSDPLY-06370=Datasource {0} JDBC Datasource DriverParams property {1} value {2} does not exist in the file system. # deployments_discoverer.py WLSDPLY-06380=Discovering domain model deployments From bcc930930624e5329216825598207f3f06e3f497 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Fri, 3 Feb 2023 12:10:08 -0600 Subject: [PATCH 11/20] copyright change --- .../test/java/oracle/weblogic/deploy/integration/BaseTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java index 57d5a3f86b..a849b57c2f 100644 --- a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java +++ b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java @@ -1,4 +1,4 @@ -// Copyright 2019, 2021, Oracle Corporation and/or its affiliates. +// Copyright 2019, 2023, Oracle Corporation and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. package oracle.weblogic.deploy.integration; From 452ce47974c024afb934fbbdace0e00c0c1cb0ca Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Fri, 3 Feb 2023 12:47:09 -0600 Subject: [PATCH 12/20] add info for not trying to collect if remote --- .../wlsdeploy/tool/discover/common_resources_discoverer.py | 3 +++ .../oracle/weblogic/deploy/messages/wlsdeploy_rb.properties | 2 ++ 2 files changed, 5 insertions(+) diff --git a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py index c008f9e3dc..6431e27503 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py +++ b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py @@ -123,6 +123,9 @@ def get_datasources(self): def _collect_jdbc_driver_wallet(self, datasource, collected_wallet, driver_params): _method_name = '_collect_jdbc_driver_wallet' + if self._model_context.is_remote(): + _logger.info("WLSDPLY-06371") + return if model_constants.JDBC_DRIVER_PARAMS_PROPERTIES in driver_params: properties = driver_params[model_constants.JDBC_DRIVER_PARAMS_PROPERTIES] for connection_property in [model_constants.DRIVER_PARAMS_KEYSTORE_PROPERTY, diff --git a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties index 695367dbac..6ce1c6ae1b 100644 --- a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties +++ b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties @@ -747,6 +747,8 @@ WLSDPLY-06369=Parent directory of JDBC Datasource DriverParams property value {0 individual file will be added to the wallet, other files that may exists in the original database wallet will not be \ collected. WLSDPLY-06370=Datasource {0} JDBC Datasource DriverParams property {1} value {2} does not exist in the file system. +WLSDPLY-06371=Remote discovery will not collect any JDBC Datasource DriverParams connection property that references \ + file or directory. # deployments_discoverer.py WLSDPLY-06380=Discovering domain model deployments From 2ef21f24d2f98c47272394553ca246f80289d3a4 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Fri, 3 Feb 2023 17:47:42 -0600 Subject: [PATCH 13/20] fix remote discovery and skip archive --- .../deploy/util/WLSDeployArchive.java | 14 +++++- .../discover/common_resources_discoverer.py | 44 +++++++++++-------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java b/core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java index 3d9712a323..f4639527bb 100644 --- a/core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java +++ b/core/src/main/java/oracle/weblogic/deploy/util/WLSDeployArchive.java @@ -1394,7 +1394,7 @@ public int removeStructuredApplication(String appPath, boolean silent) throws WL * @param shlibPath file name to find the name for * @return name for model archive file name */ - public String getSharedLibraryArchivePath(String shlibPath) { + public static String getSharedLibraryArchivePath(String shlibPath) { return getArchiveName(ARCHIVE_SHLIBS_TARGET_DIR, shlibPath); } @@ -1718,7 +1718,7 @@ public int removeSharedLibraryDeploymentPlan(String planPath, boolean silent) th * @param domainLibPath the file name to get the archive file name * @return model ready archive file name */ - public String getDomainLibArchiveName(String domainLibPath) { + public static String getDomainLibArchiveName(String domainLibPath) { return getArchiveName(ARCHIVE_DOMLIB_TARGET_DIR, domainLibPath); } @@ -3718,6 +3718,16 @@ public String addDatabaseWallet(String walletName, String sourceLocation) throws return newName; } + /** + * Return the database wallet path of a file. + * @param walletName database wallet name + * @param fileLocation a file in the wallet + * @return path to the particular file in the database wallet + */ + public static String getDatabaseWalletArchivePath(String walletName, String fileLocation) { + return getArchiveName(ARCHIVE_DB_WALLETS_DIR + ZIP_SEP + walletName, fileLocation); + } + /** * Add the RCU database wallet to the archive. * diff --git a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py index 6431e27503..8501924199 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py +++ b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py @@ -123,8 +123,7 @@ def get_datasources(self): def _collect_jdbc_driver_wallet(self, datasource, collected_wallet, driver_params): _method_name = '_collect_jdbc_driver_wallet' - if self._model_context.is_remote(): - _logger.info("WLSDPLY-06371") + if self._model_context.skip_archive(): return if model_constants.JDBC_DRIVER_PARAMS_PROPERTIES in driver_params: properties = driver_params[model_constants.JDBC_DRIVER_PARAMS_PROPERTIES] @@ -155,26 +154,18 @@ def _collect_jdbc_driver_wallet(self, datasource, collected_wallet, driver_param def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictionary, property_value): _method_name = '_add_wallet_directory_to_archive' - if self._model_context.skip_archive() or self._model_context.is_remote(): - return property_value - - if os.path.isdir(property_value): - onprem_wallet_parent_path = os.path.abspath(property_value) - else: - onprem_wallet_parent_path = os.path.dirname(os.path.abspath(property_value)) # error if wallet parent path is at oracle home - if self._model_context.get_oracle_home() == onprem_wallet_parent_path: - _logger.severe('WLSDPLY-06368', property_value, self._model_context.get_oracle_home()) - de = exception_helper.create_discover_exception('WLSDPLY-06368', property_value, - self._model_context.get_oracle_home()) - _logger.throwing(class_name=_class_name, method_name=_method_name, error=de) - raise de + onprem_wallet_parent_path, wallet_name = self._get_wallet_name_and_path(datasource, property_value) + + if self._model_context.is_remote(): + fixed_path = WLSDeployArchive.getDatabaseWalletArchivePath(wallet_name, property_value) + self.add_to_remote_map(property_value, fixed_path, + WLSDeployArchive.ArchiveEntryType.DB_WALLET.name()) + return fixed_path onprem_wallet_dir_is_not_flat = self._is_on_prem_wallet_dir_flat(onprem_wallet_parent_path, property_value) archive_file = self._model_context.get_archive_file() - # fix up name just in case - wallet_name = datasource.replace(' ','').replace('(', '').replace(')','') # keep track of the wallet name and from where it is collected # { : { 'wallet_name': , 'path_into_archive': , @@ -183,6 +174,7 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona # if not onprem_wallet_parent_path in collected_wallet_dictionary: if onprem_wallet_dir_is_not_flat: + # collect the specific file fixed_path = archive_file.addDatabaseWallet(wallet_name, os.path.abspath(property_value)) path_into_archive = os.path.dirname(fixed_path) else: @@ -202,7 +194,7 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona # only case is it is not flat directory if the particular file has not been collected before, add # it to the previous wallet fixed_path = archive_file.addDatabaseWallet(collected_wallet_dictionary[onprem_wallet_parent_path]['wallet_name'], - os.path.abspath(property_value)) + os.path.abspath(property_value)) else: # already in archive just figure out the path if (os.path.isdir(property_value)): @@ -213,6 +205,22 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona return fixed_path + def _get_wallet_name_and_path(self, datasource, property_value): + _method_name = '_get_wallet_name_and_path' + # fix up name just in case + wallet_name = datasource.replace(' ', '').replace('(', '').replace(')', '') + if os.path.isdir(property_value): + onprem_wallet_parent_path = os.path.abspath(property_value) + else: + onprem_wallet_parent_path = os.path.dirname(os.path.abspath(property_value)) + if self._model_context.get_oracle_home() == onprem_wallet_parent_path: + _logger.severe('WLSDPLY-06368', property_value, self._model_context.get_oracle_home()) + de = exception_helper.create_discover_exception('WLSDPLY-06368', property_value, + self._model_context.get_oracle_home()) + _logger.throwing(class_name=_class_name, method_name=_method_name, error=de) + raise de + return onprem_wallet_parent_path, wallet_name + def _is_on_prem_wallet_dir_flat(self, onprem_wallet_parent_path, property_value): # info if wallet parent is not flat and only collect the particular file and not the entire directory dir_list = os.listdir(onprem_wallet_parent_path) From 7d8f1e126ac58242d25bc254ce0247867716e0eb Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Mon, 6 Feb 2023 09:43:42 -0600 Subject: [PATCH 14/20] fix problem where domain directory does not exist yet before extracting wallet --- core/src/main/python/create.py | 7 +++++++ .../src/test/resources/simple-topology-jdbcwallet.yaml | 3 +++ 2 files changed, 10 insertions(+) diff --git a/core/src/main/python/create.py b/core/src/main/python/create.py index c446cd34e3..d17a87eb76 100644 --- a/core/src/main/python/create.py +++ b/core/src/main/python/create.py @@ -322,6 +322,13 @@ def main(model_context): has_atp, has_ssl = validate_rcu_args_and_model(model_context, model_dictionary, archive_helper, aliases) if archive_helper: + domain_parent = model_context.get_domain_parent_dir() + domain_home = model_context.get_domain_home() + if domain_parent and domain_home is None: + domain_home = os.path.join(domain_parent, model_dictionary[model_constants.TOPOLOGY]['Name']) + if not os.path.exists(os.path.abspath(domain_home)): + os.mkdir(os.path.abspath(domain_home)) + archive_helper.extract_all_database_wallets() creator = DomainCreator(model_dictionary, model_context, aliases) diff --git a/integration-tests/system-test/src/test/resources/simple-topology-jdbcwallet.yaml b/integration-tests/system-test/src/test/resources/simple-topology-jdbcwallet.yaml index d14ce44e1e..23f0b29aae 100644 --- a/integration-tests/system-test/src/test/resources/simple-topology-jdbcwallet.yaml +++ b/integration-tests/system-test/src/test/resources/simple-topology-jdbcwallet.yaml @@ -17,6 +17,9 @@ resources: DatasourceType: GENERIC JDBCConnectionPoolParams: TestTableName: SQL ISVALID + InitialCapacity: 0 + MinCapacity: 0 + MaxCapacity: 1 JDBCDataSourceParams: GlobalTransactionsProtocol: OnePhaseCommit JNDIName: testds From 68be854e21069afa9571ee27c8527f1037432e4a Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Mon, 6 Feb 2023 12:28:05 -0600 Subject: [PATCH 15/20] undo model change --- .../src/test/resources/simple-topology-jdbcwallet.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/integration-tests/system-test/src/test/resources/simple-topology-jdbcwallet.yaml b/integration-tests/system-test/src/test/resources/simple-topology-jdbcwallet.yaml index 23f0b29aae..d14ce44e1e 100644 --- a/integration-tests/system-test/src/test/resources/simple-topology-jdbcwallet.yaml +++ b/integration-tests/system-test/src/test/resources/simple-topology-jdbcwallet.yaml @@ -17,9 +17,6 @@ resources: DatasourceType: GENERIC JDBCConnectionPoolParams: TestTableName: SQL ISVALID - InitialCapacity: 0 - MinCapacity: 0 - MaxCapacity: 1 JDBCDataSourceParams: GlobalTransactionsProtocol: OnePhaseCommit JNDIName: testds From aab8842c54d6566e8b8cf4d7664cfdf9835b7814 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Mon, 6 Feb 2023 13:11:14 -0600 Subject: [PATCH 16/20] fix compare test result --- .../src/test/java/oracle/weblogic/deploy/integration/ITWdt.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java index 2ced5e8f1a..7ea521e80a 100644 --- a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java +++ b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java @@ -1222,7 +1222,7 @@ private void verifyDiscoveredJDBCWalletModelFile(String expectedModelFile) throw checkContents.add(" DomainVersion: 12.2.1.4.0"); checkContents.add(" ProductionModeEnabled: true"); checkContents.add(" NMProperties:"); - checkContents.add(" JavaHome: /home/johnny/jdk1.8.0_201"); + checkContents.add(" JavaHome: /usr/java/jdk1.8.0_361"); checkContents.add(" Server:"); checkContents.add(" admin-server: {}"); checkContents.add(" SecurityConfiguration:"); From 3f6ebdfb8ba7b8ad63f9f5a5c0c7918ce6380bd6 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Mon, 6 Feb 2023 13:12:42 -0600 Subject: [PATCH 17/20] fix compare result --- .../src/test/java/oracle/weblogic/deploy/integration/ITWdt.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java index 7ea521e80a..1302824ccd 100644 --- a/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java +++ b/integration-tests/system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java @@ -1219,7 +1219,7 @@ private void verifyDiscoveredJDBCWalletModelFile(String expectedModelFile) throw checkContents.add("topology:"); checkContents.add(" Name: domain2"); checkContents.add(" AdminServerName: admin-server"); - checkContents.add(" DomainVersion: 12.2.1.4.0"); + checkContents.add(" DomainVersion: 12.2.1.3.0"); checkContents.add(" ProductionModeEnabled: true"); checkContents.add(" NMProperties:"); checkContents.add(" JavaHome: /usr/java/jdk1.8.0_361"); From ef732f2fef8fbf532c0bd8f88ad7a9be6c118a2a Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Mon, 6 Feb 2023 15:33:54 -0600 Subject: [PATCH 18/20] fix sonar issue --- .../wlsdeploy/tool/util/archive_helper.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/core/src/main/python/wlsdeploy/tool/util/archive_helper.py b/core/src/main/python/wlsdeploy/tool/util/archive_helper.py index 580a28b398..7acd296aea 100644 --- a/core/src/main/python/wlsdeploy/tool/util/archive_helper.py +++ b/core/src/main/python/wlsdeploy/tool/util/archive_helper.py @@ -402,18 +402,19 @@ def extract_database_wallet(self, wallet_name=WLSDeployArchive.DEFAULT_RCU_WALLE return resulting_wallet_path def extract_all_database_wallets(self): - archive_entries = self.get_archive_entries() - wallet_names = sets.Set() - for entry in archive_entries: - if entry.startswith(WLSDeployArchive.ARCHIVE_DB_WALLETS_DIR): - if os.path.isdir(entry): - name = wallet_names.add(os.path.basename(entry)) - else: - name = os.path.basename(os.path.dirname(entry)) - - wallet_names.add(name) - for wallet_name in wallet_names: - self.extract_database_wallet(wallet_name) + + for archive_file in self.__archive_files: + archive_entries = archive_file.getArchiveEntries() + wallet_names = sets.Set() + for entry in archive_entries: + if entry.startswith(WLSDeployArchive.ARCHIVE_DB_WALLETS_DIR): + if os.path.isdir(entry): + wallet_names.add(os.path.basename(entry)) + else: + name = os.path.basename(os.path.dirname(entry)) + wallet_names.add(name) + for wallet_name in wallet_names: + self.extract_database_wallet(wallet_name) def extract_opss_wallet(self): """ From f3559053e2b18a4211cd51d8964bffc07c8ce667 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Mon, 6 Feb 2023 16:46:52 -0600 Subject: [PATCH 19/20] sonar fix --- .../wlsdeploy/tool/discover/common_resources_discoverer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py index 8501924199..14d9cda436 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py +++ b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py @@ -172,7 +172,7 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona # }, # .... } # - if not onprem_wallet_parent_path in collected_wallet_dictionary: + if onprem_wallet_parent_path not in collected_wallet_dictionary: if onprem_wallet_dir_is_not_flat: # collect the specific file fixed_path = archive_file.addDatabaseWallet(wallet_name, os.path.abspath(property_value)) @@ -190,7 +190,7 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona check_path = os.path.join( collected_wallet_dictionary[onprem_wallet_parent_path]['path_into_archive'], os.path.basename(property_value)) - if not check_path in archive_file.getArchiveEntries() and os.path.isfile(property_value): + if check_path not in archive_file.getArchiveEntries() and os.path.isfile(property_value): # only case is it is not flat directory if the particular file has not been collected before, add # it to the previous wallet fixed_path = archive_file.addDatabaseWallet(collected_wallet_dictionary[onprem_wallet_parent_path]['wallet_name'], From 91a6bf76ee7e7b82728cb488992f8bd275657033 Mon Sep 17 00:00:00 2001 From: Johnny Shum Date: Mon, 6 Feb 2023 18:47:54 -0600 Subject: [PATCH 20/20] sonar code smell --- .../discover/common_resources_discoverer.py | 61 +++++++++---------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py index 14d9cda436..ef804bc8d4 100644 --- a/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py +++ b/core/src/main/python/wlsdeploy/tool/discover/common_resources_discoverer.py @@ -122,39 +122,39 @@ def get_datasources(self): return model_top_folder_name, result def _collect_jdbc_driver_wallet(self, datasource, collected_wallet, driver_params): - _method_name = '_collect_jdbc_driver_wallet' - if self._model_context.skip_archive(): - return - if model_constants.JDBC_DRIVER_PARAMS_PROPERTIES in driver_params: + if not self._model_context.skip_archive() and model_constants.JDBC_DRIVER_PARAMS_PROPERTIES in driver_params: properties = driver_params[model_constants.JDBC_DRIVER_PARAMS_PROPERTIES] - for connection_property in [model_constants.DRIVER_PARAMS_KEYSTORE_PROPERTY, - model_constants.DRIVER_PARAMS_TRUSTSTORE_PROPERTY, - model_constants.DRIVER_PARAMS_NET_TNS_ADMIN]: - if connection_property in properties: - qualified_property_value = properties[connection_property]['Value'] - if qualified_property_value: - if qualified_property_value.startswith(WLSDeployArchive.WLSDPLY_ARCHIVE_BINARY_DIR - + WLSDeployArchive.ZIP_SEP): - qualified_property_value = os.path.join(self._model_context.get_domain_home() - ,qualified_property_value) - if os.path.exists(qualified_property_value): - fixed_path = self._add_wallet_directory_to_archive(datasource, collected_wallet, - qualified_property_value) - _logger.info('WLSDPLY-06367', connection_property, fixed_path, - class_name=_class_name, method_name=_method_name) - properties[connection_property]['Value'] = fixed_path - else: - _logger.severe('WLSDPLY-06370', datasource, connection_property, - properties[connection_property]['Value']) - de = exception_helper.create_discover_exception('WLSDPLY-06370', datasource, - connection_property, - properties[connection_property]['Value']) - _logger.throwing(class_name=_class_name, method_name=_method_name, error=de) - raise de + self._update_wallet_property_and_collect_files(collected_wallet, datasource, properties) + + def _update_wallet_property_and_collect_files(self, collected_wallet, datasource, properties): + _method_name = '_update_wallet_property_and_collect_files' + for connection_property in [model_constants.DRIVER_PARAMS_KEYSTORE_PROPERTY, + model_constants.DRIVER_PARAMS_TRUSTSTORE_PROPERTY, + model_constants.DRIVER_PARAMS_NET_TNS_ADMIN]: + if connection_property in properties: + qualified_property_value = properties[connection_property]['Value'] + if qualified_property_value: + if qualified_property_value.startswith(WLSDeployArchive.WLSDPLY_ARCHIVE_BINARY_DIR + + WLSDeployArchive.ZIP_SEP): + qualified_property_value = os.path.join(self._model_context.get_domain_home() + , qualified_property_value) + if os.path.exists(qualified_property_value): + fixed_path = self._add_wallet_directory_to_archive(datasource, collected_wallet, + qualified_property_value) + _logger.info('WLSDPLY-06367', connection_property, fixed_path, + class_name=_class_name, method_name=_method_name) + properties[connection_property]['Value'] = fixed_path + else: + _logger.severe('WLSDPLY-06370', datasource, connection_property, + properties[connection_property]['Value']) + de = exception_helper.create_discover_exception('WLSDPLY-06370', datasource, + connection_property, + properties[connection_property][ + 'Value']) + _logger.throwing(class_name=_class_name, method_name=_method_name, error=de) + raise de def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictionary, property_value): - _method_name = '_add_wallet_directory_to_archive' - # error if wallet parent path is at oracle home onprem_wallet_parent_path, wallet_name = self._get_wallet_name_and_path(datasource, property_value) @@ -341,7 +341,6 @@ def archive_file_store_directory(self, file_store_name, file_store_dictionary): file_store_dictionary[model_constants.DIRECTORY] = new_source_name _logger.exiting(class_name=_class_name, method_name=_method_name) - return def get_jdbc_stores(self): """