Skip to content

Commit c79782c

Browse files
committed
Merge branch 'brendanbenson-insight_agent_ng2'
2 parents 7c13555 + a7b0edf commit c79782c

5 files changed

Lines changed: 24 additions & 67 deletions

File tree

lib/java_buildpack/container/tomcat/tomcat_insight_support.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def detect
3434
# (see JavaBuildpack::Component::BaseComponent#compile)
3535
def compile
3636
link_to(container_libs_directory.children, tomcat_lib) if container_libs_directory.exist?
37-
link_to(extra_applications_directory.children, tomcat_webapps) if extra_applications_directory.exist?
3837
end
3938

4039
# (see JavaBuildpack::Component::BaseComponent#release)
@@ -46,11 +45,6 @@ def release
4645
def container_libs_directory
4746
@droplet.root + '.spring-insight/container-libs'
4847
end
49-
50-
def extra_applications_directory
51-
@droplet.root + '.spring-insight/extra-applications'
52-
end
53-
5448
end
5549

5650
end

lib/java_buildpack/framework/spring_insight.rb

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SpringInsight < JavaBuildpack::Component::BaseComponent
3131
# @param [Hash] context a collection of utilities used the component
3232
def initialize(context)
3333
super(context)
34-
@version, @uri = supports? ? find_insight_agent : [nil, nil]
34+
@version, @uri, @agent_id, @agent_pass = supports? ? find_insight_agent : [nil, nil, nil, nil]
3535
end
3636

3737
# (see JavaBuildpack::Component::BaseComponent#detect)
@@ -79,8 +79,8 @@ def add_agent_configuration
7979
.add_system_property('agent.http.host', URI(@uri).host)
8080
.add_system_property('agent.http.port', 80)
8181
.add_system_property('agent.http.context.path', 'insight')
82-
.add_system_property('agent.http.username', 'spring')
83-
.add_system_property('agent.http.password', 'insight')
82+
.add_system_property('agent.http.username', @agent_id)
83+
.add_system_property('agent.http.password', @agent_pass)
8484
.add_system_property('agent.http.send.json', false)
8585
.add_system_property('agent.http.use.proxy', false)
8686
end
@@ -111,21 +111,16 @@ def install_insight(agent_dir)
111111

112112
init_container_libs root
113113
init_insight_cloudfoundry_agent_plugin root
114-
init_extra_applications root
115114
init_insight root
116-
init_insight_analyzer root
115+
init_insight_agent_plugins root
117116
init_weaver root
118117
end
119118

120119
def init_container_libs(root)
121120
move container_libs_directory,
122121
root + 'agents/common/insight-bootstrap-generic-*.jar',
123-
root + 'agents/tomcat/7/lib/insight-bootstrap-tomcat-common-*.jar'
124-
end
125-
126-
def init_extra_applications(root)
127-
move extra_applications_directory,
128-
root + 'insight-agent'
122+
root + 'agents/tomcat/7/lib/insight-bootstrap-tomcat-common-*.jar',
123+
root + 'agents/tomcat/7/lib/insight-agent-*.jar'
129124
end
130125

131126
def init_insight(root)
@@ -134,8 +129,8 @@ def init_insight(root)
134129
root + 'insight/conf'
135130
end
136131

137-
def init_insight_analyzer(root)
138-
move insight_analyzer_directory + 'WEB-INF/lib',
132+
def init_insight_agent_plugins(root)
133+
move insight_directory + 'agent-plugins',
139134
root + 'transport/http/insight-agent-http-*.jar',
140135
root + 'cloudfoundry/insight-agent-cloudfoundry-*.jar'
141136
end
@@ -147,27 +142,21 @@ def init_insight_cloudfoundry_agent_plugin(root)
147142

148143
def init_weaver(root)
149144
move weaver_directory,
150-
root + 'agents/common/insight-weaver-*.jar'
145+
root + 'cloudfoundry/insight-weaver-*.jar'
151146
end
152147

153148
def container_libs_directory
154149
@droplet.root + '.spring-insight/container-libs'
155150
end
156151

157-
def extra_applications_directory
158-
@droplet.root + '.spring-insight/extra-applications'
159-
end
160-
161152
def find_insight_agent
162-
service = @application.services.find_service FILTER
163-
version = service['label'].match(/(.*)-(.*)/)[2]
164-
uri = service['credentials']['dashboard_url']
165-
166-
return version, uri # rubocop:disable RedundantReturn
167-
end
168-
169-
def insight_analyzer_directory
170-
extra_applications_directory + 'insight-agent'
153+
service = @application.services.find_service FILTER
154+
version = service['label'].match(/(.*)-(.*)/)[2]
155+
credentials = service['credentials']
156+
uri = credentials['dashboard_url']
157+
id = credentials['agent_username']
158+
pass = credentials['agent_password']
159+
return version, uri, id, pass # rubocop:disable RedundantReturn
171160
end
172161

173162
def insight_directory
@@ -187,7 +176,7 @@ def move(destination, *globs)
187176
end
188177

189178
def supports?
190-
@application.services.one_service? FILTER, 'dashboard_url'
179+
@application.services.one_service? FILTER, 'dashboard_url', 'agent_username', 'agent_password'
191180
end
192181

193182
def uber_agent_zip(location)
-5.46 KB
Binary file not shown.

spec/java_buildpack/container/tomcat/tomcat_insight_support_spec.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,6 @@
3232
component.release
3333
end
3434

35-
context do
36-
let(:extra_applications_dir) { app_dir + '.spring-insight/extra-applications' }
37-
38-
before do
39-
FileUtils.mkdir_p extra_applications_dir
40-
FileUtils.cp_r 'spec/fixtures/framework_spring_insight', extra_applications_dir
41-
end
42-
43-
it 'should link extra applications to the applications directory' do
44-
45-
component.compile
46-
47-
webapps_dir = sandbox + 'webapps'
48-
49-
insight_test_dir = webapps_dir + 'framework_spring_insight'
50-
expect(insight_test_dir).to exist
51-
expect(insight_test_dir).to be_symlink
52-
expect(insight_test_dir.readlink).to eq((extra_applications_dir + 'framework_spring_insight')
53-
.relative_path_from(webapps_dir))
54-
end
55-
end
56-
5735
context do
5836
let(:container_libs_dir) { app_dir + '.spring-insight/container-libs' }
5937

spec/java_buildpack/framework/spring_insight_spec.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
context do
3030

3131
before do
32-
allow(services).to receive(:one_service?).with(/insight/, 'dashboard_url').and_return(true)
32+
allow(services).to receive(:one_service?).with(/insight/, 'dashboard_url', 'agent_username', 'agent_password').and_return(true)
3333
allow(services).to receive(:find_service).and_return('label' => 'insight-1.0',
34-
'credentials' => { 'dashboard_url' => 'test-uri' })
34+
'credentials' => { 'dashboard_url' => 'test-uri', 'agent_password' => 'foo', 'agent_username' => 'bar' })
3535
allow(application_cache).to receive(:get).with('test-uri/services/config/agent-download')
3636
.and_yield(Pathname.new('spec/fixtures/stub-insight-agent.jar').open)
3737
end
@@ -44,17 +44,11 @@
4444
component.compile
4545

4646
container_libs_dir = app_dir + '.spring-insight/container-libs'
47-
extra_applications_dir = app_dir + '.spring-insight/extra-applications'
4847

49-
expect(sandbox + 'weaver/insight-weaver-1.2.4-CI-SNAPSHOT.jar').to exist
50-
expect(container_libs_dir + 'insight-bootstrap-generic-1.2.3-CI-SNAPSHOT.jar').to exist
51-
expect(container_libs_dir + 'insight-bootstrap-tomcat-common-1.2.5-CI-SNAPSHOT.jar').to exist
48+
expect(sandbox + 'weaver/insight-weaver-cf-2.0.0-CI-SNAPSHOT.jar').to exist
49+
expect(container_libs_dir + 'insight-bootstrap-generic-2.0.0-CI-SNAPSHOT.jar').to exist
50+
expect(container_libs_dir + 'insight-bootstrap-tomcat-common-2.0.0-CI-SNAPSHOT.jar').to exist
5251
expect(sandbox + 'insight/conf/insight.properties').to exist
53-
expect(sandbox + 'insight/collection-plugins/test-collection-plugins').to exist
54-
expect(extra_applications_dir + 'insight-agent').to exist
55-
expect(extra_applications_dir + 'insight-agent/WEB-INF/lib/insight-agent-http-1.9.3-CI-SNAPSHOT.jar').to exist
56-
expect(extra_applications_dir + 'insight-agent/WEB-INF/lib/insight-agent-cloudfoundry-1.2.3.jar').to exist
57-
expect(container_libs_dir + 'cloudfoundry-runtime-1.2.3.jar').to exist
5852
end
5953

6054
it 'should update JAVA_OPTS',
@@ -67,6 +61,8 @@
6761
expect(java_opts).to include('-Dinsight.logs=$PWD/.java-buildpack/spring_insight/insight/logs')
6862
expect(java_opts).to include('-Daspectj.overweaving=true')
6963
expect(java_opts).to include('-Dorg.aspectj.tracing.factory=default')
64+
expect(java_opts).to include('-Dagent.http.username=bar')
65+
expect(java_opts).to include('-Dagent.http.password=foo')
7066
end
7167
end
7268

0 commit comments

Comments
 (0)