From 993ec2e753e22dc59e230adad8902e897ba89bc6 Mon Sep 17 00:00:00 2001 From: Brendan Benson Date: Mon, 24 Mar 2014 14:43:08 -0600 Subject: [PATCH] Next Generation Insight Agent Support - Removed code which installed the Insight Analyzer WAR file - Added code to install the cloudfoundry specific Insight weaver instead of the vfabric weaver. --- .../tomcat/tomcat_insight_support.rb | 6 --- .../framework/spring_insight.rb | 45 +++++++----------- spec/fixtures/stub-insight-agent.jar | Bin 7311 -> 1724 bytes .../tomcat/tomcat_insight_support_spec.rb | 22 --------- .../framework/spring_insight_spec.rb | 18 +++---- 5 files changed, 24 insertions(+), 67 deletions(-) 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 f130d8460ccfd78efecc56645c44ef4cec88b55f..6148c8743f898785d0a97cbd7ddcea25947301a2 100644 GIT binary patch delta 1401 zcmV-<1%~>MIlK)GP)h>@6aWYa2msPma*+)>1JYG;kxESg8j+YD8Htxb0Yd-)07L)) z08mQ<1QY-W2nYbkRdSP93o(B(E-)@IEkj8yQ%*rpQ%Fx#E_!Kjt(RM9990;{XOlfO zO=}F+n2>BsELij4tmy`gt+%GBYiey0b3yvh(#>RcGj=nx&d!?DK+#GtLcP?A4?<}b zA4QQui4Q{2mWqfJ484e?))xh-_@WO|!I}NGv**moo|Bn#HiWrsCjWomeCPTb-cuiM zRJ_keZ>hT!?2}RwO0i%YX0B+JY)w}UvuNa|9JMr|+iE7Kn~s`Fb|<^l{@v>6VBhfQ zz|h!3<6~=;`nMOBM)u8ijh1HDDY5w9F-3`c|8dyQ+M>7i<5}AxWtHz2A@bW#TiKDR zA)9!;9U_sMH9c*akocN(g-kA`flM+E^^vuidLjrW01ARuQ0Uc{v%Q(=0=XhP`i&x3I?39q)3)!D-Yhh>K zJx+Gpw3O_;F#-AU8BXU7<{Q%TZ$DV$8NXwAh|G?W2z1*y>4<;TQ3hYD(774VQ@q}M zCQ#R>B0+0;t2CLlO6H_}7#eizET=(#JVXwo{o=v+g=&{f$C%dDt;tlf$FIkM#a4Db zf>_ZeNdk-PU<73ChU0>Ej*tzPl?PgxBeg7pZ|)_|Xb3Lj+avK+{%DoU`I*27+$)r+ zS^2!KIfgsH3i*Fh&bc@Zd9CWX2_xE}6;L1g^U|R*){k0i27*U!G$o!zy;`h5T5tpm%4PON`#zd!f>Pq&V5DjffJ{=;#7 z{&LR~H-6Ed`R3GIYQE=KV)(zk17~k8|8U>CC$&9C{+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UY*i4}7*15^R|RVn8ttZiyWgmaA~l|f4{N!b*A^@iUZa}NoAaM0k6~aF%^MMPDfsjhYw{<(k6Zg0f)P9 z1|P~Acq1HI0T>+bVFdtfLnA$`2Vh@C4(0It4{RayIP@w)4S+q2#SK5a0}tiUJGUMtcy3vf&=UuvLK>8ubAhcD{y(ePGwsfHrve{q50zcyjO^9T*L& zvXQUoK*k4BF-Y#~QUGA2Obh^w?yACQNE!fW%ESSH=A@}Y{0ON4;3*Re0N#GJ;Pu~3 z0j4tX0APMl8|L6jgEIVEQUV~VOiTborBI_Ac`+jAZ0HgSz_8a)SX==1yXs&_WMxvr z@Kl(92lT`qqjKDXEAw^f0T9B@7O?mL?B%Ek4RAoMfif`y;CO3|Ch$R=zv==gXl3FA zfX-Jp^srI|NV+ny0x+`ERxKHQ(gnCiz~TjR?uW$-V7pWY8(0Q}l!4rQ%ESc#&w>6= zF!G&_Dst3XD-#<4+6^_J0qFs(Csq=G#Rp(^x~j)Gh>C6aSY%j?0CrH#$UvF^v11zu zEKUH^gKm=}UtgqD0g$k5+zY@!Pb?LY2BeGO;b8FsSfx7PP<8xODFbY0Sj<3946v91 e%wKO5`G%#9ApbE?BgEk*Lq9R&pa&xS*Z%<%{%uzP 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