Example #1
0
    def testreportFailureToDashboard(self):
        """
        _testreportFailureToDashboard_

        test report Failure to dashboard with/without job_ad file
        """
        self.assertEqual(0, reportFailureToDashboard(0, None))
        # parseAd is called by reportFailureToDashboard, but if we would
        # call it from reportFailureToDashboard error will be suppressed
        # and it will return same exit code
        # So lets call it directly
        if '_CONDOR_JOB_AD' in os.environ:
            del os.environ["_CONDOR_JOB_AD"]
        self.assertRaises(KeyError, parseAd)
        self.assertEqual(0, reportFailureToDashboard(0))
        os.environ["_CONDOR_JOB_AD"] = "testFile"
        # if this environment variable is set, it will check this file
        # if file is not present, it will raise IOError
        self.assertRaises(IOError, parseAd)
        # Test real job_ad file and check if it returns dict.
        os.environ["_CONDOR_JOB_AD"] = os.path.join(getTestBase(), '..', 'data', 'WMCore', 'Services', 'Dashboard', 'job_ad_file')
        out = parseAd()
        self.assertTrue(isinstance(out, dict))
        # Also test it sending directly parsed job ad
        self.assertEqual(0, reportFailureToDashboard(0, out))
Example #2
0
    def testreportFailureToDashboard(self):
        """
        _testreportFailureToDashboard_

        test report Failure to dashboard with/without job_ad file
        """
        self.assertEqual(0, reportFailureToDashboard(0, None))
        # parseAd is called by reportFailureToDashboard, but if we would
        # call it from reportFailureToDashboard error will be suppressed
        # and it will return same exit code
        # So lets call it directly
        if '_CONDOR_JOB_AD' in os.environ:
            del os.environ["_CONDOR_JOB_AD"]
        self.assertRaises(KeyError, parseAd)
        self.assertEqual(0, reportFailureToDashboard(0))
        os.environ["_CONDOR_JOB_AD"] = "testFile"
        # if this environment variable is set, it will check this file
        # if file is not present, it will raise IOError
        self.assertRaises(IOError, parseAd)
        # Test real job_ad file and check if it returns dict.
        os.environ["_CONDOR_JOB_AD"] = os.path.join(getTestBase(), '..',
                                                    'data', 'WMCore',
                                                    'Services', 'Dashboard',
                                                    'job_ad_file')
        out = parseAd()
        self.assertTrue(isinstance(out, dict))
        # Also test it sending directly parsed job ad
        self.assertEqual(0, reportFailureToDashboard(0, out))
Example #3
0
    def testDashboardAPI(self):
        """
        _testDashboardAPI_

        Test dashboard API which can be used through python to publish values
        """
        os.environ["_CONDOR_JOB_AD"] = os.path.join(getTestBase(), '..', 'data', 'WMCore', 'Services', 'Dashboard', 'job_ad_file')
        out = parseAd()
        with DashboardAPI() as dashboardAPI:
            self.assertTrue(isinstance(out, dict))
            self.assertEqual(None, dashboardAPI.publish())
            self.assertEqual(None, dashboardAPI.sendValues(out))
            self.assertEqual(None, dashboardAPI.sendValues(out, out['CRAB_Id']))
            self.assertEqual(None, dashboardAPI.sendValues(out, out['CRAB_Id'], out['CRAB_ReqName']))
Example #4
0
    def testDashboardAPI(self):
        """
        _testDashboardAPI_

        Test dashboard API which can be used through python to publish values
        """
        dashboardAPI = DashboardAPI()
        os.environ["_CONDOR_JOB_AD"] = os.path.join(getTestBase(), '..', 'data', 'WMCore', 'Services', 'Dashboard', 'job_ad_file')
        out = parseAd()
        # No one expects anything to be returned, so double check if it is None
        self.assertTrue(isinstance(out, dict))
        self.assertEqual(None, dashboardAPI.publish())
        self.assertEqual(None, dashboardAPI.sendValues(out))
        self.assertEqual(None, dashboardAPI.sendValues(out, out['CRAB_Id']))
        self.assertEqual(None, dashboardAPI.sendValues(out, out['CRAB_Id'], out['CRAB_ReqName']))
        self.assertEqual(None, dashboardAPI.free())
Example #5
0
    def testDashboardAPI(self):
        """
        _testDashboardAPI_

        Test dashboard API which can be used through python to publish values
        """
        dashboardAPI = DashboardAPI()
        os.environ["_CONDOR_JOB_AD"] = os.path.join(getTestBase(), '..',
                                                    'data', 'WMCore',
                                                    'Services', 'Dashboard',
                                                    'job_ad_file')
        out = parseAd()
        # No one expects anything to be returned, so double check if it is None
        self.assertTrue(isinstance(out, dict))
        self.assertEqual(None, dashboardAPI.publish())
        self.assertEqual(None, dashboardAPI.sendValues(out))
        self.assertEqual(None, dashboardAPI.sendValues(out, out['CRAB_Id']))
        self.assertEqual(
            None,
            dashboardAPI.sendValues(out, out['CRAB_Id'], out['CRAB_ReqName']))
        self.assertEqual(None, dashboardAPI.free())