crazy-yard 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +19 -0
  3. data/README.md +438 -0
  4. data/bin/ey +9 -0
  5. data/lib/engineyard.rb +9 -0
  6. data/lib/engineyard/cli.rb +816 -0
  7. data/lib/engineyard/cli/api.rb +98 -0
  8. data/lib/engineyard/cli/recipes.rb +129 -0
  9. data/lib/engineyard/cli/ui.rb +275 -0
  10. data/lib/engineyard/cli/web.rb +85 -0
  11. data/lib/engineyard/config.rb +158 -0
  12. data/lib/engineyard/deploy_config.rb +65 -0
  13. data/lib/engineyard/deploy_config/ref.rb +56 -0
  14. data/lib/engineyard/error.rb +82 -0
  15. data/lib/engineyard/eyrc.rb +59 -0
  16. data/lib/engineyard/repo.rb +105 -0
  17. data/lib/engineyard/serverside_runner.rb +159 -0
  18. data/lib/engineyard/templates.rb +6 -0
  19. data/lib/engineyard/templates/ey.yml.erb +196 -0
  20. data/lib/engineyard/templates/ey_yml.rb +119 -0
  21. data/lib/engineyard/thor.rb +215 -0
  22. data/lib/engineyard/version.rb +4 -0
  23. data/lib/vendor/thor/Gemfile +15 -0
  24. data/lib/vendor/thor/LICENSE.md +20 -0
  25. data/lib/vendor/thor/README.md +35 -0
  26. data/lib/vendor/thor/lib/thor.rb +473 -0
  27. data/lib/vendor/thor/lib/thor/actions.rb +318 -0
  28. data/lib/vendor/thor/lib/thor/actions/create_file.rb +105 -0
  29. data/lib/vendor/thor/lib/thor/actions/create_link.rb +60 -0
  30. data/lib/vendor/thor/lib/thor/actions/directory.rb +119 -0
  31. data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +137 -0
  32. data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +314 -0
  33. data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +109 -0
  34. data/lib/vendor/thor/lib/thor/base.rb +652 -0
  35. data/lib/vendor/thor/lib/thor/command.rb +136 -0
  36. data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +80 -0
  37. data/lib/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
  38. data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +100 -0
  39. data/lib/vendor/thor/lib/thor/error.rb +28 -0
  40. data/lib/vendor/thor/lib/thor/group.rb +282 -0
  41. data/lib/vendor/thor/lib/thor/invocation.rb +172 -0
  42. data/lib/vendor/thor/lib/thor/parser.rb +4 -0
  43. data/lib/vendor/thor/lib/thor/parser/argument.rb +74 -0
  44. data/lib/vendor/thor/lib/thor/parser/arguments.rb +171 -0
  45. data/lib/vendor/thor/lib/thor/parser/option.rb +121 -0
  46. data/lib/vendor/thor/lib/thor/parser/options.rb +218 -0
  47. data/lib/vendor/thor/lib/thor/rake_compat.rb +72 -0
  48. data/lib/vendor/thor/lib/thor/runner.rb +322 -0
  49. data/lib/vendor/thor/lib/thor/shell.rb +88 -0
  50. data/lib/vendor/thor/lib/thor/shell/basic.rb +393 -0
  51. data/lib/vendor/thor/lib/thor/shell/color.rb +148 -0
  52. data/lib/vendor/thor/lib/thor/shell/html.rb +127 -0
  53. data/lib/vendor/thor/lib/thor/util.rb +270 -0
  54. data/lib/vendor/thor/lib/thor/version.rb +3 -0
  55. data/lib/vendor/thor/thor.gemspec +24 -0
  56. data/spec/engineyard/cli/api_spec.rb +50 -0
  57. data/spec/engineyard/cli_spec.rb +28 -0
  58. data/spec/engineyard/config_spec.rb +61 -0
  59. data/spec/engineyard/deploy_config_spec.rb +194 -0
  60. data/spec/engineyard/eyrc_spec.rb +76 -0
  61. data/spec/engineyard/repo_spec.rb +83 -0
  62. data/spec/engineyard_spec.rb +7 -0
  63. data/spec/ey/console_spec.rb +57 -0
  64. data/spec/ey/deploy_spec.rb +435 -0
  65. data/spec/ey/ey_spec.rb +23 -0
  66. data/spec/ey/init_spec.rb +123 -0
  67. data/spec/ey/list_environments_spec.rb +120 -0
  68. data/spec/ey/login_spec.rb +33 -0
  69. data/spec/ey/logout_spec.rb +24 -0
  70. data/spec/ey/logs_spec.rb +36 -0
  71. data/spec/ey/rebuild_spec.rb +18 -0
  72. data/spec/ey/recipes/apply_spec.rb +29 -0
  73. data/spec/ey/recipes/download_spec.rb +43 -0
  74. data/spec/ey/recipes/upload_spec.rb +99 -0
  75. data/spec/ey/rollback_spec.rb +73 -0
  76. data/spec/ey/scp_spec.rb +176 -0
  77. data/spec/ey/servers_spec.rb +209 -0
  78. data/spec/ey/ssh_spec.rb +273 -0
  79. data/spec/ey/status_spec.rb +45 -0
  80. data/spec/ey/timeout_deploy_spec.rb +18 -0
  81. data/spec/ey/web/disable_spec.rb +21 -0
  82. data/spec/ey/web/enable_spec.rb +26 -0
  83. data/spec/ey/web/restart_spec.rb +21 -0
  84. data/spec/ey/whoami_spec.rb +30 -0
  85. data/spec/spec_helper.rb +84 -0
  86. data/spec/support/bundled_ey +7 -0
  87. data/spec/support/fixture_recipes.tgz +0 -0
  88. data/spec/support/git_repos.rb +115 -0
  89. data/spec/support/helpers.rb +330 -0
  90. data/spec/support/matchers.rb +16 -0
  91. data/spec/support/ruby_ext.rb +13 -0
  92. data/spec/support/shared_behavior.rb +278 -0
  93. metadata +411 -0
@@ -0,0 +1,99 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ey recipes upload" do
4
+ given "integration"
5
+
6
+ use_git_repo('+cookbooks')
7
+
8
+ def command_to_run(opts)
9
+ cmd = %w[recipes upload]
10
+ cmd << "--environment" << opts[:environment] if opts[:environment]
11
+ cmd << "--account" << opts[:account] if opts[:account]
12
+ cmd
13
+ end
14
+
15
+ def verify_ran(scenario)
16
+ expect(@out).to match(%r|Recipes in cookbooks/ uploaded successfully for #{scenario[:environment]}|)
17
+ end
18
+
19
+ include_examples "it takes an environment name and an account name"
20
+ end
21
+
22
+ describe "ey recipes upload -f recipes.tgz" do
23
+ given "integration"
24
+
25
+ use_git_repo('+recipes')
26
+
27
+ def command_to_run(opts)
28
+ cmd = %w[recipes upload]
29
+ cmd << "--environment" << opts[:environment] if opts[:environment]
30
+ cmd << "--account" << opts[:account] if opts[:account]
31
+ cmd << "-f" << "recipes.tgz"
32
+ cmd
33
+ end
34
+
35
+ def verify_ran(scenario)
36
+ expect(@out).to match(%r|Recipes file recipes.tgz uploaded successfully for #{scenario[:environment]}|)
37
+ end
38
+
39
+ include_examples "it takes an environment name and an account name"
40
+ end
41
+
42
+ describe "ey recipes upload -f with a missing filenamen" do
43
+ given "integration"
44
+ def command_to_run(opts)
45
+ cmd = %w[recipes upload]
46
+ cmd << "--environment" << opts[:environment] if opts[:environment]
47
+ cmd << "--account" << opts[:account] if opts[:account]
48
+ cmd << "-f" << "recipes.tgz"
49
+ cmd
50
+ end
51
+
52
+ it "errors with file not found" do
53
+ login_scenario "one app, one environment"
54
+ fast_failing_ey(%w[recipes upload --environment giblets -f recipes.tgz])
55
+ expect(@err).to match(/Recipes file not found: recipes.tgz/i)
56
+ end
57
+ end
58
+
59
+ describe "ey recipes upload with an ambiguous git repo" do
60
+ given "integration"
61
+ def command_to_run(_) %w[recipes upload] end
62
+ include_examples "it requires an unambiguous git repo"
63
+ end
64
+
65
+ describe "ey recipes upload from a separate cookbooks directory" do
66
+ given "integration"
67
+
68
+ context "without any git remotes" do
69
+ use_git_repo "only cookbooks, no remotes"
70
+
71
+ it "takes the environment specified by -e" do
72
+ login_scenario "one app, one environment"
73
+
74
+ ey %w[recipes upload -e giblets]
75
+ expect(@out).to match(%r|Recipes in cookbooks/ uploaded successfully|)
76
+ expect(@out).not_to match(/Uploaded recipes started for giblets/)
77
+ end
78
+
79
+ it "applies the recipes with --apply" do
80
+ login_scenario "one app, one environment"
81
+
82
+ ey %w[recipes upload -e giblets --apply]
83
+ expect(@out).to match(%r|Recipes in cookbooks/ uploaded successfully|)
84
+ expect(@out).to match(/Uploaded recipes started for giblets/)
85
+ end
86
+ end
87
+
88
+ context "with a git remote unrelated to any application" do
89
+ use_git_repo "only cookbooks, unrelated remotes"
90
+
91
+ it "takes the environment specified by -e" do
92
+ login_scenario "one app, one environment"
93
+
94
+ ey %w[recipes upload -e giblets]
95
+ expect(@out).to match(%r|Recipes in cookbooks/ uploaded successfully|)
96
+ end
97
+
98
+ end
99
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ey rollback" do
4
+ given "integration"
5
+
6
+ def command_to_run(opts)
7
+ cmd = ["rollback"]
8
+ cmd << "-e" << opts[:environment] if opts[:environment]
9
+ cmd << "-a" << opts[:app] if opts[:app]
10
+ cmd << "-c" << opts[:account] if opts[:account]
11
+ cmd << "--verbose" if opts[:verbose]
12
+ cmd
13
+ end
14
+
15
+ def verify_ran(scenario)
16
+ expect(@out).to match(/Rolling back.*#{scenario[:application]}.*#{scenario[:environment]}/)
17
+ expect(@err).to eq('')
18
+ expect(@ssh_commands.last).to match(/engineyard-serverside.*deploy rollback.*--app #{scenario[:application]}/)
19
+ end
20
+
21
+ include_examples "it takes an environment name and an app name and an account name"
22
+ include_examples "it invokes engineyard-serverside"
23
+
24
+ it "passes along the web server stack to engineyard-serverside" do
25
+ login_scenario "one app, one environment"
26
+ ey %w[rollback]
27
+ expect(@ssh_commands.last).to match(/--stack nginx_mongrel/)
28
+ end
29
+
30
+ context "--config (--extra-deploy-hook-options)" do
31
+ before(:all) do
32
+ login_scenario "one app, one environment"
33
+ end
34
+
35
+ def config_options
36
+ if @ssh_commands.last =~ /--config (.*?)(?: -|$)/
37
+ # the echo strips off the layer of shell escaping, leaving us
38
+ # with pristine JSON
39
+ MultiJson.load `echo #{$1}`
40
+ end
41
+ end
42
+
43
+ it "passes --config to engineyard-serverside" do
44
+ ey %w[rollback --config some:stuff more:crap]
45
+ expect(config_options).not_to be_nil
46
+ expect(config_options['some']).to eq('stuff')
47
+ expect(config_options['more']).to eq('crap')
48
+ expect(config_options['input_ref']).not_to be_nil
49
+ expect(config_options['deployed_by']).not_to be_nil
50
+ end
51
+
52
+ it "supports legacy --extra-deploy-hook-options" do
53
+ ey %w[rollback --extra-deploy-hook-options some:stuff more:crap]
54
+ expect(config_options).not_to be_nil
55
+ expect(config_options['some']).to eq('stuff')
56
+ expect(config_options['more']).to eq('crap')
57
+ end
58
+
59
+ context "when ey.yml is present" do
60
+ before do
61
+ write_yaml({"environments" => {"giblets" => {"beer" => "stout"}}}, 'ey.yml')
62
+ end
63
+
64
+ after { File.unlink("ey.yml") }
65
+
66
+ it "overrides what's in ey.yml" do
67
+ ey %w[rollback --config beer:esb]
68
+ expect(config_options['beer']).to eq('esb')
69
+ end
70
+ end
71
+ end
72
+
73
+ end
@@ -0,0 +1,176 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples_for "running ey scp" do
4
+ given "integration"
5
+
6
+ def extra_ey_options
7
+ {:prepend_to_path => {'scp' => "#!/bin/sh\necho scp $*"}}
8
+ end
9
+ end
10
+
11
+ shared_examples_for "running ey scp for select role" do
12
+ given "integration"
13
+
14
+ def extra_ey_options
15
+ {:prepend_to_path => {'scp' => "#!/bin/sh\necho scp $*"}}
16
+ end
17
+
18
+ def command_to_run(opts)
19
+ cmd = ["scp", opts[:from], opts[:to]].compact + (@scp_flag || [])
20
+ cmd << "--environment" << opts[:environment] if opts[:environment]
21
+ cmd << "--quiet" if opts[:quiet]
22
+ cmd
23
+ end
24
+
25
+ it "runs the command on the right servers" do
26
+ login_scenario "one app, one environment"
27
+ ey command_to_run(from: "from", to: "to", environment: 'giblets', verbose: true)
28
+ @hosts.each do |host_prefix|
29
+ expect(@raw_ssh_commands.grep(/^scp from turkey@#{host_prefix}.+:to$/)).not_to be_empty
30
+ end
31
+ expect(@raw_ssh_commands.grep(/^scp from turkey@.+:to$/).count).to eq(@hosts.count)
32
+ end
33
+
34
+ it "is quiet" do
35
+ login_scenario "one app, one environment"
36
+ ey command_to_run(from: "from", to: "to", environment: 'giblets', quiet: true)
37
+ expect(@out).to match(/scp.*from.*to/)
38
+ expect(@out).not_to match(/Loading application data/)
39
+ end
40
+
41
+ it "raises an error when there are no matching hosts" do
42
+ login_scenario "one app, one environment, no instances"
43
+ ey command_to_run({from: "from", to: "to", environment: 'giblets', verbose: true}), expect_failure: true
44
+ end
45
+
46
+ it "errors correctly when no file paths are specified" do
47
+ login_scenario "one app, one environment"
48
+ ey command_to_run({environment: 'giblets', verbose: true}), expect_failure: true
49
+ ey command_to_run({from: "from", environment: 'giblets', verbose: true}), expect_failure: true
50
+ end
51
+ end
52
+
53
+ describe "ey scp" do
54
+ include_examples "running ey scp"
55
+
56
+ before(:all) do
57
+ login_scenario "one app, many environments"
58
+ end
59
+
60
+ it "complains if it has no app master" do
61
+ ey %w[scp from to -e bakon], :expect_failure => true
62
+ expect(@err).to match(/'bakon' does not have any matching instances/)
63
+ end
64
+
65
+ end
66
+
67
+ describe "ey scp with an ambiguous git repo" do
68
+ include_examples "running ey scp"
69
+ def command_to_run(_) %w[scp from to] end
70
+ include_examples "it requires an unambiguous git repo"
71
+ end
72
+
73
+ describe "ey scp" do
74
+ include_examples "running ey scp"
75
+
76
+ def command_to_run(opts)
77
+ cmd = %w[scp HOST:from to]
78
+ cmd << "--environment" << opts[:environment] if opts[:environment]
79
+ cmd << "--account" << opts[:account] if opts[:account]
80
+ cmd
81
+ end
82
+
83
+ def verify_ran(scenario)
84
+ scp_target = scenario[:ssh_username] + '@' + scenario[:master_hostname]
85
+ expect(@raw_ssh_commands).to eq(["scp #{scp_target}:from to"])
86
+ end
87
+
88
+ include_examples "it takes an environment name and an account name"
89
+ end
90
+
91
+ describe "ey scp --all" do
92
+ before do
93
+ @scp_flag = %w[--all]
94
+ @hosts = %w(app_hostname
95
+ app_master_hostname
96
+ util_fluffy_hostname
97
+ util_rocky_hostname
98
+ db_master_hostname
99
+ db_slave_1_hostname
100
+ db_slave_2_hostname)
101
+ end
102
+
103
+ include_examples "running ey scp"
104
+ include_examples "running ey scp for select role"
105
+ end
106
+
107
+ describe "ey scp --app-servers" do
108
+ before do
109
+ @scp_flag = %w[--app-servers]
110
+ @hosts = %w(app_hostname app_master_hostname)
111
+ end
112
+
113
+ include_examples "running ey scp"
114
+ include_examples "running ey scp for select role"
115
+ end
116
+
117
+ describe "ey scp --db-master" do
118
+ before do
119
+ @scp_flag = %w[--db-master]
120
+ @hosts = %w(db_master_hostname)
121
+ end
122
+
123
+ include_examples "running ey scp"
124
+ include_examples "running ey scp for select role"
125
+ end
126
+
127
+ describe "ey scp --db-slaves" do
128
+ before do
129
+ @scp_flag = %w[--db-slaves]
130
+ @hosts = %w(db_slave_1_hostname db_slave_2_hostname)
131
+ end
132
+
133
+ include_examples "running ey scp"
134
+ include_examples "running ey scp for select role"
135
+ end
136
+
137
+ describe "ey scp --db-servers" do
138
+ before do
139
+ @scp_flag = %w[--db-servers]
140
+ @hosts = %w(db_master_hostname db_slave_1_hostname db_slave_2_hostname)
141
+ end
142
+
143
+ include_examples "running ey scp"
144
+ include_examples "running ey scp for select role"
145
+ end
146
+
147
+ describe "ey scp --utilities" do
148
+ before do
149
+ @scp_flag = %w[--utilities]
150
+ @hosts = %w(util_fluffy_hostname util_rocky_hostname)
151
+ end
152
+
153
+ include_examples "running ey scp"
154
+ include_examples "running ey scp for select role"
155
+ end
156
+
157
+ describe "ey scp --utilities fluffy" do
158
+ before do
159
+ @scp_flag = %w[--utilities fluffy]
160
+ @hosts = %w(util_fluffy_hostname)
161
+ end
162
+
163
+ include_examples "running ey scp"
164
+ include_examples "running ey scp for select role"
165
+ end
166
+
167
+ describe "ey scp --utilities fluffy rocky" do
168
+ before do
169
+ @scp_flag = %w[--utilities fluffy rocky]
170
+ @hosts = %w(util_fluffy_hostname util_rocky_hostname)
171
+ end
172
+
173
+ include_examples "running ey scp"
174
+ include_examples "running ey scp for select role"
175
+ end
176
+
@@ -0,0 +1,209 @@
1
+ require 'spec_helper'
2
+
3
+ describe "ey servers" do
4
+
5
+ given "integration"
6
+
7
+ def command_to_run(opts)
8
+ cmd = ["servers"]
9
+ cmd << "--environment" << opts[:environment] if opts[:environment]
10
+ cmd << "--account" << opts[:account] if opts[:account]
11
+ cmd
12
+ end
13
+
14
+ def verify_ran(scenario)
15
+ expect(@out).to match(/#{scenario[:environment]}/) if scenario[:environment]
16
+ expect(@out).to match(/#{scenario[:account]}/) if scenario[:account]
17
+ end
18
+
19
+ include_examples "it takes an environment name and an account name"
20
+
21
+ context "with no servers" do
22
+ before do
23
+ login_scenario "empty"
24
+ end
25
+
26
+ it "prints error when no application found" do
27
+ fast_failing_ey %w[servers]
28
+ expect(@err).to match(/No application found/)
29
+ end
30
+ end
31
+
32
+ context "with 1 server" do
33
+ before(:all) do
34
+ login_scenario "one app, many environments"
35
+ end
36
+
37
+ it "lists the servers with specified env" do
38
+ fast_ey %w[servers -e giblets]
39
+ expect(@out).to match(/main \/ giblets/)
40
+ expect(@out).to include('1 server ')
41
+ end
42
+ end
43
+
44
+ context "with servers" do
45
+ before(:all) do
46
+ login_scenario "two accounts, two apps, two environments, ambiguous"
47
+ end
48
+
49
+ it "lists the servers with specified env" do
50
+ fast_ey %w[servers -c main -e giblets]
51
+ expect(@out).to include("# 7 servers on main / giblets")
52
+ expect(@out).to include("app_master_hostname.compute-1.amazonaws.com \ti-ddbbdd92\tapp_master")
53
+ expect(@out).to include("app_hostname.compute-1.amazonaws.com \ti-d2e3f1b9\tapp")
54
+ expect(@out).to include("db_master_hostname.compute-1.amazonaws.com \ti-d4cdddbf\tdb_master")
55
+ expect(@out).to include("db_slave_1_hostname.compute-1.amazonaws.com \ti-asdfasdfaj\tdb_slave \tSlave I")
56
+ expect(@out).to include("db_slave_2_hostname.compute-1.amazonaws.com \ti-asdfasdfaj\tdb_slave")
57
+ expect(@out).to include("util_fluffy_hostname.compute-1.amazonaws.com\ti-80e3f1eb\tutil \tfluffy")
58
+ expect(@out).to include("util_rocky_hostname.compute-1.amazonaws.com \ti-80etf1eb\tutil \trocky")
59
+ end
60
+
61
+ it "lists the servers with specified env with users" do
62
+ fast_ey %w[servers -c main -e giblets -u]
63
+ expect(@out).to include("# 7 servers on main / giblets")
64
+ expect(@out).to include("turkey@app_master_hostname.compute-1.amazonaws.com \ti-ddbbdd92\tapp_master")
65
+ expect(@out).to include("turkey@app_hostname.compute-1.amazonaws.com \ti-d2e3f1b9\tapp")
66
+ expect(@out).to include("turkey@db_master_hostname.compute-1.amazonaws.com \ti-d4cdddbf\tdb_master")
67
+ expect(@out).to include("turkey@db_slave_1_hostname.compute-1.amazonaws.com \ti-asdfasdfaj\tdb_slave \tSlave I")
68
+ expect(@out).to include("turkey@db_slave_2_hostname.compute-1.amazonaws.com \ti-asdfasdfaj\tdb_slave")
69
+ expect(@out).to include("turkey@util_fluffy_hostname.compute-1.amazonaws.com\ti-80e3f1eb\tutil \tfluffy")
70
+ expect(@out).to include("turkey@util_rocky_hostname.compute-1.amazonaws.com \ti-80etf1eb\tutil \trocky")
71
+ end
72
+
73
+ it "lists simple format servers" do
74
+ fast_ey %w[servers -c main -e giblets -qs], :debug => false
75
+ expect(@out.split(/\n/).map {|x| x.split(/\t/) }).to eq([
76
+ ['app_master_hostname.compute-1.amazonaws.com', 'i-ddbbdd92', 'app_master' ],
77
+ ['app_hostname.compute-1.amazonaws.com', 'i-d2e3f1b9', 'app' ],
78
+ ['db_master_hostname.compute-1.amazonaws.com', 'i-d4cdddbf', 'db_master' ],
79
+ ['db_slave_1_hostname.compute-1.amazonaws.com', 'i-asdfasdfaj', 'db_slave', 'Slave I'],
80
+ ['db_slave_2_hostname.compute-1.amazonaws.com', 'i-asdfasdfaj', 'db_slave' ],
81
+ ['util_fluffy_hostname.compute-1.amazonaws.com', 'i-80e3f1eb', 'util', 'fluffy' ],
82
+ ['util_rocky_hostname.compute-1.amazonaws.com', 'i-80etf1eb', 'util', 'rocky' ],
83
+ ])
84
+ end
85
+
86
+ it "lists simple format servers with users" do
87
+ fast_ey %w[servers -c main -e giblets -qsu], :debug => false
88
+ expect(@out.split(/\n/).map {|x| x.split(/\t/) }).to eq([
89
+ ['turkey@app_master_hostname.compute-1.amazonaws.com', 'i-ddbbdd92', 'app_master' ],
90
+ ['turkey@app_hostname.compute-1.amazonaws.com', 'i-d2e3f1b9', 'app' ],
91
+ ['turkey@db_master_hostname.compute-1.amazonaws.com', 'i-d4cdddbf', 'db_master' ],
92
+ ['turkey@db_slave_1_hostname.compute-1.amazonaws.com', 'i-asdfasdfaj', 'db_slave', 'Slave I'],
93
+ ['turkey@db_slave_2_hostname.compute-1.amazonaws.com', 'i-asdfasdfaj', 'db_slave' ],
94
+ ['turkey@util_fluffy_hostname.compute-1.amazonaws.com', 'i-80e3f1eb', 'util', 'fluffy' ],
95
+ ['turkey@util_rocky_hostname.compute-1.amazonaws.com', 'i-80etf1eb', 'util', 'rocky' ],
96
+ ])
97
+ end
98
+
99
+ it "lists host only" do
100
+ fast_ey %w[servers -c main -e giblets -qS], :debug => false
101
+ expect(@out.split(/\n/)).to eq([
102
+ 'app_master_hostname.compute-1.amazonaws.com',
103
+ 'app_hostname.compute-1.amazonaws.com',
104
+ 'db_master_hostname.compute-1.amazonaws.com',
105
+ 'db_slave_1_hostname.compute-1.amazonaws.com',
106
+ 'db_slave_2_hostname.compute-1.amazonaws.com',
107
+ 'util_fluffy_hostname.compute-1.amazonaws.com',
108
+ 'util_rocky_hostname.compute-1.amazonaws.com',
109
+ ])
110
+ end
111
+
112
+ it "lists host only with users" do
113
+ fast_ey %w[servers -c main -e giblets -qSu], :debug => false
114
+ expect(@out.split(/\n/)).to eq([
115
+ 'turkey@app_master_hostname.compute-1.amazonaws.com',
116
+ 'turkey@app_hostname.compute-1.amazonaws.com',
117
+ 'turkey@db_master_hostname.compute-1.amazonaws.com',
118
+ 'turkey@db_slave_1_hostname.compute-1.amazonaws.com',
119
+ 'turkey@db_slave_2_hostname.compute-1.amazonaws.com',
120
+ 'turkey@util_fluffy_hostname.compute-1.amazonaws.com',
121
+ 'turkey@util_rocky_hostname.compute-1.amazonaws.com',
122
+ ])
123
+ end
124
+
125
+ it "lists servers constrained to app servers" do
126
+ fast_ey %w[servers -c main -e giblets -qs --app-servers], :debug => false
127
+ expect(@out.split(/\n/).map {|x| x.split(/\t/) }).to eq([
128
+ ['app_master_hostname.compute-1.amazonaws.com', 'i-ddbbdd92', 'app_master' ],
129
+ ['app_hostname.compute-1.amazonaws.com', 'i-d2e3f1b9', 'app' ],
130
+ ])
131
+ end
132
+
133
+ it "lists servers constrained to db servers" do
134
+ fast_ey %w[servers -c main -e giblets -qs --db-servers], :debug => false
135
+ expect(@out.split(/\n/).map {|x| x.split(/\t/) }).to eq([
136
+ ['db_master_hostname.compute-1.amazonaws.com', 'i-d4cdddbf', 'db_master' ],
137
+ ['db_slave_1_hostname.compute-1.amazonaws.com', 'i-asdfasdfaj', 'db_slave', 'Slave I'],
138
+ ['db_slave_2_hostname.compute-1.amazonaws.com', 'i-asdfasdfaj', 'db_slave' ],
139
+ ])
140
+ end
141
+
142
+ it "lists servers constrained to db master" do
143
+ fast_ey %w[servers -c main -e giblets -qs --db-master], :debug => false
144
+ expect(@out.split(/\n/).map {|x| x.split(/\t/) }).to eq([
145
+ ['db_master_hostname.compute-1.amazonaws.com', 'i-d4cdddbf', 'db_master' ],
146
+ ])
147
+ end
148
+
149
+ it "lists servers constrained to db slaves" do
150
+ fast_ey %w[servers -c main -e giblets -qs --db-slaves], :debug => false
151
+ expect(@out.split(/\n/).map {|x| x.split(/\t/) }).to eq([
152
+ ['db_slave_1_hostname.compute-1.amazonaws.com', 'i-asdfasdfaj', 'db_slave', 'Slave I'],
153
+ ['db_slave_2_hostname.compute-1.amazonaws.com', 'i-asdfasdfaj', 'db_slave' ],
154
+ ])
155
+ end
156
+
157
+ it "lists servers constrained to utilities" do
158
+ fast_ey %w[servers -c main -e giblets -qs --utilities], :debug => false
159
+ expect(@out.split(/\n/).map {|x| x.split(/\t/) }).to eq([
160
+ ['util_fluffy_hostname.compute-1.amazonaws.com', 'i-80e3f1eb', 'util', 'fluffy' ],
161
+ ['util_rocky_hostname.compute-1.amazonaws.com', 'i-80etf1eb', 'util', 'rocky' ],
162
+ ])
163
+ end
164
+
165
+ it "lists servers constrained to utilities with names" do
166
+ fast_ey %w[servers -c main -e giblets -qs --utilities fluffy], :debug => false
167
+ expect(@out.split(/\n/).map {|x| x.split(/\t/) }).to eq([
168
+ ['util_fluffy_hostname.compute-1.amazonaws.com', 'i-80e3f1eb', 'util', 'fluffy' ],
169
+ ])
170
+ end
171
+
172
+ it "lists servers constrained to app servers and utilities" do
173
+ fast_ey %w[servers -c main -e giblets -qs --app --util], :debug => false
174
+ expect(@out.split(/\n/).map {|x| x.split(/\t/) }).to eq([
175
+ ['app_master_hostname.compute-1.amazonaws.com', 'i-ddbbdd92', 'app_master' ],
176
+ ['app_hostname.compute-1.amazonaws.com', 'i-d2e3f1b9', 'app' ],
177
+ ['util_fluffy_hostname.compute-1.amazonaws.com', 'i-80e3f1eb', 'util', 'fluffy' ],
178
+ ['util_rocky_hostname.compute-1.amazonaws.com', 'i-80etf1eb', 'util', 'rocky' ],
179
+ ])
180
+ end
181
+
182
+ it "lists servers constrained to app or util with name" do
183
+ fast_ey %w[servers -c main -e giblets -qs --app --util rocky], :debug => false
184
+ expect(@out.split(/\n/).map {|x| x.split(/\t/) }).to eq([
185
+ ['app_master_hostname.compute-1.amazonaws.com', 'i-ddbbdd92', 'app_master' ],
186
+ ['app_hostname.compute-1.amazonaws.com', 'i-d2e3f1b9', 'app' ],
187
+ ['util_rocky_hostname.compute-1.amazonaws.com', 'i-80etf1eb', 'util', 'rocky' ],
188
+ ])
189
+ end
190
+
191
+ it "finds no servers with gibberish " do
192
+ fast_failing_ey %w[servers --account main --environment gibberish]
193
+ expect(@err).to include('No environment found matching "gibberish"')
194
+ end
195
+
196
+ it "finds no servers with gibberish account" do
197
+ fast_failing_ey %w[servers --account gibberish --environment giblets]
198
+ expect(@err).to include('No account found matching "gibberish"')
199
+ end
200
+
201
+ it "reports failure to find a git repo when not in one" do
202
+ Dir.chdir(Dir.tmpdir) do
203
+ fast_failing_ey %w[servers]
204
+ expect(@err).to match(/fatal: Not a git repository \(or any of the parent directories\): .*#{Regexp.escape(Dir.tmpdir)}/)
205
+ expect(@out).not_to match(/no application configured/)
206
+ end
207
+ end
208
+ end
209
+ end