示例#1
0
    def setUp(self):
        glideinwms.frontend.glideinFrontendLib.logSupport.log = FakeLogger()
        # Only condor cliens are mocked, not the python bindings
        condorMonitor.USE_HTCONDOR_PYTHON_BINDINGS = False
        with mock.patch('glideinwms.lib.condorExe.exe_cmd') as m_exe_cmd:
            f = open('cs.fixture')
            m_exe_cmd.return_value = f.readlines()
            self.status_dict = glideinFrontendLib.getCondorStatus(['coll1'])

        self.frontend_name = 'fe_name'
        self.group_name = 'group_name'
        self.request_name = 'request_name'
        self.cred_id = 1234
        self.default_format = [('JobStatus', 'i'), ('EnteredCurrentStatus', 'i'),
                               ('ServerTime', 'i'), ('RemoteHost', 's')]

        self.prepare_condorq_dict()

        self.glidein_dict_k1 = (
            'submit.local',
            'Site_Name1@v3_0@factory1',
            'frontend@factory1')
        self.glidein_dict_k2 = (
            'submit.local',
            'Site_Name2@v3_0@factory1',
            'frontend@factory1')
        self.glidein_dict_k3 = (
            'submit.local',
            'Site_Name3@v3_0@factory1',
            'frontend@factory1')
        self.glidein_dict = {self.glidein_dict_k1: {'attrs': {'GLIDEIN_Site': 'Site_Name1', 'GLIDEIN_CPUS': 1}, 'monitor': {}, 'params': {}},
                             self.glidein_dict_k2: {'attrs': {'GLIDEIN_Site': 'Site_Name2', 'GLIDEIN_CPUS': 4}, 'monitor': {}, 'params': {}},
                             self.glidein_dict_k3: {'attrs': {'GLIDEIN_Site': 'Site_Name3', 'GLIDEIN_CPUS': 'aUtO'}, 'monitor': {}, 'params': {}}
                             }
    def test_get_q_credentials(self):
        glideinwms.factory.glideFactoryLib.logSupport.log = FakeLogger()
        glideinwms.factory.glideFactoryLib.condorMonitor = mock.Mock()
        glideinwms.factory.glideFactoryLib.condorMonitor.SubQuery = mock.Mock()
        condorq = mock.Mock()
        schedd_name = 'schedd_name'
        condorq.schedd_name = schedd_name
        factory_name = 'factory_name'
        condorq.factory_name = factory_name
        glidein_name = 'glidein_name'
        condorq.glidein_name = glidein_name
        entry_name = 'entry_name'
        condorq.entry_name = entry_name
        client_name = 'client_name'
        condorq.client_name = client_name
        creds = mock.Mock()
        client_sa = 'fake'
        cred_secclass_sa = 'fake'
        cred_id_sa = 'fake'

        crd = getQCredentials(condorq, client_name,
                              creds, client_sa, cred_secclass_sa, cred_id_sa)
        self.assertEqual(crd.schedd_name, condorq.schedd_name)
        self.assertEqual(crd.factory_name, condorq.factory_name)
        self.assertEqual(crd.glidein_name, condorq.glidein_name)
        self.assertEqual(crd.entry_name, condorq.entry_name)
        self.assertEqual(crd.client_name, condorq.client_name)
    def test_get_q_prox_sec_class(self):
        glideinwms.factory.glideFactoryLib.logSupport.log = FakeLogger()
        glideinwms.factory.glideFactoryLib.condorMonitor = mock.Mock()
        glideinwms.factory.glideFactoryLib.condorMonitor.SubQuery = mock.Mock()
        condorq = mock.Mock()
        schedd_name = 'schedd_name'
        condorq.schedd_name = schedd_name
        factory_name = 'factory_name'
        condorq.factory_name = factory_name
        glidein_name = 'glidein_name'
        condorq.glidein_name = glidein_name
        entry_name = 'entry_name'
        condorq.entry_name = entry_name
        client_name = 'client_name'
        condorq.client_name = client_name
        proxy_security_class = 'fake'
        credential_secclass_schedd_attribute = 'fake'
        client_schedd_attribute = 'fake'

        crd = getQProxSecClass(condorq, client_name, proxy_security_class,
                               client_schedd_attribute,
                               credential_secclass_schedd_attribute, self.cnf)
        self.assertEqual(crd.schedd_name, condorq.schedd_name)
        self.assertEqual(crd.factory_name, condorq.factory_name)
        self.assertEqual(crd.glidein_name, condorq.glidein_name)
        self.assertEqual(crd.entry_name, condorq.entry_name)
示例#4
0
 def setUp(self):
     logSupport.log = FakeLogger()
     self.config_dir="/tmp"
     #self.working_dir = tempfile.mkdtemp()
     self.credlist=[]
     # Create fake descript
     self.elementDescript=fakeDescript()
     self.createCondor()
 def test_get_condor_q_data(self):
     entry_name = 'entry_name'
     client_name = 'client_name'
     schedd_name = 'sched_name'
     glideinwms.factory.glideFactoryLib.logSupport.log = FakeLogger()
     glideinwms.factory.glideFactoryLib.condorMonitor = mock.Mock()
     glideinwms.factory.glideFactoryLib.condorMonitor.CondorQ = mock.Mock()
     cd = getCondorQData(entry_name, client_name, schedd_name, self.cnf)
     self.assertEqual(cd.factory_name, self.cnf.factory_name)
     self.assertEqual(cd.glidein_name, self.cnf.glidein_name)
     self.assertEqual(cd.client_name, client_name)
     self.assertEqual(cd.entry_name, entry_name)
    def test_get_condor_status_data(self):
        glideinwms.factory.glideFactoryLib.logSupport.log = FakeLogger()
        glideinwms.factory.glideFactoryLib.condorMonitor = mock.Mock()
        condorq = mock.Mock()
        glideinwms.factory.glideFactoryLib.condorMonitor.CondorStatus = condorq

        entry_name = 'entry_name'
        client_name = 'client_name'

        crd = getCondorStatusData(entry_name, client_name)

        self.assertEqual(crd.factory_name, self.cnf.factory_name)
        self.assertEqual(crd.glidein_name, self.cnf.glidein_name)
        self.assertEqual(crd.entry_name, entry_name)
        self.assertEqual(crd.client_name, client_name)
示例#7
0
    def setUp(self):
        """
        The cleanupSupport module logs so implement the FakeLogger so that things
        don't break.  We will create a bunch of files to cleanup and a bunch to
        keep around.
        """
        logSupport.log = FakeLogger()
        self.num_cleanup_files_wanted = 10
        self.num_noncleanup_files_wanted = 5
        self.cleanup_extension = '.cleanup'
        self.keep_extension = '.dont_cleanup'

        # mkdir tempdir
        self.cleanup_dir = tempfile.mkdtemp()
        # make non cleanup temp files
        self.create_noncleanup_tempfiles()
        # make cleanup temp files
        self.create_cleanup_tempfiles()
示例#8
0
    def setUp(self):
        self.testdir = os.getcwd()
        self.datadir = 'fixtures/factory/work-dir'
        os.system('git checkout %s' % self.datadir)
        self.startup_dir = os.path.join(self.testdir, self.datadir)
        self.entry_name = 'el6_osg34'
        os.chdir(self.datadir)
        self.monitorDir = os.path.join(self.startup_dir,'monitor/entry_%s' % self.entry_name)
        try:
            os.makedirs(self.monitorDir)
        except Exception:
            pass
        self.glidein_descript = GlideinDescript()
        self.frontend_descript = FrontendDescript()
        glideinwms.factory.glideFactoryEntry.logSupport.log = FakeLogger()

        self.entry = Entry(self.entry_name, self.startup_dir,
                           self.glidein_descript, self.frontend_descript)
        os.chdir(self.testdir)
示例#9
0
 def setUp(self):
     parent_pid = 0
     work_dir = 'fixtures/frontend'
     group_name = 'group1'
     action = 'yada yada'
     condorMonitor.USE_HTCONDOR_PYTHON_BINDINGS = False
     condorMonitor.LocalScheddCache.iGetEnv = mock.Mock()
     #condorExe.exe_cmd = mock.Mock()
     #condorExe.exe_cmd.side_effect = condor_side_effect
     glideinwms.frontend.glideinFrontendLib.logSupport.log = FakeLogger()
     self.gfe = glideinFrontendElement(os.getpid(), work_dir, group_name,
                                       action)
     self.gfe.frontend_name = 'Frontend-master-v1_0'
     #self.gfe.configure()
     init_factory_stats_arr()
     self.verbose = os.environ.get('DEBUG_OUTPUT')
     self.gfe.get_condor_q = mock.Mock()
     self.gfe.get_condor_q.side_effect = condor_q_side_effect
     self.gfe.get_condor_status = mock.Mock()
     self.gfe.get_condor_status.side_effect = condor_status_side_effect
示例#10
0
    def setUp(self):
        glideinwms.frontend.glideinFrontendLib.logSupport.log = FakeLogger()
        condorMonitor.USE_HTCONDOR_PYTHON_BINDINGS = False
        self.frontendDescript = glideinwms.frontend.glideinFrontendConfig.FrontendDescript(
            'fixtures/frontend')

        with mock.patch.object(glideinFrontendConfig.ConfigFile, 'load') as m_load:
            # simpler data structures
            self.attrDescript = glideinwms.frontend.glideinFrontendConfig.AttrsDescript(
                '', '')
            self.paramsDescript = glideinwms.frontend.glideinFrontendConfig.ParamsDescript(
                '', '')

            # bases for derived data structures
            elementDescriptBase = glideinwms.frontend.glideinFrontendConfig.ElementDescript(
                '', '')
            signatureDescript = glideinwms.frontend.glideinFrontendConfig.SignatureDescript(
                '')
            signatureDescript.data = {
                'group_group1': (
                    'ad0f57615c3df8bbb2130d96cfdf09363f4bd3ed',
                    'description.e98f4o.cfg'),
                'main': (
                    '7cea6e20d5a4e65e9468937f27511e3e44c72735',
                    'description.e98f4o.cfg')}

        self.paramsDescript.data = {
            'USE_MATCH_AUTH': 'True',
            'GLIDECLIENT_Rank': '1',
            'GLIDEIN_Collector': 'frontend:9620-9640'}
        self.paramsDescript.const_data = {
            'USE_MATCH_AUTH': (
                'CONST',
                'True'),
            'GLIDEIN_Collector': (
                'CONST',
                'frontend:9620-9640'),
            'GLIDECLIENT_Rank': (
                'CONST',
                '1')}

        self.attrDescript.data = {
            'GLIDEIN_Glexec_Use': 'OPTIONAL',
            'GLIDECLIENT_Rank': '1',
            'GLIDEIN_Expose_Grid_Env': 'True',
            'GLIDECLIENT_Start': 'True',
            'USE_MATCH_AUTH': 'True',
            'GLIDECLIENT_Group_Start': 'True',
            'GLIDEIN_Collector': 'frontend:9620-9640'}

        elementDescriptBase.data = {
            'GLIDEIN_Glexec_Use': 'OPTIONAL',
            'MapFile': '/var/lib/gwms-frontend/vofrontend/group_main/group.mapfile',
            'MaxRunningTotal': '100000',
            'JobMatchAttrs': '[]',
            'JobSchedds': '',
            'FactoryCollectors': '[]',
            'MaxIdleVMsPerEntry': '100',
            'CurbRunningTotal': '90000',
            'ReserveIdlePerEntry': '5',
            'MaxRunningPerEntry': '10000',
            'JobQueryExpr': 'True',
            'MaxIdleVMsTotal': '1000',
            'FactoryMatchAttrs': '[]',
            'MaxIdlePerEntry': '100',
            'FracRunningPerEntry': '1.15',
            'FactoryQueryExpr': 'True',
            'MatchExpr': 'True',
            'CurbIdleVMsTotal': '200',
            'GroupName': 'group1',
            'MaxMatchmakers': '3',
            'MapFileWPilots': '/var/lib/gwms-frontend/vofrontend/group_main/group_wpilots.mapfile',
            'CurbIdleVMsPerEntry': '5',
            'MinRunningPerEntry': '0',
            'IdleLifetime': '0',
            'RemovalType': 'NO',
            'RemovalWait': '0',
            'RemovalRequestsTracking': 'False',
            'RemovalMargin': '0'}

        with mock.patch.object(glideinFrontendConfig, 'SignatureDescript') as m_signatureDescript:
            m_signatureDescript.return_value = signatureDescript
            self.groupSignatureDescript = glideinwms.frontend.glideinFrontendConfig.GroupSignatureDescript(
                '', 'group1')

        with mock.patch.object(glideinFrontendConfig, 'ElementDescript') as m_elementDescript:
            with mock.patch.object(glideinFrontendConfig, 'FrontendDescript') as m_feDescript:
                m_elementDescript.return_value = elementDescriptBase
                m_feDescript.return_value = self.frontendDescript
                self.elementDescript = glideinwms.frontend.glideinFrontendConfig.ElementMergedDescript(
                    '', 'group1')

        @mock.patch(
            'glideinwms.frontend.glideinFrontendConfig.ElementMergedDescript')
        @mock.patch('glideinwms.frontend.glideinFrontendConfig.ParamsDescript')
        @mock.patch(
            'glideinwms.frontend.glideinFrontendConfig.GroupSignatureDescript')
        @mock.patch('glideinwms.frontend.glideinFrontendConfig.AttrsDescript')
        def create_glideinFrontendElement(
                m_AttrsDescript,
                m_GroupSignatureDescript,
                m_ParamsDescript,
                m_ElementMergedDescript):
            m_AttrsDescript.return_value = self.attrDescript
            m_GroupSignatureDescript.return_value = self.groupSignatureDescript
            m_ParamsDescript.return_value = self.paramsDescript
            m_ElementMergedDescript.return_value = self.elementDescript

            self.gfe = glideinFrontendElement.glideinFrontendElement(
                1, '', 'group1', '')
            self.gfe.elementDescript = self.elementDescript

        # @mock.patch defines these so disable pylint complaint
        create_glideinFrontendElement()  # pylint: disable=no-value-for-parameter
 def test_get_condor_q_credential_list(self):
     glideinwms.factory.glideFactoryLib.logSupport.log = FakeLogger()
     glideinwms.factory.glideFactoryLib.condorMonitor = mock.Mock()
     crdl = getCondorQCredentialList(self.cnf)
     self.assertEqual([], crdl)
 def test_get_q_status_stale(self):
     glideinwms.factory.glideFactoryLib.logSupport.log = FakeLogger()
     condorq = mock.Mock()
     condorq.stored_data = {}
     qs = getQStatusStale(condorq)
 def test_get_q_status_s_f(self):
     glideinwms.factory.glideFactoryLib.logSupport.log = FakeLogger()
     glideinwms.factory.glideFactoryLib.condorMonitor = mock.Mock()
     condorq = mock.Mock()
     condorq.stored_data = {}
     self.assertEqual({}, getQStatusSF(condorq))
示例#14
0
def global_log_setup():
    fd = open(LOG_FILE, 'w', 0)
    glideinwms.lib.logSupport.log = FakeLogger(fd)