Exemple #1
0
    def testServiceList(self):
        """
        Test to make sure right services get returned
        """

        config_file = get_test_config("sge/check_ok.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)

        settings = sge.SGEConfiguration(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("sge/sge_disabled.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)

        settings = sge.SGEConfiguration(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))

        config_file = get_test_config("sge/ignored.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)

        settings = sge.SGEConfiguration(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))
Exemple #2
0
    def testParsing(self):
        """
        Test configuration parsing
        """

        config_file = get_test_config("sge/sge1.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)

        settings = sge.SGEConfiguration(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': './test_files',
            'OSG_SGE_LOCATION': './test_files',
            'OSG_SGE_ROOT': './test_files',
            'OSG_SGE_CELL': 'sge',
            'OSG_JOB_MANAGER': 'SGE'
        }
        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)
Exemple #3
0
    def testParsingIgnored(self):
        """
        Test parsing ignored configuration
        """

        config_file = get_test_config("sge/ignored.ini")
        configuration = ConfigParser.SafeConfigParser()
        configuration.read(config_file)

        settings = sge.SGEConfiguration(logger=global_logger)
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Exemple #4
0
    def testServiceList(self):
        """
        Test to make sure right services get returned
        """

        config_file = get_test_config("sge/check_ok.ini")
        configuration = ConfigParser.SafeConfigParser()
        configuration.read(config_file)

        settings = sge.SGEConfiguration(logger=global_logger)
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Exemple #5
0
    def testMissingSGEConfig(self):
        """
        Test the check_attributes function to see if it catches missing SGE config
        """

        config_file = get_test_config("sge/missing_config.ini")
        configuration = ConfigParser.SafeConfigParser()
        configuration.read(config_file)

        settings = sge.SGEConfiguration(logger=global_logger)
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Exemple #6
0
    def testMissingAttribute(self):
        """
        Test the parsing when attributes are missing, should get exceptions
        """

        mandatory = ['sge_root', 'sge_cell', 'sge_bin_location']
        for option in mandatory:
            config_file = get_test_config("sge/sge1.ini")
            configuration = configparser.SafeConfigParser()
            configuration.read(config_file)
            configuration.remove_option('SGE', option)

            settings = sge.SGEConfiguration(logger=global_logger)
            self.assertRaises(exceptions.SettingError,
                              settings.parse_configuration, configuration)
Exemple #7
0
    def testInvalidUtilityContact(self):
        """
        Test the check_attributes function to see if it catches invalid
        utility contacts
        """

        config_file = get_test_config("sge/invalid_utility_contact.ini")
        configuration = ConfigParser.SafeConfigParser()
        configuration.read(config_file)

        settings = sge.SGEConfiguration(logger=global_logger)
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Exemple #8
0
    def testLogDir(self):
        """
        Test the check_attributes function to see if it works on valid settings
        """

        config_file = get_test_config("sge/sge_log_dir.ini")
        configuration = ConfigParser.SafeConfigParser()
        configuration.read(config_file)
        root = os.path.join(config_file[:-20], 'test_files')
        configuration.set('SGE', 'sge_root', root)

        settings = sge.SGEConfiguration(logger=global_logger)
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Exemple #9
0
    def testParsingIgnored(self):
        """
        Test parsing ignored configuration
        """

        config_file = get_test_config("sge/ignored.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)

        settings = sge.SGEConfiguration(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")
Exemple #10
0
    def testMissingSGECell(self):
        """
        Test the check_attributes function to see if it catches missing SGE cell
        """

        config_file = get_test_config("sge/missing_cell.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)

        settings = sge.SGEConfiguration(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.assertFalse(settings.check_attributes(attributes),
                         "Did not notice missing SGE cell")
Exemple #11
0
    def testValidSettings2(self):
        """
        Test the check_attributes function to see if it works on valid settings
        """

        config_file = get_test_config("sge/check_ok2.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)
        root = os.path.join(config_file[:-17], 'test_files')
        configuration.set('SGE', 'sge_root', root)

        settings = sge.SGEConfiguration(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")
Exemple #12
0
        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("sge/seg_enabled.ini")
        configuration = ConfigParser.SafeConfigParser()
        configuration.read(config_file)

        settings = sge.SGEConfiguration(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([
            'condor-ce', 'globus-gatekeeper', 'globus-gridftp-server',
            'globus-scheduler-event-generator'
        ])
        self.assertEqual(
            services, expected_services,
            "List of enabled services incorrect, " + "got %s but expected %s" %
            (services, expected_services))

        config_file = get_test_config("sge/sge_disabled.ini")