trucker-cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +1277 -0
- data/Rakefile +13 -0
- data/bin/truck +18 -0
- data/lib/admin/README.md +30 -0
- data/lib/admin/curl.rb +59 -0
- data/lib/admin/guid.rb +89 -0
- data/lib/admin/plugin.rb +8 -0
- data/lib/admin/service_auth_token.rb +93 -0
- data/lib/admin/service_broker/add.rb +54 -0
- data/lib/admin/service_broker/remove.rb +33 -0
- data/lib/admin/service_broker/service_brokers.rb +29 -0
- data/lib/admin/service_broker/update.rb +60 -0
- data/lib/admin/set_quota.rb +44 -0
- data/lib/cf.rb +14 -0
- data/lib/cf/cli.rb +495 -0
- data/lib/cf/cli/app/app.rb +43 -0
- data/lib/cf/cli/app/apps.rb +87 -0
- data/lib/cf/cli/app/base.rb +72 -0
- data/lib/cf/cli/app/delete.rb +95 -0
- data/lib/cf/cli/app/deprecated.rb +11 -0
- data/lib/cf/cli/app/env.rb +99 -0
- data/lib/cf/cli/app/events.rb +45 -0
- data/lib/cf/cli/app/files.rb +137 -0
- data/lib/cf/cli/app/health.rb +26 -0
- data/lib/cf/cli/app/instances.rb +53 -0
- data/lib/cf/cli/app/logs.rb +76 -0
- data/lib/cf/cli/app/push.rb +104 -0
- data/lib/cf/cli/app/push/create.rb +108 -0
- data/lib/cf/cli/app/push/interactions.rb +90 -0
- data/lib/cf/cli/app/push/sync.rb +57 -0
- data/lib/cf/cli/app/rename.rb +35 -0
- data/lib/cf/cli/app/restart.rb +31 -0
- data/lib/cf/cli/app/scale.rb +63 -0
- data/lib/cf/cli/app/start.rb +175 -0
- data/lib/cf/cli/app/stats.rb +66 -0
- data/lib/cf/cli/app/stop.rb +27 -0
- data/lib/cf/cli/domain/base.rb +9 -0
- data/lib/cf/cli/domain/domains.rb +40 -0
- data/lib/cf/cli/domain/map.rb +55 -0
- data/lib/cf/cli/domain/unmap.rb +56 -0
- data/lib/cf/cli/help.rb +15 -0
- data/lib/cf/cli/interactive.rb +104 -0
- data/lib/cf/cli/login_requirements.rb +13 -0
- data/lib/cf/cli/organization/base.rb +12 -0
- data/lib/cf/cli/organization/create.rb +36 -0
- data/lib/cf/cli/organization/delete.rb +61 -0
- data/lib/cf/cli/organization/org.rb +45 -0
- data/lib/cf/cli/organization/orgs.rb +30 -0
- data/lib/cf/cli/organization/rename.rb +36 -0
- data/lib/cf/cli/populators/base.rb +16 -0
- data/lib/cf/cli/populators/organization.rb +32 -0
- data/lib/cf/cli/populators/populator_methods.rb +64 -0
- data/lib/cf/cli/populators/space.rb +33 -0
- data/lib/cf/cli/populators/target.rb +14 -0
- data/lib/cf/cli/route/base.rb +9 -0
- data/lib/cf/cli/route/delete.rb +28 -0
- data/lib/cf/cli/route/map.rb +68 -0
- data/lib/cf/cli/route/routes.rb +26 -0
- data/lib/cf/cli/route/unmap.rb +56 -0
- data/lib/cf/cli/service/base.rb +9 -0
- data/lib/cf/cli/service/bind.rb +43 -0
- data/lib/cf/cli/service/create.rb +158 -0
- data/lib/cf/cli/service/delete.rb +82 -0
- data/lib/cf/cli/service/rename.rb +35 -0
- data/lib/cf/cli/service/service.rb +40 -0
- data/lib/cf/cli/service/service_helper.rb +25 -0
- data/lib/cf/cli/service/service_instance_helper.rb +100 -0
- data/lib/cf/cli/service/services.rb +110 -0
- data/lib/cf/cli/service/unbind.rb +36 -0
- data/lib/cf/cli/space/base.rb +27 -0
- data/lib/cf/cli/space/create.rb +66 -0
- data/lib/cf/cli/space/delete.rb +55 -0
- data/lib/cf/cli/space/rename.rb +38 -0
- data/lib/cf/cli/space/space.rb +66 -0
- data/lib/cf/cli/space/spaces.rb +57 -0
- data/lib/cf/cli/space/switch.rb +18 -0
- data/lib/cf/cli/start/base.rb +35 -0
- data/lib/cf/cli/start/colors.rb +13 -0
- data/lib/cf/cli/start/login.rb +104 -0
- data/lib/cf/cli/start/logout.rb +17 -0
- data/lib/cf/cli/start/target.rb +50 -0
- data/lib/cf/cli/start/target_prettifier.rb +35 -0
- data/lib/cf/cli/start/targets.rb +16 -0
- data/lib/cf/cli/user/base.rb +29 -0
- data/lib/cf/cli/user/create.rb +51 -0
- data/lib/cf/cli/user/passwd.rb +36 -0
- data/lib/cf/cli/user/register.rb +42 -0
- data/lib/cf/cli/user/users.rb +32 -0
- data/lib/cf/constants.rb +10 -0
- data/lib/cf/errors.rb +19 -0
- data/lib/cf/plugin.rb +56 -0
- data/lib/cf/spacing.rb +89 -0
- data/lib/cf/spec_helper.rb +1 -0
- data/lib/cf/test_support.rb +6 -0
- data/lib/cf/version.rb +3 -0
- data/lib/console/README.md +16 -0
- data/lib/console/console.rb +187 -0
- data/lib/console/plugin.rb +32 -0
- data/lib/manifests/errors.rb +35 -0
- data/lib/manifests/loader.rb +31 -0
- data/lib/manifests/loader/builder.rb +39 -0
- data/lib/manifests/loader/normalizer.rb +145 -0
- data/lib/manifests/loader/resolver.rb +79 -0
- data/lib/manifests/manifests.rb +343 -0
- data/lib/manifests/plugin.rb +140 -0
- data/lib/micro/README.md +25 -0
- data/lib/micro/errors.rb +4 -0
- data/lib/micro/micro.rb +56 -0
- data/lib/micro/plugin.rb +197 -0
- data/lib/micro/switcher/base.rb +79 -0
- data/lib/micro/switcher/darwin.rb +21 -0
- data/lib/micro/switcher/dummy.rb +15 -0
- data/lib/micro/switcher/linux.rb +16 -0
- data/lib/micro/switcher/windows.rb +31 -0
- data/lib/micro/vmrun.rb +175 -0
- data/lib/tasks/gem_release.rake +56 -0
- data/lib/tasks/windows_build.rake +14 -0
- data/lib/tunnel/README.md +29 -0
- data/lib/tunnel/config/clients.yml +17 -0
- data/lib/tunnel/helper-app/Gemfile +10 -0
- data/lib/tunnel/helper-app/Gemfile.lock +48 -0
- data/lib/tunnel/helper-app/server.rb +43 -0
- data/lib/tunnel/plugin.rb +183 -0
- data/lib/tunnel/tunnel.rb +295 -0
- data/spec/admin/curl_spec.rb +52 -0
- data/spec/admin/guid_spec.rb +85 -0
- data/spec/admin/service_broker/add_spec.rb +64 -0
- data/spec/admin/service_broker/remove_spec.rb +46 -0
- data/spec/admin/service_broker/service_brokers_spec.rb +34 -0
- data/spec/admin/service_broker/update_spec.rb +51 -0
- data/spec/admin/set_quota_spec.rb +89 -0
- data/spec/assets/env/Gemfile +4 -0
- data/spec/assets/env/Gemfile.lock +20 -0
- data/spec/assets/env/env_test.rb +58 -0
- data/spec/assets/hello-sinatra/Gemfile +3 -0
- data/spec/assets/hello-sinatra/Gemfile.lock +17 -0
- data/spec/assets/hello-sinatra/config.ru +3 -0
- data/spec/assets/hello-sinatra/fat-cat-makes-app-larger.png +0 -0
- data/spec/assets/hello-sinatra/main.rb +8 -0
- data/spec/assets/rails328_ruby187_app/Gemfile +39 -0
- data/spec/assets/rails328_ruby187_app/README.rdoc +261 -0
- data/spec/assets/rails328_ruby187_app/Rakefile +7 -0
- data/spec/assets/rails328_ruby187_app/app/assets/images/rails.png +0 -0
- data/spec/assets/rails328_ruby187_app/app/assets/javascripts/application.js +15 -0
- data/spec/assets/rails328_ruby187_app/app/assets/stylesheets/application.css +13 -0
- data/spec/assets/rails328_ruby187_app/app/controllers/application_controller.rb +3 -0
- data/spec/assets/rails328_ruby187_app/app/helpers/application_helper.rb +2 -0
- data/spec/assets/rails328_ruby187_app/app/views/layouts/application.html.erb +14 -0
- data/spec/assets/rails328_ruby187_app/config.ru +4 -0
- data/spec/assets/rails328_ruby187_app/config/application.rb +62 -0
- data/spec/assets/rails328_ruby187_app/config/boot.rb +6 -0
- data/spec/assets/rails328_ruby187_app/config/database.yml +25 -0
- data/spec/assets/rails328_ruby187_app/config/environment.rb +5 -0
- data/spec/assets/rails328_ruby187_app/config/environments/development.rb +37 -0
- data/spec/assets/rails328_ruby187_app/config/environments/production.rb +67 -0
- data/spec/assets/rails328_ruby187_app/config/environments/test.rb +37 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/inflections.rb +15 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/mime_types.rb +5 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/secret_token.rb +7 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/session_store.rb +8 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/assets/rails328_ruby187_app/config/locales/en.yml +5 -0
- data/spec/assets/rails328_ruby187_app/config/routes.rb +58 -0
- data/spec/assets/rails328_ruby187_app/db/seeds.rb +7 -0
- data/spec/assets/rails328_ruby187_app/doc/README_FOR_APP +2 -0
- data/spec/assets/rails328_ruby187_app/manifest.yml +7 -0
- data/spec/assets/rails328_ruby187_app/public/404.html +26 -0
- data/spec/assets/rails328_ruby187_app/public/422.html +26 -0
- data/spec/assets/rails328_ruby187_app/public/500.html +25 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-7270767b2a9e9fff880aa5de378ca791.css +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-7270767b2a9e9fff880aa5de378ca791.css.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-ccab98dc1abdf097c0af693e20aed861.js +17 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-ccab98dc1abdf097c0af693e20aed861.js.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.css +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.css.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.js +17 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.js.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/manifest.yml +4 -0
- data/spec/assets/rails328_ruby187_app/public/assets/rails-be8732dac73d845ac5b142c8fb5f9fb0.png +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/rails.png +0 -0
- data/spec/assets/rails328_ruby187_app/public/favicon.ico +0 -0
- data/spec/assets/rails328_ruby187_app/public/index.html +241 -0
- data/spec/assets/rails328_ruby187_app/public/robots.txt +5 -0
- data/spec/assets/rails328_ruby187_app/script/rails +6 -0
- data/spec/assets/rails328_ruby187_app/test/performance/browsing_test.rb +12 -0
- data/spec/assets/rails328_ruby187_app/test/test_helper.rb +13 -0
- data/spec/cf/cli/app/base_spec.rb +17 -0
- data/spec/cf/cli/app/delete_spec.rb +197 -0
- data/spec/cf/cli/app/env_spec.rb +261 -0
- data/spec/cf/cli/app/events_spec.rb +72 -0
- data/spec/cf/cli/app/help_spec.rb +39 -0
- data/spec/cf/cli/app/instances_spec.rb +69 -0
- data/spec/cf/cli/app/push/create_spec.rb +444 -0
- data/spec/cf/cli/app/push/interactions_spec.rb +32 -0
- data/spec/cf/cli/app/push_spec.rb +332 -0
- data/spec/cf/cli/app/rename_spec.rb +108 -0
- data/spec/cf/cli/app/restart_spec.rb +47 -0
- data/spec/cf/cli/app/scale_spec.rb +63 -0
- data/spec/cf/cli/app/start_spec.rb +255 -0
- data/spec/cf/cli/app/stats_spec.rb +66 -0
- data/spec/cf/cli/domain/help_spec.rb +39 -0
- data/spec/cf/cli/domain/map_spec.rb +140 -0
- data/spec/cf/cli/domain/unmap_spec.rb +77 -0
- data/spec/cf/cli/help_spec.rb +21 -0
- data/spec/cf/cli/organization/create_spec.rb +121 -0
- data/spec/cf/cli/organization/delete_spec.rb +105 -0
- data/spec/cf/cli/organization/help_spec.rb +39 -0
- data/spec/cf/cli/organization/orgs_spec.rb +116 -0
- data/spec/cf/cli/organization/rename_spec.rb +116 -0
- data/spec/cf/cli/populators/organization_spec.rb +179 -0
- data/spec/cf/cli/populators/space_spec.rb +156 -0
- data/spec/cf/cli/populators/target_spec.rb +39 -0
- data/spec/cf/cli/route/delete_spec.rb +92 -0
- data/spec/cf/cli/route/help_spec.rb +32 -0
- data/spec/cf/cli/route/map_spec.rb +148 -0
- data/spec/cf/cli/route/unmap_spec.rb +114 -0
- data/spec/cf/cli/service/bind_spec.rb +25 -0
- data/spec/cf/cli/service/create_spec.rb +147 -0
- data/spec/cf/cli/service/delete_spec.rb +22 -0
- data/spec/cf/cli/service/help_spec.rb +39 -0
- data/spec/cf/cli/service/rename_spec.rb +103 -0
- data/spec/cf/cli/service/service_helper_spec.rb +66 -0
- data/spec/cf/cli/service/service_instance_helper_spec.rb +155 -0
- data/spec/cf/cli/service/service_spec.rb +23 -0
- data/spec/cf/cli/service/services_spec.rb +156 -0
- data/spec/cf/cli/service/unbind_spec.rb +25 -0
- data/spec/cf/cli/space/base_spec.rb +49 -0
- data/spec/cf/cli/space/create_spec.rb +144 -0
- data/spec/cf/cli/space/delete_spec.rb +109 -0
- data/spec/cf/cli/space/help_spec.rb +39 -0
- data/spec/cf/cli/space/rename_spec.rb +110 -0
- data/spec/cf/cli/space/space_spec.rb +80 -0
- data/spec/cf/cli/space/spaces_spec.rb +107 -0
- data/spec/cf/cli/space/switch_space_spec.rb +57 -0
- data/spec/cf/cli/start/help_spec.rb +39 -0
- data/spec/cf/cli/start/login_spec.rb +142 -0
- data/spec/cf/cli/start/logout_spec.rb +49 -0
- data/spec/cf/cli/start/target_prettifier_spec.rb +78 -0
- data/spec/cf/cli/start/target_spec.rb +123 -0
- data/spec/cf/cli/user/create_spec.rb +98 -0
- data/spec/cf/cli/user/help_spec.rb +32 -0
- data/spec/cf/cli/user/passwd_spec.rb +94 -0
- data/spec/cf/cli/user/register_spec.rb +145 -0
- data/spec/cf/cli_spec.rb +474 -0
- data/spec/console/console_spec.rb +189 -0
- data/spec/factories/cfoundry/v2/apps_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/clients_factory.rb +7 -0
- data/spec/factories/cfoundry/v2/domains_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/managed_service_instances_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/organizations_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/quota_definitions.rb +13 -0
- data/spec/factories/cfoundry/v2/routes_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/service_bindings_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_brokers_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_plans_factory.rb +17 -0
- data/spec/factories/cfoundry/v2/services_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/spaces_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/stacks_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/user_provided_service_instances_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/users_factory.rb +7 -0
- data/spec/features/backspace_spec.rb +46 -0
- data/spec/features/create_user_spec.rb +74 -0
- data/spec/features/delete_orphaned_service_spec.rb +64 -0
- data/spec/features/login_spec.rb +65 -0
- data/spec/features/manifests_spec.rb +86 -0
- data/spec/features/org_spec.rb +50 -0
- data/spec/features/push_flow_spec.rb +169 -0
- data/spec/features/service_brokers_spec.rb +173 -0
- data/spec/features/services_spec.rb +122 -0
- data/spec/features/space_spec.rb +107 -0
- data/spec/features/switching_targets_spec.rb +70 -0
- data/spec/manifests/errors_spec.rb +43 -0
- data/spec/manifests/loader/builder_spec.rb +80 -0
- data/spec/manifests/loader/normalizer_spec.rb +158 -0
- data/spec/manifests/manifests_spec.rb +335 -0
- data/spec/manifests/plugin_spec.rb +410 -0
- data/spec/micro/plugin_spec.rb +64 -0
- data/spec/spec_helper.rb +69 -0
- data/spec/support/cli_helper.rb +87 -0
- data/spec/support/config_helper.rb +15 -0
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/fake_home_dir.rb +55 -0
- data/spec/support/features_helper.rb +99 -0
- data/spec/support/interact_helper.rb +27 -0
- data/spec/support/matchers.rb +16 -0
- data/spec/support/mock_commands/mock_restart.rb +16 -0
- data/spec/support/mock_commands/mock_start.rb +17 -0
- data/spec/support/shared_examples/errors.rb +40 -0
- data/spec/support/shared_examples/input.rb +14 -0
- data/spec/tunnel/plugin_spec.rb +31 -0
- data/spec/tunnel/tunnel_spec.rb +54 -0
- metadata +814 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF
|
4
|
+
module App
|
5
|
+
describe Restart do
|
6
|
+
let(:restart_command) { CF::App::Restart.new(Mothership.commands[:restart]) }
|
7
|
+
let(:inputs) { {:apps => [app]} }
|
8
|
+
let(:app) { build(:app, :command => "rails s") }
|
9
|
+
|
10
|
+
before do
|
11
|
+
restart_command.input = Mothership::Inputs.new(nil, restart_command, inputs, {}, {})
|
12
|
+
app.stub(:update!)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "restarts the application" do
|
16
|
+
restart_command.should_receive(:invoke).with(:stop, anything) do
|
17
|
+
restart_command.should_receive(:invoke).with(:start, anything)
|
18
|
+
end
|
19
|
+
restart_command.restart
|
20
|
+
end
|
21
|
+
|
22
|
+
it "does not change the command if we do not pass the command argument" do
|
23
|
+
restart_command.stub(:invoke).with(:start, anything)
|
24
|
+
restart_command.stub(:invoke).with(:stop, anything)
|
25
|
+
restart_command.restart
|
26
|
+
app.command.should == "rails s"
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when passing in a new start command" do
|
30
|
+
let(:inputs) { {:apps => [app], :command => 'rake db:migrate'} }
|
31
|
+
|
32
|
+
before do
|
33
|
+
restart_command.stub(:invoke).with(:stop, anything)
|
34
|
+
restart_command.input = Mothership::Inputs.new(nil, restart_command, inputs, {}, {})
|
35
|
+
end
|
36
|
+
|
37
|
+
it "updates the start command" do
|
38
|
+
app.should_receive(:update!) do
|
39
|
+
restart_command.should_receive(:invoke).with(:start, anything)
|
40
|
+
end
|
41
|
+
restart_command.restart
|
42
|
+
app.command.should == "rake db:migrate"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF
|
4
|
+
module App
|
5
|
+
describe Scale do
|
6
|
+
before do
|
7
|
+
stub_client_and_precondition
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:client) { build(:client) }
|
11
|
+
let(:app) { }
|
12
|
+
|
13
|
+
before do
|
14
|
+
client.stub(:apps).and_return([app])
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when the --disk flag is given" do
|
18
|
+
let(:before_value) { 512 }
|
19
|
+
let(:app) { build(:app, :disk_quota => before_value) }
|
20
|
+
|
21
|
+
subject { cf %W[scale #{app.name} --disk 1G] }
|
22
|
+
|
23
|
+
it "changes the application's disk quota" do
|
24
|
+
app.should_receive(:update!)
|
25
|
+
expect { subject }.to change(app, :disk_quota).from(before_value).to(1024)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when the --memory flag is given" do
|
30
|
+
let(:before_value) { 512 }
|
31
|
+
let(:app) { build(:app, :memory => before_value) }
|
32
|
+
|
33
|
+
subject { cf %W[scale #{app.name} --memory 1G] }
|
34
|
+
|
35
|
+
it "changes the application's memory" do
|
36
|
+
app.should_receive(:update!)
|
37
|
+
expect { subject }.to change(app, :memory).from(before_value).to(1024)
|
38
|
+
end
|
39
|
+
|
40
|
+
context "if --restart is true" do
|
41
|
+
it "restarts the application" do
|
42
|
+
app.stub(:update!)
|
43
|
+
app.stub(:started?) { true }
|
44
|
+
mock_invoke :restart, :app => app
|
45
|
+
subject
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when the --instances flag is given" do
|
51
|
+
let(:before_value) { 3 }
|
52
|
+
let(:app) { build(:app, :total_instances => before_value) }
|
53
|
+
|
54
|
+
subject { cf %W[scale #{app.name} --instances 5] }
|
55
|
+
|
56
|
+
it "changes the application's number of instances" do
|
57
|
+
app.should_receive(:update!)
|
58
|
+
expect { subject }.to change(app, :total_instances).from(before_value).to(5)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,255 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF
|
4
|
+
module App
|
5
|
+
describe Start do
|
6
|
+
let(:client) { build(:client) }
|
7
|
+
let(:app) { build(:app, :client => client, :name => "app-name", :guid => "app-id-1") }
|
8
|
+
|
9
|
+
before do
|
10
|
+
stub_client_and_precondition
|
11
|
+
client.stub(:apps).and_return([app])
|
12
|
+
|
13
|
+
app.stub(:host).and_return("some_host")
|
14
|
+
app.stub(:domain).and_return("some_domain")
|
15
|
+
app.stub(:subdomain).and_return("some_subdomain")
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute_start_app
|
19
|
+
cf %W[start #{app.name}]
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with an app that's already started" do
|
23
|
+
let(:app) { build(:app, :state => "STARTED") }
|
24
|
+
|
25
|
+
it "skips starting the application" do
|
26
|
+
app.should_not_receive(:start!)
|
27
|
+
execute_start_app
|
28
|
+
end
|
29
|
+
|
30
|
+
it "says the app is already started" do
|
31
|
+
execute_start_app
|
32
|
+
expect(error_output).to say("Application #{app.name} is already started.")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "with an app that's NOT already started" do
|
37
|
+
def self.it_says_application_is_starting
|
38
|
+
it "says that it's starting the application" do
|
39
|
+
execute_start_app
|
40
|
+
expect(output).to say("Preparing to start #{app.name}... OK")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.it_prints_log_progress
|
45
|
+
it "prints out the log progress" do
|
46
|
+
execute_start_app
|
47
|
+
expect(output).to say(log_text)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.it_does_not_print_log_progress
|
52
|
+
it "does not print the log progress" do
|
53
|
+
execute_start_app
|
54
|
+
expect(output).to_not say(log_text)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.it_waits_for_application_to_become_healthy
|
59
|
+
describe "waits for application to become healthy" do
|
60
|
+
let(:app) { build(:app, :total_instances => 2) }
|
61
|
+
|
62
|
+
def after_sleep
|
63
|
+
described_class.any_instance.stub(:sleep) { yield }
|
64
|
+
end
|
65
|
+
|
66
|
+
before do
|
67
|
+
app.stub(:instances) do
|
68
|
+
[CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "DOWN"),
|
69
|
+
CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "DOWN")
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
after_sleep do
|
74
|
+
app.stub(:instances) { final_instances }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "when one instance becomes running" do
|
79
|
+
let(:final_instances) do
|
80
|
+
[CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "RUNNING"),
|
81
|
+
CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "DOWN")
|
82
|
+
]
|
83
|
+
end
|
84
|
+
|
85
|
+
it "says app is started" do
|
86
|
+
execute_start_app
|
87
|
+
expect(output).to say("Checking status of app '#{app.name}'...")
|
88
|
+
expect(output).to say("1 running, 1 down")
|
89
|
+
expect(output).to say("Push successful!")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "staging fails" do
|
94
|
+
before do
|
95
|
+
app.stub(:instances) { raise CFoundry::StagingError.new("Failed to stage", 170001, nil, nil) }
|
96
|
+
end
|
97
|
+
|
98
|
+
it "says the app failed to stage" do
|
99
|
+
execute_start_app
|
100
|
+
expect(output).to say("Checking status of app '#{app.name}'...")
|
101
|
+
expect(error_output).to say("Application failed to stage")
|
102
|
+
expect(output).to_not say(/\d (running|down|flapping)/)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "staging has not completed" do
|
107
|
+
let(:final_instances) do
|
108
|
+
[CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "RUNNING"),
|
109
|
+
CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "RUNNING")
|
110
|
+
]
|
111
|
+
end
|
112
|
+
|
113
|
+
before do
|
114
|
+
app.stub(:instances) { raise CFoundry::NotStaged.new("Staging is pending", 170002, nil, nil) }
|
115
|
+
end
|
116
|
+
|
117
|
+
it "keeps polling" do
|
118
|
+
execute_start_app
|
119
|
+
expect(output).to say("Checking status of app '#{app.name}'...")
|
120
|
+
expect(output).to say("2 running")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context "when any instance becomes flapping" do
|
125
|
+
before do
|
126
|
+
app.stub(:instances) do
|
127
|
+
[
|
128
|
+
CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "FLAPPING"),
|
129
|
+
CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "DOWN"),
|
130
|
+
]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
it "says app failed to start" do
|
135
|
+
execute_start_app
|
136
|
+
expect(output).to say("Checking status of app '#{app.name}'...")
|
137
|
+
expect(output).to say("1 crashing, 1 down")
|
138
|
+
expect(error_output).to say("Push unsuccessful.")
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
let(:log_url) { nil }
|
145
|
+
|
146
|
+
before do
|
147
|
+
app.stub(:invalidate!)
|
148
|
+
app.stub(:instances) do
|
149
|
+
[CFoundry::V2::App::Instance.new(nil, nil, nil, :state => "RUNNING")]
|
150
|
+
end
|
151
|
+
|
152
|
+
app.should_receive(:start!) do |_, &blk|
|
153
|
+
app.state = "STARTED"
|
154
|
+
blk.call(log_url)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context "when progress log url is provided" do
|
159
|
+
let(:log_url) { "http://example.com/my-app-log" }
|
160
|
+
let(:log_text) { "Staging complete!" }
|
161
|
+
|
162
|
+
context "and progress log url is not available immediately" do
|
163
|
+
before do
|
164
|
+
stub_request(:get, "#{log_url}&tail&tail_offset=0").to_return(
|
165
|
+
:status => 404, :body => "")
|
166
|
+
end
|
167
|
+
|
168
|
+
it_says_application_is_starting
|
169
|
+
it_does_not_print_log_progress
|
170
|
+
it_waits_for_application_to_become_healthy
|
171
|
+
end
|
172
|
+
|
173
|
+
context "and progress log url becomes unavailable after some time" do
|
174
|
+
before do
|
175
|
+
stub_request(:get, "#{log_url}&tail&tail_offset=0").to_return(
|
176
|
+
:status => 200, :body => log_text[0...5])
|
177
|
+
stub_request(:get, "#{log_url}&tail&tail_offset=5").to_return(
|
178
|
+
:status => 200, :body => log_text[5..-1])
|
179
|
+
stub_request(:get, "#{log_url}&tail&tail_offset=#{log_text.size}").to_return(
|
180
|
+
:status => 404, :body => "")
|
181
|
+
end
|
182
|
+
|
183
|
+
it_says_application_is_starting
|
184
|
+
it_prints_log_progress
|
185
|
+
it_waits_for_application_to_become_healthy
|
186
|
+
end
|
187
|
+
|
188
|
+
context "and a request times out" do
|
189
|
+
before do
|
190
|
+
stub_request(:get, "#{log_url}&tail&tail_offset=0").to_return(
|
191
|
+
:should_timeout => true)
|
192
|
+
stub_request(:get, "#{log_url}&tail&tail_offset=0").to_return(
|
193
|
+
:status => 200, :body => log_text)
|
194
|
+
stub_request(:get, "#{log_url}&tail&tail_offset=#{log_text.size}").to_return(
|
195
|
+
:status => 404, :body => "")
|
196
|
+
end
|
197
|
+
|
198
|
+
it_says_application_is_starting
|
199
|
+
it_prints_log_progress
|
200
|
+
it_waits_for_application_to_become_healthy
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
context "when progress log url is not provided" do
|
205
|
+
let(:log_url) { nil }
|
206
|
+
let(:log_text) { "Staging complete!" }
|
207
|
+
|
208
|
+
it_says_application_is_starting
|
209
|
+
it_does_not_print_log_progress
|
210
|
+
it_waits_for_application_to_become_healthy
|
211
|
+
end
|
212
|
+
|
213
|
+
context "when a debug mode is given" do
|
214
|
+
let(:mode) { "some_mode" }
|
215
|
+
|
216
|
+
def execute_start_app_with_mode
|
217
|
+
cf %W[start #{app.name} -d #{mode}]
|
218
|
+
end
|
219
|
+
|
220
|
+
context "and the debug mode is different from the one already set" do
|
221
|
+
it "starts the app with the given debug mode" do
|
222
|
+
expect { execute_start_app_with_mode }.to change { app.debug }.from(nil).to("some_mode")
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
context "and the debug mode is the same as the one already set" do
|
227
|
+
let(:app) { build(:app, :debug => "in_debug") }
|
228
|
+
|
229
|
+
it "does not set the debug mode to anything different" do
|
230
|
+
app.should_not_receive(:debug).with(anything)
|
231
|
+
execute_start_app_with_mode
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
context "and the mode is given as 'none'" do
|
236
|
+
let(:app) { build(:app, :debug => "in_debug") }
|
237
|
+
let(:mode) { "none" }
|
238
|
+
|
239
|
+
it "removes the debug mode" do
|
240
|
+
expect { execute_start_app_with_mode }.to change { app.debug }.from("in_debug").to("none")
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
context "and an empty mode is given" do
|
245
|
+
let(:mode) { "" }
|
246
|
+
|
247
|
+
it "sets debug to 'run'" do
|
248
|
+
expect { execute_start_app_with_mode }.to change { app.debug }.from(nil).to("run")
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF
|
4
|
+
module App
|
5
|
+
describe Stats do
|
6
|
+
let(:global) { {} }
|
7
|
+
let(:given) { {} }
|
8
|
+
let(:inputs) { {:app => apps[0]} }
|
9
|
+
let(:apps) { [build(:app)] }
|
10
|
+
|
11
|
+
before do
|
12
|
+
inputs[:app].stub(:stats) do
|
13
|
+
{"0" => {
|
14
|
+
:state => "RUNNING",
|
15
|
+
:stats => {
|
16
|
+
:name => "basic_app",
|
17
|
+
:uris => ["basic_app.p01.rbconsvcs.com"],
|
18
|
+
:host => "172.20.183.93",
|
19
|
+
:port => 61006,
|
20
|
+
:uptime => 3250,
|
21
|
+
:mem_quota => 301989888,
|
22
|
+
:disk_quota => 268435456,
|
23
|
+
:fds_quota => 256,
|
24
|
+
:usage => {
|
25
|
+
:time => "2013-01-04 19:53:39 +0000",
|
26
|
+
:cpu => 0.0019777013519415455,
|
27
|
+
:mem => 31395840,
|
28
|
+
:disk => 15638528
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
subject do
|
37
|
+
capture_output { Mothership.new.invoke(:stats, inputs, given, global) }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "metadata" do
|
41
|
+
let(:command) { Mothership.commands[:stats] }
|
42
|
+
|
43
|
+
describe "command" do
|
44
|
+
subject { command }
|
45
|
+
its(:description) { should eq "Display application instance status" }
|
46
|
+
it { expect(Mothership::Help.group(:apps, :info)).to include(subject) }
|
47
|
+
end
|
48
|
+
|
49
|
+
include_examples "inputs must have descriptions"
|
50
|
+
|
51
|
+
describe "arguments" do
|
52
|
+
subject { command.arguments }
|
53
|
+
it "has no arguments" do
|
54
|
+
should eq([:name => :app, :type => :optional, :value => nil])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "prints out the stats" do
|
60
|
+
subject
|
61
|
+
stdout.rewind
|
62
|
+
expect(stdout.readlines.last).to match /.*0\s+0\.0%\s+29\.9M of 288M\s+14\.9M of 256M.*/
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF
|
4
|
+
module Domain
|
5
|
+
describe "Help" do
|
6
|
+
let(:global) { {} }
|
7
|
+
let(:given) { {} }
|
8
|
+
|
9
|
+
subject do
|
10
|
+
capture_output { Mothership.new.invoke(:help, :command => "domains") }
|
11
|
+
end
|
12
|
+
|
13
|
+
it "describes the command" do
|
14
|
+
subject
|
15
|
+
stdout.rewind
|
16
|
+
expect(stdout.readlines.first).to match /List domains in a space/
|
17
|
+
end
|
18
|
+
|
19
|
+
it "prints the options" do
|
20
|
+
subject
|
21
|
+
stdout.rewind
|
22
|
+
expect(stdout.readlines.any? {|line| line =~ /Options:/ }).to be_true
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when the user is not logged in" do
|
27
|
+
before do
|
28
|
+
capture_output { Mothership.new.invoke(:logout) }
|
29
|
+
end
|
30
|
+
|
31
|
+
it "does not require login" do
|
32
|
+
subject
|
33
|
+
stdout.rewind
|
34
|
+
expect(stdout.readlines.first).to_not match /Please log in first to proceed/
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|