class RealTimeJobTestCase

Public Instance Methods

setup() click to toggle source
Calls superclass method TestCaseWithSplunkConnection#setup
# File test/test_jobs.rb, line 367
def setup
  super
  query = "search index=_internal"
  @job = @service.jobs.create(query,
                              :earliest_time => "rt-1d",
                              :latest_time => "rt",
                              :priority => 5)
  while !@job.is_ready?
    sleep(0.2)
  end
end
teardown() click to toggle source
Calls superclass method TestCaseWithSplunkConnection#teardown
# File test/test_jobs.rb, line 379
def teardown
  if @job
    @job.cancel()
    assert_eventually_true() do
      !@service.jobs.has_key?(@job.sid)
    end
  end

  super
end
test_get_preview() click to toggle source
# File test/test_jobs.rb, line 402
def test_get_preview
  assert_equal("1", @job["isPreviewEnabled"])
  assert_eventually_true do
    response = @job.preview()
    results = Splunk::ResultsReader.new(response)
    results.is_preview?
  end
end
test_pause_unpause_finalize() click to toggle source
# File test/test_jobs.rb, line 411
def test_pause_unpause_finalize
  assert_equal("0", @job["isPaused"])

  @job.pause()
  assert_eventually_true() { @job.refresh()["isPaused"] == "1" }

  @job.unpause()
  assert_eventually_true() { @job.refresh()["isPaused"] == "0" }

  assert_equal("0", @job["isFinalized"])

  @job.finalize()
  assert_eventually_true() { @job.refresh()["isFinalized"] == "1" }
end
test_searchlog() click to toggle source
# File test/test_jobs.rb, line 426
def test_searchlog
  log_stream = @job.searchlog
  assert_false(log_stream.empty?)
end
test_set_priority() click to toggle source
# File test/test_jobs.rb, line 390
def test_set_priority
  assert_equal("5", @job["priority"])
  sleep(1)
  new_priority = 3
  @job.set_priority(new_priority)
  assert_eventually_true(50) do
    @job.refresh()
    fail("Job finished before priority was set.") if @job.is_done?()
    @job["priority"] == "3"
  end
end