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.
@@ -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
- if es_version_1_x?
20
- it "fitlers node info" do
21
- h = $client.nodes.info(:info => "os")
22
- node = h["nodes"].values.first
23
- assert node.key?("os"), "expected os info to be present"
24
- assert !node.key?("jvm"), "expected jvm info to be absent"
25
-
26
- h = $client.nodes.info(:info => %w[jvm process])
27
- node = h["nodes"].values.first
28
- assert node.key?("jvm"), "expected jvm info to be present"
29
- assert node.key?("process"), "expected process info to be present"
30
- assert !node.key?("network"), "expected network info to be absent"
31
- end
32
-
33
- it "filters node stats" do
34
- h = $client.nodes.stats(:stats => "http")
35
- node = h["nodes"].values.first
36
- assert node.key?("http"), "expected http stats to be present"
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
@@ -15,7 +15,7 @@ describe Elastomer::Client::Percolator do
15
15
  describe "when an index exists" do
16
16
  before do
17
17
  @index.create(nil)
18
- wait_for_index(@index_name)
18
+ wait_for_index(@index.name)
19
19
  end
20
20
 
21
21
  it "creates a query" 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
- if es_version_1_x?
6
-
7
- before do
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
- @name = "elastomer-repository-test"
13
- @repo = $client.repository(@name)
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
- it "determines if a repo exists" do
17
- assert_equal false, @repo.exists?
18
- assert_equal false, @repo.exist?
19
- with_tmp_repo(@name) do
20
- assert_equal true, @repo.exists?
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
- it "creates repos" do
25
- response = create_repo(@name)
26
- assert_equal true, response["acknowledged"]
27
- delete_repo(@name)
28
- end
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
- it "cannot create a repo without a name" do
31
- lambda {
32
- create_repo(nil)
33
- }.must_raise ArgumentError
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
- it "gets repos" do
37
- with_tmp_repo do |repo|
38
- response = repo.get
39
- refute_nil response[repo.name]
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
- it "gets all repos" do
44
- with_tmp_repo do |repo|
45
- response = $client.repository.get
46
- refute_nil response[repo.name]
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
- it "gets repo status" do
51
- with_tmp_repo do |repo|
52
- response = repo.status
53
- assert_equal [], response["snapshots"]
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
- it "gets status of all repos" do
58
- response = $client.repository.status
59
- assert_equal [], response["snapshots"]
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
- it "updates repos" do
63
- with_tmp_repo do |repo|
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
- response = repo.update(:type => "fs", :settings => settings.merge("compress" => true))
66
- assert_equal true, response["acknowledged"]
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
- it "cannot update a repo without a name" do
72
- with_tmp_repo do |repo|
73
- lambda {
74
- settings = repo.get[repo.name]["settings"]
75
- $client.repository.update(:type => "fs", :settings => settings.merge("compress" => true))
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
- it "deletes repos" do
81
- with_tmp_repo do |repo|
82
- response = repo.delete
83
- assert_equal true, response["acknowledged"]
84
- assert_equal false, repo.exists?
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
- it "cannot delete a repo without a name" do
89
- lambda {
90
- $client.repository.delete
91
- }.must_raise ArgumentError
92
- end
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
- it "gets snapshots" do
95
- with_tmp_repo do |repo|
96
- response = repo.snapshots.get
97
- assert_equal [], response["snapshots"]
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
- if es_version_1_x?
6
- before do
7
- if !run_snapshot_tests?
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
- @index_name = "elastomer-snapshot-test-index"
12
- @index = $client.index(@index_name)
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
- after do
17
- @index.delete if @index && @index.exists?
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
- it "determines if a snapshot exists" do
21
- with_tmp_repo do |repo|
22
- snapshot = repo.snapshot(@name)
23
- assert_equal false, snapshot.exists?
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
- it "creates snapshots" do
31
- with_tmp_repo do |repo|
32
- response = repo.snapshot(@name).create({}, :wait_for_completion => true)
33
- assert_equal @name, response["snapshot"]["snapshot"]
34
- end
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
- it "creates snapshots with options" do
38
- @index.create(:number_of_shards => 1, :number_of_replicas => 0)
39
- with_tmp_repo do |repo|
40
- response = repo.snapshot(@name).create({:indices => [@index_name]}, :wait_for_completion => true)
41
- assert_equal [@index_name], response["snapshot"]["indices"]
42
- assert_equal 1, response["snapshot"]["shards"]["total"]
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
- it "gets snapshot info for one and all" do
47
- with_tmp_snapshot do |snapshot, repo|
48
- response = snapshot.get
49
- assert_equal snapshot.name, response["snapshots"][0]["snapshot"]
50
- response = repo.snapshots.get
51
- assert_equal snapshot.name, response["snapshots"][0]["snapshot"]
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
- it "gets snapshot status for one and all" do
56
- @index.create(:number_of_shards => 1, :number_of_replicas => 0)
57
- with_tmp_repo do |repo|
58
- repo.snapshot(@name).create({:indices => [@index_name]}, :wait_for_completion => true)
59
- response = repo.snapshot(@name).status
60
- assert_equal 1, response["snapshots"][0]["shards_stats"]["total"]
61
- end
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
- it "gets status of snapshots in progress" do
65
- # we can't reliably get status of an in-progress snapshot in tests, so
66
- # check for an empty result instead
67
- with_tmp_repo do |repo|
68
- response = repo.snapshots.status
69
- assert_equal [], response["snapshots"]
70
- response = $client.snapshot.status
71
- assert_equal [], response["snapshots"]
72
- end
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
- it "disallows nil repo name with non-nil snapshot name" do
76
- assert_raises(ArgumentError) { $client.repository.snapshot("snapshot") }
77
- assert_raises(ArgumentError) { $client.snapshot(nil, "snapshot") }
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
- it "deletes snapshots" do
81
- with_tmp_snapshot do |snapshot|
82
- response = snapshot.delete
83
- assert_equal true, response["acknowledged"]
84
- end
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
- @index.delete
94
- response = snapshot.restore({}, :wait_for_completion => true)
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