Ejemplo n.º 1
0
    def testParsing(self):
        """
        Test condor parsing
        """

        config_file = get_test_config("condor/condor1.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)

        settings = condor.CondorConfiguration(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/condor',
            'OSG_CONDOR_LOCATION': '/opt/condor',
            'OSG_CONDOR_CONFIG': '/etc/condor/condor_config',
            'OSG_JOB_MANAGER': 'Condor'
        }
        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)
Ejemplo n.º 2
0
    def testMissingCondorConfig(self):
        """
        Test the check_attributes function to see if it catches missing
        condor config locations
        """

        for filename in [
                get_test_config("condor/missing_config1.ini"),
                get_test_config("condor/missing_config2.ini")
        ]:
            config_file = os.path.abspath(filename)
            configuration = configparser.SafeConfigParser()
            configuration.read(config_file)

            settings = condor.CondorConfiguration(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 condor config location: " +
                attributes['OSG_CONDOR_CONFIG'])
Ejemplo n.º 3
0
    def testServiceList(self):
        """
        Test to make sure right services get returned
        """

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

        settings = condor.CondorConfiguration(logger=global_logger)
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Ejemplo n.º 4
0
    def testParsingIgnored(self):
        """
        Test condor parsing when ignored
        """

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

        settings = condor.CondorConfiguration(logger=global_logger)
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Ejemplo n.º 5
0
    def testInvalidJobContact(self):
        """
        Test the check_attributes function to see if it catches invalid job contacts
        """

        config_file = get_test_config("condor/invalid_job_contact.ini")
        configuration = ConfigParser.SafeConfigParser()
        configuration.read(config_file)

        settings = condor.CondorConfiguration(logger=global_logger)
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Ejemplo n.º 6
0
    def testValidSettings2(self):
        """
        Test the check_attributes function to see if it works on valid settings
        """

        config_file = get_test_config("condor/check_ok2.ini")
        configuration = ConfigParser.SafeConfigParser()
        configuration.read(config_file)

        settings = condor.CondorConfiguration(logger=global_logger)
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Ejemplo n.º 7
0
    def testMissingCondorLocation(self):
        """
        Test the check_attributes function to see if it catches missing condor location
        """

        config_file = get_test_config("condor/missing_location.ini")
        configuration = ConfigParser.SafeConfigParser()
        configuration.read(config_file)

        settings = condor.CondorConfiguration(logger=global_logger)
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Ejemplo n.º 8
0
    def testServiceList(self):
        """
        Test to make sure right services get returned
        """

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

        settings = condor.CondorConfiguration(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("condor/condor_disabled.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)

        settings = condor.CondorConfiguration(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))
Ejemplo n.º 9
0
    def testParsingDefaults(self):
        """
        Test handling of defaults when parsing a configuration
        """

        config_file = get_test_config("condor/condor_defaults1.ini")
        configuration = ConfigParser.SafeConfigParser()
        configuration.read(config_file)

        # check to see if we can get values from condor_* variables
        os.environ['CONDOR_LOCATION'] = '/my/condor'
        os.environ['CONDOR_CONFIG'] = '/my/condor/etc/condor_config'
        settings = condor.CondorConfiguration(logger=global_logger)
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)
Ejemplo n.º 10
0
    def testParsingDisabled(self):
        """
        Test condor parsing when disabled
        """

        config_file = get_test_config("condor/condor_disabled.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)

        settings = condor.CondorConfiguration(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,
                         "Disabled configuration should have no attributes")
Ejemplo n.º 11
0
    def testValidSettings2(self):
        """
        Test the check_attributes function to see if it works on valid settings
        """

        config_file = get_test_config("condor/check_ok2.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)

        settings = condor.CondorConfiguration(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 missing")
Ejemplo n.º 12
0
    def testParsingDefaults(self):
        """
        Test handling of defaults when parsing a configuration
        """

        config_file = get_test_config("condor/condor_defaults1.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)

        # check to see if we can get values from condor_* variables
        os.environ['CONDOR_LOCATION'] = '/my/condor'
        os.environ['CONDOR_CONFIG'] = '/my/condor/etc/condor_config'
        settings = condor.CondorConfiguration(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('OSG_CONDOR_LOCATION' in attributes,
                        'Attribute OSG_CONDOR_LOCATION missing')
        self.assertEqual(attributes['OSG_CONDOR_LOCATION'], '/my/condor',
                         'Wrong value obtained for OSG_CONDOR_LOCATION')

        self.assertTrue('OSG_CONDOR_CONFIG' in attributes,
                        'Attribute OSG_CONDOR_CONFIG missing')
        self.assertEqual(attributes['OSG_CONDOR_CONFIG'],
                         '/my/condor/etc/condor_config',
                         'Wrong value obtained for OSG_CONDOR_CONFIG')

        # check when condor_config is not present
        del os.environ['CONDOR_CONFIG']
        settings = condor.CondorConfiguration(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('OSG_CONDOR_LOCATION' in attributes,
                        'Attribute OSG_CONDOR_LOCATION missing')
        self.assertEqual(attributes['OSG_CONDOR_LOCATION'], '/my/condor',
                         'Wrong value obtained for OSG_CONDOR_LOCATION')

        self.assertTrue('OSG_CONDOR_CONFIG' in attributes,
                        'Attribute OSG_CONDOR_CONFIG missing')
        self.assertEqual(attributes['OSG_CONDOR_CONFIG'],
                         '/etc/condor/condor_config',
                         'Wrong value obtained for OSG_CONDOR_CONFIG')

        # check to make sure that config values take precedence over
        # environment variables
        config_file = get_test_config("condor/condor1.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)
        os.environ['CONDOR_LOCATION'] = '/my/condor1'
        settings = condor.CondorConfiguration(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('OSG_CONDOR_LOCATION' in attributes,
                        'Attribute OSG_CONDOR_LOCATION missing')
        self.assertEqual(attributes['OSG_CONDOR_LOCATION'], '/opt/condor',
                         'Wrong value obtained for OSG_CONDOR_LOCATION')

        self.assertTrue('OSG_CONDOR_CONFIG' in attributes,
                        'Attribute OSG_CONDOR_CONFIG missing')
        self.assertEqual(attributes['OSG_CONDOR_CONFIG'],
                         '/etc/condor/condor_config',
                         'Wrong value obtained for OSG_CONDOR_CONFIG')

        # check to see if jobmanager home values get used in preference to other values
        config_file = get_test_config("condor/condor_defaults2.ini")
        configuration = configparser.SafeConfigParser()
        configuration.read(config_file)
        os.environ['CONDOR_LOCATION'] = '/my/condor1'
        settings = condor.CondorConfiguration(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('OSG_CONDOR_LOCATION' in attributes,
                        'Attribute OSG_CONDOR_LOCATION missing')
        self.assertEqual(attributes['OSG_CONDOR_LOCATION'],
                         '/usr/local/condor',
                         'Wrong value obtained for OSG_CONDOR_LOCATION')

        self.assertTrue('OSG_CONDOR_CONFIG' in attributes,
                        'Attribute OSG_CONDOR_CONFIG missing')
        self.assertEqual(attributes['OSG_CONDOR_CONFIG'],
                         '/etc/condor/condor_config',
                         'Wrong value obtained for OSG_CONDOR_CONFIG')
Ejemplo n.º 13
0
        attributes = settings.get_attributes()
        self.assertTrue(attributes.has_key('OSG_CONDOR_LOCATION'),
                        'Attribute OSG_CONDOR_LOCATION missing')
        self.assertEqual(attributes['OSG_CONDOR_LOCATION'], '/my/condor',
                         'Wrong value obtained for OSG_CONDOR_LOCATION')

        self.assertTrue(attributes.has_key('OSG_CONDOR_CONFIG'),
                        'Attribute OSG_CONDOR_CONFIG missing')
        self.assertEqual(attributes['OSG_CONDOR_CONFIG'],
                         '/my/condor/etc/condor_config',
                         'Wrong value obtained for OSG_CONDOR_CONFIG')

        # check when condor_config is not present
        del os.environ['CONDOR_CONFIG']
        settings = condor.CondorConfiguration(logger=global_logger)
        try:
            settings.parse_configuration(configuration)
        except Exception, e:
            self.fail("Received exception while parsing configuration: %s" % e)

        attributes = settings.get_attributes()
        self.assertTrue(attributes.has_key('OSG_CONDOR_LOCATION'),
                        'Attribute OSG_CONDOR_LOCATION missing')
        self.assertEqual(attributes['OSG_CONDOR_LOCATION'], '/my/condor',
                         'Wrong value obtained for OSG_CONDOR_LOCATION')

        self.assertTrue(attributes.has_key('OSG_CONDOR_CONFIG'),
                        'Attribute OSG_CONDOR_CONFIG missing')
        self.assertEqual(attributes['OSG_CONDOR_CONFIG'],
                         '/etc/condor/condor_config',