rhc 1.16.9 → 1.17.6
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/core_feature.rb +33 -1
- data/features/domains_feature.rb +9 -0
- data/lib/rhc/cartridge_helpers.rb +1 -1
- data/lib/rhc/commands/cartridge.rb +6 -1
- data/lib/rhc/commands/domain.rb +9 -5
- data/lib/rhc/commands/server.rb +1 -1
- data/lib/rhc/deployment_helpers.rb +28 -5
- data/lib/rhc/exceptions.rb +6 -0
- data/lib/rhc/rest/application.rb +7 -0
- data/lib/rhc/rest/cartridge.rb +1 -1
- data/lib/rhc/rest/mock.rb +4 -3
- data/spec/direct_execution_helper.rb +17 -1
- data/spec/rhc/commands/cartridge_spec.rb +45 -1
- data/spec/rhc/commands/deployment_spec.rb +45 -4
- data/spec/rhc/commands/domain_spec.rb +18 -0
- metadata +5 -5
data/features/core_feature.rb
CHANGED
@@ -45,7 +45,7 @@ describe "rhc core scenarios" do
|
|
45
45
|
|
46
46
|
context "when creating an app" do
|
47
47
|
when_running 'create-app', 'test1', a_web_cartridge
|
48
|
-
before{ no_applications
|
48
|
+
before{ no_applications }
|
49
49
|
it "returns the proper info and is in the rest api" do
|
50
50
|
status.should == 0
|
51
51
|
output.should match "Your application 'test1' is now available"
|
@@ -146,4 +146,36 @@ describe "rhc core scenarios" do
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|
149
|
+
|
150
|
+
context "when adding a cartridge" do
|
151
|
+
context "with a scalable app" do
|
152
|
+
before(:all) do
|
153
|
+
standard_config
|
154
|
+
@app = has_a_scalable_application
|
155
|
+
end
|
156
|
+
|
157
|
+
after(:all) do
|
158
|
+
debug.puts "cleaning up scalable app" if debug?
|
159
|
+
@app.destroy
|
160
|
+
end
|
161
|
+
|
162
|
+
let(:app){ @app }
|
163
|
+
|
164
|
+
it "should add a cartridge with small gear size" do
|
165
|
+
cartridge = a_random_cartridge(['embedded', 'service', 'database'])
|
166
|
+
r = rhc 'add-cartridge', cartridge, '-a', app.name, '--gear-size', 'small'
|
167
|
+
r.stdout.should match /#{cartridge}/
|
168
|
+
r.stdout.should match /Gears:\s+1 small/
|
169
|
+
r.status.should == 0
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should fail for a cartridge with not allowed gear size" do
|
173
|
+
cartridge = a_random_cartridge(['embedded', 'service', 'database'])
|
174
|
+
r = rhc 'add-cartridge', cartridge, '-a', app.name, '--gear-size', 'medium'
|
175
|
+
r.stdout.should match "The gear size 'medium' is not valid for this domain. Allowed sizes: small."
|
176
|
+
r.status.should_not == 0
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
149
181
|
end
|
data/features/domains_feature.rb
CHANGED
@@ -34,12 +34,21 @@ describe "rhc domain scenarios" do
|
|
34
34
|
|
35
35
|
it "should reject invalid gear size configuration changes" do
|
36
36
|
all_sizes = client.user.capabilities.gear_sizes
|
37
|
+
valid_sizes = client.api.links['ADD_DOMAIN']['optional_params'].inject([]) {|sizes, p| sizes += p['valid_options'] if p['name'] == 'allowed_gear_sizes' } rescue []
|
38
|
+
disallowed_sizes = valid_sizes - all_sizes
|
37
39
|
|
38
40
|
r = rhc 'configure-domain', domain.name, '--allowed-gear-sizes', '_not_a_size_'
|
39
41
|
r.status.should_not == 1
|
40
42
|
r.stdout.should match "Updating domain configuration.*The following gear sizes are invalid: _not_a_size_"
|
41
43
|
client.reset.find_domain(domain.name).allowed_gear_sizes.should == all_sizes
|
42
44
|
|
45
|
+
if disallowed_sizes.first
|
46
|
+
r = rhc 'configure-domain', domain.name, '--allowed-gear-sizes', disallowed_sizes.first
|
47
|
+
r.status.should_not == 1
|
48
|
+
r.stdout.should match "Updating domain configuration.*The following gear sizes are not available.*: #{disallowed_sizes.first}"
|
49
|
+
client.reset.find_domain(domain.name).allowed_gear_sizes.should == all_sizes
|
50
|
+
end
|
51
|
+
|
43
52
|
r = rhc 'configure-domain', domain.name, '--allowed-gear-sizes'
|
44
53
|
r.status.should_not == 1
|
45
54
|
r.stdout.should match "invalid option: Provide a comma delimited .* --allowed-gear-sizes"
|
@@ -51,7 +51,7 @@ module RHC
|
|
51
51
|
].compact.any?{ |s| s.present? && s.downcase.gsub(/[_\-\s]/,' ').include?(search) } ||
|
52
52
|
search.length > 2 && [
|
53
53
|
cart.description
|
54
|
-
].compact.any?{ |s| s.present? && !s.downcase.match(/\b#{search}\b/).nil? }
|
54
|
+
].compact.any?{ |s| s.present? && !s.downcase.match(/\b#{Regexp.escape(search)}\b/).nil? }
|
55
55
|
end
|
56
56
|
|
57
57
|
def web_carts_only
|
@@ -72,6 +72,7 @@ module RHC::Commands
|
|
72
72
|
syntax "<cartridge_type> [--namespace NAME] [--app NAME]"
|
73
73
|
takes_application
|
74
74
|
option ["-e", "--env VARIABLE=VALUE"], "Environment variable(s) to be set on this cartridge, or path to a file containing environment variables", :type => :list
|
75
|
+
option ["-g", "--gear-size SIZE"], "Gear size controls how much memory and CPU your cartridge can use"
|
75
76
|
argument :cart_type, "The type of the cartridge you are adding (run 'rhc cartridge list' to obtain a list of available cartridges)", ["-c", "--cartridge cart_type"]
|
76
77
|
alias_action :"app cartridge add", :root_command => true, :deprecated => true
|
77
78
|
def add(cart_type)
|
@@ -84,7 +85,10 @@ module RHC::Commands
|
|
84
85
|
rest_app = find_app(:include => :cartridges)
|
85
86
|
|
86
87
|
supports_env_vars = rest_app.supports_add_cartridge_with_env_vars?
|
88
|
+
supports_gear_size = rest_app.supports_add_cartridge_with_gear_size?
|
89
|
+
|
87
90
|
cart.environment_variables = collect_env_vars(options.env).map { |item| item.to_hash } if options.env && supports_env_vars
|
91
|
+
cart.gear_size = options.gear_size if options.gear_size && supports_gear_size
|
88
92
|
|
89
93
|
rest_cartridge = rest_app.add_cartridge(cart)
|
90
94
|
|
@@ -95,6 +99,7 @@ module RHC::Commands
|
|
95
99
|
paragraph{ display_cart(rest_cartridge) }
|
96
100
|
paragraph{ say "Use 'rhc env --help' to manage environment variable(s) on this cartridge and application." } if cart.environment_variables.present?
|
97
101
|
paragraph{ warn "Server does not support environment variables." if options.env && !supports_env_vars }
|
102
|
+
paragraph{ warn "Server does not support gear sizes for cartridges." if options.gear_size && !supports_gear_size }
|
98
103
|
paragraph{ rest_cartridge.messages.each { |msg| success msg } }
|
99
104
|
|
100
105
|
0
|
@@ -194,7 +199,7 @@ module RHC::Commands
|
|
194
199
|
cartridges such as databases may require specific increments of scaling (1, 3, 5) in order to
|
195
200
|
properly function. Please consult the cartridge documentation for more on specifics of scaling.
|
196
201
|
|
197
|
-
Set both values the same to guarantee a scale value. You may
|
202
|
+
Set both values the same to guarantee a scale value. You may specify both values with the argument
|
198
203
|
'multiplier' or use '--min' and '--max' independently.
|
199
204
|
|
200
205
|
Scaling may take several minutes or more if the server must provision multiple gears. Your operation
|
data/lib/rhc/commands/domain.rb
CHANGED
@@ -37,7 +37,8 @@ module RHC::Commands
|
|
37
37
|
'--allowed-gear-sizes' option. If '--no-allowed-gear-sizes' is set, no applications
|
38
38
|
can be created in the domain. Older servers may not support this option.
|
39
39
|
DESC
|
40
|
-
option ['--
|
40
|
+
option ['--no-allowed-gear-sizes'], 'Do not allow any gear sizes in this domain.', :optional => true
|
41
|
+
option ['--allowed-gear-sizes [SIZES]'], 'A comma-delimited list of the gear sizes that will be allowed in this domain.', :optional => true
|
41
42
|
argument :namespace, "New domain name (letters and numbers, max 16 chars)", ["-n", "--namespace NAME"]
|
42
43
|
def create(namespace)
|
43
44
|
say "Creating domain '#{namespace}' ... "
|
@@ -68,12 +69,13 @@ module RHC::Commands
|
|
68
69
|
|
69
70
|
summary "Change one or more configuration settings on the domain"
|
70
71
|
syntax "<namespace>"
|
71
|
-
option ['--
|
72
|
+
option ['--no-allowed-gear-sizes'], 'Do not allow any gear sizes in this domain.', :optional => true
|
73
|
+
option ['--allowed-gear-sizes [SIZES]'], "A comma-delimited list of gear sizes allowed in this domain. To see available sizes, run 'rhc account'.", :optional => true
|
72
74
|
takes_domain :argument => true
|
73
75
|
def configure(_)
|
74
76
|
domain = find_domain
|
75
77
|
payload = {}
|
76
|
-
payload[:allowed_gear_sizes] = check_allowed_gear_sizes unless options.allowed_gear_sizes.nil?
|
78
|
+
payload[:allowed_gear_sizes] = check_allowed_gear_sizes unless options.allowed_gear_sizes.nil? and options.no_allowed_gear_sizes.nil?
|
77
79
|
|
78
80
|
if payload.present?
|
79
81
|
say "Updating domain configuration ... "
|
@@ -128,11 +130,12 @@ module RHC::Commands
|
|
128
130
|
summary "Delete a domain"
|
129
131
|
syntax "<namespace>"
|
130
132
|
takes_domain :argument => true
|
133
|
+
option ["-f", "--force"], "Force the action"
|
131
134
|
def delete(_)
|
132
135
|
domain = find_domain
|
133
136
|
|
134
137
|
say "Deleting domain '#{domain.name}' ... "
|
135
|
-
domain.destroy
|
138
|
+
domain.destroy(options.force.present?)
|
136
139
|
success "deleted"
|
137
140
|
|
138
141
|
0
|
@@ -153,7 +156,8 @@ module RHC::Commands
|
|
153
156
|
|
154
157
|
protected
|
155
158
|
def check_allowed_gear_sizes
|
156
|
-
sizes
|
159
|
+
raise OptionParser::InvalidOption, "--allowed-gear-sizes and --no-allowed-gear-sizes cannot both be specified" unless options.allowed_gear_sizes.nil? or options.no_allowed_gear_sizes.nil?
|
160
|
+
sizes = options.no_allowed_gear_sizes.nil? ? options.allowed_gear_sizes : false
|
157
161
|
raise OptionParser::InvalidOption, "The server does not support --allowed-gear-sizes" unless sizes.nil? || rest_client.api.has_param?(:add_domain, 'allowed_gear_sizes')
|
158
162
|
if sizes.is_a? String
|
159
163
|
sizes.split(',').map(&:strip).map(&:presence)
|
data/lib/rhc/commands/server.rb
CHANGED
@@ -2,7 +2,7 @@ module RHC::Commands
|
|
2
2
|
class Server < Base
|
3
3
|
suppress_wizard
|
4
4
|
|
5
|
-
summary "Display information about the status of the OpenShift service
|
5
|
+
summary "Display information about the status of the OpenShift service"
|
6
6
|
description <<-DESC
|
7
7
|
Retrieves any open issues or notices about the operation of the
|
8
8
|
OpenShift service and displays them in the order they were opened.
|
@@ -10,11 +10,34 @@ module RHC
|
|
10
10
|
protected
|
11
11
|
|
12
12
|
def deploy_artifact(rest_app, artifact, hot_deploy, force_clean_build)
|
13
|
-
File.file?(artifact)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
is_file = File.file?(artifact)
|
14
|
+
is_url = URI::ABS_URI.match(artifact).present?
|
15
|
+
|
16
|
+
if rest_app.deployment_type == 'binary'
|
17
|
+
if is_file
|
18
|
+
deploy_local_file(rest_app, artifact, hot_deploy, force_clean_build)
|
19
|
+
elsif is_url
|
20
|
+
deploy_file_from_url(rest_app, artifact, hot_deploy, force_clean_build)
|
21
|
+
else
|
22
|
+
paragraph do
|
23
|
+
warn "The application '#{rest_app.name}' is configured for binary deployments but the artifact "\
|
24
|
+
"provided ('#{artifact}') is not a binary file. Please provide the path to a deployable file on "\
|
25
|
+
"your local filesystem or a url, or configure your app to deploy from a git reference with 'rhc "\
|
26
|
+
"configure-app #{rest_app.name} --deployment-type git'."
|
27
|
+
end
|
28
|
+
raise IncompatibleDeploymentTypeException
|
29
|
+
end
|
30
|
+
elsif is_file || is_url
|
31
|
+
paragraph do
|
32
|
+
warn "The application '#{rest_app.name}' is configured for git "\
|
33
|
+
"reference deployments but the artifact provided ('#{artifact}') is #{is_file ? 'a file' : 'a url'}. Please "\
|
34
|
+
"provide a git reference to deploy (branch, tag or commit SHA1) or configure your app to deploy from binaries "\
|
35
|
+
"with 'rhc configure-app #{rest_app.name} --deployment-type binary'."
|
36
|
+
end
|
37
|
+
raise IncompatibleDeploymentTypeException
|
38
|
+
else
|
39
|
+
deploy_git_ref(rest_app, artifact, hot_deploy, force_clean_build)
|
40
|
+
end
|
18
41
|
end
|
19
42
|
|
20
43
|
def deploy_git_ref(rest_app, ref, hot_deploy, force_clean_build)
|
data/lib/rhc/exceptions.rb
CHANGED
@@ -132,6 +132,12 @@ module RHC
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
class IncompatibleDeploymentTypeException < Exception
|
136
|
+
def initialize(message="The artifact provided is not compatible with the app deployment type.")
|
137
|
+
super message, 133
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
135
141
|
class MissingScalingValueException < Exception
|
136
142
|
def initialize(message="Must provide either a min or max value for scaling")
|
137
143
|
super message
|
data/lib/rhc/rest/application.rb
CHANGED
@@ -45,6 +45,9 @@ module RHC
|
|
45
45
|
if cart.respond_to?(:environment_variables) && cart.environment_variables.present?
|
46
46
|
c[:environment_variables] = cart.environment_variables
|
47
47
|
end
|
48
|
+
if cart.respond_to?(:gear_size) && cart.gear_size.present?
|
49
|
+
c[:gear_size] = cart.gear_size
|
50
|
+
end
|
48
51
|
cart = c
|
49
52
|
end
|
50
53
|
|
@@ -178,6 +181,10 @@ module RHC
|
|
178
181
|
has_param?('ADD_CARTRIDGE', 'environment_variables')
|
179
182
|
end
|
180
183
|
|
184
|
+
def supports_add_cartridge_with_gear_size?
|
185
|
+
has_param?('ADD_CARTRIDGE', 'gear_size')
|
186
|
+
end
|
187
|
+
|
181
188
|
def deployments
|
182
189
|
debug "Listing deployments for application #{name}"
|
183
190
|
raise RHC::DeploymentsNotSupportedException if !supports? "LIST_DEPLOYMENTS"
|
data/lib/rhc/rest/cartridge.rb
CHANGED
@@ -5,7 +5,7 @@ module RHC
|
|
5
5
|
|
6
6
|
define_attr :type, :name, :display_name, :properties, :gear_profile, :status_messages, :scales_to, :scales_from, :scales_with,
|
7
7
|
:current_scale, :supported_scales_to, :supported_scales_from, :tags, :description, :collocated_with, :base_gear_storage,
|
8
|
-
:additional_gear_storage, :url, :environment_variables
|
8
|
+
:additional_gear_storage, :url, :environment_variables, :gear_size
|
9
9
|
|
10
10
|
def scalable?
|
11
11
|
supported_scales_to != supported_scales_from
|
data/lib/rhc/rest/mock.rb
CHANGED
@@ -667,8 +667,8 @@ module RHC::Rest::Mock
|
|
667
667
|
self
|
668
668
|
end
|
669
669
|
|
670
|
-
def destroy
|
671
|
-
raise RHC::Rest::ClientErrorException.new("Applications must be empty.") unless @applications.empty?
|
670
|
+
def destroy(force=false)
|
671
|
+
raise RHC::Rest::ClientErrorException.new("Applications must be empty.") unless @applications.empty? or force.present?
|
672
672
|
client.domains.delete_if { |d| d.name == @name }
|
673
673
|
|
674
674
|
@applications = nil
|
@@ -929,9 +929,10 @@ module RHC::Rest::Mock
|
|
929
929
|
|
930
930
|
attr_accessor :usage_rate
|
931
931
|
|
932
|
-
def initialize(client, name, type, app=nil, tags=[], properties=[{'type' => 'cart_data', 'name' => 'connection_url', 'value' => "http://fake.url" }])
|
932
|
+
def initialize(client, name, type, app=nil, tags=[], properties=[{'type' => 'cart_data', 'name' => 'connection_url', 'value' => "http://fake.url" }], description=nil)
|
933
933
|
super({}, client)
|
934
934
|
@name = name
|
935
|
+
@description = description || "Description of #{name}"
|
935
936
|
@type = type
|
936
937
|
@app = app
|
937
938
|
@tags = tags
|
@@ -36,6 +36,11 @@ module RhcExecutionHelper
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
def a_random_cartridge(with_tags=nil, for_user=nil)
|
40
|
+
c = for_user ? for_user.client : client
|
41
|
+
c.cartridges.select{|cartridge| with_tags.nil? || (with_tags - cartridge.tags).empty?}.shuffle.first.name
|
42
|
+
end
|
43
|
+
|
39
44
|
def rhc(*args)
|
40
45
|
opts = args.pop if args.last.is_a? Hash
|
41
46
|
opts ||= {}
|
@@ -139,13 +144,24 @@ module RhcExecutionHelper
|
|
139
144
|
c = for_user ? for_user.client : client
|
140
145
|
debug.puts "Creating or reusing an app" if debug?
|
141
146
|
apps = c.applications
|
142
|
-
apps.
|
147
|
+
apps.find{|app| !app.scalable?} or begin
|
143
148
|
domain = has_a_domain(for_user)
|
144
149
|
debug.puts " creating a new application" if debug?
|
145
150
|
c.domains.first.add_application("test#{random}", :cartridges => [a_web_cartridge])
|
146
151
|
end
|
147
152
|
end
|
148
153
|
|
154
|
+
def has_a_scalable_application(for_user=nil)
|
155
|
+
c = for_user ? for_user.client : client
|
156
|
+
debug.puts "Creating or reusing a scalable app" if debug?
|
157
|
+
apps = c.applications
|
158
|
+
apps.find(&:scalable?) or begin
|
159
|
+
domain = has_a_domain(for_user)
|
160
|
+
debug.puts " creating a new scalable application" if debug?
|
161
|
+
c.domains.first.add_application("scalable#{random}", :cartridges => [a_web_cartridge], :scale => true)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
149
165
|
def has_a_domain(for_user=nil)
|
150
166
|
c = for_user ? for_user.client : client
|
151
167
|
debug.puts "Creating or reusing a domain" if debug?
|
@@ -92,6 +92,38 @@ describe RHC::Commands::Cartridge do
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
+
describe 'cartridge add' do
|
96
|
+
let!(:rest_client){ MockRestClient.new }
|
97
|
+
let(:arguments) { ['cartridge', 'add', 'mock_cart-1', '--app', 'app1', '--gear-size', 'small'] }
|
98
|
+
|
99
|
+
context 'with gear size' do
|
100
|
+
before do
|
101
|
+
domain = rest_client.add_domain("mock_domain")
|
102
|
+
app = domain.add_application("app1", "mock_type", true)
|
103
|
+
end
|
104
|
+
it { succeed_with_message /Adding mock_cart-1 to application 'app1' \.\.\. / }
|
105
|
+
it { succeed_with_message /Connection URL:\s+http\:\/\/fake\.url/ }
|
106
|
+
it { succeed_with_message /Prop1:\s+value1/ }
|
107
|
+
it { succeed_with_message /Cartridge added with properties/ }
|
108
|
+
it "should not contain env var info" do
|
109
|
+
run_output.should_not match(/Environment Variables/)
|
110
|
+
end
|
111
|
+
it { succeed_with_message /Gears:\s+1 small/ }
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'with gear size on unsupported server' do
|
115
|
+
let(:arguments) { ['cartridge', 'add', 'mock_cart-1', '--app', 'app1', '--gear-size', 'small'] }
|
116
|
+
before do
|
117
|
+
domain = rest_client.add_domain("mock_domain")
|
118
|
+
app = domain.add_application("app1", "mock_type", true)
|
119
|
+
@app.stub(:has_param?).with('ADD_CARTRIDGE','environment_variables').and_return(true)
|
120
|
+
@app.stub(:has_param?).with('ADD_CARTRIDGE','gear_size').and_return(false)
|
121
|
+
end
|
122
|
+
it { expect { run }.to exit_with_code(0) }
|
123
|
+
it { run_output.should match(/Server does not support gear sizes for cartridges/) }
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
95
127
|
describe 'cartridge add' do
|
96
128
|
let!(:rest_client){ MockRestClient.new }
|
97
129
|
let(:instance) do
|
@@ -152,6 +184,15 @@ describe RHC::Commands::Cartridge do
|
|
152
184
|
}
|
153
185
|
end
|
154
186
|
|
187
|
+
context 'when cartridge with regex breaking name does not exist' do
|
188
|
+
let(:arguments) { ['cartridge', 'add', '*##', '--app', 'app1'] }
|
189
|
+
before do
|
190
|
+
domain = rest_client.add_domain("mock_domain")
|
191
|
+
app = domain.add_application("app1", "mock_type")
|
192
|
+
end
|
193
|
+
it{ fail_with_code 154 }
|
194
|
+
end
|
195
|
+
|
155
196
|
context 'when cartridge does not exist' do
|
156
197
|
let(:arguments) { ['cartridge', 'add', 'nomatch_cart', '--app', 'app1'] }
|
157
198
|
before do
|
@@ -595,7 +636,10 @@ describe RHC::Commands::Cartridge do
|
|
595
636
|
].each_with_index do |args, i|
|
596
637
|
context "when run against a server without env vars support #{i}" do
|
597
638
|
let(:arguments) { args }
|
598
|
-
before
|
639
|
+
before do
|
640
|
+
@app.stub(:has_param?).with('ADD_CARTRIDGE','environment_variables').and_return(false)
|
641
|
+
@app.stub(:has_param?).with('ADD_CARTRIDGE','gear_size').and_return(true)
|
642
|
+
end
|
599
643
|
it { expect { run }.to exit_with_code(0) }
|
600
644
|
it { run_output.should match(/Server does not support environment variables/) }
|
601
645
|
it { run_output.should_not match(/Environment Variables:\s+FOO=BAR/) }
|
@@ -58,6 +58,7 @@ describe RHC::Commands::Deployment do
|
|
58
58
|
|
59
59
|
context "binary file successfully" do
|
60
60
|
before do
|
61
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
61
62
|
ssh = double(Net::SSH)
|
62
63
|
session = double(Net::SSH::Connection::Session)
|
63
64
|
channel = double(Net::SSH::Connection::Channel)
|
@@ -92,6 +93,7 @@ describe RHC::Commands::Deployment do
|
|
92
93
|
URI('https://foo.com/path/to/file/' + DEPLOYMENT_APP_NAME + '.tar.gz')].each do |uri|
|
93
94
|
context "url file successfully" do
|
94
95
|
before do
|
96
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
95
97
|
ssh = double(Net::SSH)
|
96
98
|
session = double(Net::SSH::Connection::Session)
|
97
99
|
channel = double(Net::SSH::Connection::Channel)
|
@@ -126,6 +128,7 @@ describe RHC::Commands::Deployment do
|
|
126
128
|
|
127
129
|
context "binary file with corrupted file" do
|
128
130
|
before do
|
131
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
129
132
|
ssh = double(Net::SSH)
|
130
133
|
session = double(Net::SSH::Connection::Session)
|
131
134
|
channel = double(Net::SSH::Connection::Channel)
|
@@ -165,7 +168,10 @@ describe RHC::Commands::Deployment do
|
|
165
168
|
end
|
166
169
|
|
167
170
|
context "fails when deploying binary file" do
|
168
|
-
before (:each)
|
171
|
+
before (:each) do
|
172
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
173
|
+
Net::SSH.should_receive(:start).and_raise(Errno::ECONNREFUSED)
|
174
|
+
end
|
169
175
|
let(:arguments) {['app', 'deploy', @targz_filename, '--app', DEPLOYMENT_APP_NAME]}
|
170
176
|
it "should exit with error" do
|
171
177
|
expect{ run }.to exit_with_code(1)
|
@@ -173,7 +179,10 @@ describe RHC::Commands::Deployment do
|
|
173
179
|
end
|
174
180
|
|
175
181
|
context "fails when deploying binary file" do
|
176
|
-
before (:each)
|
182
|
+
before (:each) do
|
183
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
184
|
+
Net::SSH.should_receive(:start).and_raise(SocketError)
|
185
|
+
end
|
177
186
|
let(:arguments) {['app', 'deploy', @targz_filename, '--app', DEPLOYMENT_APP_NAME]}
|
178
187
|
it "should exit with error" do
|
179
188
|
expect{ run }.to exit_with_code(1)
|
@@ -181,7 +190,10 @@ describe RHC::Commands::Deployment do
|
|
181
190
|
end
|
182
191
|
|
183
192
|
context "fails when deploying url file" do
|
184
|
-
before (:each)
|
193
|
+
before (:each) do
|
194
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
195
|
+
Net::SSH.should_receive(:start).and_raise(Errno::ECONNREFUSED)
|
196
|
+
end
|
185
197
|
let(:arguments) {['app', 'deploy', 'http://foo.com/deploy.tar.gz', '--app', DEPLOYMENT_APP_NAME]}
|
186
198
|
it "should exit with error" do
|
187
199
|
expect{ run }.to exit_with_code(1)
|
@@ -189,7 +201,10 @@ describe RHC::Commands::Deployment do
|
|
189
201
|
end
|
190
202
|
|
191
203
|
context "fails when deploying url file" do
|
192
|
-
before (:each)
|
204
|
+
before (:each) do
|
205
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
206
|
+
Net::SSH.should_receive(:start).and_raise(SocketError)
|
207
|
+
end
|
193
208
|
let(:arguments) {['app', 'deploy', 'http://foo.com/deploy.tar.gz', '--app', DEPLOYMENT_APP_NAME]}
|
194
209
|
it "should exit with error" do
|
195
210
|
expect{ run }.to exit_with_code(1)
|
@@ -217,6 +232,32 @@ describe RHC::Commands::Deployment do
|
|
217
232
|
end
|
218
233
|
end
|
219
234
|
|
235
|
+
context "fails when deploying git reference on an app configured to deployment_type = binary" do
|
236
|
+
before { @rest_app.stub(:deployment_type).and_return('binary') }
|
237
|
+
let(:arguments) {['app', 'deploy', 'master', '--app', DEPLOYMENT_APP_NAME]}
|
238
|
+
it "should exit with error" do
|
239
|
+
expect{ run }.to exit_with_code(133)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
context "fails when deploying file on an app configured to deployment_type = git" do
|
244
|
+
before { @rest_app.stub(:deployment_type).and_return('git') }
|
245
|
+
let(:arguments) {['app', 'deploy', @targz_filename, '--app', DEPLOYMENT_APP_NAME]}
|
246
|
+
it "should exit with error" do
|
247
|
+
expect{ run }.to exit_with_code(133)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
[URI('http://foo.com/path/to/file/' + DEPLOYMENT_APP_NAME + '.tar.gz'),
|
252
|
+
URI('https://foo.com/path/to/file/' + DEPLOYMENT_APP_NAME + '.tar.gz')].each do |uri|
|
253
|
+
context "fails when deploying url on an app configured to deployment_type = git" do
|
254
|
+
before { @rest_app.stub(:deployment_type).and_return('git') }
|
255
|
+
let(:arguments) {['app', 'deploy', uri.to_s, '--app', DEPLOYMENT_APP_NAME]}
|
256
|
+
it "should exit with error" do
|
257
|
+
expect{ run }.to exit_with_code(133)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
220
261
|
end
|
221
262
|
|
222
263
|
describe "activate deployment" do
|
@@ -321,6 +321,11 @@ describe RHC::Commands::Domain do
|
|
321
321
|
it("should succeed"){ expect { run }.to exit_with_code(0) }
|
322
322
|
it("should display the domain config"){ run_output.should match(/Domain domain1 configuration.*Allowed Gear Sizes:\s+<none>/m) }
|
323
323
|
end
|
324
|
+
|
325
|
+
context "with --allowed-gear-sizes and --no-allowed-gear-sizes" do
|
326
|
+
let(:arguments) { ['domain', 'configure', 'domain1', '--trace', '--no-allowed-gear-sizes', '--allowed-gear-sizes', 'small'] }
|
327
|
+
it("raise an invalid option"){ expect{ run }.to raise_error(OptionParser::InvalidOption, /--allowed-gear-sizes.*--no-allowed-gear-sizes/) }
|
328
|
+
end
|
324
329
|
end
|
325
330
|
end
|
326
331
|
|
@@ -368,6 +373,19 @@ describe RHC::Commands::Domain do
|
|
368
373
|
end
|
369
374
|
it { run_output.should match("Applications must be empty") }
|
370
375
|
end
|
376
|
+
|
377
|
+
context 'when delete is forced' do
|
378
|
+
let(:arguments) { ['domain', 'delete', 'deleteme', '--force'] }
|
379
|
+
before do
|
380
|
+
domain = rest_client.add_domain("deleteme")
|
381
|
+
domain.add_application 'testapp1', 'mock-1.0'
|
382
|
+
end
|
383
|
+
it "should delete successfully" do
|
384
|
+
expect { run }.to exit_with_code(0)
|
385
|
+
rest_client.domains.empty?.should be_true
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
371
389
|
end
|
372
390
|
|
373
391
|
describe 'help' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 95
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 17
|
9
|
+
- 6
|
10
|
+
version: 1.17.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Red Hat
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-
|
18
|
+
date: 2013-12-02 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: net-ssh
|