def test_format_entry_pair_output(self): """ Test formatting """ config_entry = { 'name': 'config_entry', 'gridtype': 'gt2', 'gatekeeper': 'node1.fnal.gov/jobmanager-condor', 'rsl': '(queue=default)', 'wall_clocktime': 24, 'ref_id': 'GlueCEUniqueID=config_entry.fnal.gov:2119/jobmanager-condor_default', 'ce_status': 'cestatus', 'glexec_bin': 'NONE', 'work_dir': 'OSG', 'source': 'exp-bdii.cern.ch', 'source_type': 'BDII' } infosys_entry = { 'site_name': 'infosys_entry', 'gridtype': 'cream', 'gatekeeper': 'node2.fnal.gov/jobmanager-condor', 'rsl': '(queue=default)', 'wall_clocktime': 24, 'ref_id': 'GlueCEUniqueID=infosys_entry.fnal.gov:2119/jobmanager-condor_default', 'ce_status': 'cestatus', 'glexec_bin': 'NONE', 'work_dir': 'OSG', 'source': 'exp-bdii.cern.ch', 'source_type': 'BDII' } entry_pairs = [[config_entry, infosys_entry]] output = format_entry_pair_output(entry_pairs) expected = "Config Ref Id : GlueCEUniqueID=config_entry.fnal.gov:2119/jobmanager-condor_default\n" \ "Config entry Name : config_entry\n" \ "Config gatekeeper : node1.fnal.gov/jobmanager-condor\n" \ "Config rsl : (queue=default)\n" \ "Config gridtype : gt2\n" \ "Infosys BDII Id : GlueCEUniqueID=infosys_entry.fnal.gov:2119/jobmanager-condor_default\n" \ "Infosys source url: exp-bdii.cern.ch\n" \ "Infosys site name : infosys_entry\n" \ "Infosys gatekeeper : node2.fnal.gov/jobmanager-condor\n" \ "Infosys rsl : (queue=default)\n" \ "Infosys gridtype : cream\n\n" self.assertEqual(output, expected)
def test_format_entry_pair_output(self): """ Test formatting """ config_entry = {'name' : 'config_entry', 'gridtype' : 'gt2', 'gatekeeper' : 'node1.fnal.gov/jobmanager-condor', 'rsl' : '(queue=default)', 'wall_clocktime' : 24, 'ref_id' : 'GlueCEUniqueID=config_entry.fnal.gov:2119/jobmanager-condor_default', 'ce_status' : 'cestatus', 'glexec_bin' : 'NONE', 'work_dir' : 'OSG', 'source' : 'exp-bdii.cern.ch', 'source_type' : 'BDII'} infosys_entry = {'site_name' : 'infosys_entry', 'gridtype' : 'cream', 'gatekeeper' : 'node2.fnal.gov/jobmanager-condor', 'rsl' : '(queue=default)', 'wall_clocktime' : 24, 'ref_id' : 'GlueCEUniqueID=infosys_entry.fnal.gov:2119/jobmanager-condor_default', 'ce_status' : 'cestatus', 'glexec_bin' : 'NONE', 'work_dir' : 'OSG', 'source' : 'exp-bdii.cern.ch', 'source_type' : 'BDII'} entry_pairs = [[config_entry, infosys_entry]] output = format_entry_pair_output(entry_pairs) expected = "Config Ref Id : GlueCEUniqueID=config_entry.fnal.gov:2119/jobmanager-condor_default\n" \ "Config entry Name : config_entry\n" \ "Config gatekeeper : node1.fnal.gov/jobmanager-condor\n" \ "Config rsl : (queue=default)\n" \ "Config gridtype : gt2\n" \ "Infosys BDII Id : GlueCEUniqueID=infosys_entry.fnal.gov:2119/jobmanager-condor_default\n" \ "Infosys source url: exp-bdii.cern.ch\n" \ "Infosys site name : infosys_entry\n" \ "Infosys gatekeeper : node2.fnal.gov/jobmanager-condor\n" \ "Infosys rsl : (queue=default)\n" \ "Infosys gridtype : cream\n\n" self.assertEqual(output,expected)
def main(argv): """ Takes input configuration file and information system and finds entries where the id matches one published in the given information system but their content differs. """ # Set defaults for the arguments config_xml = "" skip_disabled = 'yes' try: opts, args = getopt.getopt(argv, "hx:d:", ["help"]) except getopt.GetoptError: print("Unrecognized or incomplete input arguments.") print(USAGE) sys.exit(2) for opt, arg in opts: if opt in ("-h", "--help"): print(USAGE) sys.exit() else: if opt == '-x': config_xml = arg elif opt == '-d': skip_disabled = arg else: print("Unrecognized input arguments.") print(USAGE) sys.exit(2) # Validate arg exists if config_xml == '': print("No configuration file was provided. ") print(USAGE) sys.exit(2) else: if not os.path.isfile(config_xml): print("Config file '%s' does not exist." % config_xml) sys.exit(2) if skip_disabled.lower() != 'yes' and skip_disabled.lower() != 'no': print("Skip disabled argument must be 'yes' or 'no'.") print(USAGE) sys.exit(2) if skip_disabled == 'yes': skip_disabled = True else: skip_disabled = False # Find matching entries that have different content id_match_bdii, id_match_ress, id_match_tg = find_entries_with_different_content( config_xml, skip_disabled) # Format output datestamp = datetime.datetime.now().strftime("%Y-%m-%d %M:%S") output = "\nThis file contains all the entries in the factory configuration file that do " \ "no match what is published in the information system.\n" output += "Script run on : %s \n" % datestamp output += "Number of entries : %i\n\n" % ( len(id_match_bdii) + len(id_match_ress) + len(id_match_tg)) if len(id_match_bdii) == 0 and len(id_match_ress) == 0 and len( id_match_tg) == 0: output += "No entries were found with matching ids and different content.\n" else: output += infosys_lib.format_entry_pair_output(id_match_bdii) output += infosys_lib.format_entry_pair_output(id_match_ress) output += infosys_lib.format_entry_pair_output(id_match_tg) # Output results print(output)
def main(argv): """ Takes input configuration file and information system and finds entries where the id matches one published in the given information system but their content differs. """ # Set defaults for the arguments config_xml = "" skip_disabled = 'yes' try: opts, args = getopt.getopt(argv, "hx:d:", ["help"]) except getopt.GetoptError: print "Unrecognized or incomplete input arguments." print USAGE sys.exit(2) for opt, arg in opts: if opt in ("-h", "--help"): print USAGE sys.exit() else: if opt == '-x': config_xml = arg elif opt == '-d': skip_disabled = arg else: print "Unrecognized input arguments." print USAGE sys.exit(2) # Validate arg exists if config_xml == '': print "No configuration file was provided. " print USAGE sys.exit(2) else: if not os.path.isfile(config_xml): print "Config file '%s' does not exist." % config_xml sys.exit(2) if skip_disabled.lower() != 'yes' and skip_disabled.lower() != 'no': print "Skip disabled argument must be 'yes' or 'no'." print USAGE sys.exit(2) if skip_disabled == 'yes': skip_disabled = True else: skip_disabled = False # Find matching entries that have different content id_match_bdii, id_match_ress, id_match_tg = find_entries_with_different_content(config_xml, skip_disabled) # Format output datestamp = datetime.datetime.now().strftime("%Y-%m-%d %M:%S") output = "\nThis file contains all the entries in the factory configuration file that do " \ "no match what is published in the information system.\n" output += "Script run on : %s \n" % datestamp output += "Number of entries : %i\n\n" % (len(id_match_bdii) + len(id_match_ress) + len(id_match_tg)) if len(id_match_bdii) == 0 and len(id_match_ress) == 0 and len(id_match_tg) == 0: output += "No entries were found with matching ids and different content.\n" else: output += infosys_lib.format_entry_pair_output(id_match_bdii) output += infosys_lib.format_entry_pair_output(id_match_ress) output += infosys_lib.format_entry_pair_output(id_match_tg) # Output results print output