elasticsearch_update 1.0.4 → 1.1.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/bin/elasticsearch_update +1 -1
- data/lib/elasticsearch_update/cli.rb +2 -2
- data/lib/elasticsearch_update/version.rb +1 -1
- data/lib/elasticsearch_update/wizard.rb +4 -2
- data/test/elasticsearch_update/downloader_spec.rb +48 -48
- data/test/elasticsearch_update/elasticsearch_spec.rb +32 -31
- data/test/elasticsearch_update/installer_spec.rb +20 -21
- data/test/elasticsearch_update/wizard_spec.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65bb030954dee148bced19b77dd94f0f6c167f37
|
4
|
+
data.tar.gz: 30cb25dc590178def7192da6e32b98e6db7305fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ffcc7fd3c48d17f17564dc9be020901a91027acdd76023859692bdb8d36371453b4a659d6f442ca47c81f383778131cbdf3b4dcb28a429d205f60186bd0049a
|
7
|
+
data.tar.gz: ce7f796aee03b585ba44a03cffe8549d2947017ab5681e1d8e391f8a193cb955ab844cb72308d797b5b8488be8c97c1e46235906cd91549be5d1f0e13a6037d8
|
data/bin/elasticsearch_update
CHANGED
@@ -175,7 +175,9 @@ module ElasticsearchUpdate
|
|
175
175
|
# wizard = ElasticsearchUpdate::Wizard.new
|
176
176
|
# password = wizard.sudo_password
|
177
177
|
def sudo_password
|
178
|
-
ask('What password should be used while updating Elasticsearch? ')
|
178
|
+
ask('What password should be used while updating Elasticsearch? ') do |q|
|
179
|
+
q.echo = 'x'
|
180
|
+
end
|
179
181
|
end
|
180
182
|
|
181
183
|
# == download_hash
|
@@ -195,7 +197,7 @@ module ElasticsearchUpdate
|
|
195
197
|
# hash = wizard.download_hash
|
196
198
|
def download_hash
|
197
199
|
{
|
198
|
-
base_url: 'download.
|
200
|
+
base_url: 'download.elastic.co',
|
199
201
|
version: version,
|
200
202
|
extension: extension
|
201
203
|
}
|
@@ -18,115 +18,115 @@ module ElasticsearchUpdate
|
|
18
18
|
it 'should initialize and correctly assign values.' do
|
19
19
|
hash =
|
20
20
|
{
|
21
|
-
base_url: 'download.
|
21
|
+
base_url: 'download.elastic.co',
|
22
22
|
version: '1.4.2',
|
23
23
|
extension: '.deb'
|
24
24
|
}
|
25
25
|
|
26
|
-
|
27
|
-
assert_kind_of ElasticsearchUpdate::Downloader,
|
26
|
+
downloader = TestDownloader.new(hash, false)
|
27
|
+
assert_kind_of ElasticsearchUpdate::Downloader, downloader
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
downloader.base.must_equal 'download.elastic.co'
|
30
|
+
downloader.extension.must_equal '.deb'
|
31
|
+
downloader.version.must_equal '1.4.2'
|
32
|
+
downloader.download_url.must_equal 'https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.4.2.deb'
|
33
|
+
downloader.verify_url.must_equal 'https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.4.2.deb.sha1.txt'
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should retrieve the correct SHA1 value from Elasticsearch\'s website' do
|
37
37
|
hash =
|
38
38
|
{
|
39
|
-
base_url: 'download.
|
39
|
+
base_url: 'download.elastic.co',
|
40
40
|
version: '1.4.2',
|
41
41
|
extension: '.deb'
|
42
42
|
}
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
mock_file = Minitest::Mock.new
|
45
|
+
mock_file.expect(:read, 'd377e39343e5cc277104beee349e1578dc50f7f8 elasticsearch-1.4.2.deb')
|
46
46
|
|
47
|
-
Kernel.stub :open, nil,
|
48
|
-
|
49
|
-
|
47
|
+
Kernel.stub :open, nil, mock_file do
|
48
|
+
downloader = TestDownloader.new(hash, true)
|
49
|
+
downloader.download_remote_sha1.must_equal 'd377e39343e5cc277104beee349e1578dc50f7f8'
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should retrieve the verify the file's SHA1 value against Elasticsearch's" do
|
54
54
|
hash =
|
55
55
|
{
|
56
|
-
base_url: 'download.
|
56
|
+
base_url: 'download.elastic.co',
|
57
57
|
version: '1.4.2',
|
58
58
|
extension: '.deb'
|
59
59
|
}
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
mock_file_obj = Minitest::Mock.new
|
62
|
+
mock_result = 'd377e39343e5cc277104beee349e1578dc50f7f8'
|
63
|
+
mock_file_obj.expect(:hexdigest, mock_result)
|
64
64
|
|
65
|
-
|
66
|
-
|
65
|
+
mock_file = Minitest::Mock.new
|
66
|
+
mock_file.expect(:path, 'fake/path')
|
67
67
|
|
68
|
-
Digest::SHA1.stub :file,
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
Digest::SHA1.stub :file, mock_file_obj do
|
69
|
+
downloader = TestDownloader.new(hash, true)
|
70
|
+
downloader.update_file = mock_file
|
71
|
+
downloader.verify_update_file.must_equal true
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should retrieve the verify the file's SHA1 value against Elasticsearch's" do
|
76
76
|
hash =
|
77
77
|
{
|
78
|
-
base_url: 'download.
|
78
|
+
base_url: 'download.elastic.co',
|
79
79
|
version: '1.4.2',
|
80
80
|
extension: '.deb'
|
81
81
|
}
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
mock_file_obj = Minitest::Mock.new
|
84
|
+
mock_result = '0'
|
85
|
+
mock_file_obj.expect(:hexdigest, mock_result)
|
86
86
|
|
87
|
-
|
88
|
-
|
87
|
+
mock_file = Minitest::Mock.new
|
88
|
+
mock_file.expect(:path, 'fake/path')
|
89
89
|
|
90
|
-
Digest::SHA1.stub :file,
|
91
|
-
|
92
|
-
|
93
|
-
|
90
|
+
Digest::SHA1.stub :file, mock_file_obj do
|
91
|
+
downloader = TestDownloader.new(hash, true)
|
92
|
+
downloader.update_file = mock_file
|
93
|
+
downloader.verify_update_file.must_equal 'File was not downloaded correctly. Please try again.'
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'creates a tempfile to store the Elasticsearch deb file' do
|
98
98
|
hash =
|
99
99
|
{
|
100
|
-
base_url: 'download.
|
100
|
+
base_url: 'download.elastic.co',
|
101
101
|
version: '1.4.2',
|
102
102
|
extension: '.deb'
|
103
103
|
}
|
104
104
|
|
105
|
-
|
106
|
-
assert_kind_of Tempfile,
|
105
|
+
downloader = TestDownloader.new(hash, true)
|
106
|
+
assert_kind_of Tempfile, downloader.download_file(true)
|
107
107
|
end
|
108
108
|
|
109
109
|
it 'writes a downloaded file' do
|
110
110
|
hash =
|
111
111
|
{
|
112
|
-
base_url: 'download.
|
112
|
+
base_url: 'download.elastic.co',
|
113
113
|
version: '1.4.2',
|
114
114
|
extension: '.deb'
|
115
115
|
}
|
116
116
|
|
117
|
-
|
118
|
-
|
117
|
+
mock_resp = Minitest::Mock.new
|
118
|
+
mock_resp.expect(:read_body, 'Test')
|
119
119
|
|
120
|
-
|
121
|
-
|
120
|
+
mock_http = Minitest::Mock.new
|
121
|
+
mock_http.expect(:request_get, mock_resp, [String])
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
mock_file = Minitest::Mock.new
|
124
|
+
mock_file.expect(:write, true, [String])
|
125
|
+
mock_file.expect(:close, true)
|
126
126
|
|
127
|
-
|
128
|
-
Net::HTTP.stub :start, true,
|
129
|
-
|
127
|
+
downloader = TestDownloader.new(hash, true)
|
128
|
+
Net::HTTP.stub :start, true, mock_http do
|
129
|
+
downloader.write_file_from_url(mock_file, 'http://test.org')
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
@@ -1,89 +1,90 @@
|
|
1
1
|
require 'minitest_helper'
|
2
2
|
|
3
3
|
module ElasticsearchUpdate
|
4
|
+
# Overrides the std Elasticsearch class for testing purposes
|
4
5
|
class TestElasticsearch < Elasticsearch
|
5
6
|
def system(command)
|
6
7
|
command
|
7
8
|
end
|
8
9
|
end
|
10
|
+
|
9
11
|
# The TestInstaller class below tests the Downloader class from the library
|
10
12
|
class TestElasticsearch
|
11
13
|
describe 'Elasticsearch', 'Used to interact with Elasticsearch' do
|
12
|
-
|
13
14
|
it 'should initialize without errors' do
|
14
|
-
|
15
|
-
assert_kind_of Elasticsearch,
|
15
|
+
es_client = TestElasticsearch.new
|
16
|
+
assert_kind_of Elasticsearch, es_client
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
es_client.es_port.must_equal 9200
|
19
|
+
es_client.es_host.must_equal 'localhost'
|
19
20
|
end
|
20
21
|
|
21
22
|
it 'should disable cluster allocation' do
|
22
|
-
|
23
|
+
es_client = TestElasticsearch.new({ host: 'localhost', port: 9200 }, true)
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
mock_http = Minitest::Mock.new
|
26
|
+
mock_http.expect(:start, 200)
|
26
27
|
|
27
|
-
Net::HTTP.stub :new,
|
28
|
-
|
28
|
+
Net::HTTP.stub :new, mock_http do
|
29
|
+
es_client.cluster_routing_allocation('none').must_equal 200
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
33
|
it 'should enable cluster allocation' do
|
33
|
-
|
34
|
+
es_client = TestElasticsearch.new({ host: 'localhost', port: 9200 }, true)
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
mock_http = Minitest::Mock.new
|
37
|
+
mock_http.expect(:start, 200)
|
37
38
|
|
38
|
-
Net::HTTP.stub :new,
|
39
|
-
|
39
|
+
Net::HTTP.stub :new, mock_http do
|
40
|
+
es_client.cluster_routing_allocation('all').must_equal 200
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
43
44
|
it 'should shutdown the local node' do
|
44
|
-
|
45
|
+
es_client = TestElasticsearch.new({ host: 'localhost', port: 9200 }, true)
|
45
46
|
|
46
47
|
Net::HTTP.stub :post_form, 200 do
|
47
|
-
|
48
|
+
es_client.shutdown_local_node.must_equal 200
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
51
52
|
it 'start elasticsearch service' do
|
52
|
-
|
53
|
+
es_client = TestElasticsearch.new({ host: 'localhost', port: 9200 }, true)
|
53
54
|
|
54
|
-
result =
|
55
|
+
result = es_client.start_elasticsearch_service('test')
|
55
56
|
|
56
57
|
result.must_equal 'echo test | sudo -S service elasticsearch start'
|
57
58
|
end
|
58
59
|
|
59
60
|
it 'start elasticsearch binary' do
|
60
|
-
|
61
|
+
es_client = TestElasticsearch.new({ host: 'localhost', port: 9200 }, true)
|
61
62
|
|
62
|
-
result =
|
63
|
+
result = es_client.start_elasticsearch_binary('/path/to/elasticsearch/')
|
63
64
|
|
64
65
|
result.must_equal '/path/to/elasticsearch/bin/elasticsearch'
|
65
66
|
end
|
66
67
|
|
67
68
|
it 'start elasticsearch service from the deb extension' do
|
68
|
-
|
69
|
-
|
70
|
-
|
69
|
+
mock = Minitest::Mock.new
|
70
|
+
mock.expect(:extension, '.deb')
|
71
|
+
mock.expect(:sudo_password, 'test')
|
71
72
|
|
72
|
-
|
73
|
+
es_client = TestElasticsearch.new({ host: 'localhost', port: 9200 }, true)
|
73
74
|
|
74
|
-
result =
|
75
|
+
result = es_client.start_elasticsearch(mock)
|
75
76
|
|
76
77
|
result.must_equal 'echo test | sudo -S service elasticsearch start'
|
77
78
|
end
|
78
79
|
|
79
80
|
it 'start elasticsearch service from the rpm extension' do
|
80
|
-
|
81
|
-
|
82
|
-
|
81
|
+
mock = Minitest::Mock.new
|
82
|
+
mock.expect(:extension, '.rpm')
|
83
|
+
mock.expect(:sudo_password, 'test')
|
83
84
|
|
84
|
-
|
85
|
+
es_client = TestElasticsearch.new({ host: 'localhost', port: 9200 }, true)
|
85
86
|
|
86
|
-
result =
|
87
|
+
result = es_client.start_elasticsearch(mock)
|
87
88
|
|
88
89
|
result.must_equal 'echo test | sudo -S service elasticsearch start'
|
89
90
|
end
|
@@ -4,58 +4,57 @@ module ElasticsearchUpdate
|
|
4
4
|
# The TestInstaller class below tests the Downloader class from the library
|
5
5
|
class TestInstaller < Minitest::Test
|
6
6
|
describe 'Installer', 'Used to install Elasticsearch file' do
|
7
|
-
|
8
7
|
it 'should initialize and correctly assign values.' do
|
9
|
-
|
10
|
-
assert_kind_of ElasticsearchUpdate::Installer,
|
8
|
+
installer = ElasticsearchUpdate::Installer.new('test_password', '.deb', false)
|
9
|
+
assert_kind_of ElasticsearchUpdate::Installer, installer
|
11
10
|
|
12
|
-
|
13
|
-
|
11
|
+
installer.sudo_password.must_equal 'test_password'
|
12
|
+
installer.extension.must_equal '.deb'
|
14
13
|
end
|
15
14
|
|
16
15
|
it 'should install the .deb file' do
|
17
|
-
|
18
|
-
|
16
|
+
mock_file = Minitest::Mock.new
|
17
|
+
mock_file.expect(:path, '/path/to/file.deb')
|
19
18
|
|
20
19
|
Kernel.stub :system, true do
|
21
|
-
|
22
|
-
response =
|
20
|
+
installer = ElasticsearchUpdate::Installer.new('test_password', '.deb', true)
|
21
|
+
response = installer.install_file(mock_file)
|
23
22
|
|
24
23
|
response.must_equal true
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
28
27
|
it 'should install the .rpm file' do
|
29
|
-
|
30
|
-
|
28
|
+
mock_file = Minitest::Mock.new
|
29
|
+
mock_file.expect(:path, '/path/to/file.rpm')
|
31
30
|
|
32
31
|
Kernel.stub :system, true do
|
33
|
-
|
34
|
-
response =
|
32
|
+
installer = ElasticsearchUpdate::Installer.new('test_password', '.rpm', true)
|
33
|
+
response = installer.install_file(mock_file)
|
35
34
|
|
36
35
|
response.must_equal true
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
39
|
it 'should install the .zip file' do
|
41
|
-
|
42
|
-
|
40
|
+
mock_file = Minitest::Mock.new
|
41
|
+
mock_file.expect(:path, '/path/to/file.rpm')
|
43
42
|
|
44
43
|
Kernel.stub :system, true do
|
45
|
-
|
46
|
-
response =
|
44
|
+
installer = ElasticsearchUpdate::Installer.new('test_password', '.zip', true)
|
45
|
+
response = installer.install_file(mock_file)
|
47
46
|
|
48
47
|
response.must_equal true
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
51
|
it 'should install the .rpm file' do
|
53
|
-
|
54
|
-
|
52
|
+
mock_file = Minitest::Mock.new
|
53
|
+
mock_file.expect(:path, '/path/to/file.rpm')
|
55
54
|
|
56
55
|
Kernel.stub :system, true do
|
57
|
-
|
58
|
-
response =
|
56
|
+
installer = ElasticsearchUpdate::Installer.new('test_password', '.tar.gz', true)
|
57
|
+
response = installer.install_file(mock_file)
|
59
58
|
|
60
59
|
response.must_equal true
|
61
60
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'minitest_helper'
|
2
2
|
|
3
3
|
module ElasticsearchUpdate
|
4
|
+
# Test wizard overrides the Wizard class methods for testing.
|
4
5
|
class TestWizard < Wizard
|
5
6
|
def ask(_question, _type = String, &_block)
|
6
7
|
'Question asked.'
|
@@ -85,7 +86,7 @@ module ElasticsearchUpdate
|
|
85
86
|
|
86
87
|
result = wizard.download_hash
|
87
88
|
|
88
|
-
result.must_equal(base_url: 'download.
|
89
|
+
result.must_equal(base_url: 'download.elastic.co',
|
89
90
|
version: 'Question asked.',
|
90
91
|
extension: '.deb')
|
91
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch_update
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Kirsche
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.4.6
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Updates the elasticsearch instance on the local machine.
|