예제 #1
0
    def test_countMatch(self):
        match_expr = 'not job.has_key("DESIRED_Sites") or glidein["attrs"].get("GLIDEIN_Site") in job["DESIRED_Sites"]'
        match_obj = compile(match_expr, "<string>", "eval")
        unmatched = (None, None, None)
        match_counts = glideinFrontendLib.countMatch(match_obj, self.condorq_dict, self.glidein_dict, {})

        straight_match = match_counts[0]
        # straight match
        self.assertEqual(
            (straight_match[self.glidein_dict_k1], straight_match[self.glidein_dict_k2], straight_match[self.glidein_dict_k3]),
            (10, 8, 4) )

        prop_match = match_counts[1]
        # proportional match
        self.assertEqual(
            (prop_match[self.glidein_dict_k1], prop_match[self.glidein_dict_k2], prop_match[self.glidein_dict_k3]),
            (7, 5, 2) )

        only_match = match_counts[2]
        # only match: elements can only run on this site
        self.assertEqual(
            (only_match[self.glidein_dict_k1], only_match[self.glidein_dict_k2], only_match[self.glidein_dict_k3]),
            (4, 2, 0) )

        uniq_match = match_counts[3]
        # uniq match: glideins requested based on unique subsets after considering multicore
        self.assertEqual(
            (uniq_match[self.glidein_dict_k1], uniq_match[self.glidein_dict_k2], uniq_match[self.glidein_dict_k3]),
            (7, 2, 2) )

        # unmatched
        self.assertEqual((straight_match[unmatched], prop_match[unmatched], only_match[unmatched], uniq_match[unmatched]),
                         (1, 1, 1, 1))
예제 #2
0
    def test_countMatch_otherException(self):
        with mock.patch.object(glideinwms.frontend.glideinFrontendLib.logSupport.log, 'debug') as m_debug:
            match_obj = compile('3/0', "<string>", "eval")
            match_counts = glideinFrontendLib.countMatch(match_obj, self.condorq_dict, self.glidein_dict, {})
            log_msg = m_debug.call_args[0]

            self.assertTrue('exceptions in countMatch subprocess. Most recent traceback') in log_msg
            self.assertTrue('ZeroDivisionError: integer division or modulo by zero') in log_msg
예제 #3
0
    def test_countMatch_missingKey(self):
        with mock.patch.object(glideinwms.frontend.glideinFrontendLib.logSupport.log, 'debug') as m_debug:

            match_obj = compile('glidein["attrs"]["FOO"] == 3', "<string>", "eval")
            match_counts = glideinFrontendLib.countMatch(match_obj, self.condorq_dict, self.glidein_dict, {})
            m_debug.assert_called_with(
                "Failed to evaluate resource match in countMatch. Possibly match_expr has "
                "errors and trying to reference job or site attribute(s) ''FOO'' in an inappropriate way.")
예제 #4
0
    def test_countMatch_otherException(self):
        with mock.patch.object(glideinwms.frontend.glideinFrontendLib.logSupport.log, 'debug') as m_debug:
            match_obj = compile('3/0', "<string>", "eval")
            match_counts = glideinFrontendLib.countMatch(
                match_obj, self.condorq_dict, self.glidein_dict, {})
            log_msg = m_debug.call_args[0]

            self.assertTrue(
                'Most recent traceback' in str(log_msg), log_msg)
            self.assertTrue(
                'ZeroDivisionError: integer division or modulo by zero' in str(log_msg), log_msg)
예제 #5
0
    def test_countMatch_missingKey(self):
        with mock.patch.object(glideinwms.frontend.glideinFrontendLib.logSupport.log, 'debug') as m_debug:

            match_obj = compile(
                'glidein["attrs"]["FOO"] == 3',
                "<string>",
                "eval")
            match_counts = glideinFrontendLib.countMatch(
                match_obj, self.condorq_dict, self.glidein_dict, {})
            m_debug.assert_called_with(
                "Failed to evaluate resource match in countMatch. Possibly match_expr has "
                "errors and trying to reference job or site attribute(s) ''FOO'' in an inappropriate way.")
예제 #6
0
    def test_countMatchDowntime(self):
        self.glidein_dict[self.glidein_dict_k1]['attrs']['GLIDEIN_In_Downtime'] = True
        # test_countMatch should give the same results unless we call countMatch with ignore_down_entries = False
        self.test_countMatch()
        match_expr = 'not job.has_key("DESIRED_Sites") or glidein["attrs"].get("GLIDEIN_Site") in job["DESIRED_Sites"]'
        match_obj = compile(match_expr, "<string>", "eval")
        unmatched = (None, None, None)
        match_counts = glideinFrontendLib.countMatch(
            match_obj, self.condorq_dict, self.glidein_dict, {}, True)

        straight_match = match_counts[0]
        # glidein 1 is not matching anymore. There are more unmatched now
        self.assertEqual(
            (straight_match[self.glidein_dict_k1],
             straight_match[self.glidein_dict_k2],
             straight_match[self.glidein_dict_k3],
             straight_match[unmatched]),
            (0, 8, 4, 5))
예제 #7
0
    def test_countMatch(self):
        match_expr = 'not job.has_key("DESIRED_Sites") or glidein["attrs"].get("GLIDEIN_Site") in job["DESIRED_Sites"]'
        match_obj = compile(match_expr, "<string>", "eval")
        unmatched = (None, None, None)
        match_counts = glideinFrontendLib.countMatch(
            match_obj, self.condorq_dict, self.glidein_dict, {})

        straight_match = match_counts[0]
        # straight match
        self.assertEqual(
            (straight_match[self.glidein_dict_k1],
             straight_match[self.glidein_dict_k2],
             straight_match[self.glidein_dict_k3]),
            (10, 8, 4))

        prop_match = match_counts[1]
        # proportional match
        self.assertEqual(
            (prop_match[self.glidein_dict_k1],
             prop_match[self.glidein_dict_k2],
             prop_match[self.glidein_dict_k3]),
            (7, 5, 2))

        only_match = match_counts[2]
        # only match: elements can only run on this site
        self.assertEqual(
            (only_match[self.glidein_dict_k1],
             only_match[self.glidein_dict_k2],
             only_match[self.glidein_dict_k3]),
            (4, 2, 0))

        uniq_match = match_counts[3]
        # uniq match: glideins requested based on unique subsets after
        # considering multicore
        self.assertEqual(
            (uniq_match[self.glidein_dict_k1],
             uniq_match[self.glidein_dict_k2],
             uniq_match[self.glidein_dict_k3]),
            (7, 2, 2))

        # unmatched
        self.assertEqual((straight_match[unmatched], prop_match[unmatched], only_match[unmatched], uniq_match[unmatched]),
                         (1, 1, 1, 1))
예제 #8
0
    def test_countMatchDowntime(self):
        self.glidein_dict[
            self.glidein_dict_k1]['attrs']['GLIDEIN_In_Downtime'] = True
        # test_countMatch should give the same results unless we call countMatch with ignore_down_entries = False
        self.test_countMatch()
        match_expr = 'not job.has_key("DESIRED_Sites") or glidein["attrs"].get("GLIDEIN_Site") in job["DESIRED_Sites"]'
        match_obj = compile(match_expr, "<string>", "eval")
        unmatched = (None, None, None)
        match_counts = glideinFrontendLib.countMatch(match_obj,
                                                     self.condorq_dict,
                                                     self.glidein_dict, {},
                                                     True)

        straight_match = match_counts[0]
        # glidein 1 is not matching anymore. There are more unmatched now
        self.assertEqual(
            (straight_match[self.glidein_dict_k1],
             straight_match[self.glidein_dict_k2],
             straight_match[self.glidein_dict_k3], straight_match[unmatched]),
            (0, 8, 4, 5))
            os.close(r)
            try:
                if dt=='Real':
                    out=glideinFrontendLib.countRealRunning(elementDescript.merged_data['MatchExprCompiledObj'],condorq_dict_running,glidein_dict,attr_dict,condorq_match_list)
                elif dt=='Glidein':
                    count_status_multi={}
                    for glideid in glidein_dict.keys():
                        request_name=glideid[1]

                        count_status_multi[request_name]={}
                        for st in status_dict_types.keys():
                            c=glideinFrontendLib.getClientCondorStatus(status_dict_types[st]['dict'],frontend_name,group_name,request_name)
                            count_status_multi[request_name][st]=glideinFrontendLib.countCondorStatus(c)
                    out=count_status_multi
                else:
                    c,p,h=glideinFrontendLib.countMatch(elementDescript.merged_data['MatchExprCompiledObj'],condorq_dict_types[dt]['dict'],glidein_dict,attr_dict,condorq_match_list)
                    t=glideinFrontendLib.countCondorQ(condorq_dict_types[dt]['dict'])
                    out=(c,p,h,t)

                os.write(w,cPickle.dumps(out))
            finally:
                os.close(w)
                # hard kill myself... don't want any cleanup, since i was created just for this calculation
                os.kill(os.getpid(),signal.SIGKILL) 
        else:
            # this is the original
            # just remember what you did for now
            os.close(w)
            pipe_ids[dt]={'r':r,'pid':pid} 

    try: