-
Notifications
You must be signed in to change notification settings - Fork 594
/
node_stats_test.rb
65 lines (51 loc) · 2.15 KB
/
node_stats_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'test_helper'
module Elasticsearch
module Test
class ClusterNodeStatsTest < ::Test::Unit::TestCase
context "Cluster: Node stats" do
subject { FakeClient.new }
should "perform correct request" do
subject.expects(:perform_request).with do |method, url, params, body|
assert_equal 'GET', method
assert_equal '_nodes/stats', url
assert_equal Hash.new, params
assert_nil body
true
end.returns(FakeResponse.new)
subject.cluster.node_stats
end
should "send :node_id correctly" do
subject.expects(:perform_request).with do |method, url, params, body|
assert_equal '_nodes/foo/stats', url
true
end.returns(FakeResponse.new)
subject.cluster.node_stats :node_id => 'foo'
end
should "get specific metric families" do
subject.expects(:perform_request).with do |method, url, params, body|
assert_equal '_nodes/stats/http,fs', url
assert_equal( {}, params )
true
end.returns(FakeResponse.new)
subject.cluster.node_stats :metric => [:http, :fs]
end
should "get specific metric for the indices family" do
subject.expects(:perform_request).with do |method, url, params, body|
assert_equal '_nodes/stats/indices/filter_cache', url
true
end.returns(FakeResponse.new)
subject.cluster.node_stats :metric => :indices, :index_metric => 'filter_cache'
end
should "get fielddata statistics for the indices family" do
subject.expects(:perform_request).with do |method, url, params, body|
assert_equal '_nodes/stats/indices/fielddata', url
assert_equal( {:fields => 'foo,bar'}, params )
true
end.returns(FakeResponse.new).twice
subject.cluster.node_stats :metric => 'indices', :index_metric => 'fielddata', :fields => 'foo,bar'
subject.cluster.node_stats :metric => 'indices', :index_metric => 'fielddata', :fields => ['foo','bar']
end
end
end
end
end