crazy-yard 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +19 -0
- data/README.md +438 -0
- data/bin/ey +9 -0
- data/lib/engineyard.rb +9 -0
- data/lib/engineyard/cli.rb +816 -0
- data/lib/engineyard/cli/api.rb +98 -0
- data/lib/engineyard/cli/recipes.rb +129 -0
- data/lib/engineyard/cli/ui.rb +275 -0
- data/lib/engineyard/cli/web.rb +85 -0
- data/lib/engineyard/config.rb +158 -0
- data/lib/engineyard/deploy_config.rb +65 -0
- data/lib/engineyard/deploy_config/ref.rb +56 -0
- data/lib/engineyard/error.rb +82 -0
- data/lib/engineyard/eyrc.rb +59 -0
- data/lib/engineyard/repo.rb +105 -0
- data/lib/engineyard/serverside_runner.rb +159 -0
- data/lib/engineyard/templates.rb +6 -0
- data/lib/engineyard/templates/ey.yml.erb +196 -0
- data/lib/engineyard/templates/ey_yml.rb +119 -0
- data/lib/engineyard/thor.rb +215 -0
- data/lib/engineyard/version.rb +4 -0
- data/lib/vendor/thor/Gemfile +15 -0
- data/lib/vendor/thor/LICENSE.md +20 -0
- data/lib/vendor/thor/README.md +35 -0
- data/lib/vendor/thor/lib/thor.rb +473 -0
- data/lib/vendor/thor/lib/thor/actions.rb +318 -0
- data/lib/vendor/thor/lib/thor/actions/create_file.rb +105 -0
- data/lib/vendor/thor/lib/thor/actions/create_link.rb +60 -0
- data/lib/vendor/thor/lib/thor/actions/directory.rb +119 -0
- data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +137 -0
- data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +314 -0
- data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +109 -0
- data/lib/vendor/thor/lib/thor/base.rb +652 -0
- data/lib/vendor/thor/lib/thor/command.rb +136 -0
- data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +80 -0
- data/lib/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
- data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +100 -0
- data/lib/vendor/thor/lib/thor/error.rb +28 -0
- data/lib/vendor/thor/lib/thor/group.rb +282 -0
- data/lib/vendor/thor/lib/thor/invocation.rb +172 -0
- data/lib/vendor/thor/lib/thor/parser.rb +4 -0
- data/lib/vendor/thor/lib/thor/parser/argument.rb +74 -0
- data/lib/vendor/thor/lib/thor/parser/arguments.rb +171 -0
- data/lib/vendor/thor/lib/thor/parser/option.rb +121 -0
- data/lib/vendor/thor/lib/thor/parser/options.rb +218 -0
- data/lib/vendor/thor/lib/thor/rake_compat.rb +72 -0
- data/lib/vendor/thor/lib/thor/runner.rb +322 -0
- data/lib/vendor/thor/lib/thor/shell.rb +88 -0
- data/lib/vendor/thor/lib/thor/shell/basic.rb +393 -0
- data/lib/vendor/thor/lib/thor/shell/color.rb +148 -0
- data/lib/vendor/thor/lib/thor/shell/html.rb +127 -0
- data/lib/vendor/thor/lib/thor/util.rb +270 -0
- data/lib/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/vendor/thor/thor.gemspec +24 -0
- data/spec/engineyard/cli/api_spec.rb +50 -0
- data/spec/engineyard/cli_spec.rb +28 -0
- data/spec/engineyard/config_spec.rb +61 -0
- data/spec/engineyard/deploy_config_spec.rb +194 -0
- data/spec/engineyard/eyrc_spec.rb +76 -0
- data/spec/engineyard/repo_spec.rb +83 -0
- data/spec/engineyard_spec.rb +7 -0
- data/spec/ey/console_spec.rb +57 -0
- data/spec/ey/deploy_spec.rb +435 -0
- data/spec/ey/ey_spec.rb +23 -0
- data/spec/ey/init_spec.rb +123 -0
- data/spec/ey/list_environments_spec.rb +120 -0
- data/spec/ey/login_spec.rb +33 -0
- data/spec/ey/logout_spec.rb +24 -0
- data/spec/ey/logs_spec.rb +36 -0
- data/spec/ey/rebuild_spec.rb +18 -0
- data/spec/ey/recipes/apply_spec.rb +29 -0
- data/spec/ey/recipes/download_spec.rb +43 -0
- data/spec/ey/recipes/upload_spec.rb +99 -0
- data/spec/ey/rollback_spec.rb +73 -0
- data/spec/ey/scp_spec.rb +176 -0
- data/spec/ey/servers_spec.rb +209 -0
- data/spec/ey/ssh_spec.rb +273 -0
- data/spec/ey/status_spec.rb +45 -0
- data/spec/ey/timeout_deploy_spec.rb +18 -0
- data/spec/ey/web/disable_spec.rb +21 -0
- data/spec/ey/web/enable_spec.rb +26 -0
- data/spec/ey/web/restart_spec.rb +21 -0
- data/spec/ey/whoami_spec.rb +30 -0
- data/spec/spec_helper.rb +84 -0
- data/spec/support/bundled_ey +7 -0
- data/spec/support/fixture_recipes.tgz +0 -0
- data/spec/support/git_repos.rb +115 -0
- data/spec/support/helpers.rb +330 -0
- data/spec/support/matchers.rb +16 -0
- data/spec/support/ruby_ext.rb +13 -0
- data/spec/support/shared_behavior.rb +278 -0
- metadata +411 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
print_my_args_ssh = "#!/bin/sh\necho ssh $*"
|
4
|
+
|
5
|
+
shared_examples_for "running ey console" do
|
6
|
+
given "integration"
|
7
|
+
|
8
|
+
def extra_ey_options
|
9
|
+
{:prepend_to_path => {'ssh' => "#!/bin/sh\necho ssh $*"}}
|
10
|
+
end
|
11
|
+
|
12
|
+
def command_to_run(opts)
|
13
|
+
cmd = ["console"]
|
14
|
+
cmd << "--environment" << opts[:environment] if opts[:environment]
|
15
|
+
cmd << "--quiet" if opts[:quiet]
|
16
|
+
cmd
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "ey console" do
|
21
|
+
include_examples "running ey console"
|
22
|
+
|
23
|
+
it "complains if it has no app master" do
|
24
|
+
login_scenario "one app, many environments"
|
25
|
+
ey %w[console -e bakon], :expect_failure => true
|
26
|
+
expect(@err).to match(/'bakon' does not have any matching instances/)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "opens the console on the right server" do
|
30
|
+
login_scenario "one app, one environment"
|
31
|
+
ey command_to_run(:environment => 'giblets', :verbose => true)
|
32
|
+
expect(@raw_ssh_commands.select do |command|
|
33
|
+
command =~ /^ssh -t turkey@app_master_hostname.+ bash -lc '.+bundle exec rails console'$/
|
34
|
+
end).not_to be_empty
|
35
|
+
expect(@raw_ssh_commands.select do |command|
|
36
|
+
command =~ /^ssh -t turkey.+$/
|
37
|
+
end.count).to eq(1)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "is quiet" do
|
41
|
+
login_scenario "one app, one environment"
|
42
|
+
ey command_to_run(:environment => 'giblets', :quiet => true)
|
43
|
+
expect(@out).to match(/ssh.*-t turkey/)
|
44
|
+
expect(@out).not_to match(/Loading application data/)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "runs in bash by default" do
|
48
|
+
login_scenario "one app, one environment"
|
49
|
+
ey command_to_run(:environment => 'giblets', :quiet => true)
|
50
|
+
expect(@out).to match(/ssh.*bash -lc '.+bundle/)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "raises an error when there are no matching hosts" do
|
54
|
+
login_scenario "one app, one environment, no instances"
|
55
|
+
ey command_to_run(:environment => 'giblets', :quiet => true), :expect_failure => true
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,435 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "ey deploy without an eyrc file" do
|
4
|
+
given "integration"
|
5
|
+
|
6
|
+
it "prompts for authentication before continuing" do
|
7
|
+
api_scenario "one app, one environment"
|
8
|
+
|
9
|
+
ey(%w[deploy --no-migrate], :hide_err => true) do |input|
|
10
|
+
input.puts(scenario_email)
|
11
|
+
input.puts(scenario_password)
|
12
|
+
end
|
13
|
+
|
14
|
+
expect(@out).to include("We need to fetch your API token; please log in.")
|
15
|
+
expect(@out).to include("Email:")
|
16
|
+
expect(@out).to include("Password:")
|
17
|
+
expect(@ssh_commands).not_to be_empty
|
18
|
+
|
19
|
+
expect(read_eyrc).to eq({"api_token" => scenario_api_token})
|
20
|
+
end
|
21
|
+
|
22
|
+
it "uses the token on the command line" do
|
23
|
+
api_scenario "one app, one environment"
|
24
|
+
ey(%w[deploy --no-migrate --api-token] + [scenario_api_token])
|
25
|
+
expect(@ssh_commands).not_to be_empty
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
describe "ey deploy" do
|
31
|
+
given "integration"
|
32
|
+
|
33
|
+
def command_to_run(opts)
|
34
|
+
cmd = ["deploy"]
|
35
|
+
cmd << "--environment" << opts[:environment] if opts[:environment]
|
36
|
+
cmd << "--app" << opts[:app] if opts[:app]
|
37
|
+
cmd << "--account" << opts[:account] if opts[:account]
|
38
|
+
cmd << "--ref" << opts[:ref] if opts[:ref]
|
39
|
+
cmd << "--migrate" if opts[:migrate]
|
40
|
+
cmd << opts[:migrate] if opts[:migrate].respond_to?(:to_str)
|
41
|
+
cmd << "--no-migrate" if opts[:migrate] == nil
|
42
|
+
cmd << "--verbose" if opts[:verbose]
|
43
|
+
cmd
|
44
|
+
end
|
45
|
+
|
46
|
+
def verify_ran(scenario)
|
47
|
+
expect(@out).to match(/Beginning deploy.../)
|
48
|
+
expect(@out).to match(/Application:\s+#{scenario[:application]}/)
|
49
|
+
expect(@out).to match(/Environment:\s+#{scenario[:environment]}/)
|
50
|
+
expect(@out).to match(/deployment recorded/i)
|
51
|
+
expect(@ssh_commands).to have_command_like(/engineyard-serverside.*deploy.*--app #{scenario[:application]}/)
|
52
|
+
end
|
53
|
+
|
54
|
+
# common behavior
|
55
|
+
include_examples "it takes an environment name and an app name and an account name"
|
56
|
+
include_examples "it invokes engineyard-serverside"
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "ey deploy" do
|
60
|
+
given "integration"
|
61
|
+
|
62
|
+
context "without ssh keys (with ssh enabled)" do
|
63
|
+
before do
|
64
|
+
ENV.delete('NO_SSH')
|
65
|
+
allow(Net::SSH).to receive(:start).and_raise(Net::SSH::AuthenticationFailed.new("no key"))
|
66
|
+
end
|
67
|
+
|
68
|
+
after do
|
69
|
+
ENV['NO_SSH'] = 'true'
|
70
|
+
end
|
71
|
+
|
72
|
+
it "tells you that you need to add an appropriate ssh key (even with --quiet)" do
|
73
|
+
login_scenario "one app, one environment"
|
74
|
+
fast_failing_ey %w[deploy --no-migrate --quiet]
|
75
|
+
expect(@err).to include("Authentication Failed")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "with invalid input" do
|
80
|
+
it "complains when there is no app" do
|
81
|
+
login_scenario "empty"
|
82
|
+
fast_failing_ey ["deploy"]
|
83
|
+
expect(@err).to include(%|No application found|)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "complains when the specified environment does not contain the app" do
|
87
|
+
login_scenario "one app, one environment, not linked"
|
88
|
+
fast_failing_ey %w[deploy -e giblets -r master]
|
89
|
+
expect(@err).to match(/Application "rails232app" and environment "giblets" are not associated./)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "complains when environment is not specified and app is in >1 environment" do
|
93
|
+
login_scenario "one app, many environments"
|
94
|
+
fast_failing_ey %w[deploy --ref master --no-migrate]
|
95
|
+
expect(@err).to match(/Multiple application environments possible/i)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "complains when the app master is in a non-running state" do
|
99
|
+
login_scenario "one app, one environment, app master red"
|
100
|
+
fast_failing_ey %w[deploy --environment giblets --ref master --no-migrate]
|
101
|
+
expect(@err).not_to match(/No running instances/i)
|
102
|
+
expect(@err).to match(/running.*\(green\)/)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "migration command" do
|
107
|
+
before(:each) do
|
108
|
+
login_scenario "one app, one environment"
|
109
|
+
end
|
110
|
+
|
111
|
+
context "no ey.yml" do
|
112
|
+
def clean_ey_yml
|
113
|
+
File.unlink 'ey.yml' if File.exist?('ey.yml')
|
114
|
+
FileUtils.rm_r 'config' if FileTest.exist?('config')
|
115
|
+
end
|
116
|
+
|
117
|
+
before { clean_ey_yml }
|
118
|
+
after { clean_ey_yml }
|
119
|
+
|
120
|
+
it "tells you to run ey init" do
|
121
|
+
fast_failing_ey %w[deploy]
|
122
|
+
expect(@err).to match(/ey init/)
|
123
|
+
expect(@ssh_commands).to be_empty
|
124
|
+
end
|
125
|
+
|
126
|
+
it "tells you to run ey init" do
|
127
|
+
fast_failing_ey %w[deploy --migrate]
|
128
|
+
expect(@err).to match(/ey init/)
|
129
|
+
expect(@ssh_commands).to be_empty
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it "can be disabled with --no-migrate" do
|
134
|
+
fast_ey %w[deploy --no-migrate]
|
135
|
+
expect(@ssh_commands.last).to match(/engineyard-serverside.*deploy/)
|
136
|
+
expect(@ssh_commands.last).not_to match(/--migrate/)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "runs the migrate command when one is given" do
|
140
|
+
fast_ey ['deploy', '--migrate', 'thor fancy:migrate']
|
141
|
+
expect(@ssh_commands.last).to match(/--migrate 'thor fancy:migrate'/)
|
142
|
+
end
|
143
|
+
|
144
|
+
context "ey.yml migrate only" do
|
145
|
+
before { write_yaml({"defaults" => {"migrate" => true}}, 'ey.yml') }
|
146
|
+
after { File.unlink 'ey.yml' }
|
147
|
+
|
148
|
+
it "tells you to run ey init" do
|
149
|
+
fast_failing_ey %w[deploy]
|
150
|
+
expect(@err).to match(/ey init/)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context "ey.yml migration_command only" do
|
155
|
+
before { write_yaml({"defaults" => {"migration_command" => "thor fancy:migrate"}}, 'ey.yml') }
|
156
|
+
after { File.unlink 'ey.yml' }
|
157
|
+
|
158
|
+
it "tells you to run ey init" do
|
159
|
+
fast_failing_ey %w[deploy]
|
160
|
+
expect(@err).to match(/ey init/)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context "ey.yml with environment specific options overriding the defaults" do
|
165
|
+
before do
|
166
|
+
write_yaml({
|
167
|
+
"defaults" => { "migrate" => true, "migration_command" => "rake plain:migrate"},
|
168
|
+
"environments" => {"giblets" => { "migration_command" => 'thor fancy:migrate' }}
|
169
|
+
}, 'ey.yml')
|
170
|
+
end
|
171
|
+
after { File.unlink 'ey.yml' }
|
172
|
+
|
173
|
+
it "migrates with the custom command" do
|
174
|
+
fast_ey %w[deploy]
|
175
|
+
expect(@ssh_commands.last).to match(/--migrate 'thor fancy:migrate'/)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
context "disabled in ey.yml" do
|
180
|
+
before { write_yaml({"defaults" => {"migrate" => false}}, 'ey.yml') }
|
181
|
+
after { File.unlink 'ey.yml' }
|
182
|
+
|
183
|
+
it "does not migrate by default" do
|
184
|
+
fast_ey %w[deploy]
|
185
|
+
expect(@ssh_commands.last).to match(/engineyard-serverside.*deploy/)
|
186
|
+
expect(@ssh_commands.last).not_to match(/--migrate/)
|
187
|
+
end
|
188
|
+
|
189
|
+
it "can be turned back on with --migrate" do
|
190
|
+
fast_ey ["deploy", "--migrate", "rake fancy:migrate"]
|
191
|
+
expect(@ssh_commands.last).to match(/--migrate 'rake fancy:migrate'/)
|
192
|
+
end
|
193
|
+
|
194
|
+
it "tells you to initialize ey.yml when --migrate is specified with no value" do
|
195
|
+
fast_failing_ey %w[deploy --migrate]
|
196
|
+
expect(@err).to match(/ey init/)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
context "customized and disabled in ey.yml" do
|
201
|
+
before { write_yaml({"defaults" => { "migrate" => false, "migration_command" => "thor fancy:migrate" }}, 'ey.yml') }
|
202
|
+
after { File.unlink 'ey.yml' }
|
203
|
+
|
204
|
+
it "does not migrate by default" do
|
205
|
+
fast_ey %w[deploy]
|
206
|
+
expect(@ssh_commands.last).not_to match(/--migrate/)
|
207
|
+
end
|
208
|
+
|
209
|
+
it "migrates with the custom command when --migrate is specified with no value" do
|
210
|
+
fast_ey %w[deploy --migrate]
|
211
|
+
expect(@ssh_commands.last).to match(/--migrate 'thor fancy:migrate'/)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
context "the --framework-env option" do
|
217
|
+
before(:each) do
|
218
|
+
login_scenario "one app, one environment"
|
219
|
+
end
|
220
|
+
|
221
|
+
it "passes the framework environment" do
|
222
|
+
fast_ey %w[deploy --no-migrate]
|
223
|
+
expect(@ssh_commands.last).to match(/--framework-env production/)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
context "choosing something to deploy" do
|
228
|
+
use_git_repo('deploy test')
|
229
|
+
|
230
|
+
before(:all) do
|
231
|
+
login_scenario "one app, one environment"
|
232
|
+
end
|
233
|
+
|
234
|
+
context "without a configured default branch" do
|
235
|
+
it "defaults to the checked-out local branch" do
|
236
|
+
fast_ey %w[deploy --no-migrate]
|
237
|
+
expect(@ssh_commands.last).to match(/--ref resolved-current-branch/)
|
238
|
+
end
|
239
|
+
|
240
|
+
it "deploys another branch if given" do
|
241
|
+
fast_ey %w[deploy --ref master --no-migrate]
|
242
|
+
expect(@ssh_commands.last).to match(/--ref resolved-master/)
|
243
|
+
end
|
244
|
+
|
245
|
+
it "deploys a tag if given" do
|
246
|
+
fast_ey %w[deploy --ref v1 --no-migrate]
|
247
|
+
expect(@ssh_commands.last).to match(/--ref resolved-v1/)
|
248
|
+
end
|
249
|
+
|
250
|
+
it "allows using --branch to specify a branch" do
|
251
|
+
fast_ey %w[deploy --branch master --no-migrate]
|
252
|
+
expect(@ssh_commands.last).to match(/--ref resolved-master/)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "allows using --tag to specify the tag" do
|
256
|
+
fast_ey %w[deploy --tag v1 --no-migrate]
|
257
|
+
expect(@ssh_commands.last).to match(/--ref resolved-v1/)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
context "with a configured default branch" do
|
262
|
+
before(:each) do
|
263
|
+
write_yaml({"environments" => {"giblets" => {"branch" => "master", "migrate" => false}}}, 'ey.yml')
|
264
|
+
end
|
265
|
+
|
266
|
+
after(:each) do
|
267
|
+
File.unlink "ey.yml"
|
268
|
+
end
|
269
|
+
|
270
|
+
it "deploys the default branch by default" do
|
271
|
+
fast_ey %w[deploy]
|
272
|
+
expect(@ssh_commands.last).to match(/--ref resolved-master/)
|
273
|
+
end
|
274
|
+
|
275
|
+
it "complains about a non-default branch without --ignore-default-branch" do
|
276
|
+
fast_failing_ey %w[deploy -r current-branch]
|
277
|
+
expect(@err).to match(/default branch is set to "master"/)
|
278
|
+
end
|
279
|
+
|
280
|
+
it "deploys a non-default branch with --ignore-default-branch" do
|
281
|
+
fast_ey %w[deploy -r current-branch --ignore-default-branch]
|
282
|
+
expect(@ssh_commands.last).to match(/--ref resolved-current-branch/)
|
283
|
+
end
|
284
|
+
|
285
|
+
it "deploys a non-default branch with --R ref" do
|
286
|
+
fast_ey %w[deploy -R current-branch]
|
287
|
+
expect(@ssh_commands.last).to match(/--ref resolved-current-branch/)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
context "when there is extra configuration" do
|
293
|
+
before(:each) do
|
294
|
+
write_yaml({"environments" => {"giblets" => {"migrate" => true, "migration_command" => "rake", "bert" => "ernie"}}}, 'ey.yml')
|
295
|
+
end
|
296
|
+
|
297
|
+
after(:each) do
|
298
|
+
File.unlink("ey.yml")
|
299
|
+
end
|
300
|
+
|
301
|
+
it "no longer gets passed along to engineyard-serverside (since serverside will read it on its own)" do
|
302
|
+
fast_ey %w[deploy --no-migrate]
|
303
|
+
expect(@ssh_commands.last).not_to match(/"bert":"ernie"/)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
context "specifying an environment" do
|
308
|
+
before(:all) do
|
309
|
+
login_scenario "one app, many similarly-named environments"
|
310
|
+
end
|
311
|
+
|
312
|
+
it "lets you choose by complete name even if the complete name is ambiguous" do
|
313
|
+
fast_ey %w[deploy --environment railsapp_staging --no-migrate]
|
314
|
+
expect(@out).to match(/Beginning deploy.../)
|
315
|
+
expect(@out).to match(/Ref:\s+master/)
|
316
|
+
expect(@out).to match(/Environment:\s+railsapp_staging/)
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
context "--config (--extra-deploy-hook-options)" do
|
321
|
+
before(:all) do
|
322
|
+
login_scenario "one app, one environment"
|
323
|
+
end
|
324
|
+
|
325
|
+
def config_options
|
326
|
+
if @ssh_commands.last =~ /--config (.*?)(?: -|$)/
|
327
|
+
# the echo strips off the layer of shell escaping, leaving us
|
328
|
+
# with pristine JSON
|
329
|
+
MultiJson.load `echo #{$1}`
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
it "passes --config to engineyard-serverside" do
|
334
|
+
ey %w[deploy --config some:stuff more:crap --no-migrate]
|
335
|
+
expect(config_options).not_to be_nil
|
336
|
+
expect(config_options['some']).to eq('stuff')
|
337
|
+
expect(config_options['more']).to eq('crap')
|
338
|
+
end
|
339
|
+
|
340
|
+
it "supports legacy --extra-deploy-hook-options" do
|
341
|
+
ey %w[deploy --extra-deploy-hook-options some:stuff more:crap --no-migrate]
|
342
|
+
expect(config_options).not_to be_nil
|
343
|
+
expect(config_options['some']).to eq('stuff')
|
344
|
+
expect(config_options['more']).to eq('crap')
|
345
|
+
end
|
346
|
+
|
347
|
+
context "when ey.yml is present" do
|
348
|
+
before do
|
349
|
+
write_yaml({"environments" => {"giblets" => {"beer" => "stout", "migrate" => true, "migration_command" => "rake"}}}, 'ey.yml')
|
350
|
+
end
|
351
|
+
|
352
|
+
after { File.unlink("ey.yml") }
|
353
|
+
|
354
|
+
it "overrides what's in ey.yml" do
|
355
|
+
fast_ey %w[deploy --config beer:esb]
|
356
|
+
expect(config_options['beer']).to eq('esb')
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
context "specifying the application" do
|
362
|
+
before(:all) do
|
363
|
+
login_scenario "one app, one environment"
|
364
|
+
end
|
365
|
+
|
366
|
+
before(:each) do
|
367
|
+
@_deploy_spec_start_dir = Dir.getwd
|
368
|
+
Dir.chdir(File.expand_path("~"))
|
369
|
+
end
|
370
|
+
|
371
|
+
after(:each) do
|
372
|
+
Dir.chdir(@_deploy_spec_start_dir)
|
373
|
+
end
|
374
|
+
|
375
|
+
it "allows you to specify an app when not in a directory" do
|
376
|
+
fast_ey %w[deploy --app rails232app --ref master --migrate]
|
377
|
+
expect(@ssh_commands.last).to match(/--app rails232app/)
|
378
|
+
expect(@ssh_commands.last).to match(/--ref resolved-master/)
|
379
|
+
expect(@ssh_commands.last).to match(/--migrate 'rake db:migrate --trace'/)
|
380
|
+
end
|
381
|
+
|
382
|
+
it "requires that you specify a ref when specifying the application" do
|
383
|
+
Dir.chdir(File.expand_path("~")) do
|
384
|
+
fast_failing_ey %w[deploy --app rails232app --no-migrate]
|
385
|
+
expect(@err).to match(/you must also specify the --ref/)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
it "requires that you specify a migrate option when specifying the application" do
|
390
|
+
Dir.chdir(File.expand_path("~")) do
|
391
|
+
fast_failing_ey %w[deploy --app rails232app --ref master]
|
392
|
+
expect(@err).to match(/you must also specify .* --migrate or --no-migrate/)
|
393
|
+
end
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
context "setting a specific serverside version" do
|
398
|
+
use_git_repo("deploy test")
|
399
|
+
|
400
|
+
before(:all) do
|
401
|
+
login_scenario "one app, one environment"
|
402
|
+
end
|
403
|
+
|
404
|
+
it "should send the correct serverside version when specified" do
|
405
|
+
fast_ey %w[deploy --no-migrate --serverside-version 1.6.4]
|
406
|
+
deploy_command = @ssh_commands.find {|c| c =~ /engineyard-serverside.*deploy/ }
|
407
|
+
expect(deploy_command).to match(/engineyard-serverside _1.6.4_ deploy/)
|
408
|
+
end
|
409
|
+
|
410
|
+
it "should send the default serverside version when unspecified" do
|
411
|
+
fast_ey %w[deploy --no-migrate]
|
412
|
+
deploy_command = @ssh_commands.find {|c| c =~ /engineyard-serverside.*deploy/ }
|
413
|
+
expect(deploy_command).to match(/engineyard-serverside _#{EY::ENGINEYARD_SERVERSIDE_VERSION}_ deploy/)
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
context "sending necessary information" do
|
418
|
+
use_git_repo("deploy test")
|
419
|
+
|
420
|
+
before(:all) do
|
421
|
+
login_scenario "one app, one environment"
|
422
|
+
fast_ey %w[deploy --no-migrate]
|
423
|
+
@deploy_command = @ssh_commands.find {|c| c =~ /engineyard-serverside.*deploy/ }
|
424
|
+
end
|
425
|
+
|
426
|
+
it "passes along the repository URL to engineyard-serverside" do
|
427
|
+
expect(@deploy_command).to match(/--git user@git.host:path\/to\/repo.git/)
|
428
|
+
end
|
429
|
+
|
430
|
+
it "passes along the web server stack to engineyard-serverside" do
|
431
|
+
expect(@deploy_command).to match(/--stack nginx_mongrel/)
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
end
|