Skip to content

Commit 5d788b0

Browse files
author
Shakeel Mohamed
committed
Fix test_touch Job test by checking update time instead of TTL
Needed to expose the updated field to make this possible.
1 parent e14c3fb commit 5d788b0

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

splunklib/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ def _parse_atom_entry(entry):
256256
'links': links,
257257
'access': metadata.access,
258258
'fields': metadata.fields,
259-
'content': content
259+
'content': content,
260+
'updated': entry.get("updated")
260261
})
261262

262263

tests/test_job.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -341,21 +341,19 @@ def test_setttl(self):
341341
self.assertGreater(ttl, old_ttl)
342342

343343
def test_touch(self):
344-
# This cannot be tested very fast. touch will reset the ttl to the
345-
# original value for the job, so first we have to wait just long enough
346-
# for the ttl to tick down. Its granularity is 1s, so we'll wait a
347-
# couple of seconds before we start.
348344
while not self.job.is_done():
349345
pass
350346
sleep(2)
351347
self.job.refresh()
352-
old_ttl = int(self.job['ttl'])
348+
old_updated = self.job.state.updated
353349
self.job.touch()
350+
sleep(2)
354351
self.job.refresh()
355-
new_ttl = int(self.job['ttl'])
356-
if new_ttl == old_ttl:
357-
self.fail("Didn't wait long enough for TTL to change and make touch meaningful.")
358-
self.assertGreater(int(self.job['ttl']), old_ttl)
352+
new_updated = self.job.state.updated
353+
354+
# Touch will increase the updated time
355+
self.assertLess(old_updated, new_updated)
356+
359357

360358
def test_search_invalid_query_as_json(self):
361359
args = {

0 commit comments

Comments
 (0)