engineyard-visualvm 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +10 -0
- data/README.md +2 -0
- data/Rakefile +12 -0
- data/lib/engineyard-visualvm/cli.rb +17 -7
- data/lib/engineyard-visualvm/version.rb +1 -1
- data/spec/engineyard-visualvm_spec.rb +22 -2
- data/spec/spec_helper.rb +19 -0
- metadata +2 -2
data/ChangeLog
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
2011-12-13 Nick Sieger <nick@nicksieger.com>
|
2
|
+
|
3
|
+
* (Changes): Release 0.5.2
|
4
|
+
|
5
|
+
* lib/engineyard-visualvm/cli.rb (EngineYard::VisualVM::Helpers#fetch_public_ip):
|
6
|
+
Use public hostname from environment's single instance
|
7
|
+
|
8
|
+
* lib/engineyard-visualvm/cli.rb (EngineYard::VisualVM::CLI#start):
|
9
|
+
Ensure host is in known_hosts file before launching visual vm
|
10
|
+
|
1
11
|
2011-12-08 Nick Sieger <nick@nicksieger.com>
|
2
12
|
|
3
13
|
* (Changes): Release 0.5.1
|
data/README.md
CHANGED
@@ -97,6 +97,8 @@ To try it yourself, do the following:
|
|
97
97
|
|
98
98
|
- Prompt for a JVM to connect to if more than one JVM process is
|
99
99
|
running on the server
|
100
|
+
- Prompt for an instance to connect to if the environment has multiple
|
101
|
+
instances
|
100
102
|
- Data collected by `jstatd` is not yet supported, so things like the
|
101
103
|
Visual GC tab are not supported yet.
|
102
104
|
- Additional utilities to make use of the JMX connection remotely
|
data/Rakefile
CHANGED
@@ -45,6 +45,18 @@ RSpec::Core::RakeTask.new
|
|
45
45
|
|
46
46
|
task :spec => :jar
|
47
47
|
|
48
|
+
# Override push to use engineyard key
|
49
|
+
class Bundler::GemHelper
|
50
|
+
def rubygem_push(path)
|
51
|
+
if Gem.configuration.api_keys.key? :engineyard
|
52
|
+
sh("gem push -k engineyard '#{path}'")
|
53
|
+
Bundler.ui.confirm "Pushed #{name} #{version} to rubygems.org"
|
54
|
+
else
|
55
|
+
raise ":engineyard key not set in ~/.gem/credentials"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
48
60
|
begin
|
49
61
|
require 'childprocess'
|
50
62
|
require 'jmx'
|
@@ -122,15 +122,21 @@ module EngineYard
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
# Return the public IP assigned to an
|
126
|
-
# may not be a booted cluster of
|
127
|
-
# exits if no public IP assigned
|
125
|
+
# Return the public IP or instance hostname assigned to an
|
126
|
+
# environment (which may or may not be a booted cluster of
|
127
|
+
# instances) Displays error and exits if no public IP assigned
|
128
|
+
# to the environment
|
128
129
|
def fetch_public_ip(environment)
|
129
|
-
|
130
|
-
|
130
|
+
if environment.load_balancer_ip_address
|
131
|
+
return environment.load_balancer_ip_address
|
131
132
|
end
|
132
133
|
|
133
|
-
environment.
|
134
|
+
if environment.instances.length == 1 && environment.instances.first.public_hostname
|
135
|
+
return environment.instances.first.public_hostname
|
136
|
+
end
|
137
|
+
|
138
|
+
warn "#{environment.account.name}/#{environment.name} has no assigned public IP address or hostname."
|
139
|
+
nil
|
134
140
|
end
|
135
141
|
end
|
136
142
|
|
@@ -173,6 +179,10 @@ module EngineYard
|
|
173
179
|
|
174
180
|
if ssh?
|
175
181
|
ssh_dest = ssh_host
|
182
|
+
unless system "ssh #{ssh_dest} true"
|
183
|
+
warn "Error establishing ssh connection; make sure you can `ssh #{ssh_dest}'."
|
184
|
+
exit 3
|
185
|
+
end
|
176
186
|
|
177
187
|
if socks_proxy?
|
178
188
|
proxy_port = next_free_port
|
@@ -181,7 +191,7 @@ module EngineYard
|
|
181
191
|
else
|
182
192
|
server_host, server_port = host, port
|
183
193
|
@host, @port = "localhost", next_free_port
|
184
|
-
@ssh_process = ChildProcess.build("ssh", "-NL", "#{@port}:#{@host}:#{server_port}",
|
194
|
+
@ssh_process = ChildProcess.build("ssh", "-NL", "#{@port}:#{@host}:#{server_port}", ssh_dest)
|
185
195
|
end
|
186
196
|
|
187
197
|
@ssh_process.start
|
@@ -23,7 +23,7 @@ describe EngineYard::VisualVM::Helpers do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe EngineYard::VisualVM::CLI do
|
26
|
-
let(:script) { Class.new(EngineYard::VisualVM::CLI) }
|
26
|
+
let(:script) { Class.new(EngineYard::VisualVM::CLI) { include SystemDouble } }
|
27
27
|
|
28
28
|
context "#help" do
|
29
29
|
it "prints the default port" do
|
@@ -42,6 +42,7 @@ describe EngineYard::VisualVM::CLI do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context "#start" do
|
45
|
+
let(:system_double) { double("system").tap {|d| script.system_double = d } }
|
45
46
|
let(:ssh_process) { double("ssh process double").tap {|d| d.should_receive(:start) } }
|
46
47
|
let(:visualvm_process) do
|
47
48
|
double("visualvm process double").tap {|d|
|
@@ -83,6 +84,7 @@ describe EngineYard::VisualVM::CLI do
|
|
83
84
|
end
|
84
85
|
|
85
86
|
it "sets up an ssh tunnel if the user@host format is used" do
|
87
|
+
system_double.should_receive(:system).with("ssh user@example.com true").ordered.and_return true
|
86
88
|
ChildProcess.should_receive(:build).ordered.and_return do |*args|
|
87
89
|
args.join(' ').should =~ /ssh -NL.*user@example.com/
|
88
90
|
ssh_process
|
@@ -97,6 +99,7 @@ describe EngineYard::VisualVM::CLI do
|
|
97
99
|
end
|
98
100
|
|
99
101
|
it "allows an ssh tunnel to be forced" do
|
102
|
+
system_double.should_receive(:system).ordered.and_return true
|
100
103
|
ChildProcess.should_receive(:build).ordered.and_return do |*args|
|
101
104
|
args.join(' ').should =~ /ssh -NL/
|
102
105
|
ssh_process
|
@@ -122,6 +125,7 @@ describe EngineYard::VisualVM::CLI do
|
|
122
125
|
end
|
123
126
|
|
124
127
|
it "finds an open port for the local side of the ssh tunnel" do
|
128
|
+
system_double.should_receive(:system).ordered.and_return true
|
125
129
|
ChildProcess.should_receive(:build).ordered.and_return do |*args|
|
126
130
|
args.join(' ').should =~ /ssh -NL #{@next_port}:localhost:#{@port}/
|
127
131
|
ssh_process
|
@@ -139,7 +143,6 @@ describe EngineYard::VisualVM::CLI do
|
|
139
143
|
context "with --environment specified" do
|
140
144
|
let(:environment) do
|
141
145
|
double(:environment).tap {|e|
|
142
|
-
e.stub!(:load_balancer_ip_address).and_return "0.0.0.0"
|
143
146
|
e.stub!(:username).and_return "deploy"
|
144
147
|
}
|
145
148
|
end
|
@@ -151,6 +154,7 @@ describe EngineYard::VisualVM::CLI do
|
|
151
154
|
end
|
152
155
|
|
153
156
|
it "sets the user to 'deploy' and the host to the load balancer IP address" do
|
157
|
+
environment.stub!(:load_balancer_ip_address).and_return "0.0.0.0"
|
154
158
|
ChildProcess.should_receive(:build).ordered.and_return do |*args|
|
155
159
|
args.join(' ').should =~ /ssh -NL.* deploy@0.0.0.0/
|
156
160
|
ssh_process
|
@@ -163,6 +167,22 @@ describe EngineYard::VisualVM::CLI do
|
|
163
167
|
|
164
168
|
script.start(["start", "--environment=jruby"])
|
165
169
|
end
|
170
|
+
|
171
|
+
it "uses the public hostname of the first instance if no load balancer" do
|
172
|
+
environment.stub!(:load_balancer_ip_address).and_return nil
|
173
|
+
environment.stub!(:instances).and_return [double("instance").tap{|d| d.stub!(:public_hostname).and_return "example.com" }]
|
174
|
+
ChildProcess.should_receive(:build).ordered.and_return do |*args|
|
175
|
+
args.join(' ').should =~ /ssh -NL.* deploy@example.com/
|
176
|
+
ssh_process
|
177
|
+
end
|
178
|
+
ChildProcess.should_receive(:build).ordered.and_return do |*args|
|
179
|
+
args[2].should =~ /service:jmx:rmi.*localhost:/
|
180
|
+
visualvm_process
|
181
|
+
end
|
182
|
+
ssh_process.should_receive(:stop)
|
183
|
+
|
184
|
+
script.start(["start", "--environment=jruby"])
|
185
|
+
end
|
166
186
|
end
|
167
187
|
end
|
168
188
|
|
data/spec/spec_helper.rb
CHANGED
@@ -25,6 +25,25 @@ module EYVisualVMSpecHelpers
|
|
25
25
|
alias capture silence
|
26
26
|
end
|
27
27
|
|
28
|
+
module SystemDouble
|
29
|
+
def self.included(base)
|
30
|
+
def base.system_double
|
31
|
+
@@double
|
32
|
+
end
|
33
|
+
def base.system_double=(d)
|
34
|
+
@@double = d
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def system_double
|
39
|
+
@@double
|
40
|
+
end
|
41
|
+
|
42
|
+
def system(*args)
|
43
|
+
system_double.system(*args)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
28
47
|
RSpec.configure do |config|
|
29
48
|
config.include EYVisualVMSpecHelpers
|
30
49
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: engineyard-visualvm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nick Sieger
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-12-
|
13
|
+
date: 2011-12-13 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: childprocess
|