elasticsearch-api 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +160 -0
- data/Rakefile +62 -0
- data/elasticsearch-api.gemspec +51 -0
- data/lib/elasticsearch-api +1 -0
- data/lib/elasticsearch/api.rb +23 -0
- data/lib/elasticsearch/api/actions/bulk.rb +71 -0
- data/lib/elasticsearch/api/actions/cluster/get_settings.rb +21 -0
- data/lib/elasticsearch/api/actions/cluster/health.rb +50 -0
- data/lib/elasticsearch/api/actions/cluster/node_hot_threads.rb +46 -0
- data/lib/elasticsearch/api/actions/cluster/node_info.rb +59 -0
- data/lib/elasticsearch/api/actions/cluster/node_shutdown.rb +36 -0
- data/lib/elasticsearch/api/actions/cluster/node_stats.rb +77 -0
- data/lib/elasticsearch/api/actions/cluster/put_settings.rb +28 -0
- data/lib/elasticsearch/api/actions/cluster/reroute.rb +44 -0
- data/lib/elasticsearch/api/actions/cluster/state.rb +47 -0
- data/lib/elasticsearch/api/actions/count.rb +46 -0
- data/lib/elasticsearch/api/actions/create.rb +34 -0
- data/lib/elasticsearch/api/actions/delete.rb +61 -0
- data/lib/elasticsearch/api/actions/delete_by_query.rb +62 -0
- data/lib/elasticsearch/api/actions/exists.rb +51 -0
- data/lib/elasticsearch/api/actions/explain.rb +71 -0
- data/lib/elasticsearch/api/actions/get.rb +59 -0
- data/lib/elasticsearch/api/actions/get_source.rb +59 -0
- data/lib/elasticsearch/api/actions/index.rb +81 -0
- data/lib/elasticsearch/api/actions/indices/analyze.rb +63 -0
- data/lib/elasticsearch/api/actions/indices/clear_cache.rb +69 -0
- data/lib/elasticsearch/api/actions/indices/close.rb +35 -0
- data/lib/elasticsearch/api/actions/indices/create.rb +83 -0
- data/lib/elasticsearch/api/actions/indices/delete.rb +48 -0
- data/lib/elasticsearch/api/actions/indices/delete_alias.rb +37 -0
- data/lib/elasticsearch/api/actions/indices/delete_mapping.rb +26 -0
- data/lib/elasticsearch/api/actions/indices/delete_template.rb +33 -0
- data/lib/elasticsearch/api/actions/indices/delete_warmer.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/exists.rb +35 -0
- data/lib/elasticsearch/api/actions/indices/exists_alias.rb +41 -0
- data/lib/elasticsearch/api/actions/indices/exists_type.rb +39 -0
- data/lib/elasticsearch/api/actions/indices/flush.rb +40 -0
- data/lib/elasticsearch/api/actions/indices/get_alias.rb +41 -0
- data/lib/elasticsearch/api/actions/indices/get_aliases.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/get_mapping.rb +36 -0
- data/lib/elasticsearch/api/actions/indices/get_settings.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/get_template.rb +30 -0
- data/lib/elasticsearch/api/actions/indices/get_warmer.rb +44 -0
- data/lib/elasticsearch/api/actions/indices/open.rb +33 -0
- data/lib/elasticsearch/api/actions/indices/optimize.rb +57 -0
- data/lib/elasticsearch/api/actions/indices/put_alias.rb +43 -0
- data/lib/elasticsearch/api/actions/indices/put_mapping.rb +49 -0
- data/lib/elasticsearch/api/actions/indices/put_settings.rb +45 -0
- data/lib/elasticsearch/api/actions/indices/put_template.rb +40 -0
- data/lib/elasticsearch/api/actions/indices/put_warmer.rb +48 -0
- data/lib/elasticsearch/api/actions/indices/refresh.rb +43 -0
- data/lib/elasticsearch/api/actions/indices/segments.rb +33 -0
- data/lib/elasticsearch/api/actions/indices/snapshot_index.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/stats.rb +96 -0
- data/lib/elasticsearch/api/actions/indices/status.rb +46 -0
- data/lib/elasticsearch/api/actions/indices/update_aliases.rb +49 -0
- data/lib/elasticsearch/api/actions/indices/validate_query.rb +68 -0
- data/lib/elasticsearch/api/actions/info.rb +19 -0
- data/lib/elasticsearch/api/actions/mget.rb +64 -0
- data/lib/elasticsearch/api/actions/mlt.rb +86 -0
- data/lib/elasticsearch/api/actions/msearch.rb +75 -0
- data/lib/elasticsearch/api/actions/percolate.rb +57 -0
- data/lib/elasticsearch/api/actions/ping.rb +29 -0
- data/lib/elasticsearch/api/actions/scroll.rb +44 -0
- data/lib/elasticsearch/api/actions/search.rb +145 -0
- data/lib/elasticsearch/api/actions/suggest.rb +46 -0
- data/lib/elasticsearch/api/actions/update.rb +103 -0
- data/lib/elasticsearch/api/namespace/cluster.rb +20 -0
- data/lib/elasticsearch/api/namespace/common.rb +27 -0
- data/lib/elasticsearch/api/namespace/indices.rb +20 -0
- data/lib/elasticsearch/api/utils.rb +97 -0
- data/lib/elasticsearch/api/version.rb +5 -0
- data/test/integration/yaml_test_runner.rb +330 -0
- data/test/test_helper.rb +52 -0
- data/test/unit/bulk_test.rb +85 -0
- data/test/unit/client_test.rb +31 -0
- data/test/unit/cluster/get_settings_test.rb +26 -0
- data/test/unit/cluster/health_test.rb +38 -0
- data/test/unit/cluster/node_hot_threads_test.rb +35 -0
- data/test/unit/cluster/node_info_test.rb +45 -0
- data/test/unit/cluster/node_shutdown_test.rb +45 -0
- data/test/unit/cluster/node_stats_test.rb +65 -0
- data/test/unit/cluster/put_settings_test.rb +26 -0
- data/test/unit/cluster/reroute_test.rb +38 -0
- data/test/unit/cluster/state_test.rb +37 -0
- data/test/unit/count_test.rb +46 -0
- data/test/unit/create_document_test.rb +38 -0
- data/test/unit/delete_by_query_test.rb +42 -0
- data/test/unit/delete_document_test.rb +62 -0
- data/test/unit/exists_document_test.rb +76 -0
- data/test/unit/explain_document_test.rb +64 -0
- data/test/unit/get_document_source_test.rb +62 -0
- data/test/unit/get_document_test.rb +62 -0
- data/test/unit/hashie_test.rb +78 -0
- data/test/unit/index_document_test.rb +77 -0
- data/test/unit/indices/analyze_test.rb +67 -0
- data/test/unit/indices/clear_cache_test.rb +45 -0
- data/test/unit/indices/close_test.rb +42 -0
- data/test/unit/indices/create_test.rb +42 -0
- data/test/unit/indices/delete_alias_test.rb +38 -0
- data/test/unit/indices/delete_mapping_test.rb +47 -0
- data/test/unit/indices/delete_template_test.rb +26 -0
- data/test/unit/indices/delete_test.rb +45 -0
- data/test/unit/indices/delete_warmer_test.rb +59 -0
- data/test/unit/indices/exists_alias_test.rb +65 -0
- data/test/unit/indices/exists_test.rb +57 -0
- data/test/unit/indices/exists_type_test.rb +59 -0
- data/test/unit/indices/flush_test.rb +45 -0
- data/test/unit/indices/get_alias_test.rb +41 -0
- data/test/unit/indices/get_aliases_test.rb +35 -0
- data/test/unit/indices/get_mapping_test.rb +53 -0
- data/test/unit/indices/get_settings_test.rb +35 -0
- data/test/unit/indices/get_template_test.rb +32 -0
- data/test/unit/indices/get_warmer_test.rb +41 -0
- data/test/unit/indices/open_test.rb +42 -0
- data/test/unit/indices/optimize_test.rb +45 -0
- data/test/unit/indices/put_alias_test.rb +47 -0
- data/test/unit/indices/put_mapping_test.rb +57 -0
- data/test/unit/indices/put_settings_test.rb +50 -0
- data/test/unit/indices/put_template_test.rb +48 -0
- data/test/unit/indices/put_warmer_test.rb +62 -0
- data/test/unit/indices/refresh_test.rb +55 -0
- data/test/unit/indices/segments_test.rb +55 -0
- data/test/unit/indices/snapshot_index_test.rb +55 -0
- data/test/unit/indices/stats_test.rb +76 -0
- data/test/unit/indices/status_test.rb +55 -0
- data/test/unit/indices/update_aliases_test.rb +42 -0
- data/test/unit/indices/validate_query_test.rb +75 -0
- data/test/unit/info_test.rb +26 -0
- data/test/unit/json_builders_test.rb +64 -0
- data/test/unit/mget_test.rb +70 -0
- data/test/unit/mlt_test.rb +80 -0
- data/test/unit/msearch_test.rb +120 -0
- data/test/unit/percolate_test.rb +49 -0
- data/test/unit/ping_test.rb +48 -0
- data/test/unit/scroll_test.rb +26 -0
- data/test/unit/search_test.rb +93 -0
- data/test/unit/suggest_test.rb +55 -0
- data/test/unit/update_document_test.rb +62 -0
- data/test/unit/utils_test.rb +118 -0
- metadata +498 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class ClientTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "API Client" do
|
8
|
+
|
9
|
+
class MyDummyClient
|
10
|
+
include Elasticsearch::API
|
11
|
+
end
|
12
|
+
|
13
|
+
subject { MyDummyClient.new }
|
14
|
+
|
15
|
+
should "have the cluster namespace" do
|
16
|
+
assert_respond_to subject, :cluster
|
17
|
+
end
|
18
|
+
|
19
|
+
should "have the indices namespace" do
|
20
|
+
assert_respond_to subject, :indices
|
21
|
+
end
|
22
|
+
|
23
|
+
should "have API methods" do
|
24
|
+
assert_respond_to subject, :bulk
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class ClusterGetSettingsTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Cluster: Get settings" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'GET', method
|
13
|
+
assert_equal '_cluster/settings', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cluster.get_settings
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class Cluster_Test < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Health" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'GET', method
|
13
|
+
assert_equal '_cluster/health', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cluster.health
|
20
|
+
end
|
21
|
+
|
22
|
+
should "encode URL parameters" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal 'GET', method
|
25
|
+
assert_equal '_cluster/health', url
|
26
|
+
assert_equal({:level => 'indices'}, params)
|
27
|
+
assert_nil body
|
28
|
+
true
|
29
|
+
end.returns(FakeResponse.new)
|
30
|
+
|
31
|
+
subject.cluster.health :level => 'indices'
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class ClusterNodeHotThreadsTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Cluster: Node hot threads" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'GET', method
|
13
|
+
assert_equal '_cluster/nodes/hot_threads', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cluster.node_hot_threads
|
20
|
+
end
|
21
|
+
|
22
|
+
should "send :node_id correctly" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal '_cluster/nodes/foo/hot_threads', url
|
25
|
+
true
|
26
|
+
end.returns(FakeResponse.new)
|
27
|
+
|
28
|
+
subject.cluster.node_hot_threads :node_id => 'foo'
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class ClusterNodeInfoTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Cluster: Node info" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'GET', method
|
13
|
+
assert_equal '_cluster/nodes', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cluster.node_info
|
20
|
+
end
|
21
|
+
|
22
|
+
should "send :node_id correctly" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal '_cluster/nodes/foo', url
|
25
|
+
true
|
26
|
+
end.returns(FakeResponse.new)
|
27
|
+
|
28
|
+
subject.cluster.node_info :node_id => 'foo'
|
29
|
+
end
|
30
|
+
|
31
|
+
should "send multiple :node_id-s correctly" do
|
32
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
33
|
+
assert_equal '_cluster/nodes/A,B,C', url
|
34
|
+
true
|
35
|
+
end.returns(FakeResponse.new).twice
|
36
|
+
|
37
|
+
subject.cluster.node_info :node_id => 'A,B,C'
|
38
|
+
subject.cluster.node_info :node_id => ['A', 'B', 'C']
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class ClusterNodeShutdownTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Cluster: Node shutdown" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'POST', method
|
13
|
+
assert_equal '_cluster/nodes/_shutdown', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cluster.node_shutdown
|
20
|
+
end
|
21
|
+
|
22
|
+
should "send :node_id correctly" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal '_cluster/nodes/foo/_shutdown', url
|
25
|
+
true
|
26
|
+
end.returns(FakeResponse.new)
|
27
|
+
|
28
|
+
subject.cluster.node_shutdown :node_id => 'foo'
|
29
|
+
end
|
30
|
+
|
31
|
+
should "send multiple :node_id-s correctly" do
|
32
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
33
|
+
assert_equal '_cluster/nodes/A,B,C/_shutdown', url
|
34
|
+
true
|
35
|
+
end.returns(FakeResponse.new).twice
|
36
|
+
|
37
|
+
subject.cluster.node_shutdown :node_id => 'A,B,C'
|
38
|
+
subject.cluster.node_shutdown :node_id => ['A', 'B', 'C']
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class ClusterNodeStatsTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Cluster: Node stats" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'GET', method
|
13
|
+
assert_equal '_nodes/stats', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cluster.node_stats
|
20
|
+
end
|
21
|
+
|
22
|
+
should "send :node_id correctly" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal '_nodes/foo/stats', url
|
25
|
+
true
|
26
|
+
end.returns(FakeResponse.new)
|
27
|
+
|
28
|
+
subject.cluster.node_stats :node_id => 'foo'
|
29
|
+
end
|
30
|
+
|
31
|
+
should "get specific metric families" do
|
32
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
33
|
+
assert_equal '_nodes/stats', url
|
34
|
+
assert_equal( {:http => true, :fs => true}, params )
|
35
|
+
true
|
36
|
+
end.returns(FakeResponse.new)
|
37
|
+
|
38
|
+
subject.cluster.node_stats :http => true, :fs => true
|
39
|
+
end
|
40
|
+
|
41
|
+
should "get specific metric for the indices family" do
|
42
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
43
|
+
assert_equal '_nodes/stats/indices/filter_cache', url
|
44
|
+
true
|
45
|
+
end.returns(FakeResponse.new)
|
46
|
+
|
47
|
+
subject.cluster.node_stats :indices => true, :metric => 'filter_cache'
|
48
|
+
end
|
49
|
+
|
50
|
+
should "get fielddata statistics for the indices family" do
|
51
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
52
|
+
assert_equal '_nodes/stats/indices/fielddata', url
|
53
|
+
assert_equal( {:fields => 'foo,bar'}, params )
|
54
|
+
true
|
55
|
+
end.returns(FakeResponse.new).twice
|
56
|
+
|
57
|
+
subject.cluster.node_stats :indices => true, :metric => 'fielddata', :fields => 'foo,bar'
|
58
|
+
subject.cluster.node_stats :indices => true, :metric => 'fielddata', :fields => ['foo','bar']
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class ClusterPutSettingsTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Cluster: Put settings" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'PUT', method
|
13
|
+
assert_equal '_cluster/settings', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_equal Hash.new, body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cluster.put_settings
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class ClusterRerouteTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Cluster: Reroute" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'POST', method
|
13
|
+
assert_equal '_cluster/reroute', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_equal Hash.new, body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cluster.reroute
|
20
|
+
end
|
21
|
+
|
22
|
+
should "send the body" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal 'POST', method
|
25
|
+
assert_equal '_cluster/reroute', url
|
26
|
+
assert_equal Hash.new, params
|
27
|
+
assert_equal({:commands => [ :move => { :index => 'myindex', :shard => 0 } ]}, body)
|
28
|
+
true
|
29
|
+
end.returns(FakeResponse.new)
|
30
|
+
|
31
|
+
subject.cluster.reroute :body => { :commands => [ :move => { :index => 'myindex', :shard => 0 } ] }
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class ClusterStateTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Cluster: State" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'GET', method
|
13
|
+
assert_equal '_cluster/state', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.cluster.state
|
20
|
+
end
|
21
|
+
|
22
|
+
should "send the API parameters" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal 'GET', method
|
25
|
+
assert_equal '_cluster/state', url
|
26
|
+
assert_equal({:filter_blocks => true}, params)
|
27
|
+
true
|
28
|
+
end.returns(FakeResponse.new)
|
29
|
+
|
30
|
+
subject.cluster.state :filter_blocks => true
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Elasticsearch
|
4
|
+
module Test
|
5
|
+
class CountTest < ::Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Count" do
|
8
|
+
subject { FakeClient.new }
|
9
|
+
|
10
|
+
should "perform correct request" do
|
11
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
12
|
+
assert_equal 'GET', method
|
13
|
+
assert_equal '_count', url
|
14
|
+
assert_equal Hash.new, params
|
15
|
+
assert_nil body
|
16
|
+
true
|
17
|
+
end.returns(FakeResponse.new)
|
18
|
+
|
19
|
+
subject.count
|
20
|
+
end
|
21
|
+
|
22
|
+
should "encode indices and types" do
|
23
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
24
|
+
assert_equal 'GET', method
|
25
|
+
assert_equal 'foo,bar/t1,t2/_count', url
|
26
|
+
true
|
27
|
+
end.returns(FakeResponse.new)
|
28
|
+
|
29
|
+
subject.count :index => ['foo','bar'], :type => ['t1','t2']
|
30
|
+
end
|
31
|
+
|
32
|
+
should "take the query" do
|
33
|
+
subject.expects(:perform_request).with do |method, url, params, body|
|
34
|
+
assert_equal 'GET', method
|
35
|
+
assert_equal( {:query => {:match => {:foo => 'bar'}}}, body)
|
36
|
+
true
|
37
|
+
end.returns(FakeResponse.new)
|
38
|
+
|
39
|
+
subject.count :body => { :query => { :match => { :foo => 'bar' } } }
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|