@@ -114,33 +114,48 @@ def test_read_jobs(self):
114114 job .refresh ()
115115 self .check_job (job )
116116
117- @unittest .skipUnless (testlib .has_app_collection , "Test requires sdk-app-collection." )
118117class TestJobWithDelayedDone (testlib .SDKTestCase ):
119118 def setUp (self ):
120119 super (TestJobWithDelayedDone , self ).setUp ()
120+ self .job = None
121+
122+ def tearDown (self ):
123+ super (TestJobWithDelayedDone , self ).tearDown ()
124+ if self .job is not None :
125+ self .job .cancel ()
126+ self .assertEventuallyTrue (lambda : self .job .sid not in self .service .jobs )
127+
128+ def test_enable_preview (self ):
129+ if not self .app_collection_installed ():
130+ print "Test requires sdk-app-collection. Skipping."
131+ return
121132 self .install_app_from_collection ("sleep_command" )
122- self .query = "search index=_internal | sleep done= 100"
133+ self .query = "search index=_internal | sleep 100"
123134 self .job = self .service .jobs .create (
124135 query = self .query ,
125136 earliest_time = "-1m" ,
126137 priority = 5 ,
127138 latest_time = "now" )
128-
129- def tearDown (self ):
130- super (TestJobWithDelayedDone , self ).tearDown ()
131- self .job .cancel ()
132- self .assertEventuallyTrue (lambda : self .job .sid not in self .service .jobs )
133-
134- def test_enable_preview (self ):
135139 self .assertEqual (self .job ['isPreviewEnabled' ], '0' )
136140 self .job .enable_preview ()
137141 def is_preview ():
142+ self .job .refresh ()
138143 if self .job .is_done ():
139144 self .fail ('Job finished before preview enabled.' )
140145 return self .job ['isPreviewEnabled' ] == '1'
141146 self .assertEventuallyTrue (is_preview )
142147
143148 def test_setpriority (self ):
149+ if not self .app_collection_installed ():
150+ print "Test requires sdk-app-collection. Skipping."
151+ return
152+ self .install_app_from_collection ("sleep_command" )
153+ self .query = "search index=_internal | sleep 100"
154+ self .job = self .service .jobs .create (
155+ query = self .query ,
156+ earliest_time = "-1m" ,
157+ priority = 5 ,
158+ latest_time = "now" )
144159 # Note that you can only *decrease* the priority (i.e., 5 decreased to 3)
145160 # of a job unless Splunk is running as root. This is because Splunk jobs
146161 # are tied up with operating system processes and their priorities.
@@ -232,7 +247,7 @@ def test_touch(self):
232247 # This cannot be tested very fast. touch will reset the ttl to the original value for the job,
233248 # so first we have to wait just long enough for the ttl to tick down. Its granularity is 1s,
234249 # so we'll wait 1.1s before we start.
235- import time ; time .sleep (1.1 )
250+ import time ; time .sleep (2 )
236251 old_ttl = int (self .job ['ttl' ])
237252 self .job .touch ()
238253 self .job .refresh ()
0 commit comments