marathon-api 0.9.0 → 1.0.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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.simplecov +2 -2
  3. data/.travis.yml +1 -1
  4. data/README.md +40 -14
  5. data/bin/marathon +242 -0
  6. data/fixtures/marathon_docker_sample_2.json +2 -1
  7. data/fixtures/vcr/Marathon_App/_restart/restarts_an_app.yml +32 -0
  8. data/fixtures/vcr/Marathon_Group/_changes/changes_the_group.yml +61 -0
  9. data/fixtures/vcr/Marathon_Group/_delete/deletes_the_group.yml +32 -0
  10. data/fixtures/vcr/Marathon_Group/_delete/fails_deleting_not_existing_app.yml +32 -0
  11. data/fixtures/vcr/Marathon_Group/_get/fails_getting_not_existing_app.yml +32 -0
  12. data/fixtures/vcr/Marathon_Group/_get/gets_the_group.yml +32 -0
  13. data/fixtures/vcr/Marathon_Group/_list/lists_apps.yml +33 -0
  14. data/fixtures/vcr/Marathon_Group/_start/fails_getting_not_existing_group.yml +32 -0
  15. data/fixtures/vcr/Marathon_Group/_start/starts_the_group.yml +35 -0
  16. data/lib/marathon.rb +33 -5
  17. data/lib/marathon/app.rb +72 -22
  18. data/lib/marathon/base.rb +32 -0
  19. data/lib/marathon/connection.rb +32 -22
  20. data/lib/marathon/constraint.rb +39 -0
  21. data/lib/marathon/container.rb +41 -0
  22. data/lib/marathon/container_docker.rb +33 -0
  23. data/lib/marathon/container_docker_port_mapping.rb +32 -0
  24. data/lib/marathon/container_volume.rb +31 -0
  25. data/lib/marathon/deployment.rb +5 -15
  26. data/lib/marathon/deployment_info.rb +20 -0
  27. data/lib/marathon/error.rb +8 -2
  28. data/lib/marathon/group.rb +166 -0
  29. data/lib/marathon/health_check.rb +35 -0
  30. data/lib/marathon/queue.rb +4 -13
  31. data/lib/marathon/task.rb +15 -12
  32. data/lib/marathon/util.rb +47 -3
  33. data/lib/marathon/version.rb +1 -1
  34. data/marathon-api.gemspec +4 -3
  35. data/spec/marathon/app_spec.rb +108 -50
  36. data/spec/marathon/base_spec.rb +53 -0
  37. data/spec/marathon/connection_spec.rb +1 -1
  38. data/spec/marathon/constraint_spec.rb +27 -0
  39. data/spec/marathon/container_docker_port_mapping_spec.rb +55 -0
  40. data/spec/marathon/container_docker_spec.rb +42 -0
  41. data/spec/marathon/container_spec.rb +40 -0
  42. data/spec/marathon/container_volume_spec.rb +50 -0
  43. data/spec/marathon/deployment_info_spec.rb +43 -0
  44. data/spec/marathon/deployment_spec.rb +15 -16
  45. data/spec/marathon/error_spec.rb +17 -0
  46. data/spec/marathon/group_spec.rb +172 -0
  47. data/spec/marathon/health_check_spec.rb +50 -0
  48. data/spec/marathon/marathon_spec.rb +31 -0
  49. data/spec/marathon/queue_spec.rb +2 -2
  50. data/spec/marathon/task_spec.rb +24 -11
  51. data/spec/marathon/util_spec.rb +21 -1
  52. metadata +58 -6
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Marathon::HealthCheck do
4
+
5
+ describe '#init' do
6
+ subject { described_class.new({'protocol' => 'TCP'}) }
7
+
8
+ its(:protocol) { should == 'TCP' }
9
+ its(:portIndex) { should == 0 }
10
+ its(:timeoutSeconds) { should == 20 }
11
+ end
12
+
13
+ describe '#to_s with protocol==HTTP' do
14
+ subject { described_class.new({'protocol' => 'HTTP', 'portIndex' => 0, 'path' => '/ping'}) }
15
+
16
+ let(:expected_string) do
17
+ 'Marathon::HealthCheck { :protocol => HTTP :portIndex => 0 :path => /ping }'
18
+ end
19
+
20
+ its(:to_s) { should == expected_string }
21
+ end
22
+
23
+ describe '#to_s with protocol==TCP' do
24
+ subject { described_class.new({'protocol' => 'TCP', 'portIndex' => 0, 'path' => '/ping'}) }
25
+
26
+ let(:expected_string) do
27
+ 'Marathon::HealthCheck { :protocol => TCP :portIndex => 0 }'
28
+ end
29
+
30
+ its(:to_s) { should == expected_string }
31
+ end
32
+
33
+ describe '#to_s with protocol==COMMAND' do
34
+ subject { described_class.new({'protocol' => 'COMMAND', 'command' => 'true'}) }
35
+
36
+ let(:expected_string) do
37
+ 'Marathon::HealthCheck { :protocol => COMMAND :command => true }'
38
+ end
39
+
40
+ its(:to_s) { should == expected_string }
41
+ end
42
+
43
+ describe '#to_json' do
44
+ subject { described_class.new({'protocol' => 'HTTP', 'portIndex' => 0, 'path' => '/ping'}) }
45
+
46
+ its(:to_json) { should == '{"gracePeriodSeconds":300,"intervalSeconds":60,"maxConsecutiveFailures":3,' \
47
+ + '"path":"/ping","portIndex":0,"protocol":"HTTP","timeoutSeconds":20}' }
48
+ end
49
+
50
+ end
@@ -24,6 +24,37 @@ describe Marathon do
24
24
  end
25
25
  end
26
26
 
27
+ describe '.options=' do
28
+ subject { described_class }
29
+
30
+ it 'sets new options' do
31
+ described_class.options = {:foo => 'bar'}
32
+ expect(described_class.options).to eq({:foo => 'bar'})
33
+
34
+ # reset connection after running this spec
35
+ described_class.options = nil
36
+ end
37
+
38
+ it 'resets connection' do
39
+ old_connection = described_class.connection
40
+ described_class.options = {:foo => 'bar'}
41
+
42
+ expect(described_class.connection).not_to be(old_connection)
43
+
44
+ # reset connection after running this spec
45
+ described_class.options = nil
46
+ end
47
+
48
+ it 'adds :basic_auth options for :username and :password' do
49
+ described_class.options = {:username => 'user', :password => 'password'}
50
+ expect(described_class.connection.options)
51
+ .to eq({:basic_auth => {:username => 'user', :password => 'password'}})
52
+
53
+ # reset connection after running this spec
54
+ described_class.options = nil
55
+ end
56
+ end
57
+
27
58
  describe '.info' do
28
59
  subject { described_class }
29
60
 
@@ -19,7 +19,7 @@ describe Marathon::Queue do
19
19
 
20
20
  it 'has delay' do
21
21
  expect(subject.delay).to be_instance_of(Hash)
22
- expect(subject.delay['overdue']).to be(true)
22
+ expect(subject.delay[:overdue]).to be(true)
23
23
  end
24
24
  end
25
25
 
@@ -30,7 +30,7 @@ describe Marathon::Queue do
30
30
  }) }
31
31
 
32
32
  let(:expected_string) do
33
- 'Marathon::Queue { :appId => /app/foo :delay => {"overdue"=>true} }'
33
+ 'Marathon::Queue { :appId => /app/foo :delay => {:overdue=>true} }'
34
34
  end
35
35
 
36
36
  its(:to_s) { should == expected_string }
@@ -4,16 +4,29 @@ describe Marathon::Task do
4
4
 
5
5
  describe '#to_s' do
6
6
  subject { described_class.new({
7
- 'id' => 'task-id-foo',
8
- 'appId' => '/app/foo',
9
- 'host' => 'foo-host',
7
+ 'id' => 'task-id-foo',
8
+ 'appId' => '/app/foo',
9
+ 'host' => 'foo-host',
10
+ 'ports' => [31000, 31001],
11
+ 'version' => 'foo-version'
10
12
  }) }
11
13
 
12
14
  let(:expected_string) do
13
15
  "Marathon::Task { :id => task-id-foo :appId => /app/foo :host => foo-host }"
14
16
  end
15
17
 
18
+ let(:expected_pretty_string) do
19
+ "Task ID: task-id-foo\n" + \
20
+ "App ID: /app/foo\n" + \
21
+ "Host: foo-host\n" + \
22
+ "Ports: 31000,31001\n" + \
23
+ "Staged at: \n" + \
24
+ "Started at: \n" + \
25
+ "Version: foo-version"
26
+ end
27
+
16
28
  its(:to_s) { should == expected_string }
29
+ its(:to_pretty_s) { should == expected_pretty_string }
17
30
  end
18
31
 
19
32
  describe '#to_json' do
@@ -42,7 +55,7 @@ describe Marathon::Task do
42
55
  })
43
56
  end
44
57
  task.delete!
45
- expect(task.info['deleted']).to be(true)
58
+ expect(task.info[:deleted]).to be(true)
46
59
  end
47
60
  end
48
61
 
@@ -51,18 +64,18 @@ describe Marathon::Task do
51
64
 
52
65
  it 'raises error when run with strange status' do
53
66
  expect {
54
- described_class.list('foo')
67
+ subject.list('foo')
55
68
  }.to raise_error(Marathon::Error::ArgumentError)
56
69
  end
57
70
 
58
71
  it 'lists tasks', :vcr do
59
- tasks = described_class.list
72
+ tasks = subject.list
60
73
  expect(tasks.size).to be_within(1).of(2)
61
74
  expect(tasks.first).to be_instance_of(described_class)
62
75
  end
63
76
 
64
77
  it 'lists running tasks', :vcr do
65
- tasks = described_class.list('running')
78
+ tasks = subject.list('running')
66
79
  expect(tasks.size).to be_within(1).of(2)
67
80
  expect(tasks.first).to be_instance_of(described_class)
68
81
  end
@@ -72,7 +85,7 @@ describe Marathon::Task do
72
85
  subject { described_class }
73
86
 
74
87
  it 'gets tasks of an app', :vcr do
75
- tasks = described_class.get('/ubuntu2')
88
+ tasks = subject.get('/ubuntu2')
76
89
  expect(tasks.size).to eq(1)
77
90
  expect(tasks.first).to be_instance_of(described_class)
78
91
  expect(tasks.first.appId).to eq('/ubuntu2')
@@ -83,8 +96,8 @@ describe Marathon::Task do
83
96
  subject { described_class }
84
97
 
85
98
  it 'kills a tasks of an app', :vcr do
86
- tasks = described_class.get('/ubuntu2')
87
- task = described_class.delete('/ubuntu2', tasks.first.id)
99
+ tasks = subject.get('/ubuntu2')
100
+ task = subject.delete('/ubuntu2', tasks.first.id)
88
101
  task.id == tasks.first.id
89
102
  end
90
103
  end
@@ -93,7 +106,7 @@ describe Marathon::Task do
93
106
  subject { described_class }
94
107
 
95
108
  it 'kills all tasks of an app', :vcr do
96
- described_class.delete_all('/ubuntu2')
109
+ subject.delete_all('/ubuntu2')
97
110
  end
98
111
  end
99
112
 
@@ -41,4 +41,24 @@ describe Marathon::Util do
41
41
  end
42
42
  end
43
43
 
44
- end
44
+ describe '.keywordize_hash' do
45
+ subject { described_class }
46
+
47
+ it 'keywordizes the hash' do
48
+ expect(subject.keywordize_hash({
49
+ 'foo' => 'bar',
50
+ 'f00' => {'w00h00' => 'yeah'},
51
+ 'bang' => [{'tricky' => 'one'}],
52
+ 'env' => {'foo' => 'bar'},
53
+ 'null' => nil
54
+ })).to eq({
55
+ :foo => 'bar',
56
+ :f00 => {:w00h00 => 'yeah'},
57
+ :bang => [{:tricky => 'one'}],
58
+ :env => {'foo' => 'bar'},
59
+ :null => nil
60
+ })
61
+ end
62
+ end
63
+
64
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marathon-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Bechstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: trollop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -166,8 +180,9 @@ dependencies:
166
180
  version: '0'
167
181
  description: A simple REST client for the Marathon Remote API
168
182
  email:
169
- - f@ub0r.de
170
- executables: []
183
+ - felix.bechstein@otto.de
184
+ executables:
185
+ - marathon
171
186
  extensions: []
172
187
  extra_rdoc_files: []
173
188
  files:
@@ -180,6 +195,7 @@ files:
180
195
  - README.md
181
196
  - Rakefile
182
197
  - TESTING.md
198
+ - bin/marathon
183
199
  - fixtures/marathon_docker_sample.json
184
200
  - fixtures/marathon_docker_sample_2.json
185
201
  - fixtures/vcr/Marathon/_info/returns_the_info_hash.yml
@@ -192,6 +208,7 @@ files:
192
208
  - fixtures/vcr/Marathon_App/_get/gets_the_app.yml
193
209
  - fixtures/vcr/Marathon_App/_list/lists_apps.yml
194
210
  - fixtures/vcr/Marathon_App/_restart/fails_restarting_not_existing_app.yml
211
+ - fixtures/vcr/Marathon_App/_restart/restarts_an_app.yml
195
212
  - fixtures/vcr/Marathon_App/_start/fails_getting_not_existing_app.yml
196
213
  - fixtures/vcr/Marathon_App/_start/starts_the_app.yml
197
214
  - fixtures/vcr/Marathon_App/_tasks/has_tasks.yml
@@ -202,6 +219,14 @@ files:
202
219
  - fixtures/vcr/Marathon_EventSubscriptions/_list/lists_callbacks.yml
203
220
  - fixtures/vcr/Marathon_EventSubscriptions/_register/registers_callback.yml
204
221
  - fixtures/vcr/Marathon_EventSubscriptions/_unregister/unregisters_callback.yml
222
+ - fixtures/vcr/Marathon_Group/_changes/changes_the_group.yml
223
+ - fixtures/vcr/Marathon_Group/_delete/deletes_the_group.yml
224
+ - fixtures/vcr/Marathon_Group/_delete/fails_deleting_not_existing_app.yml
225
+ - fixtures/vcr/Marathon_Group/_get/fails_getting_not_existing_app.yml
226
+ - fixtures/vcr/Marathon_Group/_get/gets_the_group.yml
227
+ - fixtures/vcr/Marathon_Group/_list/lists_apps.yml
228
+ - fixtures/vcr/Marathon_Group/_start/fails_getting_not_existing_group.yml
229
+ - fixtures/vcr/Marathon_Group/_start/starts_the_group.yml
205
230
  - fixtures/vcr/Marathon_Leader/_delete/delete/.yml
206
231
  - fixtures/vcr/Marathon_Leader/_get/get/.yml
207
232
  - fixtures/vcr/Marathon_Queue/_list/lists_queue.yml
@@ -212,10 +237,19 @@ files:
212
237
  - fixtures/vcr/Marathon_Task/_list/lists_tasks.yml
213
238
  - lib/marathon.rb
214
239
  - lib/marathon/app.rb
240
+ - lib/marathon/base.rb
215
241
  - lib/marathon/connection.rb
242
+ - lib/marathon/constraint.rb
243
+ - lib/marathon/container.rb
244
+ - lib/marathon/container_docker.rb
245
+ - lib/marathon/container_docker_port_mapping.rb
246
+ - lib/marathon/container_volume.rb
216
247
  - lib/marathon/deployment.rb
248
+ - lib/marathon/deployment_info.rb
217
249
  - lib/marathon/error.rb
218
250
  - lib/marathon/event_subscriptions.rb
251
+ - lib/marathon/group.rb
252
+ - lib/marathon/health_check.rb
219
253
  - lib/marathon/leader.rb
220
254
  - lib/marathon/queue.rb
221
255
  - lib/marathon/task.rb
@@ -223,17 +257,26 @@ files:
223
257
  - lib/marathon/version.rb
224
258
  - marathon-api.gemspec
225
259
  - spec/marathon/app_spec.rb
260
+ - spec/marathon/base_spec.rb
226
261
  - spec/marathon/connection_spec.rb
262
+ - spec/marathon/constraint_spec.rb
263
+ - spec/marathon/container_docker_port_mapping_spec.rb
264
+ - spec/marathon/container_docker_spec.rb
265
+ - spec/marathon/container_spec.rb
266
+ - spec/marathon/container_volume_spec.rb
267
+ - spec/marathon/deployment_info_spec.rb
227
268
  - spec/marathon/deployment_spec.rb
228
269
  - spec/marathon/error_spec.rb
229
270
  - spec/marathon/event_subscriptions_spec.rb
271
+ - spec/marathon/group_spec.rb
272
+ - spec/marathon/health_check_spec.rb
230
273
  - spec/marathon/leader_spec.rb
231
274
  - spec/marathon/marathon_spec.rb
232
275
  - spec/marathon/queue_spec.rb
233
276
  - spec/marathon/task_spec.rb
234
277
  - spec/marathon/util_spec.rb
235
278
  - spec/spec_helper.rb
236
- homepage: https://github.com/felixb/marathon-api
279
+ homepage: https://github.com/otto-de/marathon-api
237
280
  licenses:
238
281
  - MIT
239
282
  metadata: {}
@@ -253,16 +296,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
296
  version: '0'
254
297
  requirements: []
255
298
  rubyforge_project:
256
- rubygems_version: 2.2.2
299
+ rubygems_version: 2.4.3
257
300
  signing_key:
258
301
  specification_version: 4
259
302
  summary: A simple REST client for the Marathon Remote API
260
303
  test_files:
261
304
  - spec/marathon/app_spec.rb
305
+ - spec/marathon/base_spec.rb
262
306
  - spec/marathon/connection_spec.rb
307
+ - spec/marathon/constraint_spec.rb
308
+ - spec/marathon/container_docker_port_mapping_spec.rb
309
+ - spec/marathon/container_docker_spec.rb
310
+ - spec/marathon/container_spec.rb
311
+ - spec/marathon/container_volume_spec.rb
312
+ - spec/marathon/deployment_info_spec.rb
263
313
  - spec/marathon/deployment_spec.rb
264
314
  - spec/marathon/error_spec.rb
265
315
  - spec/marathon/event_subscriptions_spec.rb
316
+ - spec/marathon/group_spec.rb
317
+ - spec/marathon/health_check_spec.rb
266
318
  - spec/marathon/leader_spec.rb
267
319
  - spec/marathon/marathon_spec.rb
268
320
  - spec/marathon/queue_spec.rb