etsy-deployinator 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,9 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'deployinator'
2
4
  require 'deployinator/helpers'
3
5
  require 'deployinator/helpers/dsh'
6
+ require 'tempfile'
4
7
 
5
8
  class HelpersTest < Test::Unit::TestCase
6
9
  include Deployinator::Helpers,
@@ -12,6 +15,7 @@ class HelpersTest < Test::Unit::TestCase
12
15
  @issue2 = "DEF-456"
13
16
  @issue1_linked = "#{@jurl % ([@issue1] * 2)}"
14
17
  @issue2_linked = "#{@jurl % ([@issue2] * 2)}"
18
+ @utf8_canary = 'Iñtërnâtiônàlizætiøn'
15
19
  Deployinator.default_user = "testuser"
16
20
  Deployinator.deploy_host = "deploytest.vm.ny4dev.etsy.com"
17
21
  Deployinator.issue_tracker = proc do |issue|
@@ -61,9 +65,9 @@ class HelpersTest < Test::Unit::TestCase
61
65
 
62
66
  def test_with_timeout_success
63
67
  res = with_timeout 3 do
64
- `sleep 2 && echo -n "foo"`
68
+ `sleep 2 && echo "foo"`
65
69
  end
66
- assert_equal "foo", res
70
+ assert_equal "foo\n", res
67
71
  end
68
72
 
69
73
  def test_strip_to_nil
@@ -74,4 +78,59 @@ class HelpersTest < Test::Unit::TestCase
74
78
  assert_equal('host01,host02', strip_ws_to_nil(' host01 , host02 '))
75
79
  assert_equal('host01', strip_ws_to_nil('host01'))
76
80
  end
81
+
82
+ def test_get_from_cache
83
+ Tempfile.open('cache_file', encoding: 'UTF-8') do |tf|
84
+ tf.write(@utf8_canary)
85
+ tf.flush
86
+
87
+ cached_content = get_from_cache(tf.path)
88
+ assert_equal(@utf8_canary, cached_content)
89
+ assert_equal(Encoding.find('UTF-8'), cached_content.encoding)
90
+ end
91
+ end
92
+
93
+ def test_get_from_cache_when_file_does_not_exist
94
+ assert_equal(false, get_from_cache('/does/not/exist'))
95
+ assert_equal(false, get_from_cache('/does/not/exist', -1))
96
+ assert_equal(false, get_from_cache('/does/not/exist', 10))
97
+ end
98
+
99
+ def test_get_from_cache_when_file_is_old
100
+ Tempfile.open('cache_file') do |tf|
101
+ File.stubs(:mtime).with(tf.path).returns(Time.now - 10)
102
+
103
+ assert_equal(false, get_from_cache(tf.path))
104
+ assert_not_equal(false, get_from_cache(tf.path, 30))
105
+ assert_not_equal(false, get_from_cache(tf.path, -1))
106
+ end
107
+ end
108
+
109
+ def test_write_to_cache
110
+ Tempfile.open('cache_file') do |tf|
111
+ write_to_cache(tf.path, @utf8_canary)
112
+
113
+ cached_content = get_from_cache(tf.path)
114
+ assert_equal(@utf8_canary, cached_content)
115
+ assert_equal(Encoding.find('UTF-8'), cached_content.encoding)
116
+ end
117
+ end
118
+
119
+ def test_is_admin_groups_nil
120
+ assert_false(is_admin?)
121
+ end
122
+
123
+ def test_is_admin_groups_true
124
+ assert_true(is_admin?(["foo", "bar"], ["bar"]))
125
+ end
126
+
127
+ def test_is_admin_groups_false
128
+ assert_false(is_admin?(["foo", "bar"], ["bla"]))
129
+ end
130
+
131
+ def test_is_admin_groups_true_with_fallback
132
+ @groups = ["foo", "bar"]
133
+ Deployinator.admin_groups = ["bar"]
134
+ assert_true(is_admin?(["foo", "bar"], ["bar"]))
135
+ end
77
136
  end
@@ -34,42 +34,42 @@ class VersionTest < Test::Unit::TestCase
34
34
  # unit test get_version_by_url with mocked curl_get_url
35
35
  def test_get_version_by_url_with_real_version
36
36
  Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
37
- .with("http://testhost.etsy.com/version.txt")
37
+ .with("https://testhost.etsy.com/version.txt")
38
38
  .returns("c5e3d40-20111227-195028-UTC")
39
- res = Deployinator::Helpers::VersionHelpers.get_version_by_url("http://testhost.etsy.com/version.txt")
39
+ res = Deployinator::Helpers::VersionHelpers.get_version_by_url("https://testhost.etsy.com/version.txt")
40
40
  assert_equal("c5e3d40-20111227-195028-UTC", res)
41
41
  end
42
42
 
43
43
  def test_get_version_by_url_with_invalid_string
44
44
  Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
45
- .with("http://testhost.etsy.com/version.txt")
45
+ .with("https://testhost.etsy.com/version.txt")
46
46
  .returns('<!DOCTYPE html>
47
47
  <html xmlns="http://www.w3.org/1999/xhtml">
48
48
  <head>')
49
- res = Deployinator::Helpers::VersionHelpers.get_version_by_url("http://testhost.etsy.com/version.txt")
49
+ res = Deployinator::Helpers::VersionHelpers.get_version_by_url("https://testhost.etsy.com/version.txt")
50
50
  assert_equal(nil, res)
51
51
  end
52
52
 
53
53
  def test_get_version_by_url_with_too_short_format
54
54
  Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
55
- .with("http://testhost.etsy.com/version.txt")
55
+ .with("https://testhost.etsy.com/version.txt")
56
56
  .returns("c5e3d40-201127-195028-UTC")
57
- res = Deployinator::Helpers::VersionHelpers.get_version_by_url("http://testhost.etsy.com/version.txt")
57
+ res = Deployinator::Helpers::VersionHelpers.get_version_by_url("https://testhost.etsy.com/version.txt")
58
58
  assert_equal(nil, res)
59
59
  end
60
60
 
61
61
  def test_get_version_by_url_with_too_long_format
62
62
  Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
63
- .with("http://testhost.etsy.com/version.txt")
63
+ .with("https://testhost.etsy.com/version.txt")
64
64
  .returns("c5e3d40-2011122700-195028-UTC")
65
- res = Deployinator::Helpers::VersionHelpers.get_version_by_url("http://testhost.etsy.com/version.txt")
65
+ res = Deployinator::Helpers::VersionHelpers.get_version_by_url("https://testhost.etsy.com/version.txt")
66
66
  assert_equal(nil, res)
67
67
  end
68
68
 
69
69
  # integration testing the get_version method with get_version_by_url
70
70
  def test_get_version_with_real_version
71
71
  Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
72
- .with("http://testhost.etsy.com/version.txt")
72
+ .with("https://testhost.etsy.com/version.txt")
73
73
  .returns("c5e3d40-20111227-195028-UTC")
74
74
  res = Deployinator::Helpers::VersionHelpers.get_version("testhost.etsy.com")
75
75
  assert_equal("c5e3d40-20111227-195028-UTC", res)
@@ -77,7 +77,7 @@ class VersionTest < Test::Unit::TestCase
77
77
 
78
78
  def test_get_version_with_invalid_string
79
79
  Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
80
- .with("http://testhost.etsy.com/version.txt")
80
+ .with("https://testhost.etsy.com/version.txt")
81
81
  .returns('<!DOCTYPE html>
82
82
  <html xmlns="http://www.w3.org/1999/xhtml">
83
83
  <head>')
@@ -87,7 +87,7 @@ class VersionTest < Test::Unit::TestCase
87
87
 
88
88
  def test_get_version_with_too_short_format
89
89
  Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
90
- .with("http://testhost.etsy.com/version.txt")
90
+ .with("https://testhost.etsy.com/version.txt")
91
91
  .returns("c5e3d40-201127-195028-UTC")
92
92
  res = Deployinator::Helpers::VersionHelpers.get_version("testhost.etsy.com")
93
93
  assert_equal(nil, res)
@@ -95,7 +95,7 @@ class VersionTest < Test::Unit::TestCase
95
95
 
96
96
  def test_get_version_with_too_long_format
97
97
  Deployinator::Helpers::VersionHelpers.expects(:curl_get_url)
98
- .with("http://testhost.etsy.com/version.txt")
98
+ .with("https://testhost.etsy.com/version.txt")
99
99
  .returns("c5e3d40-2011122700-195028-UTC")
100
100
  res = Deployinator::Helpers::VersionHelpers.get_version("testhost.etsy.com")
101
101
  assert_equal(nil, res)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etsy-deployinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JPaul
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-24 00:00:00.000000000 Z
11
+ date: 2016-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mocha
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-unit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '3'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -31,7 +45,7 @@ dependencies:
31
45
  - - ~>
32
46
  - !ruby/object:Gem::Version
33
47
  version: '10'
34
- - - ! '>='
48
+ - - '>='
35
49
  - !ruby/object:Gem::Version
36
50
  version: 10.3.2
37
51
  type: :runtime
@@ -41,7 +55,7 @@ dependencies:
41
55
  - - ~>
42
56
  - !ruby/object:Gem::Version
43
57
  version: '10'
44
- - - ! '>='
58
+ - - '>='
45
59
  - !ruby/object:Gem::Version
46
60
  version: 10.3.2
47
61
  - !ruby/object:Gem::Dependency
@@ -72,6 +86,20 @@ dependencies:
72
86
  - - ~>
73
87
  - !ruby/object:Gem::Version
74
88
  version: '0.99'
89
+ - !ruby/object:Gem::Dependency
90
+ name: mail
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '='
94
+ - !ruby/object:Gem::Version
95
+ version: 2.6.3
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '='
101
+ - !ruby/object:Gem::Version
102
+ version: 2.6.3
75
103
  - !ruby/object:Gem::Dependency
76
104
  name: pony
77
105
  requirement: !ruby/object:Gem::Requirement
@@ -107,7 +135,7 @@ dependencies:
107
135
  - - ~>
108
136
  - !ruby/object:Gem::Version
109
137
  version: '1.0'
110
- - - ! '>='
138
+ - - '>='
111
139
  - !ruby/object:Gem::Version
112
140
  version: 1.0.4
113
141
  type: :runtime
@@ -117,7 +145,7 @@ dependencies:
117
145
  - - ~>
118
146
  - !ruby/object:Gem::Version
119
147
  version: '1.0'
120
- - - ! '>='
148
+ - - '>='
121
149
  - !ruby/object:Gem::Version
122
150
  version: 1.0.4
123
151
  - !ruby/object:Gem::Dependency
@@ -127,9 +155,9 @@ dependencies:
127
155
  - - ~>
128
156
  - !ruby/object:Gem::Version
129
157
  version: '0.6'
130
- - - ! '>='
158
+ - - '>='
131
159
  - !ruby/object:Gem::Version
132
- version: 0.6.4
160
+ version: 0.6.5
133
161
  type: :runtime
134
162
  prerelease: false
135
163
  version_requirements: !ruby/object:Gem::Requirement
@@ -137,9 +165,9 @@ dependencies:
137
165
  - - ~>
138
166
  - !ruby/object:Gem::Version
139
167
  version: '0.6'
140
- - - ! '>='
168
+ - - '>='
141
169
  - !ruby/object:Gem::Version
142
- version: 0.6.4
170
+ version: 0.6.5
143
171
  - !ruby/object:Gem::Dependency
144
172
  name: em-websocket
145
173
  requirement: !ruby/object:Gem::Requirement
@@ -147,7 +175,7 @@ dependencies:
147
175
  - - ~>
148
176
  - !ruby/object:Gem::Version
149
177
  version: '0.5'
150
- - - ! '>='
178
+ - - '>='
151
179
  - !ruby/object:Gem::Version
152
180
  version: 0.5.1
153
181
  type: :runtime
@@ -157,7 +185,7 @@ dependencies:
157
185
  - - ~>
158
186
  - !ruby/object:Gem::Version
159
187
  version: '0.5'
160
- - - ! '>='
188
+ - - '>='
161
189
  - !ruby/object:Gem::Version
162
190
  version: 0.5.1
163
191
  - !ruby/object:Gem::Dependency
@@ -167,7 +195,7 @@ dependencies:
167
195
  - - ~>
168
196
  - !ruby/object:Gem::Version
169
197
  version: '1.4'
170
- - - ! '>='
198
+ - - '>='
171
199
  - !ruby/object:Gem::Version
172
200
  version: 1.4.3
173
201
  type: :runtime
@@ -177,9 +205,23 @@ dependencies:
177
205
  - - ~>
178
206
  - !ruby/object:Gem::Version
179
207
  version: '1.4'
180
- - - ! '>='
208
+ - - '>='
181
209
  - !ruby/object:Gem::Version
182
210
  version: 1.4.3
211
+ - !ruby/object:Gem::Dependency
212
+ name: celluloid
213
+ requirement: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - ~>
216
+ - !ruby/object:Gem::Version
217
+ version: '0.16'
218
+ type: :runtime
219
+ prerelease: false
220
+ version_requirements: !ruby/object:Gem::Requirement
221
+ requirements:
222
+ - - ~>
223
+ - !ruby/object:Gem::Version
224
+ version: '0.16'
183
225
  description: Deployinator as a Gem
184
226
  email:
185
227
  - jpaul@etsy.com
@@ -188,6 +230,8 @@ executables:
188
230
  extensions: []
189
231
  extra_rdoc_files: []
190
232
  files:
233
+ - .gitignore
234
+ - .travis.yml
191
235
  - Gemfile
192
236
  - LICENSE.txt
193
237
  - README.md
@@ -200,6 +244,7 @@ files:
200
244
  - lib/deployinator/config.rb
201
245
  - lib/deployinator/controller.rb
202
246
  - lib/deployinator/helpers.rb
247
+ - lib/deployinator/helpers/concurrency.rb
203
248
  - lib/deployinator/helpers/deploy.rb
204
249
  - lib/deployinator/helpers/dsh.rb
205
250
  - lib/deployinator/helpers/git.rb
@@ -212,23 +257,29 @@ files:
212
257
  - lib/deployinator/stack-tail.rb
213
258
  - lib/deployinator/static/css/diff_style.css
214
259
  - lib/deployinator/static/css/highlight.css
260
+ - lib/deployinator/static/css/maintenance.css
215
261
  - lib/deployinator/static/css/style.css
262
+ - lib/deployinator/static/images/maintenance.gif
216
263
  - lib/deployinator/static/js/flot/jquery.flot.min.js
217
264
  - lib/deployinator/static/js/flot/jquery.flot.selection.js
218
265
  - lib/deployinator/static/js/jquery-1.8.3.min.js
219
266
  - lib/deployinator/static/js/jquery-ui-1.8.24.min.js
220
267
  - lib/deployinator/static/js/jquery.timed_bar.js
268
+ - lib/deployinator/static/js/stats_load.js
221
269
  - lib/deployinator/tasks/initialize.rake
222
270
  - lib/deployinator/tasks/tests.rake
223
271
  - lib/deployinator/templates/deploys_status.mustache
272
+ - lib/deployinator/templates/exception.mustache
224
273
  - lib/deployinator/templates/generic_single_push.mustache
225
274
  - lib/deployinator/templates/index.mustache
226
275
  - lib/deployinator/templates/layout.mustache
227
276
  - lib/deployinator/templates/log.mustache
228
277
  - lib/deployinator/templates/log_table.mustache
278
+ - lib/deployinator/templates/maintenance.mustache
229
279
  - lib/deployinator/templates/messageboxes.mustache
230
280
  - lib/deployinator/templates/run_logs.mustache
231
281
  - lib/deployinator/templates/scroll_control.mustache
282
+ - lib/deployinator/templates/stats.mustache
232
283
  - lib/deployinator/templates/stream.mustache
233
284
  - lib/deployinator/version.rb
234
285
  - lib/deployinator/views/deploys_status.rb
@@ -236,13 +287,17 @@ files:
236
287
  - lib/deployinator/views/layout.rb
237
288
  - lib/deployinator/views/log.rb
238
289
  - lib/deployinator/views/log_table.rb
290
+ - lib/deployinator/views/maintenance.rb
239
291
  - lib/deployinator/views/run_logs.rb
292
+ - lib/deployinator/views/stats.rb
240
293
  - templates/app.rb.erb
241
294
  - templates/config.ru.erb
242
295
  - templates/helper.rb.erb
243
296
  - templates/stack.rb.erb
244
297
  - templates/template.mustache
245
298
  - templates/view.rb.erb
299
+ - test/unit/concurrency_test.rb
300
+ - test/unit/git_test.rb
246
301
  - test/unit/helpers_dsh_test.rb
247
302
  - test/unit/helpers_test.rb
248
303
  - test/unit/version_test.rb
@@ -256,21 +311,23 @@ require_paths:
256
311
  - lib
257
312
  required_ruby_version: !ruby/object:Gem::Requirement
258
313
  requirements:
259
- - - ! '>='
314
+ - - '>='
260
315
  - !ruby/object:Gem::Version
261
316
  version: 1.9.3
262
317
  required_rubygems_version: !ruby/object:Gem::Requirement
263
318
  requirements:
264
- - - ! '>='
319
+ - - '>='
265
320
  - !ruby/object:Gem::Version
266
321
  version: '0'
267
322
  requirements: []
268
323
  rubyforge_project:
269
- rubygems_version: 2.2.2
324
+ rubygems_version: 2.0.14
270
325
  signing_key:
271
326
  specification_version: 4
272
327
  summary: Rewrite of deployinator to be a gem
273
328
  test_files:
329
+ - test/unit/concurrency_test.rb
330
+ - test/unit/git_test.rb
274
331
  - test/unit/helpers_dsh_test.rb
275
332
  - test/unit/helpers_test.rb
276
333
  - test/unit/version_test.rb