def testServiceList(self): """ Test to make sure right services get returned """ config_file = get_test_config("lsf/check_ok.ini") configuration = configparser.SafeConfigParser() configuration.read(config_file) settings = lsf.LSFConfiguration(logger=global_logger) try: settings.parse_configuration(configuration) except Exception as e: self.fail("Received exception while parsing configuration: %s" % e) services = settings.enabled_services() expected_services = {'condor-ce', 'globus-gridftp-server'} self.assertEqual(services, expected_services, "List of enabled services incorrect, " + "got %s but expected %s" % (services, expected_services)) config_file = get_test_config("lsf/lsf_disabled.ini") configuration = configparser.SafeConfigParser() configuration.read(config_file) settings = lsf.LSFConfiguration(logger=global_logger) try: settings.parse_configuration(configuration) except Exception as e: self.fail("Received exception while parsing configuration: %s" % e) services = settings.enabled_services() expected_services = set() self.assertEqual(services, expected_services, "List of enabled services incorrect, " + "got %s but expected %s" % (services, expected_services))
def testParsing(self): """ Test configuration parsing """ config_file = get_test_config("lsf/lsf1.ini") configuration = configparser.SafeConfigParser() configuration.read(config_file) settings = lsf.LSFConfiguration(logger=global_logger) try: settings.parse_configuration(configuration) except Exception as e: self.fail("Received exception while parsing configuration: %s" % e) attributes = settings.get_attributes() options = {'OSG_JOB_MANAGER_HOME': '/opt/lsf', 'OSG_LSF_LOCATION': '/opt/lsf', 'OSG_JOB_MANAGER': 'LSF'} for option in options: value = options[option] self.assertTrue(option in attributes, "Attribute %s missing" % option) err_msg = "Wrong value obtained for %s, " \ "got %s instead of %s" % (option, attributes[option], value) self.assertEqual(attributes[option], value, err_msg)
def testMissingLSFProfile(self): """ Test the check_attributes function to see if it catches missing LSF profile """ config_file = get_test_config("lsf/missing_profile.ini") configuration = ConfigParser.SafeConfigParser() configuration.read(config_file) settings = lsf.LSFConfiguration(logger=global_logger) self.assertRaises(exceptions.SettingError, settings.parse_configuration, configuration)
def testValidSettings2(self): """ Test the check_attributes function to see if it works on valid settings """ config_file = get_test_config("lsf/check_ok2.ini") configuration = ConfigParser.SafeConfigParser() configuration.read(config_file) settings = lsf.LSFConfiguration(logger=global_logger) try: settings.parse_configuration(configuration) except Exception, e: self.fail("Received exception while parsing configuration: %s" % e)
def testMissingLSFLocation(self): """ Test the check_attributes function to see if it catches missing LSF location """ config_file = get_test_config("lsf/missing_location.ini") configuration = ConfigParser.SafeConfigParser() configuration.read(config_file) settings = lsf.LSFConfiguration(logger=global_logger) try: settings.parse_configuration(configuration) except Exception, e: self.fail("Received exception while parsing configuration: %s" % e)
def testParsingIgnored(self): """ Test parsing when ignored """ config_file = get_test_config("lsf/ignored.ini") configuration = ConfigParser.SafeConfigParser() configuration.read(config_file) settings = lsf.LSFConfiguration(logger=global_logger) try: settings.parse_configuration(configuration) except Exception, e: self.fail("Received exception while parsing configuration: %s" % e)
def testServiceList(self): """ Test to make sure right services get returned """ config_file = get_test_config("lsf/check_ok.ini") configuration = ConfigParser.SafeConfigParser() configuration.read(config_file) settings = lsf.LSFConfiguration(logger=global_logger) try: settings.parse_configuration(configuration) except Exception, e: self.fail("Received exception while parsing configuration: %s" % e)
def testInvalidUtilityContact(self): """ Test the check_attributes function to see if it catches invalid utility contacts """ config_file = get_test_config("lsf/invalid_utility_contact.ini") configuration = ConfigParser.SafeConfigParser() configuration.read(config_file) settings = lsf.LSFConfiguration(logger=global_logger) try: settings.parse_configuration(configuration) except Exception, e: self.fail("Received exception while parsing configuration: %s" % e)
def testValidSettings2(self): """ Test the check_attributes function to see if it works on valid settings """ config_file = get_test_config("lsf/check_ok2.ini") configuration = configparser.SafeConfigParser() configuration.read(config_file) settings = lsf.LSFConfiguration(logger=global_logger) try: settings.parse_configuration(configuration) except Exception as e: self.fail("Received exception while parsing configuration: %s" % e) attributes = settings.get_attributes() self.assertTrue(settings.check_attributes(attributes), "Correct settings incorrectly flagged as invalid")
def testParsingIgnored(self): """ Test parsing when ignored """ config_file = get_test_config("lsf/ignored.ini") configuration = configparser.SafeConfigParser() configuration.read(config_file) settings = lsf.LSFConfiguration(logger=global_logger) try: settings.parse_configuration(configuration) except Exception as e: self.fail("Received exception while parsing configuration: %s" % e) attributes = settings.get_attributes() self.assertEqual(len(attributes), 0, "Ignored configuration should have no attributes")
try: settings.parse_configuration(configuration) except Exception, e: self.fail("Received exception while parsing configuration: %s" % e) services = settings.enabled_services() expected_services = set(['condor-ce', 'globus-gridftp-server']) self.assertEqual( services, expected_services, "List of enabled services incorrect, " + "got %s but expected %s" % (services, expected_services)) config_file = get_test_config("lsf/lsf_disabled.ini") configuration = ConfigParser.SafeConfigParser() configuration.read(config_file) settings = lsf.LSFConfiguration(logger=global_logger) try: settings.parse_configuration(configuration) except Exception, e: self.fail("Received exception while parsing configuration: %s" % e) services = settings.enabled_services() expected_services = set() self.assertEqual( services, expected_services, "List of enabled services incorrect, " + "got %s but expected %s" % (services, expected_services)) if __name__ == '__main__': console = logging.StreamHandler() console.setLevel(logging.ERROR)