Skip to content

Commit 594929e

Browse files
author
David Noble
committed
Resolves test_job.TestJobWithDelayedDone.test_setpriority test failure
1 parent 43f7ba8 commit 594929e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/test_job.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,9 @@ def test_setpriority(self):
215215
if not self.app_collection_installed():
216216
print "Test requires sdk-app-collection. Skipping."
217217
return
218+
sleep_duration = 10
218219
self.install_app_from_collection("sleep_command")
219-
self.query = "search index=_internal | sleep 100"
220+
self.query = "search index=_internal | sleep %s" % sleep_duration
220221
self.job = self.service.jobs.create(
221222
query=self.query,
222223
earliest_time="-1m",
@@ -226,18 +227,21 @@ def test_setpriority(self):
226227
# Note that you can only *decrease* the priority (i.e., 5 decreased to 3)
227228
# of a job unless Splunk is running as root. This is because Splunk jobs
228229
# are tied up with operating system processes and their priorities.
229-
self.assertEqual(5, int(self.job['priority']))
230-
231230
new_priority = 3
232231
self.job.set_priority(new_priority)
233232

233+
while not self.job.is_ready():
234+
pass
235+
236+
self.assertEqual(5, int(self.job.content['priority']))
237+
234238
def f():
235239
if self.job.is_done():
236240
self.fail("Job already done before priority was set.")
237-
self.job.refresh()
238-
return int(self.job['priority']) == new_priority
241+
print self.job.content['dispatchState']
242+
return int(self.job.content['priority']) == new_priority
239243

240-
self.assertEventuallyTrue(f, timeout=120)
244+
self.assertEventuallyTrue(f, timeout=sleep_duration + 5)
241245

242246

243247
class TestJob(testlib.SDKTestCase):

0 commit comments

Comments
 (0)