diff --git a/lib/java_buildpack/container/tomcat/tomcat_insight_support.rb b/lib/java_buildpack/container/tomcat/tomcat_insight_support.rb index 59543ff699..4b1d7c12e8 100644 --- a/lib/java_buildpack/container/tomcat/tomcat_insight_support.rb +++ b/lib/java_buildpack/container/tomcat/tomcat_insight_support.rb @@ -34,7 +34,6 @@ def detect # @macro base_component_compile def compile link_to(container_libs_directory.children, tomcat_lib) if container_libs_directory.exist? - link_to(extra_applications_directory.children, tomcat_webapps) if extra_applications_directory.exist? end # @macro base_component_release @@ -46,11 +45,6 @@ def release def container_libs_directory @droplet.root + '.spring-insight/container-libs' end - - def extra_applications_directory - @droplet.root + '.spring-insight/extra-applications' - end - end end diff --git a/lib/java_buildpack/framework/spring_insight.rb b/lib/java_buildpack/framework/spring_insight.rb index 6514239814..265c45736d 100644 --- a/lib/java_buildpack/framework/spring_insight.rb +++ b/lib/java_buildpack/framework/spring_insight.rb @@ -31,7 +31,7 @@ class SpringInsight < JavaBuildpack::Component::BaseComponent # @param [Hash] context a collection of utilities used the component def initialize(context) super(context) - @version, @uri = supports? ? find_insight_agent : [nil, nil] + @version, @uri, @agent_id, @agent_pass = supports? ? find_insight_agent : [nil, nil, nil, nil] end # @macro base_component_detect @@ -79,8 +79,8 @@ def add_agent_configuration .add_system_property('agent.http.host', URI(@uri).host) .add_system_property('agent.http.port', 80) .add_system_property('agent.http.context.path', 'insight') - .add_system_property('agent.http.username', 'spring') - .add_system_property('agent.http.password', 'insight') + .add_system_property('agent.http.username', @agent_id) + .add_system_property('agent.http.password', @agent_pass) .add_system_property('agent.http.send.json', false) .add_system_property('agent.http.use.proxy', false) end @@ -111,21 +111,16 @@ def install_insight(agent_dir) init_container_libs root init_insight_cloudfoundry_agent_plugin root - init_extra_applications root init_insight root - init_insight_analyzer root + init_insight_agent_plugins root init_weaver root end def init_container_libs(root) move container_libs_directory, root + 'agents/common/insight-bootstrap-generic-*.jar', - root + 'agents/tomcat/7/lib/insight-bootstrap-tomcat-common-*.jar' - end - - def init_extra_applications(root) - move extra_applications_directory, - root + 'insight-agent' + root + 'agents/tomcat/7/lib/insight-bootstrap-tomcat-common-*.jar', + root + 'agents/tomcat/7/lib/insight-agent-*.jar' end def init_insight(root) @@ -134,8 +129,8 @@ def init_insight(root) root + 'insight/conf' end - def init_insight_analyzer(root) - move insight_analyzer_directory + 'WEB-INF/lib', + def init_insight_agent_plugins(root) + move insight_directory + 'agent-plugins', root + 'transport/http/insight-agent-http-*.jar', root + 'cloudfoundry/insight-agent-cloudfoundry-*.jar' end @@ -147,27 +142,21 @@ def init_insight_cloudfoundry_agent_plugin(root) def init_weaver(root) move weaver_directory, - root + 'agents/common/insight-weaver-*.jar' + root + 'cloudfoundry/insight-weaver-*.jar' end def container_libs_directory @droplet.root + '.spring-insight/container-libs' end - def extra_applications_directory - @droplet.root + '.spring-insight/extra-applications' - end - def find_insight_agent - service = @application.services.find_service FILTER - version = service['label'].match(/(.*)-(.*)/)[2] - uri = service['credentials']['dashboard_url'] - - return version, uri # rubocop:disable RedundantReturn - end - - def insight_analyzer_directory - extra_applications_directory + 'insight-agent' + service = @application.services.find_service FILTER + version = service['label'].match(/(.*)-(.*)/)[2] + credentials = service['credentials'] + uri = credentials['dashboard_url'] + id = credentials['agent_username'] + pass = credentials['agent_password'] + return version, uri, id, pass # rubocop:disable RedundantReturn end def insight_directory @@ -187,7 +176,7 @@ def move(destination, *globs) end def supports? - @application.services.one_service? FILTER, 'dashboard_url' + @application.services.one_service? FILTER, 'dashboard_url', 'agent_username', 'agent_password' end def uber_agent_zip(location) diff --git a/spec/fixtures/stub-insight-agent.jar b/spec/fixtures/stub-insight-agent.jar index f130d8460c..6148c8743f 100644 Binary files a/spec/fixtures/stub-insight-agent.jar and b/spec/fixtures/stub-insight-agent.jar differ diff --git a/spec/java_buildpack/container/tomcat/tomcat_insight_support_spec.rb b/spec/java_buildpack/container/tomcat/tomcat_insight_support_spec.rb index 56b58cec6b..79daf039a2 100644 --- a/spec/java_buildpack/container/tomcat/tomcat_insight_support_spec.rb +++ b/spec/java_buildpack/container/tomcat/tomcat_insight_support_spec.rb @@ -32,28 +32,6 @@ component.release end - context do - let(:extra_applications_dir) { app_dir + '.spring-insight/extra-applications' } - - before do - FileUtils.mkdir_p extra_applications_dir - FileUtils.cp_r 'spec/fixtures/framework_spring_insight', extra_applications_dir - end - - it 'should link extra applications to the applications directory' do - - component.compile - - webapps_dir = sandbox + 'webapps' - - insight_test_dir = webapps_dir + 'framework_spring_insight' - expect(insight_test_dir).to exist - expect(insight_test_dir).to be_symlink - expect(insight_test_dir.readlink).to eq((extra_applications_dir + 'framework_spring_insight') - .relative_path_from(webapps_dir)) - end - end - context do let(:container_libs_dir) { app_dir + '.spring-insight/container-libs' } diff --git a/spec/java_buildpack/framework/spring_insight_spec.rb b/spec/java_buildpack/framework/spring_insight_spec.rb index a0904fb6b4..7e90d519dd 100644 --- a/spec/java_buildpack/framework/spring_insight_spec.rb +++ b/spec/java_buildpack/framework/spring_insight_spec.rb @@ -29,9 +29,9 @@ context do before do - allow(services).to receive(:one_service?).with(/insight/, 'dashboard_url').and_return(true) + allow(services).to receive(:one_service?).with(/insight/, 'dashboard_url', 'agent_username', 'agent_password').and_return(true) allow(services).to receive(:find_service).and_return('label' => 'insight-1.0', - 'credentials' => { 'dashboard_url' => 'test-uri' }) + 'credentials' => { 'dashboard_url' => 'test-uri', 'agent_password' => 'foo', 'agent_username' => 'bar' }) allow(application_cache).to receive(:get).with('test-uri/services/config/agent-download') .and_yield(Pathname.new('spec/fixtures/stub-insight-agent.jar').open) end @@ -44,17 +44,11 @@ component.compile container_libs_dir = app_dir + '.spring-insight/container-libs' - extra_applications_dir = app_dir + '.spring-insight/extra-applications' - expect(sandbox + 'weaver/insight-weaver-1.2.4-CI-SNAPSHOT.jar').to exist - expect(container_libs_dir + 'insight-bootstrap-generic-1.2.3-CI-SNAPSHOT.jar').to exist - expect(container_libs_dir + 'insight-bootstrap-tomcat-common-1.2.5-CI-SNAPSHOT.jar').to exist + expect(sandbox + 'weaver/insight-weaver-cf-2.0.0-CI-SNAPSHOT.jar').to exist + expect(container_libs_dir + 'insight-bootstrap-generic-2.0.0-CI-SNAPSHOT.jar').to exist + expect(container_libs_dir + 'insight-bootstrap-tomcat-common-2.0.0-CI-SNAPSHOT.jar').to exist expect(sandbox + 'insight/conf/insight.properties').to exist - expect(sandbox + 'insight/collection-plugins/test-collection-plugins').to exist - expect(extra_applications_dir + 'insight-agent').to exist - expect(extra_applications_dir + 'insight-agent/WEB-INF/lib/insight-agent-http-1.9.3-CI-SNAPSHOT.jar').to exist - expect(extra_applications_dir + 'insight-agent/WEB-INF/lib/insight-agent-cloudfoundry-1.2.3.jar').to exist - expect(container_libs_dir + 'cloudfoundry-runtime-1.2.3.jar').to exist end it 'should update JAVA_OPTS', @@ -67,6 +61,8 @@ expect(java_opts).to include('-Dinsight.logs=$PWD/.java-buildpack/spring_insight/insight/logs') expect(java_opts).to include('-Daspectj.overweaving=true') expect(java_opts).to include('-Dorg.aspectj.tracing.factory=default') + expect(java_opts).to include('-Dagent.http.username=bar') + expect(java_opts).to include('-Dagent.http.password=foo') end end