Class: AntiSmoker::MsgpackRpcTest

Inherits:
AbstractSmokeTest
  • Object
show all
Includes:
MsgpackRpcModule
Defined in:
lib/antismoker/tests/msgpack-rpc.rb

Constant Summary

Constants included from MsgpackRpcModule

AntiSmoker::MsgpackRpcModule::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, options = {}) ⇒ MsgpackRpcTest

Returns a new instance of MsgpackRpcTest.


11
12
13
14
# File 'lib/antismoker/tests/msgpack-rpc.rb', line 11

def initialize(host, port, options={})
  super
  @message = options.fetch(:message, [:ping])
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message


15
16
17
# File 'lib/antismoker/tests/msgpack-rpc.rb', line 15

def message
  @message
end

Instance Method Details

#response_ok(response) ⇒ Object


30
31
32
# File 'lib/antismoker/tests/msgpack-rpc.rb', line 30

def response_ok(response)
  response
end

#run_once_with_timeout(options = {}) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/antismoker/tests/msgpack-rpc.rb', line 17

def run_once_with_timeout(options={})
  client = MessagePack::RPC::Client.new(host, port)
  client.timeout = timeout
  response = client.call(*message)
  response_ok(response)
rescue MessagePack::RPC::ConnectionTimeoutError => error
  logger.debug("timed out: #{self}: #{error}")
  false
rescue => error
  logger.warn("unknown error: #{self}: #{error}")
  false
end

#to_sObject


34
35
36
# File 'lib/antismoker/tests/msgpack-rpc.rb', line 34

def to_s
  "msgpack-rpc://#{host}:#{port}"
end