示例#1
0
def test_job_kill(gpi):
    from Ganga.GPI import Job, CREAM

    vo = getConfig('LCG')['VirtualOrganisation']
    call = subprocess.Popen(['lcg-infosites', 'ce', 'cream', '--vo', vo],
                            stdout=subprocess.PIPE)
    stdout, stderr = call.communicate()

    # Based on output of:
    #
    # #   CPU    Free Total Jobs      Running Waiting ComputingElement
    # ----------------------------------------------------------------
    #   19440    2089      17760        17351     409 arc-ce01.gridpp.rl.ac.uk:2811/nordugrid-Condor-grid3000M
    #    3240       0       1594         1250     344 carceri.hec.lancs.ac.uk:8443/cream-sge-grid
    #    1176      30       1007          587     420 ce01.tier2.hep.manchester.ac.uk:8443/cream-pbs-long
    #
    # Select the CREAM CEs (URL path starts with '/cream') and how many free slots they have
    ces = re.findall(
        r'^\s*\d+\s*(?P<free>\d+)\s*\d+\s*\d+\s*\d+\s*(?P<ce>[^:/\s]+uk:\d+/cream.*)$',
        stdout, re.MULTILINE)
    # Grab the one with the most empty slots
    ce = sorted(ces)[-1][1]

    j = Job()
    j.backend = CREAM(CE=ce)
    j.submit()
    j.kill()
示例#2
0
def test_job_kill(gpi):
    from Ganga.GPI import Job, LCG

    j = Job()
    j.backend = LCG()
    j.submit()
    j.kill()
示例#3
0
def test_submit_kill_resubmit(gpi):
    """
    Test that a simple submit-kill-resubmit-kill cycle works
    """

    from Ganga.GPI import Job, LCG
    j = Job()
    j.backend = LCG()

    with patch('Ganga.Lib.LCG.Grid.submit',
               return_value='https://example.com:9000/42') as submit:
        j.submit()
        submit.assert_called_once()
        assert j.backend.id == 'https://example.com:9000/42'

    with patch('Ganga.Lib.LCG.Grid.cancel', return_value=True) as cancel:
        j.kill()
        cancel.assert_called_once()
        assert j.status == 'killed'

    with patch('Ganga.Lib.LCG.Grid.submit',
               return_value='https://example.com:9000/43') as submit:
        j.resubmit()
        submit.assert_called_once()
        assert j.backend.id == 'https://example.com:9000/43'

    with patch('Ganga.Lib.LCG.Grid.cancel', return_value=True):
        j.kill()
示例#4
0
def test_job_kill(gpi):
    from Ganga.GPI import Job, LCG

    j = Job()
    j.backend = LCG()
    j.submit()
    j.kill()
示例#5
0
    def Savannah19123(self):
        from Ganga.GPI import Job, Local

        from GangaTest.Framework.utils import sleep_until_state

        # check if stdout and stderr exists or not, flag indicates if files are required to exist or not

        def check(exists_flag):
            for fn in ['stdout','stderr']:
                fn = os.path.join(j.outputdir,fn)
                file_exists = os.path.exists(fn)
                if exists_flag:
                    self.assertTrue(file_exists, 'file %s should exist but it does not' % fn)
                else:
                    self.assertFalse(file_exists, 'file %s should not exist but it does' % fn)

        j = Job()
        j.application.exe = 'bash'
        j.application.args = ['-c', 'for i in `seq 1 30`; do echo $i; sleep 1; done']
        j.backend = Local()

        j.submit()

        check(False)

        sleep_until_state(j, 5, 'running')

        j.kill()

        check(True)
示例#6
0
文件: TestLCG.py 项目: MannyMoo/ganga
def test_submit_kill_resubmit(gpi):
    """
    Test that a simple submit-kill-resubmit-kill cycle works
    """

    from Ganga.GPI import Job, LCG
    j = Job()
    j.backend = LCG()

    with patch('Ganga.Lib.LCG.Grid.submit', return_value='https://example.com:9000/42') as submit:
        j.submit()
        submit.assert_called_once()
        assert j.backend.id == 'https://example.com:9000/42'

    with patch('Ganga.Lib.LCG.Grid.cancel', return_value=True) as cancel:
        j.kill()
        cancel.assert_called_once()
        assert j.status == 'killed'

    with patch('Ganga.Lib.LCG.Grid.submit', return_value='https://example.com:9000/43') as submit:
        j.resubmit()
        submit.assert_called_once()
        assert j.backend.id == 'https://example.com:9000/43'

    with patch('Ganga.Lib.LCG.Grid.cancel', return_value=True):
        j.kill()
示例#7
0
    def test_Savannah19123(self):
        from Ganga.GPI import Job, Local

        from GangaTest.Framework.utils import sleep_until_state

        # check if stdout and stderr exists or not, flag indicates if files are required to exist or not

        def check(exists_flag):
            for fn in ['stdout', 'stderr']:
                fn = os.path.join(j.outputdir, fn)
                file_exists = os.path.exists(fn)
                if exists_flag:
                    self.assertTrue(
                        file_exists,
                        'file %s should exist but it does not' % fn)
                else:
                    self.assertFalse(
                        file_exists,
                        'file %s should not exist but it does' % fn)

        j = Job()
        j.application.exe = 'bash'
        j.application.args = [
            '-c', 'for i in `seq 1 30`; do echo $i; sleep 1; done'
        ]
        j.backend = Local()

        j.submit()

        check(False)

        if not sleep_until_state(j, 5, 'running'):
            # problem with the test - print out stdout/stderr and assert
            for fn in ['stdout', 'stderr']:
                fn = os.path.join(j.outputdir, fn)
                print " ----  Contents of " + fn
                if os.path.exists(fn):
                    print open(fn).read()
                else:
                    print "NO FILE AVAILABLE"

            self.assertEqual(j.status, 'running')

        j.kill()

        check(True)
    def test_Savannah19123(self):
        from Ganga.GPI import Job, Local

        from GangaTest.Framework.utils import sleep_until_state

        # check if stdout and stderr exists or not, flag indicates if files are required to exist or not

        def check(exists_flag):
            for fn in ['stdout','stderr']:
                fn = os.path.join(j.outputdir,fn)
                file_exists = os.path.exists(fn)
                if exists_flag:
                    self.assertTrue(file_exists, 'file %s should exist but it does not' % fn)
                else:
                    self.assertFalse(file_exists, 'file %s should not exist but it does' % fn)

        j = Job()
        j.application.exe = 'bash'
        j.application.args = ['-c', 'for i in `seq 1 30`; do echo $i; sleep 1; done']
        j.backend = Local()

        j.submit()

        check(False)

        if not sleep_until_state(j, 5, 'running'):
            # problem with the test - print out stdout/stderr and assert
            for fn in ['stdout','stderr']:
                fn = os.path.join(j.outputdir,fn)
                print " ----  Contents of " + fn
                if os.path.exists(fn):
                    print open(fn).read()
                else:
                    print "NO FILE AVAILABLE"

            self.assertEqual(j.status, 'running')

        j.kill()

        check(True)
示例#9
0
def test_submit_monitor(gpi):
    """
    Test that an LCG job can be monitored
    """

    from Ganga.GPI import Job, LCG
    j = Job()
    j.backend = LCG()

    job_id = 'https://example.com:9000/42'

    with patch('Ganga.Lib.LCG.Grid.submit', return_value=job_id) as submit:
        j.submit()
        submit.assert_called_once()
        assert j.backend.id == job_id

    status_info = {
        'status': 'Submitted',
        'name': '',
        'destination': '',
        'reason': '',
        'exit': '',
        'is_node': False,
        'id': job_id
    }

    status_results = [
        ([status_info], []),  # Once for the proper status call
        ([], [])  # Once for the bulk monitoring call
    ]

    with patch('Ganga.Lib.LCG.Grid.status',
               side_effect=status_results) as status:
        stripProxy(j).backend.master_updateMonitoringInformation(
            [stripProxy(j)])
        assert status.call_count == 1

    with patch('Ganga.Lib.LCG.Grid.cancel', return_value=True):
        j.kill()
示例#10
0
    def testKilling(self):
        """
        Create some subjobs and kill them
        """
        from Ganga.GPI import Job, GenericSplitter, Local
        from GangaTest.Framework.utils import sleep_until_state
        j = Job()
        j.application.exe = "sleep"
        j.splitter = GenericSplitter()
        j.splitter.attribute = 'application.args'
        j.splitter.values = [['400'] for _ in range(0, 5)]
        j.backend = Local()
        j.submit()

        sleep_until_state(j, None, 'running')
        assert j.status == 'running'

        j.subjobs(0).kill()
        assert j.subjobs(0).status == 'killed'
        assert j.subjobs(1).status != 'killed'
        j.kill()
        assert j.status == 'killed'
        assert all(sj.status == 'killed' for sj in j.subjobs)
示例#11
0
    def testKilling(self):
        """
        Create some subjobs and kill them
        """
        from Ganga.GPI import Job, GenericSplitter, Local
        from GangaTest.Framework.utils import sleep_until_state
        j = Job()
        j.application.exe = "sleep"
        j.splitter = GenericSplitter()
        j.splitter.attribute = 'application.args'
        j.splitter.values = [['400'] for _ in range(0, 5)]
        j.backend = Local()
        j.submit()

        sleep_until_state(j, None, 'running')
        assert j.status == 'running'

        j.subjobs(0).kill()
        assert j.subjobs(0).status == 'killed'
        assert j.subjobs(1).status != 'killed'
        j.kill()
        assert j.status == 'killed'
        assert all(sj.status == 'killed' for sj in j.subjobs)
示例#12
0
文件: TestLCG.py 项目: MannyMoo/ganga
def test_submit_monitor(gpi):
    """
    Test that an LCG job can be monitored
    """

    from Ganga.GPI import Job, LCG
    j = Job()
    j.backend = LCG()

    job_id = 'https://example.com:9000/42'

    with patch('Ganga.Lib.LCG.Grid.submit', return_value=job_id) as submit:
        j.submit()
        submit.assert_called_once()
        assert j.backend.id == job_id

    status_info = {
        'status': 'Submitted',
        'name': '',
        'destination': '',
        'reason': '',
        'exit': '',
        'is_node': False,
        'id': job_id
    }

    status_results = [
        ([status_info], []),  # Once for the proper status call
        ([], [])  # Once for the bulk monitoring call
    ]

    with patch('Ganga.Lib.LCG.Grid.status', side_effect=status_results) as status:
        stripProxy(j).backend.master_updateMonitoringInformation([stripProxy(j)])
        assert status.call_count == 2

    with patch('Ganga.Lib.LCG.Grid.cancel', return_value=True):
        j.kill()
示例#13
0
def test_job_kill(gpi):
    from Ganga.GPI import Job, CREAM

    vo = getConfig("LCG")["VirtualOrganisation"]
    call = subprocess.Popen(["lcg-infosites", "ce", "cream", "--vo", vo], stdout=subprocess.PIPE)
    stdout, stderr = call.communicate()

    # Based on output of:
    #
    # #   CPU    Free Total Jobs      Running Waiting ComputingElement
    # ----------------------------------------------------------------
    #   19440    2089      17760        17351     409 arc-ce01.gridpp.rl.ac.uk:2811/nordugrid-Condor-grid3000M
    #    3240       0       1594         1250     344 carceri.hec.lancs.ac.uk:8443/cream-sge-grid
    #    1176      30       1007          587     420 ce01.tier2.hep.manchester.ac.uk:8443/cream-pbs-long
    #
    # Select the CREAM CEs (URL path starts with '/cream') and how many free slots they have
    ces = re.findall(r"^\s*\d+\s*(?P<free>\d+)\s*\d+\s*\d+\s*\d+\s*(?P<ce>[^:/\s]+:\d+/cream.*)$", stdout, re.MULTILINE)
    # Grab the one with the most empty slots
    ce = sorted(ces)[-1][1]

    j = Job()
    j.backend = CREAM(CE=ce)
    j.submit()
    j.kill()
示例#14
0
    def Savannah19123(self):
        from Ganga.GPI import Job, Local

        from GangaTest.Framework.utils import sleep_until_state

        # check if stdout and stderr exists or not, flag indicates if files are required to exist or not

        def check(exists_flag):
            for fn in ['stdout', 'stderr']:
                fn = os.path.join(j.outputdir, fn)
                file_exists = os.path.exists(fn)
                if exists_flag:
                    self.assertTrue(
                        file_exists,
                        'file %s should exist but it does not' % fn)
                else:
                    self.assertFalse(
                        file_exists,
                        'file %s should not exist but it does' % fn)

        j = Job()
        j.application.exe = 'bash'
        j.application.args = [
            '-c', 'for i in `seq 1 30`; do echo $i; sleep 1; done'
        ]
        j.backend = Local()

        j.submit()

        check(False)

        sleep_until_state(j, 5, 'running')

        j.kill()

        check(True)