Sha256: 42bca350543eae1c3da57f89e8a4550cdc88968865e2f0efb61c8dad211532a6

Contents?: true

Size: 1.42 KB

Versions: 7

Compression:

Stored size: 1.42 KB

Contents

require_relative "test_helper"
require "splunk-sdk-ruby"

include Splunk

class TestRestarts < TestCaseWithSplunkConnection
  def test_restart_with_long_timeout
    service = Context.new(@splunkrc).login()
    begin
      service.restart(2000)
    rescue TimeoutError
      while !service.server_accepting_connections? ||
          service.server_requires_restart?
        sleep(0.3)
      end
      if !service.server_accepting_connections?
        fail("Did not restart within timeout.")
      end
    end

    assert_logged_in(service)
  end

  def test_restart_with_short_timeout
    service = Context.new(@splunkrc).login()
    begin
      service.restart(0.1)
    rescue TimeoutError
      # Wait for it to go down
      while service.server_accepting_connections? &&
          service.server_requires_restart?
        sleep(0.1)
      end

      # Wait for it to come back up
      while !service.server_accepting_connections? ||
          service.server_requires_restart?
        sleep(0.3)
      end
      assert_logged_in(service)
    else
      fail("Somehow Splunk managed to restart in 100ms...")
    end
  end

  def test_restart_with_no_timeout
    service = Context.new(@splunkrc).login()
    service.restart()

    assert_not_logged_in(service)

    # Wait for it to come back up
    while !service.server_accepting_connections? ||
        service.server_requires_restart?
      sleep(0.3)
    end
    assert_logged_in(service)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
splunk-sdk-ruby-1.0.5 test/test_restarts.rb
splunk-sdk-ruby-1.0.4 test/test_restarts.rb
splunk-sdk-ruby-1.0.3 test/test_restarts.rb
splunk-sdk-ruby-1.0.2 test/test_restarts.rb
splunk-sdk-ruby-1.0.1 test/test_restarts.rb
splunk-sdk-ruby-1.0.0 test/test_restarts.rb
splunk-sdk-ruby-0.8.1 test/test_restarts.rb