rhc 1.1.11 → 1.2.7
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.
- data/features/cartridge.feature +14 -1
- data/features/domain.feature +1 -1
- data/features/lib/rhc_helper.rb +3 -3
- data/features/lib/rhc_helper/app.rb +11 -3
- data/features/lib/rhc_helper/cartridge.rb +8 -0
- data/features/lib/rhc_helper/domain.rb +8 -15
- data/features/lib/rhc_helper/httpify.rb +11 -6
- data/features/lib/rhc_helper/runnable.rb +43 -7
- data/features/sshkey.feature +3 -4
- data/features/step_definitions/application_steps.rb +5 -5
- data/features/step_definitions/cartridge_steps.rb +12 -0
- data/features/step_definitions/client_steps.rb +3 -2
- data/features/step_definitions/sshkey_steps.rb +3 -3
- data/features/support/assumptions.rb +11 -11
- data/features/support/before_hooks.rb +23 -5
- data/features/support/env.rb +14 -4
- data/lib/rhc-common.rb +5 -2
- data/lib/rhc/cartridge_helpers.rb +7 -1
- data/lib/rhc/command_runner.rb +8 -4
- data/lib/rhc/commands.rb +6 -0
- data/lib/rhc/commands/app.rb +15 -7
- data/lib/rhc/commands/base.rb +3 -3
- data/lib/rhc/commands/cartridge.rb +78 -2
- data/lib/rhc/commands/port-forward.rb +137 -24
- data/lib/rhc/exceptions.rb +23 -8
- data/lib/rhc/helpers.rb +25 -4
- data/lib/rhc/output_helpers.rb +23 -0
- data/lib/rhc/rest.rb +38 -19
- data/lib/rhc/rest/base.rb +7 -3
- data/lib/rhc/rest/cartridge.rb +10 -1
- data/lib/rhc/usage_templates/command_help.erb +12 -12
- data/lib/rhc/usage_templates/command_syntax_help.erb +1 -1
- data/lib/rhc/usage_templates/help.erb +3 -3
- data/lib/rhc/usage_templates/missing_help.erb +1 -1
- data/lib/rhc/version.rb +1 -5
- data/lib/rhc/wizard.rb +4 -32
- data/spec/rest_spec_helper.rb +18 -4
- data/spec/rhc/commands/cartridge_spec.rb +91 -0
- data/spec/rhc/commands/domain_spec.rb +6 -2
- data/spec/rhc/commands/port-forward_spec.rb +95 -54
- data/spec/rhc/commands/snapshot_spec.rb +5 -0
- data/spec/rhc/rest_spec.rb +23 -2
- data/spec/rhc/wizard_spec.rb +9 -12
- data/spec/spec_helper.rb +5 -0
- metadata +228 -224
data/spec/rest_spec_helper.rb
CHANGED
@@ -111,6 +111,8 @@ module RestSpecHelper
|
|
111
111
|
carts << {
|
112
112
|
:name => "mock_cart_#{carts.length}",
|
113
113
|
:type => "mock_cart_#{carts.length}_type",
|
114
|
+
:base_gear_storage => 1,
|
115
|
+
:additional_gear_storage => 0,
|
114
116
|
:links => mock_response_links(mock_cart_links('mock_domain','mock_app',"mock_cart_#{carts.length}"))
|
115
117
|
}
|
116
118
|
end
|
@@ -140,6 +142,10 @@ module RestSpecHelper
|
|
140
142
|
}
|
141
143
|
end
|
142
144
|
|
145
|
+
def mock_cart_properties
|
146
|
+
{:cart_data => {:connection_url => {'name' => 'connection_url', 'value' => "http://fake.url" }}}
|
147
|
+
end
|
148
|
+
|
143
149
|
class MockRestClient < RHC::Rest::Client
|
144
150
|
def initialize
|
145
151
|
RHC::Rest::Client.stub(:new) { self }
|
@@ -286,9 +292,9 @@ module RestSpecHelper
|
|
286
292
|
@domain.applications.delete self
|
287
293
|
end
|
288
294
|
|
289
|
-
def add_cartridge(name, embedded=true)
|
295
|
+
def add_cartridge(name, embedded=true, additional_storage=0)
|
290
296
|
type = embedded ? "embedded" : "standalone"
|
291
|
-
c = MockRestCartridge.new(name, type, self)
|
297
|
+
c = MockRestCartridge.new(name, type, self, mock_cart_properties, additional_storage)
|
292
298
|
@cartridges << c
|
293
299
|
c
|
294
300
|
end
|
@@ -324,9 +330,10 @@ module RestSpecHelper
|
|
324
330
|
end
|
325
331
|
|
326
332
|
class MockRestCartridge < RHC::Rest::Cartridge
|
327
|
-
attr_accessor :scales_to, :scales_from, :current_scale, :scales_with, :display_name
|
328
|
-
def initialize(name, type, app=nil, properties=
|
333
|
+
attr_accessor :scales_to, :scales_from, :current_scale, :scales_with, :display_name, :base_gear_storage, :additional_gear_storage
|
334
|
+
def initialize(name, type, app=nil, properties=mock_cart_properties, additional_storage=0)
|
329
335
|
@name = name
|
336
|
+
@display_name = name
|
330
337
|
@type = type
|
331
338
|
@app = app
|
332
339
|
@properties = properties
|
@@ -334,6 +341,8 @@ module RestSpecHelper
|
|
334
341
|
@scales_from = 1
|
335
342
|
@scales_to = 1
|
336
343
|
@current_scale = 1
|
344
|
+
@base_gear_storage = 1
|
345
|
+
@additional_gear_storage = additional_storage
|
337
346
|
end
|
338
347
|
|
339
348
|
def destroy
|
@@ -369,6 +378,11 @@ module RestSpecHelper
|
|
369
378
|
@scales_to = values[:scales_to] if values[:scales_to]
|
370
379
|
self
|
371
380
|
end
|
381
|
+
|
382
|
+
def set_storage(values)
|
383
|
+
@additional_gear_storage = values[:additional_storage]
|
384
|
+
self
|
385
|
+
end
|
372
386
|
end
|
373
387
|
|
374
388
|
class MockRestKey < RHC::Rest::Key
|
@@ -346,4 +346,95 @@ describe RHC::Commands::Cartridge do
|
|
346
346
|
end
|
347
347
|
end
|
348
348
|
end
|
349
|
+
|
350
|
+
=begin
|
351
|
+
# Commenting this out for US2438
|
352
|
+
describe 'cartridge storage' do
|
353
|
+
let(:cmd_base) { ['cartridge', 'storage'] }
|
354
|
+
let(:std_args) { ['-a', 'app1', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] | (@extra_args || []) }
|
355
|
+
let(:cart_type) { ['mock_cart-1'] }
|
356
|
+
|
357
|
+
before(:each) do
|
358
|
+
@rc = MockRestClient.new
|
359
|
+
domain = @rc.add_domain("mock_domain")
|
360
|
+
app = domain.add_application("app1", "mock_type", false)
|
361
|
+
app.add_cartridge('mock_cart-1', true, 5)
|
362
|
+
end
|
363
|
+
|
364
|
+
context 'when run with no arguments' do
|
365
|
+
let(:arguments) { cmd_base | std_args }
|
366
|
+
it "should show a list of storage info for all carts" do
|
367
|
+
run_output.should match('mock_type')
|
368
|
+
run_output.should match('mock_cart-1')
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
context 'when run for a non-existent cartridge' do
|
373
|
+
let(:arguments) { cmd_base | ['bogus_cart'] | std_args }
|
374
|
+
it { fail_with_message("Cartridge bogus_cart can't be found in application", 154) }
|
375
|
+
end
|
376
|
+
|
377
|
+
context 'when run with -c flag' do
|
378
|
+
let(:arguments) { cmd_base | ['-c', 'mock_cart-1'] | std_args}
|
379
|
+
it "should show storage info for the indicated app and cart" do
|
380
|
+
run_output.should match('mock_cart-1')
|
381
|
+
run_output.should_not match('mock_type')
|
382
|
+
end
|
383
|
+
|
384
|
+
it "should set storage for the indicated app and cart" do
|
385
|
+
@extra_args = ["--set", "6GB"]
|
386
|
+
run_output.should match('6GB')
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
context 'when run with valid arguments' do
|
391
|
+
let(:arguments) { cmd_base | cart_type | std_args }
|
392
|
+
it "should show storage info for the indicated app and cart" do
|
393
|
+
@extra_args = ["--show"]
|
394
|
+
run_output.should match('mock_cart-1')
|
395
|
+
run_output.should_not match('mock_type')
|
396
|
+
end
|
397
|
+
it "should add storage for the indicated app and cart" do
|
398
|
+
@extra_args = ["--add", "5GB"]
|
399
|
+
run_output.should match('10GB')
|
400
|
+
end
|
401
|
+
it "should remove storage for the indicated app and cart" do
|
402
|
+
@extra_args = ["--remove", "5GB"]
|
403
|
+
run_output.should match('None')
|
404
|
+
end
|
405
|
+
it "should warn when told to remove more storage than the indicated app and cart have" do
|
406
|
+
@extra_args = ["--remove", "70GB"]
|
407
|
+
fail_with_message('The amount of additional storage to be removed exceeds the total amount in use')
|
408
|
+
end
|
409
|
+
it "should not warn when told to remove more storage than the indicated app and cart have when forced" do
|
410
|
+
@extra_args = ["--remove", "70GB", "--force"]
|
411
|
+
run_output.should match('None')
|
412
|
+
end
|
413
|
+
it "should set storage for the indicated app and cart" do
|
414
|
+
@extra_args = ["--set", "6GB"]
|
415
|
+
run_output.should match('6GB')
|
416
|
+
end
|
417
|
+
it "should work correctly with a bare number value" do
|
418
|
+
@extra_args = ["--set", "6"]
|
419
|
+
run_output.should match('6GB')
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
context 'when run with invalid arguments' do
|
424
|
+
let(:arguments) { cmd_base | cart_type | std_args }
|
425
|
+
it "should raise an error when multiple storage operations are provided" do
|
426
|
+
@extra_args = ["--show", "--add", "5GB"]
|
427
|
+
fail_with_message('Only one storage action can be performed at a time')
|
428
|
+
end
|
429
|
+
it "should raise an error when the storage amount is not provided" do
|
430
|
+
@extra_args = ["--set"]
|
431
|
+
fail_with_message('missing argument')
|
432
|
+
end
|
433
|
+
it "should raise an error when the storage amount is invalid" do
|
434
|
+
@extra_args = ["--set", "5ZB"]
|
435
|
+
fail_with_message("The amount format must be a number, optionally followed by 'GB'")
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end
|
439
|
+
=end
|
349
440
|
end
|
@@ -9,15 +9,19 @@ describe RHC::Commands::Domain do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe 'default action' do
|
12
|
-
let(:arguments) { ['domain', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
13
|
-
|
14
12
|
context 'when run with no domains' do
|
13
|
+
let(:arguments) { ['domain', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password'] }
|
15
14
|
before(:each) do
|
16
15
|
@rc = MockRestClient.new
|
17
16
|
end
|
18
17
|
it { expect { run }.should exit_with_code(0) }
|
19
18
|
it { run_output.should match(/No domain exists. You can use/) }
|
20
19
|
end
|
20
|
+
context 'when help is shown' do
|
21
|
+
let(:arguments) { ['domain', '--noprompt', '--help'] }
|
22
|
+
it { expect { run }.should exit_with_code(0) }
|
23
|
+
it { run_output.should match(/The default action for this resource is 'show'/) }
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
describe 'show' do
|
@@ -12,32 +12,32 @@ describe RHC::Commands::PortForward do
|
|
12
12
|
describe 'run' do
|
13
13
|
let(:arguments) { ['port-forward', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password', '--app', 'mockapp'] }
|
14
14
|
|
15
|
-
|
15
|
+
before :each do
|
16
|
+
@rc = MockRestClient.new
|
17
|
+
@domain = @rc.add_domain("mockdomain")
|
18
|
+
@app = @domain.add_application 'mockapp', 'mock-1.0'
|
19
|
+
@uri = URI.parse @app.ssh_url
|
20
|
+
@ssh = mock(Net::SSH)
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when port forwarding for a down appl' do
|
16
24
|
before(:each) do
|
17
|
-
@
|
18
|
-
|
19
|
-
|
25
|
+
Net::SSH.should_receive(:start).with(@uri.host, @uri.user).and_yield(@ssh)
|
26
|
+
@ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, '127.0.0.1:3306')
|
27
|
+
@gg = MockRestGearGroup.new
|
28
|
+
@app.should_receive(:gear_groups).and_return([@gg])
|
29
|
+
@gg.should_receive(:gears).and_return([{'state' => 'stopped', 'id' => 'fakegearid'}])
|
20
30
|
end
|
21
|
-
it "should error out" do
|
22
|
-
expect { run }.should exit_with_code(
|
23
|
-
end
|
24
|
-
it "should match the app state" do
|
25
|
-
@rc.domains[0].id.should == 'mockdomain'
|
26
|
-
@rc.domains[0].applications.size.should == 1
|
27
|
-
@rc.domains[0].applications[0].name.should == 'mockapp'
|
31
|
+
it "should error out and suggest restarting the application" do
|
32
|
+
expect { run }.should exit_with_code(1)
|
28
33
|
end
|
29
|
-
it { run_output.should match(
|
34
|
+
it { run_output.should match(/Application \S+ is stopped\..*restart/m) }
|
30
35
|
end
|
31
36
|
|
32
37
|
context 'when port forwarding an app without ports to forward' do
|
33
38
|
before(:each) do
|
34
|
-
@
|
35
|
-
|
36
|
-
app = domain.add_application 'mockapp', 'mock-1.0'
|
37
|
-
uri = URI.parse app.ssh_url
|
38
|
-
ssh = mock(Net::SSH)
|
39
|
-
Net::SSH.should_receive(:start).with(uri.host, uri.user).and_yield(ssh)
|
40
|
-
ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, '127.0.0.1:3306')
|
39
|
+
Net::SSH.should_receive(:start).with(@uri.host, @uri.user).and_yield(@ssh)
|
40
|
+
@ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, '127.0.0.1:3306')
|
41
41
|
end
|
42
42
|
it "should error out as no ports to forward" do
|
43
43
|
expect { run }.should exit_with_code(102)
|
@@ -50,13 +50,8 @@ describe RHC::Commands::PortForward do
|
|
50
50
|
|
51
51
|
context 'when port forwarding an app with permission denied ports' do
|
52
52
|
before(:each) do
|
53
|
-
@
|
54
|
-
|
55
|
-
app = domain.add_application 'mockapp', 'mock-1.0'
|
56
|
-
ssh = mock(Net::SSH)
|
57
|
-
uri = URI.parse app.ssh_url
|
58
|
-
Net::SSH.should_receive(:start).with(uri.host, uri.user).and_yield(ssh)
|
59
|
-
ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, 'permission denied')
|
53
|
+
Net::SSH.should_receive(:start).with(@uri.host, @uri.user).and_yield(@ssh)
|
54
|
+
@ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, 'permission denied')
|
60
55
|
end
|
61
56
|
it "should error out as permission denied" do
|
62
57
|
expect { run }.should exit_with_code(129)
|
@@ -69,34 +64,31 @@ describe RHC::Commands::PortForward do
|
|
69
64
|
|
70
65
|
context 'when port forwarding an app with ports to forward' do
|
71
66
|
before(:each) do
|
72
|
-
@
|
73
|
-
|
74
|
-
app = domain.add_application 'mockapp', 'mock-1.0'
|
75
|
-
ssh = mock(Net::SSH)
|
76
|
-
uri = URI.parse app.ssh_url
|
77
|
-
Net::SSH.should_receive(:start).with(uri.host, uri.user).and_yield(ssh).twice
|
78
|
-
ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stdout, '127.0.0.1:3306')
|
67
|
+
Net::SSH.should_receive(:start).with(@uri.host, @uri.user).and_yield(@ssh).twice
|
68
|
+
@ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, 'mysql -> 127.0.0.1:3306')
|
79
69
|
forward = mock(Net::SSH::Service::Forward)
|
80
|
-
ssh.should_receive(:forward).and_return(forward)
|
81
|
-
|
82
|
-
|
70
|
+
@ssh.should_receive(:forward).and_return(forward)
|
71
|
+
if mac?
|
72
|
+
forward.should_receive(:local).with(3306, '127.0.0.1', 3306)
|
73
|
+
else
|
74
|
+
forward.should_receive(:local).with('127.0.0.1', 3306, '127.0.0.1', 3306)
|
75
|
+
end
|
76
|
+
@ssh.should_receive(:loop)
|
83
77
|
end
|
84
|
-
it "should
|
78
|
+
it "should run successfully" do
|
85
79
|
expect { run }.should exit_with_code(0)
|
86
80
|
@rc.domains[0].id.should == 'mockdomain'
|
87
81
|
@rc.domains[0].applications.size.should == 1
|
88
82
|
@rc.domains[0].applications[0].name.should == 'mockapp'
|
89
83
|
end
|
90
|
-
it { run_output.should
|
84
|
+
it { run_output.should match(/Forwarding ports.*Press CTRL-C/m) }
|
91
85
|
end
|
92
86
|
|
93
|
-
context 'when
|
87
|
+
context 'when host is unreachable' do
|
94
88
|
before(:each) do
|
95
|
-
|
96
|
-
domain = @rc.add_domain("mockdomain")
|
97
|
-
app = domain.add_application 'mockapp', 'mock-1.0'
|
89
|
+
Net::SSH.should_receive(:start).and_raise(Errno::EHOSTUNREACH)
|
98
90
|
end
|
99
|
-
it "should error out
|
91
|
+
it "should error out" do
|
100
92
|
expect { run }.should exit_with_code(1)
|
101
93
|
@rc.domains[0].id.should == 'mockdomain'
|
102
94
|
@rc.domains[0].applications.size.should == 1
|
@@ -105,19 +97,28 @@ describe RHC::Commands::PortForward do
|
|
105
97
|
it { run_output.should include("Error trying to forward ports.") }
|
106
98
|
end
|
107
99
|
|
100
|
+
context 'when REST client connection times out' do
|
101
|
+
before(:each) do
|
102
|
+
@rc.should_receive(:find_domain).and_raise(RestClient::ServerBrokeConnection)
|
103
|
+
end
|
104
|
+
it "should error out" do
|
105
|
+
expect { run }.should exit_with_code(1)
|
106
|
+
end
|
107
|
+
it { run_output.should match("Connection.*failed:") }
|
108
|
+
end
|
109
|
+
|
108
110
|
context 'when port forwarding an app with ports to forward' do
|
109
111
|
before(:each) do
|
110
|
-
@
|
111
|
-
|
112
|
-
app = domain.add_application 'mockapp', 'mock-1.0'
|
113
|
-
ssh = mock(Net::SSH)
|
114
|
-
uri = URI.parse app.ssh_url
|
115
|
-
Net::SSH.should_receive(:start).with(uri.host, uri.user).and_yield(ssh).twice
|
116
|
-
ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stdout, '127.0.0.1:3306')
|
112
|
+
Net::SSH.should_receive(:start).with(@uri.host, @uri.user).and_yield(@ssh).twice
|
113
|
+
@ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, 'mysql -> 127.0.0.1:3306')
|
117
114
|
forward = mock(Net::SSH::Service::Forward)
|
118
|
-
ssh.should_receive(:forward).and_return(forward)
|
119
|
-
|
120
|
-
|
115
|
+
@ssh.should_receive(:forward).and_return(forward)
|
116
|
+
if mac?
|
117
|
+
forward.should_receive(:local).with(3306, '127.0.0.1', 3306)
|
118
|
+
else
|
119
|
+
forward.should_receive(:local).with('127.0.0.1', 3306, '127.0.0.1', 3306)
|
120
|
+
end
|
121
|
+
@ssh.should_receive(:loop).and_raise(Interrupt.new)
|
121
122
|
end
|
122
123
|
it "should exit when user interrupts" do
|
123
124
|
expect { run }.should exit_with_code(0)
|
@@ -128,6 +129,46 @@ describe RHC::Commands::PortForward do
|
|
128
129
|
it { run_output.should include("Ending port forward") }
|
129
130
|
end
|
130
131
|
|
131
|
-
|
132
|
+
context 'when host refuses connection' do
|
133
|
+
before(:each) do
|
134
|
+
Net::SSH.should_receive(:start).with(@uri.host, @uri.user).and_yield(@ssh).twice
|
135
|
+
@ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, 'mysql -> 127.0.0.1:3306')
|
136
|
+
forward = mock(Net::SSH::Service::Forward)
|
137
|
+
@ssh.should_receive(:forward).and_raise(Errno::ECONNREFUSED)
|
138
|
+
end
|
139
|
+
it "should error out" do
|
140
|
+
expect { run }.should exit_with_code(0)
|
141
|
+
end
|
142
|
+
it { run_output.should include("ssh -N") }
|
143
|
+
it { run_output.should include("Error forwarding") }
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'when port forwarding a scaled app with ports to forward' do
|
147
|
+
before(:each) do
|
148
|
+
Net::SSH.should_receive(:start).with(@uri.host, @uri.user).and_yield(@ssh).twice
|
149
|
+
@ssh.should_receive(:exec!).with("rhc-list-ports").and_yield(nil, :stderr, "httpd -> 127.0.0.1:8080\nhttpd -> 127.0.0.2:8080")
|
150
|
+
forward = mock(Net::SSH::Service::Forward)
|
151
|
+
@ssh.should_receive(:forward).at_least(3).times.and_return(forward)
|
152
|
+
if mac?
|
153
|
+
forward.should_receive(:local).with(8080, '127.0.0.1', 8080)
|
154
|
+
forward.should_receive(:local).with(8080, '127.0.0.2', 8080).and_raise(Errno::EADDRINUSE)
|
155
|
+
forward.should_receive(:local).with(8081, '127.0.0.2', 8080)
|
156
|
+
else
|
157
|
+
forward.should_receive(:local).with('127.0.0.1', 8080, '127.0.0.1', 8080)
|
158
|
+
forward.should_receive(:local).with('127.0.0.2', 8080, '127.0.0.2', 8080).and_raise(Errno::EADDRINUSE)
|
159
|
+
forward.should_receive(:local).with('127.0.0.2', 8081, '127.0.0.2', 8080)
|
160
|
+
end
|
161
|
+
@ssh.should_receive(:loop).and_raise(Interrupt.new)
|
162
|
+
end
|
163
|
+
it "should exit when user interrupts" do
|
164
|
+
expect { run }.should exit_with_code(0)
|
165
|
+
@rc.domains[0].id.should == 'mockdomain'
|
166
|
+
@rc.domains[0].applications.size.should == 1
|
167
|
+
@rc.domains[0].applications[0].name.should == 'mockapp'
|
168
|
+
end
|
169
|
+
it { run_output.should include("Ending port forward") }
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
132
173
|
end
|
133
174
|
|
@@ -21,6 +21,11 @@ describe RHC::Commands::Snapshot do
|
|
21
21
|
File.delete filename if File.exist? filename
|
22
22
|
end
|
23
23
|
|
24
|
+
describe 'snapshot without an action' do
|
25
|
+
let(:arguments) {['snapshot', '--trace', '--noprompt']}
|
26
|
+
it('should raise') { expect{ run }.should raise_error(ArgumentError, /Please specify an action to take/) }
|
27
|
+
end
|
28
|
+
|
24
29
|
describe 'snapshot save' do
|
25
30
|
let(:arguments) {['snapshot', 'save', '--noprompt', '--config', 'test.conf', '-l', 'test@test.foo', '-p', 'password', '--app', 'mockapp']}
|
26
31
|
|
data/spec/rhc/rest_spec.rb
CHANGED
@@ -2,9 +2,14 @@ require 'spec_helper'
|
|
2
2
|
require 'rest_spec_helper'
|
3
3
|
require 'rhc/rest'
|
4
4
|
|
5
|
-
# We have to make an object to test the RHC::Rest module
|
6
5
|
class RHCRest
|
7
6
|
include RHC::Rest
|
7
|
+
def debug?
|
8
|
+
false
|
9
|
+
end
|
10
|
+
def debug
|
11
|
+
raise "Unchecked debug"
|
12
|
+
end
|
8
13
|
end
|
9
14
|
|
10
15
|
module MockRestResponse
|
@@ -264,6 +269,22 @@ module RHC
|
|
264
269
|
end
|
265
270
|
end
|
266
271
|
|
272
|
+
context "with a 502 (Bad Gateway) error" do
|
273
|
+
before{ stub_request(method, mock_href).to_return(:status => 502) }
|
274
|
+
let(:req){ RestClient::Request.new(:url => mock_href, :method => method) }
|
275
|
+
let(:method){ :get }
|
276
|
+
|
277
|
+
it("should make two requests"){ subject.request(req) rescue nil; WebMock.should have_requested(method, mock_href).twice }
|
278
|
+
it{ expect{ subject.request(req) }.should raise_error(RHC::Rest::ConnectionException, /communicating with the server.*temporary/i) }
|
279
|
+
|
280
|
+
context "on a POST request" do
|
281
|
+
let(:method){ :post }
|
282
|
+
|
283
|
+
it("should make one request"){ subject.request(req) rescue nil; WebMock.should have_requested(method, mock_href).once }
|
284
|
+
it{ expect{ subject.request(req) }.should raise_error(RHC::Rest::ConnectionException, /communicating with the server.*temporary/i) }
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
267
288
|
context "with a request timeout" do
|
268
289
|
before do
|
269
290
|
stub_request(:get, mock_href).to_timeout
|
@@ -273,7 +294,7 @@ module RHC
|
|
273
294
|
:method => 'get',
|
274
295
|
:headers => {:accept => :json}
|
275
296
|
)
|
276
|
-
lambda { subject.request(request) }.should raise_error(RHC::Rest::TimeoutException,
|
297
|
+
lambda { subject.request(request) }.should raise_error(RHC::Rest::TimeoutException, /Connection to server timed out. It is possible/)
|
277
298
|
end
|
278
299
|
end
|
279
300
|
|
data/spec/rhc/wizard_spec.rb
CHANGED
@@ -26,9 +26,8 @@ describe RHC::Wizard do
|
|
26
26
|
it "should print out first run greeting" do
|
27
27
|
@wizard.run_next_stage
|
28
28
|
greeting = $terminal.read
|
29
|
-
greeting.count("\n").should >=
|
30
|
-
greeting.should match(
|
31
|
-
greeting.should match(Regexp.escape("\n#{@wizard.config_path}\n"))
|
29
|
+
greeting.count("\n").should >= 3
|
30
|
+
greeting.should match(/OpenShift Client Tools \(RHC\) Setup Wizard/)
|
32
31
|
end
|
33
32
|
|
34
33
|
it "should ask for login and hide password input" do
|
@@ -41,8 +40,8 @@ describe RHC::Wizard do
|
|
41
40
|
@wizard.run_next_stage
|
42
41
|
|
43
42
|
output = $terminal.read
|
44
|
-
output.should match("
|
45
|
-
output.should
|
43
|
+
output.should match("Login to ")
|
44
|
+
output.should match(/Password: [\*]{8}$/)
|
46
45
|
end
|
47
46
|
|
48
47
|
it "should write out a config" do
|
@@ -111,9 +110,7 @@ describe RHC::Wizard do
|
|
111
110
|
it "should print out repeat run greeting" do
|
112
111
|
@wizard.run_next_stage
|
113
112
|
greeting = $terminal.read
|
114
|
-
greeting.
|
115
|
-
greeting.should match(Regexp.escape("Starting Interactive Setup for OpenShift's command line interface"))
|
116
|
-
greeting.should match(Regexp.escape("#{@wizard.config_path}\n"))
|
113
|
+
greeting.should match(/OpenShift Client Tools \(RHC\) Setup Wizard/)
|
117
114
|
end
|
118
115
|
|
119
116
|
it "should ask for login and hide password input" do
|
@@ -124,8 +121,8 @@ describe RHC::Wizard do
|
|
124
121
|
@wizard.run_next_stage
|
125
122
|
|
126
123
|
output = $terminal.read
|
127
|
-
output.should match("
|
128
|
-
output.should
|
124
|
+
output.should match("Login to ")
|
125
|
+
output.should match(/Password: [\*]{8}$/)
|
129
126
|
end
|
130
127
|
|
131
128
|
it "should write out a config" do
|
@@ -432,8 +429,8 @@ describe RHC::Wizard do
|
|
432
429
|
@wizard.run_next_stage
|
433
430
|
|
434
431
|
output = $terminal.read
|
435
|
-
output.should match("
|
436
|
-
output.should
|
432
|
+
output.should match("Login to ")
|
433
|
+
output.should match(/Password: [\*]{8}$/)
|
437
434
|
end
|
438
435
|
|
439
436
|
it "should write out a config" do
|