Class: AntiSmoker::MemcacheTest
- Inherits:
-
AbstractSmokeTest
- Object
- AbstractSmokeTest
- AntiSmoker::MemcacheTest
show all
- Includes:
- MemcacheModule
- Defined in:
- lib/antismoker/tests/memcache.rb
Constant Summary
AntiSmoker::MemcacheModule::VERSION
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(host, port, options = {}) ⇒ MemcacheTest
Returns a new instance of MemcacheTest.
11
12
13
14
|
# File 'lib/antismoker/tests/memcache.rb', line 11
def initialize(host, port, options={})
super
@command = options.fetch(:command, :stats)
end
|
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
15
16
17
|
# File 'lib/antismoker/tests/memcache.rb', line 15
def command
@command
end
|
Instance Method Details
#response_ok(response) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/antismoker/tests/memcache.rb', line 26
def response_ok(response)
server_response = response.fetch(server_string, {})
if Enumerable === server_response
not server_response.empty?
else
server_response
end
end
|
#run_once(options = {}) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/antismoker/tests/memcache.rb', line 17
def run_once(options={})
client = Memcache.new(:server => server_string, :strict_reads => true)
response = client.__send__(command)
response_ok(response)
rescue => error
logger.warn("unknown error: #{self}: #{error}")
false
end
|
#server_string ⇒ Object
35
36
37
|
# File 'lib/antismoker/tests/memcache.rb', line 35
def server_string
"#{host}:#{port}"
end
|
#to_s ⇒ Object
39
40
41
|
# File 'lib/antismoker/tests/memcache.rb', line 39
def to_s
"memcache://#{host}:#{port}"
end
|