예제 #1
0
 def test_get_none(self):
     prov = stub.StubJobProvider()
     job_suc = {'job-id': 'job_suc', 'status': ('SUCCESS', '123')}
     job_fail = {'job-id': 'job_fail', 'status': ('FAILURE', '123')}
     prov.set_operations([job_suc, job_fail])
     tasks = prov.lookup_job_tasks(None)
     self.assertEqual(tasks, [job_suc, job_fail])
예제 #2
0
파일: test_dsub.py 프로젝트: otiai10/dsub
 def test_earliest_failure(self):
   prov = stub.StubJobProvider()
   ops = [{
       'job-id': 'job-1',
       'task-id': 'task-1',
       'end-time': 1,
       'status': ('SUCCESS', '1')
   }, {
       'job-id': 'job-1',
       'task-id': 'task-2',
       'end-time': 3,
       'status': ('FAILURE', '1')
   }, {
       'job-id': 'job-1',
       'task-id': 'task-3',
       'end-time': 2,
       'status': ('FAILURE', '1')
   }, {
       'job-id': 'job-1',
       'task-id': 'task-4',
       'end-time': 4,
       'status': ('FAILURE', '1')
   }, {
       'job-id': 'job-1',
       'task-id': 'task-5',
       'end-time': 5,
       'status': ('SUCCESS', '1')
   }]
   ret = dsub_command.dominant_task_for_jobs(prov, ops)
   self.assertEqual(ret[0]['task-id'], 'task-3')
예제 #3
0
def get_provider(provider_type, project_id=None, auth_token=None):
    """Construct the dsub provider for the given parameters.

        Args:
            provider_type: A string indicating google, local, or stub provider
            project_id: A string representing a Google Cloud Project ID
            auth_token: oauth2 token for authorizing Genomics API requests in
                dsub

        Returns:
            JobProvider: Instance of LocalJobProvider, GoogleJobProvider, or
                StubJobProvider.
    """
    if provider_type == ProviderType.GOOGLE:
        return _get_google_provider(project_id, auth_token)
    elif project_id or auth_token:
        raise BadRequest(
            'The Local provider does not support the `{}` field .'.format(
                'authToken' if auth_token else 'parentId'))
    elif provider_type == ProviderType.LOCAL:
        # TODO(https://github.com/googlegenomics/dsub/issues/93): Remove
        # resources parameter and import
        return local.LocalJobProvider(resources)
    elif provider_type == ProviderType.STUB:
        return stub.StubJobProvider()
예제 #4
0
 def test_get_several(self):
     prov = stub.StubJobProvider()
     job_suc = {'job-id': 'job_suc', 'status': ('SUCCESS', '123')}
     job_fail = {'job-id': 'job_fail', 'status': ('FAILURE', '123')}
     job_run = {'job-id': 'job_run', 'status': ('RUNNING', '123')}
     prov.set_operations([job_suc, job_fail, job_run])
     tasks = prov.lookup_job_tasks(['SUCCESS', 'FAILURE'])
     self.assertEqual(tasks, [job_suc, job_fail])
예제 #5
0
 def test_job_not_found(self):
     prov = stub.StubJobProvider()
     prov.set_operations([{
         'job-id': 'myjob',
         'status': ('SUCCESS', '123')
     }])
     establish_chronology(nothing_happens())
     ret = dsub_command.wait_after(prov, ['some_other_job'], 1, True)
     self.assertTrue(ret)
예제 #6
0
 def test_already_succeeded(self):
     prov = stub.StubJobProvider()
     prov.set_operations([{
         'job-id': 'myjob',
         'status': ('SUCCESS', '123')
     }])
     establish_chronology(nothing_happens())
     ret = dsub_command.wait_after(prov, ['myjob'], 1, True)
     self.assertEqual(ret, [])
예제 #7
0
 def test_already_succeeded(self):
   prov = stub.StubJobProvider()
   prov.set_operations([{
       'job-id': 'myjob',
       'status': 'SUCCESS',
       'status-message': '',
       'task-id': ''
   }])
   establish_chronology(nothing_happens())
   ret = dsub_command._wait_for_any_job(prov, {'myjob'}, 1, False)
   self.assertEqual(ret, set())
예제 #8
0
 def test_multiple_jobs(self):
   self.prov = stub.StubJobProvider()
   establish_chronology(self.progressive_chronology())
   ret = dsub_command._wait_for_any_job(self.prov, {'job-1', 'job-2'}, 1)
   self.assertEqual(ret, {'job-2'})
예제 #9
0
 def test_succeeds(self):
   self.prov = stub.StubJobProvider()
   establish_chronology(self.progressive_chronology())
   ret = dsub_command._wait_for_any_job(self.prov, {'job-1'}, 1)
   self.assertEqual(ret, set())
예제 #10
0
 def test_job_2(self):
   self.prov = stub.StubJobProvider()
   establish_chronology(self.fail_in_sequence())
   ret = dsub_command._wait_after(self.prov, ['job-1'], 1, True)
   self.assertEqual(ret, [['failed to frob']])
예제 #11
0
 def test_job_1(self):
   self.prov = stub.StubJobProvider()
   establish_chronology(self.progressive_chronology())
   ret = dsub_command._wait_after(self.prov, ['job-1'], 1, True)
   self.assertEqual(ret, [])
예제 #12
0
 def setUp(self):
     super(TestWaitAndRetry, self).setUp()
     self.provider = stub.StubJobProvider()
예제 #13
0
파일: test_dsub.py 프로젝트: otiai10/dsub
 def test_fails(self):
   self.prov = stub.StubJobProvider()
   establish_chronology(self.progressive_chronology())
   ret = dsub_command.wait_for_any_job(self.prov, ['job-2'], 1)
   self.assertEqual(ret, set([]))
예제 #14
0
파일: test_dsub.py 프로젝트: otiai10/dsub
 def test_job_2(self):
   self.prov = stub.StubJobProvider()
   establish_chronology(self.progressive_chronology())
   ret = dsub_command.wait_after(self.prov, ['job-2'], 1, True)
   self.assertEqual(ret, [['failed to frob']])