startapp 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYRIGHT +1 -0
- data/LICENSE +11 -0
- data/README.md +95 -0
- data/Rakefile +6 -0
- data/autocomplete/rhc_bash +1672 -0
- data/bin/app +37 -0
- data/conf/express.conf +8 -0
- data/features/assets/deploy.tar.gz +0 -0
- data/features/core_feature.rb +191 -0
- data/features/deployments_feature.rb +129 -0
- data/features/domains_feature.rb +58 -0
- data/features/keys_feature.rb +37 -0
- data/features/members_feature.rb +166 -0
- data/lib/rhc/auth/basic.rb +64 -0
- data/lib/rhc/auth/token.rb +102 -0
- data/lib/rhc/auth/token_store.rb +53 -0
- data/lib/rhc/auth.rb +5 -0
- data/lib/rhc/autocomplete.rb +66 -0
- data/lib/rhc/autocomplete_templates/bash.erb +39 -0
- data/lib/rhc/cartridge_helpers.rb +118 -0
- data/lib/rhc/cli.rb +40 -0
- data/lib/rhc/command_runner.rb +185 -0
- data/lib/rhc/commands/account.rb +25 -0
- data/lib/rhc/commands/alias.rb +124 -0
- data/lib/rhc/commands/app.rb +726 -0
- data/lib/rhc/commands/apps.rb +20 -0
- data/lib/rhc/commands/authorization.rb +115 -0
- data/lib/rhc/commands/base.rb +174 -0
- data/lib/rhc/commands/cartridge.rb +329 -0
- data/lib/rhc/commands/clone.rb +66 -0
- data/lib/rhc/commands/configure.rb +20 -0
- data/lib/rhc/commands/create.rb +100 -0
- data/lib/rhc/commands/delete.rb +19 -0
- data/lib/rhc/commands/deploy.rb +32 -0
- data/lib/rhc/commands/deployment.rb +82 -0
- data/lib/rhc/commands/domain.rb +172 -0
- data/lib/rhc/commands/env.rb +142 -0
- data/lib/rhc/commands/force_stop.rb +17 -0
- data/lib/rhc/commands/git_clone.rb +34 -0
- data/lib/rhc/commands/logout.rb +51 -0
- data/lib/rhc/commands/logs.rb +21 -0
- data/lib/rhc/commands/member.rb +148 -0
- data/lib/rhc/commands/port_forward.rb +197 -0
- data/lib/rhc/commands/reload.rb +17 -0
- data/lib/rhc/commands/restart.rb +17 -0
- data/lib/rhc/commands/scp.rb +54 -0
- data/lib/rhc/commands/server.rb +40 -0
- data/lib/rhc/commands/setup.rb +60 -0
- data/lib/rhc/commands/show.rb +43 -0
- data/lib/rhc/commands/snapshot.rb +137 -0
- data/lib/rhc/commands/ssh.rb +51 -0
- data/lib/rhc/commands/sshkey.rb +97 -0
- data/lib/rhc/commands/start.rb +17 -0
- data/lib/rhc/commands/stop.rb +17 -0
- data/lib/rhc/commands/tail.rb +47 -0
- data/lib/rhc/commands/threaddump.rb +14 -0
- data/lib/rhc/commands/tidy.rb +17 -0
- data/lib/rhc/commands.rb +396 -0
- data/lib/rhc/config.rb +321 -0
- data/lib/rhc/context_helper.rb +121 -0
- data/lib/rhc/core_ext.rb +202 -0
- data/lib/rhc/coverage_helper.rb +33 -0
- data/lib/rhc/deployment_helpers.rb +111 -0
- data/lib/rhc/exceptions.rb +256 -0
- data/lib/rhc/git_helpers.rb +106 -0
- data/lib/rhc/help_formatter.rb +55 -0
- data/lib/rhc/helpers.rb +481 -0
- data/lib/rhc/highline_extensions.rb +479 -0
- data/lib/rhc/json.rb +51 -0
- data/lib/rhc/output_helpers.rb +260 -0
- data/lib/rhc/rest/activation.rb +11 -0
- data/lib/rhc/rest/alias.rb +42 -0
- data/lib/rhc/rest/api.rb +87 -0
- data/lib/rhc/rest/application.rb +348 -0
- data/lib/rhc/rest/attributes.rb +36 -0
- data/lib/rhc/rest/authorization.rb +8 -0
- data/lib/rhc/rest/base.rb +79 -0
- data/lib/rhc/rest/cartridge.rb +162 -0
- data/lib/rhc/rest/client.rb +650 -0
- data/lib/rhc/rest/deployment.rb +18 -0
- data/lib/rhc/rest/domain.rb +98 -0
- data/lib/rhc/rest/environment_variable.rb +15 -0
- data/lib/rhc/rest/gear_group.rb +16 -0
- data/lib/rhc/rest/httpclient.rb +145 -0
- data/lib/rhc/rest/key.rb +44 -0
- data/lib/rhc/rest/membership.rb +105 -0
- data/lib/rhc/rest/mock.rb +1042 -0
- data/lib/rhc/rest/user.rb +32 -0
- data/lib/rhc/rest.rb +148 -0
- data/lib/rhc/scp_helpers.rb +27 -0
- data/lib/rhc/ssh_helpers.rb +380 -0
- data/lib/rhc/tar_gz.rb +51 -0
- data/lib/rhc/usage_templates/command_help.erb +51 -0
- data/lib/rhc/usage_templates/command_syntax_help.erb +11 -0
- data/lib/rhc/usage_templates/help.erb +61 -0
- data/lib/rhc/usage_templates/missing_help.erb +1 -0
- data/lib/rhc/usage_templates/options_help.erb +12 -0
- data/lib/rhc/vendor/okjson.rb +600 -0
- data/lib/rhc/vendor/parseconfig.rb +178 -0
- data/lib/rhc/vendor/sshkey.rb +253 -0
- data/lib/rhc/vendor/zliby.rb +628 -0
- data/lib/rhc/version.rb +5 -0
- data/lib/rhc/wizard.rb +637 -0
- data/lib/rhc.rb +34 -0
- data/spec/coverage_helper.rb +82 -0
- data/spec/direct_execution_helper.rb +339 -0
- data/spec/keys/example.pem +23 -0
- data/spec/keys/example_private.pem +27 -0
- data/spec/keys/server.pem +19 -0
- data/spec/rest_spec_helper.rb +31 -0
- data/spec/rhc/assets/cert.crt +22 -0
- data/spec/rhc/assets/cert_key_rsa +27 -0
- data/spec/rhc/assets/empty.txt +0 -0
- data/spec/rhc/assets/env_vars.txt +7 -0
- data/spec/rhc/assets/env_vars_2.txt +1 -0
- data/spec/rhc/assets/foo.txt +1 -0
- data/spec/rhc/assets/targz_corrupted.tar.gz +1 -0
- data/spec/rhc/assets/targz_sample.tar.gz +0 -0
- data/spec/rhc/auth_spec.rb +442 -0
- data/spec/rhc/cli_spec.rb +186 -0
- data/spec/rhc/command_spec.rb +435 -0
- data/spec/rhc/commands/account_spec.rb +42 -0
- data/spec/rhc/commands/alias_spec.rb +333 -0
- data/spec/rhc/commands/app_spec.rb +777 -0
- data/spec/rhc/commands/apps_spec.rb +39 -0
- data/spec/rhc/commands/authorization_spec.rb +157 -0
- data/spec/rhc/commands/cartridge_spec.rb +665 -0
- data/spec/rhc/commands/clone_spec.rb +41 -0
- data/spec/rhc/commands/deployment_spec.rb +327 -0
- data/spec/rhc/commands/domain_spec.rb +401 -0
- data/spec/rhc/commands/env_spec.rb +493 -0
- data/spec/rhc/commands/git_clone_spec.rb +102 -0
- data/spec/rhc/commands/logout_spec.rb +86 -0
- data/spec/rhc/commands/member_spec.rb +247 -0
- data/spec/rhc/commands/port_forward_spec.rb +217 -0
- data/spec/rhc/commands/scp_spec.rb +77 -0
- data/spec/rhc/commands/server_spec.rb +69 -0
- data/spec/rhc/commands/setup_spec.rb +118 -0
- data/spec/rhc/commands/snapshot_spec.rb +179 -0
- data/spec/rhc/commands/ssh_spec.rb +163 -0
- data/spec/rhc/commands/sshkey_spec.rb +188 -0
- data/spec/rhc/commands/tail_spec.rb +81 -0
- data/spec/rhc/commands/threaddump_spec.rb +84 -0
- data/spec/rhc/config_spec.rb +407 -0
- data/spec/rhc/helpers_spec.rb +531 -0
- data/spec/rhc/highline_extensions_spec.rb +314 -0
- data/spec/rhc/json_spec.rb +30 -0
- data/spec/rhc/rest_application_spec.rb +258 -0
- data/spec/rhc/rest_client_spec.rb +752 -0
- data/spec/rhc/rest_spec.rb +740 -0
- data/spec/rhc/targz_spec.rb +55 -0
- data/spec/rhc/wizard_spec.rb +756 -0
- data/spec/spec_helper.rb +575 -0
- data/spec/wizard_spec_helper.rb +330 -0
- metadata +469 -0
@@ -0,0 +1,188 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rest_spec_helper'
|
3
|
+
require 'rhc/commands/sshkey'
|
4
|
+
require 'rhc/config'
|
5
|
+
|
6
|
+
|
7
|
+
describe RHC::Commands::Sshkey do
|
8
|
+
let!(:rest_client){ MockRestClient.new }
|
9
|
+
before{ user_config }
|
10
|
+
|
11
|
+
describe 'list' do
|
12
|
+
|
13
|
+
context "when run with list command" do
|
14
|
+
let(:arguments) { %w[sshkey list --noprompt --config test.conf -l test@test.foo -p password --trace] }
|
15
|
+
|
16
|
+
it { expect { run }.to exit_with_code(0) }
|
17
|
+
|
18
|
+
it { run_output.should match(/mockkey1 \(type: ssh-rsa\)/) }
|
19
|
+
it { run_output.should match(/Fingerprint:.*0f:ce:86:80:df:a0:81:ca:db:f1:a7:0c:70:85:ce:00/) }
|
20
|
+
|
21
|
+
it { run_output.should match(/mockkey3 \(type: krb5-principal\)/) }
|
22
|
+
it { run_output.should match(/Principal:.* mockuser@mockdomain/) }
|
23
|
+
# it { run_output.should match(/Fingerprint:.*Invalid key/) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'show' do
|
28
|
+
context "when run with show command" do
|
29
|
+
let(:arguments) { %w[sshkey show mockkey1 --noprompt --config test.conf -l test@test.foo -p password --trace] }
|
30
|
+
|
31
|
+
it { expect { run }.to exit_with_code(0) }
|
32
|
+
it { run_output.should match(/mockkey1 \(type: ssh-rsa\)/) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "add" do
|
37
|
+
context "when adding a valid key" do
|
38
|
+
let(:arguments) { %w[sshkey add --noprompt --config test.conf -l test@test.foo -p password foobar id_rsa.pub] }
|
39
|
+
|
40
|
+
it 'adds the key' do
|
41
|
+
FakeFS do
|
42
|
+
keys = rest_client.sshkeys
|
43
|
+
num_keys = keys.length
|
44
|
+
File.open('id_rsa.pub', 'w') do |f|
|
45
|
+
f << 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCnCOqK7/mmvZ9AtCAerxjAasJ1rSpfuWT4vNm1+O/Fh0Di3chTWjY9a0M2hEnqkqnVG589L9CqCUeT0kdc3Vgw3JEcacSUr1z7tLr9kO+p/D5lSdQYzDGGRFOZ0H6lc/y8iNxWV1VO/sJvKx6cr5zvKIn8Q6GvhVNOxlai0IOb9FJxLGK95GLpZ+elzh8Tc9giy7KfwheAwhV2JoF9uRltE5JP/CNs7w/E29i1Z+jlueuu8RVotLmhSVNJm91Ey7OCtoI1iBE0Wv/SucFe32Qi08RWTM/MaGGz93KQNOVRGjNkosJjPmP1qU6WGBfliDkJAZXB0b6sEcnx1fbVikwZ'
|
46
|
+
end
|
47
|
+
expect { run }.to exit_with_code(0)
|
48
|
+
rest_client.sshkeys.length.should == num_keys + 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when adding a valid key via command line arguments" do
|
54
|
+
let(:arguments) { %w[sshkey add --noprompt --config test.conf -l test@test.foo -p password foobar --type ssh-rsa --content AAAAB3NzaC1yc2EAAAADAQABAAABAQCnCOqK7/mmvZ9AtCAerxjAasJ1rSpfuWT4vNm1+O/Fh0Di3chTWjY9a0M2hEnqkqnVG589L9CqCUeT0kdc3Vgw3JEcacSUr1z7tLr9kO+p/D5lSdQYzDGGRFOZ0H6lc/y8iNxWV1VO/sJvKx6cr5zvKIn8Q6GvhVNOxlai0IOb9FJxLGK95GLpZ+elzh8Tc9giy7KfwheAwhV2JoF9uRltE5JP/CNs7w/E29i1Z+jlueuu8RVotLmhSVNJm91Ey7OCtoI1iBE0Wv/SucFe32Qi08RWTM/MaGGz93KQNOVRGjNkosJjPmP1qU6WGBfliDkJAZXB0b6sEcnx1fbVikwZ] }
|
55
|
+
|
56
|
+
it 'adds the key' do
|
57
|
+
keys = rest_client.sshkeys
|
58
|
+
num_keys = keys.length
|
59
|
+
expect { run }.to exit_with_code(0)
|
60
|
+
rest_client.sshkeys.length.should == num_keys + 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "when adding an invalid key" do
|
65
|
+
let(:arguments) { %w[sshkey add --noprompt --config test.conf -l test@test.foo -p password foobar id_rsa.pub] }
|
66
|
+
|
67
|
+
it "fails to add the key" do
|
68
|
+
FakeFS do
|
69
|
+
keys = rest_client.sshkeys
|
70
|
+
num_keys = keys.length
|
71
|
+
File.open('id_rsa.pub', 'w') do |f|
|
72
|
+
f << 'ssh-rsa AADAQABAAABAQCnCOqK7/mmvZ9AtCAerxjAasJ1rSpfuWT4vNm1+O/Fh0Di3chTWjY9a0M2hEnqkqnVG589L9CqCUeT0kdc3Vgw3JEcacSUr1z7tLr9kO+p/D5lSdQYzDGGRFOZ0H6lc/y8iNxWV1VO/sJvKx6cr5zvKIn8Q6GvhVNOxlai0IOb9FJxLGK95GLpZ+elzh8Tc9giy7KfwheAwhV2JoF9uRltE5JP/CNs7w/E29i1Z+jlueuu8RVotLmhSVNJm91Ey7OCtoI1iBE0Wv/SucFe32Qi08RWTM/MaGGz93KQNOVRGjNkosJjPmP1qU6WGBfliDkJAZXB0b6sEcnx1fbVikwZ'
|
73
|
+
end
|
74
|
+
expect { run }.to exit_with_code(128)
|
75
|
+
expect { run_output.should match(/Name:.* mockkey/) }
|
76
|
+
rest_client.sshkeys.length.should == num_keys
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it "does not throw an error on an empty file" do
|
81
|
+
FakeFS do
|
82
|
+
keys = rest_client.sshkeys
|
83
|
+
num_keys = keys.length
|
84
|
+
File.open('id_rsa.pub', 'w') do |f|
|
85
|
+
f << ''
|
86
|
+
end
|
87
|
+
expect { run }.to exit_with_code(128)
|
88
|
+
expect { run_output.should match(/Name:.* mockkey/) }
|
89
|
+
rest_client.sshkeys.length.should == num_keys
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it "exits with status code Errno::EACCES::Errno" do
|
94
|
+
IO.should_receive(:read).and_return("ssh_foo bar")
|
95
|
+
expect { run }.to exit_with_code(128)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context "when adding an invalid key via command line arguments" do
|
100
|
+
let(:arguments) { %w[sshkey add --noprompt --config test.conf -l test@test.foo -p password foobar --type ssh-rsa --content abcdef] }
|
101
|
+
|
102
|
+
it "fails to add the key" do
|
103
|
+
keys = rest_client.sshkeys
|
104
|
+
num_keys = keys.length
|
105
|
+
expect { run }.to exit_with_code(128)
|
106
|
+
expect { run_output.should match(/Name:.* mockkey/) }
|
107
|
+
rest_client.sshkeys.length.should == num_keys
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context "when adding an invalid key with --confirm" do
|
112
|
+
let(:arguments) { %w[sshkey add --noprompt --confirm --config test.conf -l test@test.foo -p password foobar id_rsa.pub] }
|
113
|
+
|
114
|
+
it "warns and then adds the key" do
|
115
|
+
FakeFS do
|
116
|
+
keys = rest_client.sshkeys
|
117
|
+
num_keys = keys.length
|
118
|
+
File.open('id_rsa.pub', 'w') do |f|
|
119
|
+
f << 'ssh-rsa AADAQABAAABAQCnCOqK7/mmvZ9AtCAerxjAasJ1rSpfuWT4vNm1+O/Fh0Di3chTWjY9a0M2hEnqkqnVG589L9CqCUeT0kdc3Vgw3JEcacSUr1z7tLr9kO+p/D5lSdQYzDGGRFOZ0H6lc/y8iNxWV1VO/sJvKx6cr5zvKIn8Q6GvhVNOxlai0IOb9FJxLGK95GLpZ+elzh8Tc9giy7KfwheAwhV2JoF9uRltE5JP/CNs7w/E29i1Z+jlueuu8RVotLmhSVNJm91Ey7OCtoI1iBE0Wv/SucFe32Qi08RWTM/MaGGz93KQNOVRGjNkosJjPmP1qU6WGBfliDkJAZXB0b6sEcnx1fbVikwZ'
|
120
|
+
end
|
121
|
+
expect { run }.to exit_with_code(0)
|
122
|
+
expect { run_output.should match("key you are uploading is not recognized") }
|
123
|
+
rest_client.sshkeys.length.should == num_keys + 1
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context "when adding a nonexistent key" do
|
129
|
+
let(:arguments) { %w[sshkey add --noprompt --config test.conf -l test@test.foo -p password foobar id_rsa.pub] }
|
130
|
+
|
131
|
+
it "exits with status code Errno::ENOENT::Errno" do
|
132
|
+
expect { run }.to exit_with_code(128)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context "when attempting to add an existing but inaccessible key" do
|
137
|
+
let(:arguments) { %w[sshkey add --noprompt --config test.conf -l test@test.foo -p password foobar inaccessible_key.pub] }
|
138
|
+
|
139
|
+
#before :all do
|
140
|
+
# @inaccessible_key = 'inaccessible_key.pub'
|
141
|
+
# File.new(@inaccessible_key, 'w+')
|
142
|
+
# File.chmod(0000, @inaccessible_key)
|
143
|
+
#end
|
144
|
+
|
145
|
+
#after :all do
|
146
|
+
# File.delete @inaccessible_key
|
147
|
+
#end
|
148
|
+
|
149
|
+
it "exits with status code Errno::EACCES::Errno" do
|
150
|
+
IO.should_receive(:read).and_raise(Errno::EACCES)
|
151
|
+
expect { run }.to exit_with_code(128)
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
context "when adding a key without correct arguments" do
|
157
|
+
let(:arguments) { %w[sshkey add --noprompt --config test.conf -l test@test.foo -p password foobar] }
|
158
|
+
|
159
|
+
it "exits with argument error" do
|
160
|
+
expect { run }.to exit_with_code(1)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "remove" do
|
166
|
+
context "when removing an existing key" do
|
167
|
+
let (:arguments) { %w[sshkey remove --noprompt --config test.conf -l test@test.foo -p password mockkey2] }
|
168
|
+
|
169
|
+
it 'deletes the key' do
|
170
|
+
keys = rest_client.sshkeys
|
171
|
+
num_keys = keys.length
|
172
|
+
expect{ run }.to exit_with_code(0)
|
173
|
+
rest_client.sshkeys.length.should == num_keys - 1
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
context "when removing a nonexistent key" do
|
178
|
+
let (:arguments) { %w[sshkey remove --noprompt --config test.conf -l test@test.foo -p password no_match] }
|
179
|
+
before{ @keys = rest_client.sshkeys }
|
180
|
+
|
181
|
+
it 'leaves keys untouched' do
|
182
|
+
num_keys = @keys.length
|
183
|
+
expect{ run }.to exit_with_code(0)
|
184
|
+
rest_client.sshkeys.length.should == num_keys
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rest_spec_helper'
|
3
|
+
require 'rhc/commands/tail'
|
4
|
+
require 'rhc/config'
|
5
|
+
|
6
|
+
describe RHC::Commands::Tail do
|
7
|
+
let!(:rest_client) { MockRestClient.new }
|
8
|
+
before(:each) do
|
9
|
+
user_config
|
10
|
+
domain = rest_client.add_domain("mock-domain-0")
|
11
|
+
@app = domain.add_application("mock-app-0", "ruby-1.8.7")
|
12
|
+
@app.stub(:ssh_url).and_return("ssh://user@test.domain.com")
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'help' do
|
16
|
+
let(:arguments) { ['tail', '--help'] }
|
17
|
+
|
18
|
+
context 'help is run' do
|
19
|
+
it "should display help" do
|
20
|
+
expect { run }.to exit_with_code(0)
|
21
|
+
end
|
22
|
+
it('should output usage') { run_output.should match("Usage: app tail") }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'tail' do
|
27
|
+
let(:arguments) { ['tail', 'mock-app-0'] }
|
28
|
+
|
29
|
+
context 'when ssh connects' do
|
30
|
+
before (:each) {Net::SSH.should_receive(:start).with('test.domain.com', 'user', :compression => false) }
|
31
|
+
it { expect { run }.to exit_with_code(0) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'is run on an unreachable domain' do
|
35
|
+
before (:each) {Net::SSH.should_receive(:start).and_raise(SocketError) }
|
36
|
+
it { expect { run }.to exit_with_code(1) }
|
37
|
+
it { run_output.should =~ /The connection to test.domain.com failed: / }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'is refused' do
|
41
|
+
before (:each) {Net::SSH.should_receive(:start).and_raise(Errno::ECONNREFUSED) }
|
42
|
+
it { expect { run }.to exit_with_code(1) }
|
43
|
+
it { run_output.should =~ /The server test.domain.com refused a connection with user user/ }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'succeeds and exits on Interrupt' do
|
47
|
+
before (:each) { rest_client.stub(:find_domain) { raise Interrupt } }
|
48
|
+
it { expect { run }.to raise_error(Interrupt) }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'succeeds when a gear is specified' do
|
52
|
+
before (:each) {Net::SSH.should_receive(:start).with('fakesshurl.com', 'fakegearid0', :compression => false) }
|
53
|
+
let(:arguments) { ['tail', 'mock-app-0', '--gear', 'fakegearid0' ] }
|
54
|
+
|
55
|
+
it { run_output.should_not =~ /Connecting to fakesshurl.com/ }
|
56
|
+
it { expect { run }.to exit_with_code(0) }
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'fails when an invalid gear is specified' do
|
60
|
+
let(:arguments) { ['tail', 'mock-app-0', '--gear', 'gearthatdoesnotexist' ] }
|
61
|
+
|
62
|
+
it { expect { run }.to exit_with_code(1) }
|
63
|
+
it { run_output.should =~ /Gear gearthatdoesnotexist not found/ }
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'fails when a gear with no ssh info is specified' do
|
67
|
+
let(:arguments) { ['tail', 'mock-app-0', '--gear', 'fakegearid' ] }
|
68
|
+
|
69
|
+
# Given - gears in gear group should not have ssh info
|
70
|
+
before(:each) do
|
71
|
+
gg = MockRestGearGroup.new(rest_client)
|
72
|
+
@app.stub(:gear_groups).and_return([gg])
|
73
|
+
gg.stub(:gears).and_return([{'state' => 'started', 'id' => 'fakegearid'}])
|
74
|
+
end
|
75
|
+
|
76
|
+
it { expect { run }.to exit_with_code(1) }
|
77
|
+
it { run_output.should =~ /The server does not support operations on individual gears./ }
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rest_spec_helper'
|
3
|
+
require 'rhc/commands/threaddump'
|
4
|
+
require 'rhc/config'
|
5
|
+
describe RHC::Commands::Threaddump do
|
6
|
+
let(:client_links) { mock_response_links(mock_client_links) }
|
7
|
+
let(:domain_0_links) { mock_response_links(mock_domain_links('mock_domain_0')) }
|
8
|
+
let(:domain_1_links) { mock_response_links(mock_domain_links('mock_domain_1')) }
|
9
|
+
let(:app_0_links) { mock_response_links(mock_app_links('mock_domain_0', 'mock_app_0')) }
|
10
|
+
let!(:rest_client){ MockRestClient.new }
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
user_config
|
14
|
+
rest_client.add_domain("mock_domain_0").add_application("mock_app_0", "ruby-1.8.7")
|
15
|
+
stub_api_request(:any, client_links['LIST_DOMAINS']['relative']).
|
16
|
+
to_return({ :body => {
|
17
|
+
:type => 'domains',
|
18
|
+
:data =>
|
19
|
+
[{ :id => 'mock_domain_0',
|
20
|
+
:links => mock_response_links(mock_domain_links('mock_domain_0')),
|
21
|
+
},
|
22
|
+
{ :id => 'mock_domain_1',
|
23
|
+
:links => mock_response_links(mock_domain_links('mock_domain_1')),
|
24
|
+
}]
|
25
|
+
}.to_json,
|
26
|
+
:status => 200
|
27
|
+
})
|
28
|
+
stub_api_request(:any, domain_0_links['LIST_APPLICATIONS']['relative']).
|
29
|
+
to_return({ :body => {
|
30
|
+
:type => 'applications',
|
31
|
+
:data =>
|
32
|
+
[{ :domain_id => 'mock_domain_0',
|
33
|
+
:name => 'mock_app_0',
|
34
|
+
:creation_time => Time.new.to_s,
|
35
|
+
:uuid => 1234,
|
36
|
+
:aliases => ['alias_1', 'alias_2'],
|
37
|
+
:server_identity => 'mock_server_identity',
|
38
|
+
:links => mock_response_links(mock_app_links('mock_domain_0','mock_app_0')),
|
39
|
+
}]
|
40
|
+
}.to_json,
|
41
|
+
:status => 200
|
42
|
+
})
|
43
|
+
stub_api_request(:post, app_0_links['THREAD_DUMP']['relative'], false).
|
44
|
+
to_return({ :body => {
|
45
|
+
:type => 'application',
|
46
|
+
:data =>
|
47
|
+
{ :domain_id => 'mock_domain_1',
|
48
|
+
:name => 'mock_app_0',
|
49
|
+
:creation_time => Time.new.to_s,
|
50
|
+
:uuid => 1234,
|
51
|
+
:aliases => ['alias_1', 'alias_2'],
|
52
|
+
:server_identity => 'mock_server_identity',
|
53
|
+
:links => mock_response_links(mock_app_links('mock_domain_1','mock_app_0')),
|
54
|
+
},
|
55
|
+
:messages => [{:text => 'Application test thread dump complete.: Success', :severity => 'result'}]
|
56
|
+
}.to_json,
|
57
|
+
:status => 200
|
58
|
+
})
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'help' do
|
62
|
+
let(:arguments) { ['threaddump', '--help'] }
|
63
|
+
|
64
|
+
context 'help is run' do
|
65
|
+
it "should display help" do
|
66
|
+
expect { run }.to exit_with_code(0)
|
67
|
+
end
|
68
|
+
it('should output usage') { run_output.should match("Usage: app threaddump") }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe 'threaddump' do
|
73
|
+
let(:arguments) { ['threaddump', 'mock_app_0'] }
|
74
|
+
it { expect { run }.to exit_with_code(0) }
|
75
|
+
it { run_output.should =~ /Application test thread dump complete/ }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'threaddump no args' do
|
79
|
+
let(:arguments) { ['threaddump'] }
|
80
|
+
context 'args not supplied' do
|
81
|
+
it { expect { run }.to exit_with_code(1) }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|