Skip to content

Commit

Permalink
Merge branch 'update_job_ids_schema' of 'https://github.com/mafesan/g…
Browse files Browse the repository at this point in the history
  • Loading branch information
sduenas committed Oct 23, 2019
2 parents 8806a3d + 80a054a commit 5d45e7f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions arthur/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _enqueue_job_task(self, task_id):
del self._tasks_events[task_id]
return

job_id = self._generate_job_id(task_id)
job_id = self._generate_job_id()
job_number = len(task.jobs) + 1
job_args = _build_job_arguments(task)

Expand Down Expand Up @@ -237,8 +237,8 @@ def _determine_queue(task):
return queue_id

@staticmethod
def _generate_job_id(task_id):
job_id = '-'.join(['arthur', str(task_id), str(uuid.uuid4())])
def _generate_job_id():
job_id = str(uuid.uuid4())
return job_id


Expand Down
34 changes: 17 additions & 17 deletions tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ class TestJobResult(unittest.TestCase):
"""Unit tests for JobResult class"""

def test_job_result_init(self):
result = JobResult('arthur-job-1234567890', 8, 'mytask',
result = JobResult('1234567890', 8, 'mytask',
'mock_backend', 'category')

self.assertEqual(result.job_id, 'arthur-job-1234567890')
self.assertEqual(result.job_id, '1234567890')
self.assertEqual(result.job_number, 8)
self.assertEqual(result.task_id, 'mytask')
self.assertEqual(result.backend, 'mock_backend')
Expand All @@ -215,11 +215,11 @@ def test_job_result_init(self):
def test_to_dict(self):
"""Test whether a JobResult object is converted to a dict"""

result = JobResult('arthur-job-1234567890', 8, 'mytask',
result = JobResult('1234567890', 8, 'mytask',
'mock_backend', 'category')

expected = {
'job_id': 'arthur-job-1234567890',
'job_id': '1234567890',
'job_number': 8,
'task_id': 'mytask'
}
Expand All @@ -242,10 +242,10 @@ def tearDown(self):
def test_init(self):
"""Test the initialization of the object"""

job = PercevalJob('arthur-job-1234567890', 8, 'mytask', 'git', 'commit',
job = PercevalJob('1234567890', 8, 'mytask', 'git', 'commit',
self.conn, 'items')

self.assertEqual(job.job_id, 'arthur-job-1234567890')
self.assertEqual(job.job_id, '1234567890')
self.assertEqual(job.job_number, 8)
self.assertEqual(job.task_id, 'mytask')
self.assertEqual(job.backend, 'git')
Expand All @@ -256,7 +256,7 @@ def test_init(self):

result = job.result
self.assertIsInstance(job.result, JobResult)
self.assertEqual(result.job_id, 'arthur-job-1234567890')
self.assertEqual(result.job_id, '1234567890')
self.assertEqual(job.job_number, 8)
self.assertEqual(result.task_id, 'mytask')
self.assertEqual(result.backend, 'git')
Expand All @@ -267,15 +267,15 @@ def test_backend_not_found(self):
"""Test if it raises an exception when a backend is not found"""

with self.assertRaises(NotFoundError) as e:
_ = PercevalJob('arthur-job-1234567890', 8, 'mytask',
_ = PercevalJob('1234567890', 8, 'mytask',
'mock_backend', 'acme-category',
self.conn, 'items')
self.assertEqual(e.exception.element, 'mock_backend')

def test_run(self):
"""Test run method using the Git backend"""

job = PercevalJob('arthur-job-1234567890', 8, 'mytask',
job = PercevalJob('1234567890', 8, 'mytask',
'git', 'commit',
self.conn, 'items')
args = {
Expand All @@ -292,7 +292,7 @@ def test_run(self):
self.assertIsInstance(job.archive_manager, ArchiveManager)
result = job.result
self.assertIsInstance(job.result, JobResult)
self.assertEqual(result.job_id, 'arthur-job-1234567890')
self.assertEqual(result.job_id, '1234567890')
self.assertEqual(result.job_number, 8)
self.assertEqual(result.task_id, 'mytask')
self.assertEqual(result.backend, 'git')
Expand Down Expand Up @@ -324,7 +324,7 @@ def test_run(self):
def test_metadata(self):
"""Check if metadata parameters are correctly set"""

job = PercevalJob('arthur-job-1234567890', 8, 'mytask',
job = PercevalJob('1234567890', 8, 'mytask',
'git', 'commit',
self.conn, 'items')
args = {
Expand All @@ -343,12 +343,12 @@ def test_metadata(self):

for item in items:
self.assertEqual(item['arthur_version'], __version__)
self.assertEqual(item['job_id'], 'arthur-job-1234567890')
self.assertEqual(item['job_id'], '1234567890')

def test_run_not_found_parameters(self):
"""Check if it fails when a required backend parameter is not found"""

job = PercevalJob('arthur-job-1234567890', 8, 'mytask',
job = PercevalJob('1234567890', 8, 'mytask',
'git', 'commit',
self.conn, 'items')
args = {
Expand Down Expand Up @@ -388,7 +388,7 @@ def _test_fetch_from_archive(self):
'fetch_from_archive': False
}

job = PercevalJob('arthur-job-1234567890', 8, 'mytask',
job = PercevalJob('1234567890', 8, 'mytask',
'bugzilla', 'issue',
self.conn, 'items')
job.run(args, archive_args=archive_args)
Expand Down Expand Up @@ -419,7 +419,7 @@ def _test_fetch_from_archive(self):
# Now, we get the bugs from the archive.
# The contents should be the same and there won't be
# any new request to the server
job_archive = PercevalJob('arthur-job-1234567890-bis', 'mytask', 'bugzilla', 'issue',
job_archive = PercevalJob('1234567890-bis', 'mytask', 'bugzilla', 'issue',
self.conn, 'items')

archive_args['fetch_from_archive'] = True
Expand Down Expand Up @@ -450,7 +450,7 @@ def _test_fetch_from_archive(self):
def test_initialize_archive_manager(self):
"""Test if the archive is initialized"""

job = PercevalJob('arthur-job-1234567890', 8, 'mytask',
job = PercevalJob('1234567890', 8, 'mytask',
'git', 'commit',
self.conn, 'items')

Expand All @@ -459,7 +459,7 @@ def test_initialize_archive_manager(self):
def test_invalid_path_for_archive(self):
"""Test whether it raises an exception when the archive path is invalid"""

job = PercevalJob('arthur-job-1234567890', 8, 'mytaks',
job = PercevalJob('1234567890', 8, 'mytaks',
'git', 'commit',
self.conn, 'items')

Expand Down

0 comments on commit 5d45e7f

Please sign in to comment.