module Asshert::Assertions

Public Instance Methods

assert_runit_service_up(hosts, service, msg=nil) click to toggle source
# File lib/asshert/assertions.rb, line 43
def assert_runit_service_up(hosts, service, msg=nil)
  msg ||= "Failed to assert runit service #{service} up. Command `%s' on `%s'"
  command = "sv status /home/protonet/dashboard/shared/services/enabled/#{service}"
  assert_shell(hosts, command, msg)
end
assert_shell(hosts, command, msg=nil) click to toggle source
# File lib/asshert/assertions.rb, line 9
def assert_shell(hosts, command, msg=nil)
  msg ||= "Failed SSH assertion `%s' on `%s'"
  results = Hash.new
  SSHKit::Coordinator.new(hosts).each(in: :sequence) do |host|
    results[host.to_s] = test(command)
  end
  results.each do |host, result|
    assert(result, sprintf(msg, command, host))
  end
end
assert_shell_file_contains(hosts, file, contents, msg=nil) click to toggle source
# File lib/asshert/assertions.rb, line 31
def assert_shell_file_contains(hosts, file, contents, msg=nil)
  msg ||= "Failed to assert #{file} contains #{contents} `%s' on `%s'"
  command = "grep \"#{contents}\" \"#{file}\""
  assert_shell(hosts, command)
end
refute_runit_service_up(hosts, service, msg=nil) click to toggle source
# File lib/asshert/assertions.rb, line 49
def refute_runit_service_up(hosts, service, msg=nil)
  msg ||= "Failed to refute runit service #{service} up. Command `%s' on `%s'"
  command = "sv status /home/protonet/dashboard/shared/services/enabled/#{service}"
  refute_shell(hosts, command, msg)
end
refute_shell(hosts, command, msg=nil) click to toggle source
# File lib/asshert/assertions.rb, line 20
def refute_shell(hosts, command, msg=nil)
  msg ||= "Failed SSH refutation on `%s' on `%s'"
  results = Hash.new
  SSHKit::Coordinator.new(hosts).each(in: :sequence) do |host|
    results[host.to_s] = test(command)
  end
  results.each do |host, result|
    refute(result, sprintf(msg, command, host))
  end
end
refute_shell_file_contains(hosts, file, contents, msg=nil) click to toggle source
# File lib/asshert/assertions.rb, line 37
def refute_shell_file_contains(hosts, file, contents, msg=nil)
  msg ||= "Failed to refute `%s' contains `%s' on `%s'"
  command = "grep \"#{contents}\" \"#{file}\""
  refute_shell(hosts, command)
end