elastomer-client 2.2.0 → 2.3.0
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 +4 -4
- data/.travis.yml +18 -9
- data/CHANGELOG.md +5 -1
- data/README.md +2 -2
- data/docs/notifications.md +0 -4
- data/elastomer-client.gemspec +6 -4
- data/lib/elastomer/client/cluster.rb +28 -61
- data/lib/elastomer/client/docs.rb +0 -27
- data/lib/elastomer/client/index.rb +3 -52
- data/lib/elastomer/client/repository.rb +3 -3
- data/lib/elastomer/client/scroller.rb +1 -2
- data/lib/elastomer/client/snapshot.rb +3 -3
- data/lib/elastomer/middleware/encode_json.rb +8 -1
- data/lib/elastomer/version.rb +1 -1
- data/script/cibuild +6 -2
- data/test/client/bulk_test.rb +28 -6
- data/test/client/cluster_test.rb +28 -32
- data/test/client/docs_test.rb +5 -49
- data/test/client/index_test.rb +15 -83
- data/test/client/nodes_test.rb +18 -20
- data/test/client/percolator_test.rb +1 -1
- data/test/client/repository_test.rb +79 -83
- data/test/client/snapshot_test.rb +91 -91
- data/test/client/template_test.rb +1 -10
- data/test/client_test.rb +1 -7
- data/test/middleware/encode_json_test.rb +12 -4
- data/test/notifications_test.rb +4 -4
- data/test/test_helper.rb +10 -43
- metadata +33 -6
- data/script/test +0 -6
data/test/client/nodes_test.rb
CHANGED
@@ -16,26 +16,24 @@ describe Elastomer::Client::Nodes do
|
|
16
16
|
assert node.key?("indices"), "indices stats are returned"
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
assert !node.key?("indices"), "expected indices stats to be absent"
|
38
|
-
end
|
19
|
+
it "filters node info" do
|
20
|
+
h = $client.nodes.info(:info => "os")
|
21
|
+
node = h["nodes"].values.first
|
22
|
+
assert node.key?("os"), "expected os info to be present"
|
23
|
+
assert !node.key?("jvm"), "expected jvm info to be absent"
|
24
|
+
|
25
|
+
h = $client.nodes.info(:info => %w[jvm process])
|
26
|
+
node = h["nodes"].values.first
|
27
|
+
assert node.key?("jvm"), "expected jvm info to be present"
|
28
|
+
assert node.key?("process"), "expected process info to be present"
|
29
|
+
assert !node.key?("network"), "expected network info to be absent"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "filters node stats" do
|
33
|
+
h = $client.nodes.stats(:stats => "http")
|
34
|
+
node = h["nodes"].values.first
|
35
|
+
assert node.key?("http"), "expected http stats to be present"
|
36
|
+
assert !node.key?("indices"), "expected indices stats to be absent"
|
39
37
|
end
|
40
38
|
|
41
39
|
it "gets the hot threads for the node(s)" do
|
@@ -1,111 +1,107 @@
|
|
1
1
|
require File.expand_path("../../test_helper", __FILE__)
|
2
2
|
|
3
3
|
describe Elastomer::Client::Repository do
|
4
|
+
before do
|
5
|
+
if !run_snapshot_tests?
|
6
|
+
skip "To enable snapshot tests, add a path.repo setting to your elasticsearch.yml file."
|
7
|
+
end
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
if !run_snapshot_tests?
|
9
|
-
skip "To enable snapshot tests, add a path.repo setting to your elasticsearch.yml file."
|
10
|
-
end
|
9
|
+
@name = "elastomer-repository-test"
|
10
|
+
@repo = $client.repository(@name)
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
it "determines if a repo exists" do
|
14
|
+
assert_equal false, @repo.exists?
|
15
|
+
assert_equal false, @repo.exist?
|
16
|
+
with_tmp_repo(@name) do
|
17
|
+
assert_equal true, @repo.exists?
|
14
18
|
end
|
19
|
+
end
|
15
20
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
21
|
+
it "creates repos" do
|
22
|
+
response = create_repo(@name)
|
23
|
+
assert_equal true, response["acknowledged"]
|
24
|
+
delete_repo(@name)
|
25
|
+
end
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
it "cannot create a repo without a name" do
|
28
|
+
lambda {
|
29
|
+
create_repo(nil)
|
30
|
+
}.must_raise ArgumentError
|
31
|
+
end
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
it "gets repos" do
|
34
|
+
with_tmp_repo do |repo|
|
35
|
+
response = repo.get
|
36
|
+
refute_nil response[repo.name]
|
34
37
|
end
|
38
|
+
end
|
35
39
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
40
|
+
it "gets all repos" do
|
41
|
+
with_tmp_repo do |repo|
|
42
|
+
response = $client.repository.get
|
43
|
+
refute_nil response[repo.name]
|
41
44
|
end
|
45
|
+
end
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
47
|
+
it "gets repo status" do
|
48
|
+
with_tmp_repo do |repo|
|
49
|
+
response = repo.status
|
50
|
+
assert_equal [], response["snapshots"]
|
48
51
|
end
|
52
|
+
end
|
49
53
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
54
|
+
it "gets status of all repos" do
|
55
|
+
response = $client.repository.status
|
56
|
+
assert_equal [], response["snapshots"]
|
57
|
+
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
it "updates repos" do
|
60
|
+
with_tmp_repo do |repo|
|
61
|
+
settings = repo.get[repo.name]["settings"]
|
62
|
+
response = repo.update(:type => "fs", :settings => settings.merge("compress" => true))
|
63
|
+
assert_equal true, response["acknowledged"]
|
64
|
+
assert_equal "true", repo.get[repo.name]["settings"]["compress"]
|
60
65
|
end
|
66
|
+
end
|
61
67
|
|
62
|
-
|
63
|
-
|
68
|
+
it "cannot update a repo without a name" do
|
69
|
+
with_tmp_repo do |repo|
|
70
|
+
lambda {
|
64
71
|
settings = repo.get[repo.name]["settings"]
|
65
|
-
|
66
|
-
|
67
|
-
assert_equal "true", repo.get[repo.name]["settings"]["compress"]
|
68
|
-
end
|
72
|
+
$client.repository.update(:type => "fs", :settings => settings.merge("compress" => true))
|
73
|
+
}.must_raise ArgumentError
|
69
74
|
end
|
75
|
+
end
|
70
76
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
}.must_raise ArgumentError
|
77
|
-
end
|
77
|
+
it "deletes repos" do
|
78
|
+
with_tmp_repo do |repo|
|
79
|
+
response = repo.delete
|
80
|
+
assert_equal true, response["acknowledged"]
|
81
|
+
assert_equal false, repo.exists?
|
78
82
|
end
|
83
|
+
end
|
79
84
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
86
|
-
end
|
85
|
+
it "cannot delete a repo without a name" do
|
86
|
+
lambda {
|
87
|
+
$client.repository.delete
|
88
|
+
}.must_raise ArgumentError
|
89
|
+
end
|
87
90
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
91
|
+
it "gets snapshots" do
|
92
|
+
with_tmp_repo do |repo|
|
93
|
+
response = repo.snapshots.get
|
94
|
+
assert_equal [], response["snapshots"]
|
95
|
+
|
96
|
+
create_snapshot(repo, "test-snapshot")
|
97
|
+
response = repo.snapshot.get
|
98
|
+
assert_equal ["test-snapshot"], response["snapshots"].collect { |info| info["snapshot"] }
|
93
99
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
create_snapshot(repo, "test-snapshot")
|
100
|
-
response = repo.snapshot.get
|
101
|
-
assert_equal ["test-snapshot"], response["snapshots"].collect { |info| info["snapshot"] }
|
102
|
-
|
103
|
-
create_snapshot(repo, "test-snapshot2")
|
104
|
-
response = repo.snapshots.get
|
105
|
-
snapshot_names = response["snapshots"].collect { |info| info["snapshot"] }
|
106
|
-
assert_includes snapshot_names, "test-snapshot"
|
107
|
-
assert_includes snapshot_names, "test-snapshot2"
|
108
|
-
end
|
100
|
+
create_snapshot(repo, "test-snapshot2")
|
101
|
+
response = repo.snapshots.get
|
102
|
+
snapshot_names = response["snapshots"].collect { |info| info["snapshot"] }
|
103
|
+
assert_includes snapshot_names, "test-snapshot"
|
104
|
+
assert_includes snapshot_names, "test-snapshot2"
|
109
105
|
end
|
110
106
|
end
|
111
107
|
end
|
@@ -1,125 +1,125 @@
|
|
1
|
-
|
2
1
|
require File.expand_path("../../test_helper", __FILE__)
|
3
2
|
|
4
3
|
describe Elastomer::Client::Snapshot do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
skip "To enable snapshot tests, add a path.repo setting to your elasticsearch.yml file."
|
9
|
-
end
|
4
|
+
before do
|
5
|
+
@index = nil
|
6
|
+
@restored_index = nil
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
@name = "elastomer-test"
|
8
|
+
if !run_snapshot_tests?
|
9
|
+
skip "To enable snapshot tests, add a path.repo setting to your elasticsearch.yml file."
|
14
10
|
end
|
15
11
|
|
16
|
-
|
17
|
-
|
12
|
+
@index_name = "elastomer-snapshot-test-index"
|
13
|
+
@index = $client.index(@index_name)
|
14
|
+
@name = "elastomer-test"
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
@index.delete if @index && @index.exists?
|
19
|
+
end
|
20
|
+
|
21
|
+
it "determines if a snapshot exists" do
|
22
|
+
with_tmp_repo do |repo|
|
23
|
+
snapshot = repo.snapshot(@name)
|
24
|
+
assert_equal false, snapshot.exists?
|
25
|
+
assert_equal false, snapshot.exist?
|
26
|
+
snapshot.create({}, :wait_for_completion => true)
|
27
|
+
assert_equal true, snapshot.exist?
|
18
28
|
end
|
29
|
+
end
|
19
30
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
assert_equal false, snapshot.exist?
|
25
|
-
snapshot.create({}, :wait_for_completion => true)
|
26
|
-
assert_equal true, snapshot.exist?
|
27
|
-
end
|
31
|
+
it "creates snapshots" do
|
32
|
+
with_tmp_repo do |repo|
|
33
|
+
response = repo.snapshot(@name).create({}, :wait_for_completion => true)
|
34
|
+
assert_equal @name, response["snapshot"]["snapshot"]
|
28
35
|
end
|
36
|
+
end
|
29
37
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
it "creates snapshots with options" do
|
39
|
+
@index.create(:number_of_shards => 1, :number_of_replicas => 0)
|
40
|
+
with_tmp_repo do |repo|
|
41
|
+
response = repo.snapshot(@name).create({:indices => [@index_name]}, :wait_for_completion => true)
|
42
|
+
assert_equal [@index_name], response["snapshot"]["indices"]
|
43
|
+
assert_equal 1, response["snapshot"]["shards"]["total"]
|
35
44
|
end
|
45
|
+
end
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
47
|
+
it "gets snapshot info for one and all" do
|
48
|
+
with_tmp_snapshot do |snapshot, repo|
|
49
|
+
response = snapshot.get
|
50
|
+
assert_equal snapshot.name, response["snapshots"][0]["snapshot"]
|
51
|
+
response = repo.snapshots.get
|
52
|
+
assert_equal snapshot.name, response["snapshots"][0]["snapshot"]
|
44
53
|
end
|
54
|
+
end
|
45
55
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
56
|
+
it "gets snapshot status for one and all" do
|
57
|
+
@index.create(:number_of_shards => 1, :number_of_replicas => 0)
|
58
|
+
with_tmp_repo do |repo|
|
59
|
+
repo.snapshot(@name).create({:indices => [@index_name]}, :wait_for_completion => true)
|
60
|
+
response = repo.snapshot(@name).status
|
61
|
+
assert_equal 1, response["snapshots"][0]["shards_stats"]["total"]
|
53
62
|
end
|
63
|
+
end
|
54
64
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
65
|
+
it "gets status of snapshots in progress" do
|
66
|
+
# we can't reliably get status of an in-progress snapshot in tests, so
|
67
|
+
# check for an empty result instead
|
68
|
+
with_tmp_repo do |repo|
|
69
|
+
response = repo.snapshots.status
|
70
|
+
assert_equal [], response["snapshots"]
|
71
|
+
response = $client.snapshot.status
|
72
|
+
assert_equal [], response["snapshots"]
|
62
73
|
end
|
74
|
+
end
|
63
75
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
76
|
+
it "disallows nil repo name with non-nil snapshot name" do
|
77
|
+
assert_raises(ArgumentError) { $client.repository.snapshot("snapshot") }
|
78
|
+
assert_raises(ArgumentError) { $client.snapshot(nil, "snapshot") }
|
79
|
+
end
|
80
|
+
|
81
|
+
it "deletes snapshots" do
|
82
|
+
with_tmp_snapshot do |snapshot|
|
83
|
+
response = snapshot.delete
|
84
|
+
assert_equal true, response["acknowledged"]
|
73
85
|
end
|
86
|
+
end
|
74
87
|
|
75
|
-
|
76
|
-
|
77
|
-
|
88
|
+
it "restores snapshots" do
|
89
|
+
@index.create(:number_of_shards => 1, :number_of_replicas => 0)
|
90
|
+
wait_for_index(@index_name)
|
91
|
+
with_tmp_repo do |repo|
|
92
|
+
snapshot = repo.snapshot(@name)
|
93
|
+
snapshot.create({:indices => [@index_name]}, :wait_for_completion => true)
|
94
|
+
@index.delete
|
95
|
+
response = snapshot.restore({}, :wait_for_completion => true)
|
96
|
+
assert_equal 1, response["snapshot"]["shards"]["total"]
|
78
97
|
end
|
98
|
+
end
|
79
99
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
100
|
+
describe "restoring to a different index" do
|
101
|
+
before do
|
102
|
+
@restored_index_name = "#{@index_name}-restored"
|
103
|
+
@restored_index = $client.index(@restored_index_name)
|
104
|
+
end
|
105
|
+
|
106
|
+
after do
|
107
|
+
@restored_index.delete if @restored_index && @restored_index.exists?
|
85
108
|
end
|
86
109
|
|
87
|
-
it "restores snapshots" do
|
110
|
+
it "restores snapshots with options" do
|
88
111
|
@index.create(:number_of_shards => 1, :number_of_replicas => 0)
|
89
112
|
wait_for_index(@index_name)
|
90
113
|
with_tmp_repo do |repo|
|
91
114
|
snapshot = repo.snapshot(@name)
|
92
115
|
snapshot.create({:indices => [@index_name]}, :wait_for_completion => true)
|
93
|
-
|
94
|
-
|
116
|
+
response = snapshot.restore({
|
117
|
+
:rename_pattern => @index_name,
|
118
|
+
:rename_replacement => @restored_index_name
|
119
|
+
}, :wait_for_completion => true)
|
120
|
+
assert_equal [@restored_index_name], response["snapshot"]["indices"]
|
95
121
|
assert_equal 1, response["snapshot"]["shards"]["total"]
|
96
122
|
end
|
97
123
|
end
|
98
|
-
|
99
|
-
describe "restoring to a different index" do
|
100
|
-
before do
|
101
|
-
@restored_index_name = "#{@index_name}-restored"
|
102
|
-
@restored_index = $client.index(@restored_index_name)
|
103
|
-
end
|
104
|
-
|
105
|
-
after do
|
106
|
-
@restored_index.delete if @restored_index && @restored_index.exists?
|
107
|
-
end
|
108
|
-
|
109
|
-
it "restores snapshots with options" do
|
110
|
-
@index.create(:number_of_shards => 1, :number_of_replicas => 0)
|
111
|
-
wait_for_index(@index_name)
|
112
|
-
with_tmp_repo do |repo|
|
113
|
-
snapshot = repo.snapshot(@name)
|
114
|
-
snapshot.create({:indices => [@index_name]}, :wait_for_completion => true)
|
115
|
-
response = snapshot.restore({
|
116
|
-
:rename_pattern => @index_name,
|
117
|
-
:rename_replacement => @restored_index_name
|
118
|
-
}, :wait_for_completion => true)
|
119
|
-
assert_equal [@restored_index_name], response["snapshot"]["indices"]
|
120
|
-
assert_equal 1, response["snapshot"]["shards"]["total"]
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
124
|
end
|
125
125
|
end
|