aptible-cli 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9eee8bccf78fd7a0814d5fb48e92c9c31aaef356
4
- data.tar.gz: 80d7cf361bba1d14c1c50ab1f832de3c46533e72
3
+ metadata.gz: ed6d33fb4df228f78616e5a2a612584c1595fbce
4
+ data.tar.gz: 4795a89a24e7108ed2ee2c8eb590d331fbd4ecc6
5
5
  SHA512:
6
- metadata.gz: 6c51adcf6c82f63b5129674a82070235d6ab079c7ed91fc8b02771ba81f8e243a459d39cf80135687797a6576320942a7ec767a5bec78bfc5155bfacdfca5caf
7
- data.tar.gz: 2c5ccc49276560307c75d5dff6b6504d87b6f77a4bf9b820910c37900b65059e341ef2676e888870ffca0dbc9ae503ad82d328be7d93f16866b45605330cf78a
6
+ metadata.gz: 7d3e19769ee760b39e9d0fe388fdfa2a8c2dac97b78678758ecaacc467989982a34c993f9d606d09388053a8c7a3c1552b693896945ac596cc668896fc93325c
7
+ data.tar.gz: 77b04483d2f82409cbc2c03ba05e0fa66b7041bfaf72646335064a305ebaa2ed3f65c9128d7345f8e76c6a726a3313e1ad690721bef5f804ffffd6a77dbd7529
@@ -8,10 +8,34 @@ module Aptible
8
8
  include Helpers::App
9
9
 
10
10
  desc 'restart', 'Restart all services associated with an app'
11
+ option :simulate_oom,
12
+ type: :boolean,
13
+ desc: 'Add this flag to simulate an OOM restart and test ' \
14
+ "your app's response (not recommended on production " \
15
+ 'apps).'
16
+ option :force,
17
+ type: :boolean,
18
+ desc: 'Add this flag to use --simulate-oom in a ' \
19
+ 'production environment, which is not allowed by ' \
20
+ 'default.'
11
21
  app_options
12
22
  def restart
13
23
  app = ensure_app(options)
14
- operation = app.create_operation!(type: 'restart')
24
+ type = 'restart'
25
+
26
+ if options[:simulate_oom]
27
+ type = 'captain_comeback_restart'
28
+
29
+ if app.account.type == 'production' && !options[:force]
30
+ e = 'This operation is designed for test purposes only, ' \
31
+ "but #{app.handle} is deployed in a production " \
32
+ 'environment. Are you sure you want to do this? If ' \
33
+ 'so, use the --force flag.'
34
+ fail Thor::Error, e
35
+ end
36
+ end
37
+
38
+ operation = app.create_operation!(type: type)
15
39
  puts 'Restarting app...'
16
40
  attach_to_operation_logs(operation)
17
41
  end
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module CLI
3
- VERSION = '0.7.2'.freeze
3
+ VERSION = '0.7.3'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Aptible::CLI::Agent do
4
+ let(:app) { Fabricate(:app) }
5
+ let(:operation) { Fabricate(:operation, resource: app) }
6
+ before { allow(subject).to receive(:ensure_app).and_return(app) }
7
+
8
+ describe '#restart' do
9
+ it 'restarts the app' do
10
+ expect(app).to receive(:create_operation!).with(type: 'restart')
11
+ .and_return(operation)
12
+ expect(subject).to receive(:attach_to_operation_logs).with(operation)
13
+
14
+ subject.send('restart')
15
+ end
16
+
17
+ it 'does not require the --force flag for a regular restart' do
18
+ app.account.type = 'production'
19
+ expect(app).to receive(:create_operation!)
20
+ expect(subject).to receive(:attach_to_operation_logs)
21
+
22
+ subject.send('restart')
23
+ end
24
+
25
+ it 'uses captain_comeback_restart if --simulate-oom is passed' do
26
+ subject.options = { simulate_oom: true }
27
+ expect(app).to receive(:create_operation!)
28
+ .with(type: 'captain_comeback_restart')
29
+ .and_return(operation)
30
+ expect(subject).to receive(:attach_to_operation_logs).with(operation)
31
+
32
+ subject.send('restart')
33
+ end
34
+
35
+ it 'fails a CC restart if the --force flag is not passed for a prod app' do
36
+ subject.options = { simulate_oom: true }
37
+ app.account.type = 'production'
38
+ expect(app).not_to receive(:create_operation!)
39
+ expect(subject).not_to receive(:attach_to_operation_logs)
40
+
41
+ expect { subject.send('restart') }.to raise_error(/are you sure/i)
42
+ end
43
+
44
+ it 'creates a CC restart if the --force flag is passed for a prod app' do
45
+ subject.options = { simulate_oom: true, force: true }
46
+ app.account.type = 'production'
47
+ expect(app).to receive(:create_operation!)
48
+ expect(subject).to receive(:attach_to_operation_logs)
49
+
50
+ subject.send('restart')
51
+ end
52
+ end
53
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-12 00:00:00.000000000 Z
11
+ date: 2016-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-api
@@ -256,6 +256,7 @@ files:
256
256
  - spec/aptible/cli/subcommands/domains_spec.rb
257
257
  - spec/aptible/cli/subcommands/logs_spec.rb
258
258
  - spec/aptible/cli/subcommands/ps_spec.rb
259
+ - spec/aptible/cli/subcommands/restart_spec.rb
259
260
  - spec/fabricators/account_fabricator.rb
260
261
  - spec/fabricators/app_fabricator.rb
261
262
  - spec/fabricators/backup_fabricator.rb
@@ -304,6 +305,7 @@ test_files:
304
305
  - spec/aptible/cli/subcommands/domains_spec.rb
305
306
  - spec/aptible/cli/subcommands/logs_spec.rb
306
307
  - spec/aptible/cli/subcommands/ps_spec.rb
308
+ - spec/aptible/cli/subcommands/restart_spec.rb
307
309
  - spec/fabricators/account_fabricator.rb
308
310
  - spec/fabricators/app_fabricator.rb
309
311
  - spec/fabricators/backup_fabricator.rb