def testDeleteModelAppDeployments(self): _method_name = 'testCompareModelFull' _variables_file = self._resources_dir + '/compare_model_model1.10.properties' _new_model_file = self._resources_dir + '/compare_model_model5.yaml' _old_model_file = self._resources_dir + '/compare_model_model1.yaml' _temp_dir = os.path.join(tempfile.gettempdir(), _method_name) if os.path.exists(_temp_dir): shutil.rmtree(_temp_dir) os.mkdir(_temp_dir) mw_home = os.environ['MW_HOME'] args_map = { '-oracle_home': mw_home, '-variable_file': _variables_file, '-output_dir': _temp_dir, '-domain_type': 'WLS', '-trailing_arguments': [_new_model_file, _old_model_file] } try: model_context = ModelContext('CompareModelTestCase', args_map) obj = ModelFileDiffer(_new_model_file, _old_model_file, model_context, _temp_dir) return_code = obj.compare() self.assertEqual(return_code, 0) yaml_result = _temp_dir + os.sep + 'diffed_model.yaml' stdout_result = obj.get_compare_msgs() model_dictionary = FileToPython(yaml_result).parse() yaml_exists = os.path.exists(yaml_result) self.assertEqual(yaml_exists, True) self.assertEqual(len(stdout_result), 0) self.assertEqual(model_dictionary.has_key('appDeployments'), True) self.assertEqual( model_dictionary['appDeployments'].has_key('Library'), True) self.assertEqual( model_dictionary['appDeployments'].has_key('Application'), True) self.assertEqual( model_dictionary['appDeployments']['Application'].has_key( '!myear'), True) self.assertEqual( model_dictionary['appDeployments']['Library'].has_key( '!jax-rs#[email protected]'), True) self.assertEqual( model_dictionary['appDeployments']['Library'].has_key( '!jsf#[email protected]'), True) except (CompareException, PyWLSTException), te: return_code = 2 self._logger.severe('WLSDPLY-05709', te.getLocalizedMessage(), error=te, class_name=self._program_name, method_name=_method_name)
def testCompareModel4(self): _method_name = 'testCompareModel4' _models_dir = self._resources_dir + '/compare' _new_model_file = _models_dir + '/model-4-new.yaml' _old_model_file = _models_dir + '/model-4-old.yaml' _output_dir = os.path.join(self._results_dir, 'model-4') if not os.path.isdir(_output_dir): os.mkdir(_output_dir) args_map = { '-oracle_home': '/oracle', '-output_dir': _output_dir, '-trailing_arguments': [_new_model_file, _old_model_file] } try: model_context = ModelContext('CompareModelTestCase', args_map) differ = ModelFileDiffer(_new_model_file, _old_model_file, model_context, _output_dir) return_code = differ.compare() self.assertEqual(return_code, 0) yaml_result = _output_dir + os.sep + 'diffed_model.yaml' self.assertEqual(os.path.exists(yaml_result), True, "YAML result should exist: " + yaml_result) json_result = _output_dir + os.sep + 'diffed_model.json' self.assertEqual(os.path.exists(json_result), True, "JSON result should exist: " + json_result) # see comments in the model for erased attributes messages = differ.get_compare_msgs() self.assertEqual(len(messages), 2) model_root = FileToPython(yaml_result).parse() # topology section not present, since no Server differences topology = dictionary_utils.get_element(model_root, TOPOLOGY) self.assertEqual(topology, None, "topology should not be present") resources = dictionary_utils.get_dictionary_element( model_root, RESOURCES) # the SelfTuning should contain delete keys for nested, named folders self_tuning = dictionary_utils.get_dictionary_element( resources, SELF_TUNING) work_manager = dictionary_utils.get_dictionary_element( self_tuning, WORK_MANAGER) delete_name = model_helper.get_delete_name('newWM') self.assertEqual(delete_name in work_manager, True, WORK_MANAGER + ' should contain ' + delete_name) min_constraint = dictionary_utils.get_dictionary_element( self_tuning, MIN_THREADS_CONSTRAINT) delete_name = model_helper.get_delete_name('SampleMinThreads') self.assertEqual( delete_name in min_constraint, True, MIN_THREADS_CONSTRAINT + ' should contain ' + delete_name) max_constraint = dictionary_utils.get_dictionary_element( self_tuning, MAX_THREADS_CONSTRAINT) delete_name = model_helper.get_delete_name('SampleMaxThreads') self.assertEqual( delete_name in max_constraint, True, MAX_THREADS_CONSTRAINT + ' should contain ' + delete_name) deployments = dictionary_utils.get_dictionary_element( model_root, APP_DEPLOYMENTS) libraries = dictionary_utils.get_dictionary_element( deployments, LIBRARY) # mylib should not appear in change model, it had no changes self.assertEqual(len(libraries), 1, "only one entry should be present in " + LIBRARY) # retarget should have a source path in change model, even though only targeting changed retarget = dictionary_utils.get_dictionary_element( libraries, 'retarget') self.assertEqual( SOURCE_PATH in retarget, True, LIBRARY + ' retarget should contain ' + SOURCE_PATH) applications = dictionary_utils.get_dictionary_element( deployments, APPLICATION) # myapp should not appear in change model, it had no changes self.assertEqual( len(applications), 1, "only one entry should be present in " + APPLICATION) # retarget should have a source path in change model, even though only targeting changed retarget = dictionary_utils.get_dictionary_element( applications, 'retarget') self.assertEqual( SOURCE_PATH in retarget, True, APPLICATION + ' retarget should contain ' + SOURCE_PATH) except (CompareException, PyWLSTException), te: return_code = 2 self._logger.severe('WLSDPLY-05709', te.getLocalizedMessage(), error=te, class_name=self._program_name, method_name=_method_name)
def testCompareModelFull3(self): _method_name = 'testCompareModelFull3' # This test for # 1. Changing MailSessionProperty # 2. Changing ODL HandlerDefaults # 3. Changing ODL Handler property # 4. Changing ODL Logger attributes _variables_file = self._resources_dir + '/compare_model_model1.10.properties' _new_model_file = self._resources_dir + '/compare_model_model8.yaml' _old_model_file = self._resources_dir + '/compare_model_model7.yaml' _temp_dir = os.path.join(tempfile.gettempdir(), _method_name) if os.path.exists(_temp_dir): shutil.rmtree(_temp_dir) os.mkdir(_temp_dir) mw_home = os.environ['MW_HOME'] args_map = { '-oracle_home': mw_home, '-variable_file': _variables_file, '-output_dir': _temp_dir, '-domain_type': 'WLS', '-trailing_arguments': [_new_model_file, _old_model_file] } try: model_context = ModelContext('CompareModelTestCase', args_map) obj = ModelFileDiffer(_new_model_file, _old_model_file, model_context, _temp_dir) return_code = obj.compare() self.assertEqual(return_code, 0) yaml_result = _temp_dir + os.sep + 'diffed_model.yaml' json_result = _temp_dir + os.sep + 'diffed_model.json' stdout_result = obj.get_compare_msgs() model_dictionary = FileToPython(yaml_result).parse() yaml_exists = os.path.exists(yaml_result) json_exists = os.path.exists(json_result) self.assertEqual(yaml_exists, True) self.assertEqual(json_exists, True) self.assertEqual(len(stdout_result), 0) self.assertEqual(model_dictionary.has_key('resources'), True) self.assertEqual( model_dictionary['resources'].has_key('MailSession'), True) self.assertEqual( model_dictionary['resources']['MailSession'].has_key( 'MyMailSession'), True) mail_session = model_dictionary['resources']['MailSession'][ 'MyMailSession'] self.assertEqual(mail_session.has_key('Properties'), True) self.assertEqual( mail_session['Properties'].has_key('mail.imap.port'), True) self.assertEqual(mail_session['Properties']['mail.imap.port'], 993) self.assertEqual( model_dictionary['resources'].has_key('ODLConfiguration'), True) self.assertEqual( model_dictionary['resources']['ODLConfiguration'].has_key( 'config'), True) self.assertEqual( model_dictionary['resources']['ODLConfiguration'] ['config'].has_key('HandlerDefaults'), True) self.assertEqual( model_dictionary['resources']['ODLConfiguration']['config'] ['HandlerDefaults'].has_key('maxFileSize'), True) self.assertEqual( model_dictionary['resources']['ODLConfiguration']['config'] ['HandlerDefaults']['maxFileSize'], 14857620) self.assertEqual( model_dictionary['resources']['ODLConfiguration'] ['config'].has_key('Handler'), True) self.assertEqual( model_dictionary['resources']['ODLConfiguration']['config'] ['Handler'].has_key('odl-handler'), True) self.assertEqual( model_dictionary['resources']['ODLConfiguration']['config'] ['Handler']['odl-handler'].has_key('Properties'), True) self.assertEqual( model_dictionary['resources']['ODLConfiguration']['config'] ['Handler']['odl-handler']['Properties'].has_key( 'maxFileSize'), True) self.assertEqual( model_dictionary['resources']['ODLConfiguration']['config'] ['Handler']['odl-handler']['Properties']['maxFileSize'], 14857620) self.assertEqual( model_dictionary['resources']['ODLConfiguration'] ['config'].has_key('Logger'), True) self.assertEqual( model_dictionary['resources']['ODLConfiguration']['config'] ['Logger'].has_key( 'oracle.communications.ordermanagement.automation.plugin.AutomationPluginManager' ), True) self.assertEqual( model_dictionary['resources']['ODLConfiguration']['config'] ['Logger'] ['oracle.communications.ordermanagement.automation.plugin.AutomationPluginManager'] .has_key('Level'), True) self.assertEqual( model_dictionary['resources']['ODLConfiguration']['config'] ['Logger'] ['oracle.communications.ordermanagement.automation.plugin.AutomationPluginManager'] ['Level'], 'TRACE:16') self.assertEqual( len(model_dictionary['resources']['ODLConfiguration'] ['config']), 3) self.assertEqual( len(model_dictionary['resources']['ODLConfiguration']['config'] ['Logger']), 1) self.assertEqual( len(model_dictionary['resources']['ODLConfiguration']['config'] ['HandlerDefaults']), 1) except (CompareException, PyWLSTException), te: return_code = 2 self._logger.severe('WLSDPLY-05709', te.getLocalizedMessage(), error=te, class_name=self._program_name, method_name=_method_name)
def testCompareModelFull2(self): _method_name = 'testCompareModelFull2' # This test for # 1. Changing weblogic password # 2. Changing RCU password # 3. Deleting an application _variables_file = self._resources_dir + '/compare_model_model1.10.properties' _new_model_file = self._resources_dir + '/compare_model_model7.yaml' _old_model_file = self._resources_dir + '/compare_model_model6.yaml' _temp_dir = os.path.join(tempfile.gettempdir(), _method_name) if os.path.exists(_temp_dir): shutil.rmtree(_temp_dir) os.mkdir(_temp_dir) mw_home = os.environ['MW_HOME'] args_map = { '-oracle_home': mw_home, '-variable_file': _variables_file, '-output_dir': _temp_dir, '-domain_type': 'WLS', '-trailing_arguments': [_new_model_file, _old_model_file] } try: model_context = ModelContext('CompareModelTestCase', args_map) obj = ModelFileDiffer(_new_model_file, _old_model_file, model_context, _temp_dir) return_code = obj.compare() self.assertEqual(return_code, 0) yaml_result = _temp_dir + os.sep + 'diffed_model.yaml' json_result = _temp_dir + os.sep + 'diffed_model.json' stdout_result = obj.get_compare_msgs() model_dictionary = FileToPython(yaml_result).parse() yaml_exists = os.path.exists(yaml_result) json_exists = os.path.exists(json_result) self.assertEqual(yaml_exists, True) self.assertEqual(json_exists, True) self.assertEqual(len(stdout_result), 0) self.assertEqual(model_dictionary.has_key('domainInfo'), True) self.assertEqual( model_dictionary['domainInfo'].has_key('AdminPassword'), True) self.assertEqual(model_dictionary['domainInfo']['AdminPassword'], 'welcome2') self.assertEqual( model_dictionary['domainInfo'].has_key('AdminUser'), False) self.assertEqual( model_dictionary['domainInfo'].has_key('RCUDbInfo'), True) self.assertEqual( model_dictionary['domainInfo']['RCUDbInfo'].has_key( 'rcu_admin_password'), True) self.assertEqual(len(model_dictionary['domainInfo']['RCUDbInfo']), 1) self.assertEqual(len(model_dictionary['domainInfo']), 2) self.assertEqual(model_dictionary.has_key('appDeployments'), True) self.assertEqual( model_dictionary['appDeployments'].has_key('Application'), True) self.assertEqual( model_dictionary['appDeployments']['Application'].has_key( '!yourear'), True) self.assertEqual( len(model_dictionary['appDeployments']['Application']), 1) except (CompareException, PyWLSTException), te: return_code = 2 self._logger.severe('WLSDPLY-05709', te.getLocalizedMessage(), error=te, class_name=self._program_name, method_name=_method_name)