Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dmod.scheduler test warnings #487

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions python/lib/scheduler/dmod/test/test_JobImpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_job_id_1_a(self):

self.assertNotEqual(job.job_id, uuid_as_str)

job.job_id = uuid_val
job.set_job_id(uuid_val)

self.assertEqual(job.job_id, uuid_as_str)

Expand All @@ -68,7 +68,7 @@ def test_job_id_1_b(self):
job = self._example_jobs[example_index]
initial_last_updated = job.last_updated

job.job_id = uuid_val
job.set_job_id(uuid_val)

self.assertLess(initial_last_updated, job.last_updated)

Expand All @@ -81,7 +81,7 @@ def test_job_id_1_c(self):

self.assertNotEqual(job.job_id, uuid_as_str)

job.job_id = uuid_as_str
job.set_job_id(uuid_as_str)

self.assertEqual(job.job_id, uuid_as_str)

Expand All @@ -93,7 +93,7 @@ def test_job_id_1_d(self):
job = self._example_jobs[example_index]
initial_last_updated = job.last_updated

job.job_id = uuid_as_str
job.set_job_id(uuid_as_str)

self.assertLess(initial_last_updated, job.last_updated)

Expand Down Expand Up @@ -142,7 +142,7 @@ def test_allocations_1_a(self):
job = self._example_jobs[example_index_job]

self.assertIsNone(job.allocations)
job.allocations = allocations
job.set_allocations(allocations)
self.assertIsNotNone(job.allocations)

# Test that allocation setter works with tuple
Expand All @@ -155,7 +155,7 @@ def test_allocations_1_b(self):
job = self._example_jobs[example_index_job]

self.assertIsNone(job.allocations)
job.allocations = allocations
job.set_allocations(allocations)
self.assertIsNotNone(job.allocations)

# Test that allocation setter works correctly with list
Expand All @@ -166,7 +166,7 @@ def test_allocations_1_c(self):
allocation = self._resource_allocations[example_index_allocation]
allocations = [allocation]
job = self._example_jobs[example_index_job]
job.allocations = allocations
job.set_allocations(allocations)
self.assertEqual(len(allocations), len(job.allocations))
for i in range(len(allocations)):
self.assertEqual(allocations[i], job.allocations[i])
Expand All @@ -179,7 +179,7 @@ def test_allocations_1_d(self):
allocation = self._resource_allocations[example_index_allocation]
allocations = (allocation,)
job = self._example_jobs[example_index_job]
job.allocations = allocations
job.set_allocations(allocations)
self.assertEqual(len(allocations), len(job.allocations))
for i in range(len(allocations)):
self.assertEqual(allocations[i], job.allocations[i])
Expand All @@ -193,7 +193,7 @@ def test_allocations_1_e(self):
allocations = [allocation]
job = self._example_jobs[example_index_job]
initial_last_updated = job.last_updated
job.allocations = allocations
job.set_allocations(allocations)
self.assertLess(initial_last_updated, job.last_updated)

# Test that allocation setter updates last_updated correctly with tuple
Expand All @@ -206,7 +206,7 @@ def test_allocations_1_f(self):
job = self._example_jobs[example_index_job]
initial_last_updated = job.last_updated

job.allocations = allocations
job.set_allocations(allocations)
self.assertLess(initial_last_updated, job.last_updated)

# TODO: add tests for rest of setters that should update last_updated property
Expand Down
4 changes: 2 additions & 2 deletions python/lib/scheduler/dmod/test/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def setUp(self) -> None:
allocation_paradigm='SINGLE_NODE')
ex_job = RequestedJob(sch_req)
alloc = ResourceAllocation('1', 'hostname1', cpu_count, mem_size)
ex_job.allocations = [alloc]
ex_job.set_allocations([alloc])
self._example_jobs.append(ex_job)

# Example 2 - with two node allocated with 4 cpus
Expand Down Expand Up @@ -96,7 +96,7 @@ def setUp(self) -> None:
allocs = []
allocs.append(ResourceAllocation('1', 'hostname1', 2, int(mem_size/2)))
allocs.append(ResourceAllocation('2', 'hostname2', 2, int(mem_size/2)))
ex_job.allocations = allocs
ex_job.set_allocations(allocs)
self._example_jobs.append(ex_job)


Expand Down
18 changes: 9 additions & 9 deletions python/services/monitorservice/dmod/test/test_monitor_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,19 @@ def setUp(self) -> None:
self._connect_metadata_examples.append('{"purpose": "PROMPT", "additional_metadata": false}')
self._connect_metadata_examples.append('{"purpose": "CONNECT", "additional_metadata": true}')

self._jobs[0].status = JobStatus(JobExecPhase.MODEL_EXEC, JobExecStep.AWAITING_ALLOCATION)
self._jobs[1].status = JobStatus(JobExecPhase.MODEL_EXEC, JobExecStep.AWAITING_SCHEDULING)
self._jobs[2].status = JobStatus(JobExecPhase.MODEL_EXEC, JobExecStep.SCHEDULED)
self._jobs[0].set_status(JobStatus(JobExecPhase.MODEL_EXEC, JobExecStep.AWAITING_ALLOCATION))
self._jobs[1].set_status(JobStatus(JobExecPhase.MODEL_EXEC, JobExecStep.AWAITING_SCHEDULING))
self._jobs[2].set_status(JobStatus(JobExecPhase.MODEL_EXEC, JobExecStep.SCHEDULED))

self._services.append(MockMonitorService(MockMonitor(monitored_jobs=self._jobs)))

self._original_statuses = []
for j in self._jobs:
self._original_statuses.append(j.status)

self._jobs[0].status = JobStatus(JobExecPhase.MODEL_EXEC, JobExecStep.AWAITING_SCHEDULING)
self._jobs[1].status = JobStatus(JobExecPhase.MODEL_EXEC, JobExecStep.SCHEDULED)
self._jobs[2].status = JobStatus(JobExecPhase.MODEL_EXEC, JobExecStep.RUNNING)
self._jobs[0].set_status(JobStatus(JobExecPhase.MODEL_EXEC, JobExecStep.AWAITING_SCHEDULING))
self._jobs[1].set_status(JobStatus(JobExecPhase.MODEL_EXEC, JobExecStep.SCHEDULED))
self._jobs[2].set_status(JobStatus(JobExecPhase.MODEL_EXEC, JobExecStep.RUNNING))

self._job_ids = list()
self._jobs_by_id = dict()
Expand Down Expand Up @@ -947,7 +947,7 @@ def test_run_monitor_check_3_a(self):
get_next_one = False
for status in self._generate_all_status_values():
if get_next_one:
job.status = status
job.set_status(status)
break
elif status == original_status:
get_next_one = True
Expand Down Expand Up @@ -978,7 +978,7 @@ def test_run_monitor_check_3_b(self):

for status in self._generate_all_status_values():
if get_next_one:
job.status = status
job.set_status(status)
break
elif status == original_status:
get_next_one = True
Expand All @@ -1004,7 +1004,7 @@ def test_run_monitor_check_3_c(self):
get_next_one = False
for status in self._generate_all_status_values():
if get_next_one:
job.status = status
job.set_status(status)
break
elif status == original_status:
get_next_one = True
Expand Down
Loading