engineyard 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/engineyard.rb +1 -1
- data/lib/engineyard/api.rb +12 -1
- data/lib/engineyard/cli.rb +116 -48
- data/lib/engineyard/cli/recipes.rb +37 -7
- data/lib/engineyard/cli/ui.rb +8 -0
- data/lib/engineyard/cli/web.rb +41 -0
- data/lib/engineyard/error.rb +8 -1
- data/lib/engineyard/model/environment.rb +32 -6
- data/lib/engineyard/model/instance.rb +39 -20
- data/lib/engineyard/repo.rb +7 -3
- data/lib/engineyard/thor.rb +55 -2
- data/spec/engineyard/api_spec.rb +2 -2
- data/spec/engineyard/cli/api_spec.rb +1 -1
- data/spec/engineyard/model/environment_spec.rb +8 -6
- data/spec/ey/deploy_spec.rb +46 -81
- data/spec/ey/ey_spec.rb +2 -2
- data/spec/ey/list_environments_spec.rb +1 -1
- data/spec/ey/logs_spec.rb +11 -21
- data/spec/ey/rebuild_spec.rb +8 -33
- data/spec/ey/recipes/apply_spec.rb +8 -33
- data/spec/ey/recipes/download_spec.rb +29 -0
- data/spec/ey/recipes/upload_spec.rb +8 -25
- data/spec/ey/rollback_spec.rb +10 -40
- data/spec/ey/ssh_spec.rb +17 -34
- data/spec/ey/web/disable_spec.rb +18 -0
- data/spec/ey/web/enable_spec.rb +18 -0
- data/spec/spec_helper.rb +7 -3
- data/spec/support/fake_awsm.ru +18 -0
- data/spec/support/helpers.rb +13 -0
- data/spec/support/shared_behavior.rb +132 -0
- metadata +8 -3
data/spec/ey/ey_spec.rb
CHANGED
@@ -3,14 +3,14 @@ require 'spec_helper'
|
|
3
3
|
describe "ey" do
|
4
4
|
context "run without arguments" do
|
5
5
|
it "prints usage information" do
|
6
|
-
ey.should include("
|
6
|
+
ey.should include("Commands:")
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
context "run with an argument that is not a command" do
|
11
11
|
it "tells the user that is not a command" do
|
12
12
|
ey "foobarbaz", :expect_failure => true
|
13
|
-
@err.should include("Could not find
|
13
|
+
@err.should include("Could not find command")
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/spec/ey/logs_spec.rb
CHANGED
@@ -1,19 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "ey logs" do
|
4
|
-
|
4
|
+
given "integration"
|
5
5
|
|
6
6
|
it "prints logs returned by awsm" do
|
7
7
|
api_scenario "one app, one environment"
|
8
|
-
ey "logs giblets"
|
9
|
-
@out.should match(/MAIN LOG OUTPUT/)
|
10
|
-
@out.should match(/CUSTOM LOG OUTPUT/)
|
11
|
-
@err.should be_empty
|
12
|
-
end
|
13
|
-
|
14
|
-
it "can infer the environment" do
|
15
|
-
api_scenario "one app, one environment"
|
16
|
-
ey "logs"
|
8
|
+
ey "logs -e giblets"
|
17
9
|
@out.should match(/MAIN LOG OUTPUT/)
|
18
10
|
@out.should match(/CUSTOM LOG OUTPUT/)
|
19
11
|
@err.should be_empty
|
@@ -26,20 +18,18 @@ describe "ey logs" do
|
|
26
18
|
end
|
27
19
|
end
|
28
20
|
|
29
|
-
describe "ey logs
|
30
|
-
|
21
|
+
describe "ey logs" do
|
22
|
+
given "integration"
|
31
23
|
|
32
|
-
|
33
|
-
|
24
|
+
def command_to_run(opts)
|
25
|
+
cmd = "logs"
|
26
|
+
cmd << " --environment #{opts[:env]}" if opts[:env]
|
27
|
+
cmd
|
34
28
|
end
|
35
29
|
|
36
|
-
|
37
|
-
|
38
|
-
@out.should match(/MAIN LOG OUTPUT/)
|
30
|
+
def verify_ran(scenario)
|
31
|
+
@out.should match(/Main logs for #{scenario[:environment]}/)
|
39
32
|
end
|
40
33
|
|
41
|
-
|
42
|
-
ey "logs staging", :hide_err => true, :expect_failure => true
|
43
|
-
@err.should match(/'staging' is ambiguous/)
|
44
|
-
end
|
34
|
+
it_should_behave_like "it takes an environment name"
|
45
35
|
end
|
data/spec/ey/rebuild_spec.rb
CHANGED
@@ -1,42 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "ey rebuild" do
|
4
|
-
|
4
|
+
given "integration"
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
def command_to_run(opts)
|
7
|
+
cmd = "rebuild"
|
8
|
+
cmd << " --environment #{opts[:env]}" if opts[:env]
|
9
|
+
cmd
|
8
10
|
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
@out.should =~ /Rebuilding giblets/i
|
12
|
+
def verify_ran(scenario)
|
13
|
+
@out.should =~ /Rebuilding #{scenario[:environment]}/
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
ey "rebuild", :debug => true
|
17
|
-
@out.should =~ /Rebuilding giblets/i
|
18
|
-
end
|
19
|
-
|
20
|
-
it "fails when the environment name is bogus" do
|
21
|
-
ey "rebuild typo", :expect_failure => true
|
22
|
-
@err.should match(/'typo'/)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "ey rebuild ENV" do
|
27
|
-
it_should_behave_like "an integration test"
|
28
|
-
|
29
|
-
before(:all) do
|
30
|
-
api_scenario "one app, many similarly-named environments"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "works when given an unambiguous substring" do
|
34
|
-
ey "rebuild prod", :debug => true
|
35
|
-
@out.should =~ /Rebuilding railsapp_production/
|
36
|
-
end
|
37
|
-
|
38
|
-
it "complains when given an ambiguous substring" do
|
39
|
-
ey "rebuild staging", :hide_err => true, :expect_failure => true
|
40
|
-
@err.should =~ /'staging' is ambiguous/
|
41
|
-
end
|
16
|
+
it_should_behave_like "it takes an environment name"
|
42
17
|
end
|
@@ -1,42 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "ey recipes apply" do
|
4
|
-
|
4
|
+
given "integration"
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
def command_to_run(opts)
|
7
|
+
cmd = "recipes apply"
|
8
|
+
cmd << " -e #{opts[:env]}" if opts[:env]
|
9
|
+
cmd
|
8
10
|
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
@out.should =~ /Uploaded recipes started for giblets/i
|
12
|
+
def verify_ran(scenario)
|
13
|
+
@out.should =~ /Uploaded recipes started for #{scenario[:environment]}/
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
ey "recipes apply", :debug => true
|
17
|
-
@out.should =~ /Uploaded recipes started for giblets/i
|
18
|
-
end
|
19
|
-
|
20
|
-
it "fails when the environment name is bogus" do
|
21
|
-
ey "recipes apply typo", :expect_failure => true
|
22
|
-
@err.should match(/'typo'/)
|
23
|
-
end
|
16
|
+
it_should_behave_like "it takes an environment name"
|
24
17
|
end
|
25
|
-
|
26
|
-
describe "ey recipes apply ENV" do
|
27
|
-
it_should_behave_like "an integration test"
|
28
|
-
|
29
|
-
before(:all) do
|
30
|
-
api_scenario "one app, many similarly-named environments"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "works when given an unambiguous substring" do
|
34
|
-
ey "recipes apply prod", :debug => true
|
35
|
-
@out.should =~ /Uploaded recipes started for railsapp_production/
|
36
|
-
end
|
37
|
-
|
38
|
-
it "complains when given an ambiguous substring" do
|
39
|
-
ey "recipes apply staging", :hide_err => true, :expect_failure => true
|
40
|
-
@err.should =~ /'staging' is ambiguous/
|
41
|
-
end
|
42
|
-
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "ey recipes download" do
|
4
|
+
given "integration"
|
5
|
+
|
6
|
+
after(:each) do
|
7
|
+
FileUtils.rm_rf('cookbooks')
|
8
|
+
end
|
9
|
+
|
10
|
+
def command_to_run(opts)
|
11
|
+
cmd = "recipes download"
|
12
|
+
cmd << " --environment #{opts[:env]}" if opts[:env]
|
13
|
+
cmd
|
14
|
+
end
|
15
|
+
|
16
|
+
def verify_ran(scenario)
|
17
|
+
@out.should =~ /Recipes downloaded successfully for #{scenario[:environment]}/
|
18
|
+
File.read('cookbooks/README').should == "Remove this file to clone an upstream git repository of cookbooks\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
it_should_behave_like "it takes an environment name"
|
22
|
+
|
23
|
+
it "fails when cookbooks/ already exists" do
|
24
|
+
api_scenario "one app, one environment"
|
25
|
+
Dir.mkdir("cookbooks")
|
26
|
+
ey "recipes download", :expect_failure => true
|
27
|
+
@err.should match(/cookbooks.*already exists/i)
|
28
|
+
end
|
29
|
+
end
|
@@ -1,40 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "ey recipes upload" do
|
4
|
-
|
4
|
+
given "integration"
|
5
5
|
|
6
6
|
define_git_repo('+cookbooks') do |git_dir|
|
7
7
|
git_dir.join("cookbooks").mkdir
|
8
8
|
File.open(git_dir.join("cookbooks/file"), "w"){|f| f << "boo" }
|
9
9
|
end
|
10
|
-
|
11
10
|
use_git_repo('+cookbooks')
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
@out.should =~ /Recipes uploaded successfully for giblets/i
|
18
|
-
end
|
19
|
-
|
20
|
-
it "errors correctly on bogus env name" do
|
21
|
-
api_scenario "one app, one environment"
|
22
|
-
ey "recipes upload bogusenv", :expect_failure => true
|
23
|
-
|
24
|
-
@err.should =~ /No environment named 'bogusenv'/
|
12
|
+
def command_to_run(opts)
|
13
|
+
cmd = "recipes upload"
|
14
|
+
cmd << " --environment #{opts[:env]}" if opts[:env]
|
15
|
+
cmd
|
25
16
|
end
|
26
17
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
ey "recipes upload", :debug => true
|
31
|
-
@out.should =~ /Recipes uploaded successfully for giblets/i
|
18
|
+
def verify_ran(scenario)
|
19
|
+
@out.should =~ /Recipes uploaded successfully for #{scenario[:environment]}/
|
32
20
|
end
|
33
21
|
|
34
|
-
|
35
|
-
api_scenario "one app, one environment, not linked"
|
36
|
-
|
37
|
-
ey "recipes upload", :debug => true, :expect_failure => true
|
38
|
-
@err.should =~ /single environment/i
|
39
|
-
end
|
22
|
+
it_should_behave_like "it takes an environment name"
|
40
23
|
end
|
data/spec/ey/rollback_spec.rb
CHANGED
@@ -1,50 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "ey rollback" do
|
4
|
-
|
4
|
+
given "integration"
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
def command_to_run(opts)
|
7
|
+
cmd = "rollback"
|
8
|
+
cmd << " -e #{opts[:env]}" if opts[:env]
|
9
|
+
cmd
|
8
10
|
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
@out.should match(/rolling back giblets/i)
|
12
|
+
def verify_ran(scenario)
|
13
|
+
@out.should match(/Rolling back #{scenario[:environment]}/)
|
13
14
|
@err.should be_empty
|
14
|
-
@ssh_commands.last.should match(/eysd deploy rollback --app
|
15
|
+
@ssh_commands.last.should match(/eysd deploy rollback --app #{scenario[:application]}/)
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
@out.should match(/rolling back giblets/i)
|
20
|
-
@err.should be_empty
|
21
|
-
@ssh_commands.last.should match(/eysd deploy rollback --app rails232app/)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "fails when the environment name is bogus" do
|
25
|
-
ey "rollback typo", :expect_failure => true
|
26
|
-
@err.should match(/'typo'/)
|
27
|
-
@ssh_commands.should be_empty
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "ey rollback ENV" do
|
32
|
-
it_should_behave_like "an integration test"
|
33
|
-
|
34
|
-
before(:all) do
|
35
|
-
api_scenario "one app, many similarly-named environments"
|
36
|
-
end
|
37
|
-
|
38
|
-
it "works when given an unambiguous substring" do
|
39
|
-
ey "rollback prod", :debug => true
|
40
|
-
@out.should match(/Rolling back railsapp_production/i)
|
41
|
-
@err.should be_empty
|
42
|
-
@ssh_commands.last.should match(/eysd deploy rollback --app rails232app/)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "complains when given an ambiguous substring" do
|
46
|
-
ey "rollback staging", :hide_err => true, :expect_failure => true
|
47
|
-
@err.should =~ /'staging' is ambiguous/
|
48
|
-
@ssh_commands.should be_empty
|
49
|
-
end
|
18
|
+
it_should_behave_like "it takes an environment name"
|
19
|
+
it_should_behave_like "it invokes eysd"
|
50
20
|
end
|
data/spec/ey/ssh_spec.rb
CHANGED
@@ -3,68 +3,51 @@ require 'spec_helper'
|
|
3
3
|
print_my_args_ssh = "#!/bin/sh\necho ssh $*"
|
4
4
|
|
5
5
|
describe "ey ssh" do
|
6
|
-
|
6
|
+
given "integration"
|
7
7
|
|
8
8
|
before(:all) do
|
9
9
|
api_scenario "one app, two environments"
|
10
10
|
end
|
11
11
|
|
12
|
-
it "SSH-es into the right environment" do
|
13
|
-
ey "ssh giblets", :prepend_to_path => {'ssh' => print_my_args_ssh}
|
14
|
-
@raw_ssh_commands.should == ["ssh turkey@174.129.198.124"]
|
15
|
-
end
|
16
|
-
|
17
12
|
it "complains if it has no app master" do
|
18
|
-
ey "ssh bakon", :expect_failure => true
|
13
|
+
ey "ssh -e bakon", :expect_failure => true
|
19
14
|
@err.should =~ /'bakon' does not have a master instance/
|
20
15
|
end
|
21
16
|
|
22
|
-
it "complains if you give it a bogus environment" do
|
23
|
-
ey "ssh bogusenv", :prepend_to_path => {'ssh' => print_my_args_ssh}, :expect_failure => true
|
24
|
-
@raw_ssh_commands.should be_empty
|
25
|
-
@err.should =~ /bogusenv/
|
26
|
-
end
|
27
17
|
end
|
28
18
|
|
29
19
|
describe "ey ssh" do
|
30
|
-
|
20
|
+
given "integration"
|
31
21
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
ey "ssh", :prepend_to_path => {'ssh' => print_my_args_ssh}
|
36
|
-
@raw_ssh_commands.should == ["ssh turkey@174.129.198.124"]
|
22
|
+
def extra_ey_options
|
23
|
+
{:prepend_to_path => {'ssh' => "#!/bin/sh\necho ssh $*"}}
|
37
24
|
end
|
38
25
|
|
39
|
-
|
40
|
-
|
26
|
+
def command_to_run(opts)
|
27
|
+
cmd = "ssh"
|
28
|
+
cmd << " --environment #{opts[:env]}" if opts[:env]
|
29
|
+
cmd
|
30
|
+
end
|
41
31
|
|
42
|
-
|
43
|
-
@
|
32
|
+
def verify_ran(scenario)
|
33
|
+
ssh_target = scenario[:ssh_username] + '@' + scenario[:master_ip]
|
34
|
+
@raw_ssh_commands.should == ["ssh #{ssh_target}"]
|
44
35
|
end
|
36
|
+
|
37
|
+
it_should_behave_like "it takes an environment name"
|
45
38
|
end
|
46
39
|
|
47
40
|
describe "ey ssh ENV" do
|
48
|
-
|
41
|
+
given "integration"
|
49
42
|
|
50
43
|
before(:all) do
|
51
44
|
api_scenario "one app, many similarly-named environments"
|
52
45
|
end
|
53
46
|
|
54
|
-
it "works when given an unambiguous substring" do
|
55
|
-
ey "ssh prod", :prepend_to_path => {'ssh' => print_my_args_ssh}
|
56
|
-
@raw_ssh_commands.should == ["ssh turkey@174.129.198.124"]
|
57
|
-
end
|
58
|
-
|
59
47
|
it "doesn't require you to be in any app's directory if the name is unambiguous" do
|
60
48
|
Dir.chdir(Dir.tmpdir) do
|
61
|
-
ey "ssh prod", :prepend_to_path => {'ssh' => print_my_args_ssh}
|
49
|
+
ey "ssh -e prod", :prepend_to_path => {'ssh' => print_my_args_ssh}
|
62
50
|
@raw_ssh_commands.should == ["ssh turkey@174.129.198.124"]
|
63
51
|
end
|
64
52
|
end
|
65
|
-
|
66
|
-
it "complains when given an ambiguous substring" do
|
67
|
-
ey "ssh staging", :hide_err => true, :expect_failure => true
|
68
|
-
@err.should match(/'staging' is ambiguous/)
|
69
|
-
end
|
70
53
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "ey web disable" do
|
4
|
+
given "integration"
|
5
|
+
|
6
|
+
def command_to_run(opts)
|
7
|
+
cmd = "web disable"
|
8
|
+
cmd << " -e #{opts[:env]}" if opts[:env]
|
9
|
+
cmd
|
10
|
+
end
|
11
|
+
|
12
|
+
def verify_ran(scenario)
|
13
|
+
@ssh_commands.should have_command_like(/eysd deploy enable_maintenance_page --app #{scenario[:application]}/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it_should_behave_like "it takes an environment name"
|
17
|
+
it_should_behave_like "it invokes eysd"
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "ey web enable" do
|
4
|
+
given "integration"
|
5
|
+
|
6
|
+
def command_to_run(opts)
|
7
|
+
cmd = "web enable"
|
8
|
+
cmd << " -e #{opts[:env]}" if opts[:env]
|
9
|
+
cmd
|
10
|
+
end
|
11
|
+
|
12
|
+
def verify_ran(scenario)
|
13
|
+
@ssh_commands.should have_command_like(/eysd deploy disable_maintenance_page --app #{scenario[:application]}/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it_should_behave_like "it takes an environment name"
|
17
|
+
it_should_behave_like "it invokes eysd"
|
18
|
+
end
|