@@ -180,7 +180,7 @@ var _ = Describe("CfJavaPlugin", func() {
180180 Expect (cliOutput ).To (Equal ("" ))
181181
182182 Expect (commandExecutor .ExecuteCallCount ()).To (Equal (1 ))
183- Expect (commandExecutor .ExecuteArgsForCall (0 )).To (Equal ([]string {"ssh" , "my_app" , "--command" , JavaDetectionCommand + "; if [ -f /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 'Heap dump /tmp/heapdump-abcd-123456.hprof already exists'; exit 1; fi; OUTPUT=$( $(find -executable -name jmap | head -1) -dump:format=b,file=/tmp/heapdump-abcd-123456.hprof $(pidof java) ) || STATUS_CODE=$?; if [ ! -s /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat /tmp/heapdump-abcd-123456.hprof; rm -f /tmp/heapdump-abcd-123456.hprof" }))
183+ Expect (commandExecutor .ExecuteArgsForCall (0 )).To (Equal ([]string {"ssh" , "my_app" , "--command" , JavaDetectionCommand + "; if [ -f /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 'Heap dump /tmp/heapdump-abcd-123456.hprof already exists'; exit 1; fi; JMAP_COMMAND=`find -executable -name jmap | head -1 | tr -d [:space:]`; if [ -n \" ${JMAP_COMMAND}\" ]; then true; OUTPUT=$( ${JMAP_COMMAND} -dump:format=b,file=/tmp/heapdump-abcd-123456.hprof $(pidof java) ) || STATUS_CODE=$?; if [ ! -s /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat /tmp/heapdump-abcd-123456.hprof; exit 0; fi; JVMMON_COMMAND=`find -executable -name jvmmon | head -1 | tr -d [:space:]`; if [ -n \" ${JVMMON_COMMAND}\" ]; then true; OUTPUT=$( ${JVMMON_COMMAND} -pid $(pidof java) -c \" dump heap\" ) || STATUS_CODE=$?; sleep 5; HEAP_DUMP_NAME=`find -name 'java_pid*.hprof' -printf '%T@ %p\\ 0' | sort -zk 1nr | sed -z 's/^[^ ]* //' | tr '\\ 0' '\\ n' | head -n 1`; SIZE=-1; OLD_SIZE=$(stat -c '%s' \" ${HEAP_DUMP_NAME}\" ); while [ \" ${SIZE}\" != \" ${OLD_SIZE}\" ]; do sleep 3; SIZE=$(stat -c '%s' \" ${HEAP_DUMP_NAME}\" ); done; if [ ! -s \" ${HEAP_DUMP_NAME}\" ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat ${HEAP_DUMP_NAME}; fi; rm -f /tmp/heapdump-abcd-123456.hprof; if [ -n \" ${HEAP_DUMP_NAME}\" ]; then rm -f ${HEAP_DUMP_NAME} ${HEAP_DUMP_NAME%.*}.addons; fi" }))
184184 })
185185
186186 })
@@ -200,7 +200,7 @@ var _ = Describe("CfJavaPlugin", func() {
200200 Expect (cliOutput ).To (Equal ("" ))
201201
202202 Expect (commandExecutor .ExecuteCallCount ()).To (Equal (1 ))
203- Expect (commandExecutor .ExecuteArgsForCall (0 )).To (Equal ([]string {"ssh" , "my_app" , "--app-instance-index" , "4" , "--command" , JavaDetectionCommand + "; if [ -f /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 'Heap dump /tmp/heapdump-abcd-123456.hprof already exists'; exit 1; fi; OUTPUT=$( $(find -executable -name jmap | head -1) -dump:format=b,file=/tmp/heapdump-abcd-123456.hprof $(pidof java) ) || STATUS_CODE=$?; if [ ! -s /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat /tmp/heapdump-abcd-123456.hprof; rm -f /tmp/heapdump-abcd-123456.hprof" }))
203+ Expect (commandExecutor .ExecuteArgsForCall (0 )).To (Equal ([]string {"ssh" , "my_app" , "--app-instance-index" , "4" , "--command" , JavaDetectionCommand + "; if [ -f /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 'Heap dump /tmp/heapdump-abcd-123456.hprof already exists'; exit 1; fi; JMAP_COMMAND=`find -executable -name jmap | head -1 | tr -d [:space:]`; if [ -n \" ${JMAP_COMMAND}\" ]; then true; OUTPUT=$( ${JMAP_COMMAND} -dump:format=b,file=/tmp/heapdump-abcd-123456.hprof $(pidof java) ) || STATUS_CODE=$?; if [ ! -s /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat /tmp/heapdump-abcd-123456.hprof; exit 0; fi; JVMMON_COMMAND=`find -executable -name jvmmon | head -1 | tr -d [:space:]`; if [ -n \" ${JVMMON_COMMAND}\" ]; then true; OUTPUT=$( ${JVMMON_COMMAND} -pid $(pidof java) -c \" dump heap\" ) || STATUS_CODE=$?; sleep 5; HEAP_DUMP_NAME=`find -name 'java_pid*.hprof' -printf '%T@ %p\\ 0' | sort -zk 1nr | sed -z 's/^[^ ]* //' | tr '\\ 0' '\\ n' | head -n 1`; SIZE=-1; OLD_SIZE=$(stat -c '%s' \" ${HEAP_DUMP_NAME}\" ); while [ \" ${SIZE}\" != \" ${OLD_SIZE}\" ]; do sleep 3; SIZE=$(stat -c '%s' \" ${HEAP_DUMP_NAME}\" ); done; if [ ! -s \" ${HEAP_DUMP_NAME}\" ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat ${HEAP_DUMP_NAME}; fi; rm -f /tmp/heapdump-abcd-123456.hprof; if [ -n \" ${HEAP_DUMP_NAME}\" ]; then rm -f ${HEAP_DUMP_NAME} ${HEAP_DUMP_NAME%.*}.addons; fi" }))
204204 })
205205
206206 })
@@ -220,7 +220,10 @@ var _ = Describe("CfJavaPlugin", func() {
220220 Expect (cliOutput ).To (Equal ("" ))
221221
222222 Expect (commandExecutor .ExecuteCallCount ()).To (Equal (1 ))
223- Expect (commandExecutor .ExecuteArgsForCall (0 )).To (Equal ([]string {"ssh" , "my_app" , "--app-instance-index" , "4" , "--command" , JavaDetectionCommand + "; if [ -f /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 'Heap dump /tmp/heapdump-abcd-123456.hprof already exists'; exit 1; fi; OUTPUT=$( $(find -executable -name jmap | head -1) -dump:format=b,file=/tmp/heapdump-abcd-123456.hprof $(pidof java) ) || STATUS_CODE=$?; if [ ! -s /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat /tmp/heapdump-abcd-123456.hprof" }))
223+ Expect (commandExecutor .ExecuteArgsForCall (0 )).To (Equal ([]string {"ssh" , "my_app" , "--app-instance-index" , "4" , "--command" , JavaDetectionCommand + "; " +
224+ "if [ -f /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 'Heap dump /tmp/heapdump-abcd-123456.hprof already exists'; exit 1; fi; " +
225+ "JMAP_COMMAND=`find -executable -name jmap | head -1 | tr -d [:space:]`; if [ -n \" ${JMAP_COMMAND}\" ]; then true; OUTPUT=$( ${JMAP_COMMAND} -dump:format=b,file=/tmp/heapdump-abcd-123456.hprof $(pidof java) ) || STATUS_CODE=$?; if [ ! -s /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat /tmp/heapdump-abcd-123456.hprof; exit 0; fi; " +
226+ "JVMMON_COMMAND=`find -executable -name jvmmon | head -1 | tr -d [:space:]`; if [ -n \" ${JVMMON_COMMAND}\" ]; then true; OUTPUT=$( ${JVMMON_COMMAND} -pid $(pidof java) -c \" dump heap\" ) || STATUS_CODE=$?; sleep 5; HEAP_DUMP_NAME=`find -name 'java_pid*.hprof' -printf '%T@ %p\\ 0' | sort -zk 1nr | sed -z 's/^[^ ]* //' | tr '\\ 0' '\\ n' | head -n 1`; SIZE=-1; OLD_SIZE=$(stat -c '%s' \" ${HEAP_DUMP_NAME}\" ); while [ \" ${SIZE}\" != \" ${OLD_SIZE}\" ]; do sleep 3; SIZE=$(stat -c '%s' \" ${HEAP_DUMP_NAME}\" ); done; if [ ! -s \" ${HEAP_DUMP_NAME}\" ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat ${HEAP_DUMP_NAME}; fi" }))
224227 })
225228
226229 })
@@ -235,9 +238,14 @@ var _ = Describe("CfJavaPlugin", func() {
235238 return output , err
236239 })
237240
238- Expect (output ).To (Equal ("cf ssh my_app --app-instance-index 4 --command '" + JavaDetectionCommand + "; if [ -f /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 'Heap dump /tmp/heapdump-abcd-123456.hprof already exists'; exit 1; fi; OUTPUT=$( $(find -executable -name jmap | head -1) -dump:format=b,file=/tmp/heapdump-abcd-123456.hprof $(pidof java) ) || STATUS_CODE=$?; if [ ! -s /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat /tmp/heapdump-abcd-123456.hprof'" ))
241+ expectedOutput := "cf ssh my_app --app-instance-index 4 --command '" + JavaDetectionCommand + "; " +
242+ "if [ -f /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 'Heap dump /tmp/heapdump-abcd-123456.hprof already exists'; exit 1; fi; " +
243+ "JMAP_COMMAND=`find -executable -name jmap | head -1 | tr -d [:space:]`; if [ -n \" ${JMAP_COMMAND}\" ]; then true; OUTPUT=$( ${JMAP_COMMAND} -dump:format=b,file=/tmp/heapdump-abcd-123456.hprof $(pidof java) ) || STATUS_CODE=$?; if [ ! -s /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat /tmp/heapdump-abcd-123456.hprof; exit 0; fi; " +
244+ "JVMMON_COMMAND=`find -executable -name jvmmon | head -1 | tr -d [:space:]`; if [ -n \" ${JVMMON_COMMAND}\" ]; then true; OUTPUT=$( ${JVMMON_COMMAND} -pid $(pidof java) -c \" dump heap\" ) || STATUS_CODE=$?; sleep 5; HEAP_DUMP_NAME=`find -name 'java_pid*.hprof' -printf '%T@ %p\\ 0' | sort -zk 1nr | sed -z 's/^[^ ]* //' | tr '\\ 0' '\\ n' | head -n 1`; SIZE=-1; OLD_SIZE=$(stat -c '%s' \" ${HEAP_DUMP_NAME}\" ); while [ \" ${SIZE}\" != \" ${OLD_SIZE}\" ]; do sleep 3; SIZE=$(stat -c '%s' \" ${HEAP_DUMP_NAME}\" ); done; if [ ! -s \" ${HEAP_DUMP_NAME}\" ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat ${HEAP_DUMP_NAME}; fi'"
245+
246+ Expect (output ).To (Equal (expectedOutput ))
239247 Expect (err ).To (BeNil ())
240- Expect (cliOutput ).To (ContainSubstring ("cf ssh my_app --app-instance-index 4 --command '" + JavaDetectionCommand + "; if [ -f /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 'Heap dump /tmp/heapdump-abcd-123456.hprof already exists'; exit 1; fi; OUTPUT=$( $(find -executable -name jmap | head -1) -dump:format=b,file=/tmp/heapdump-abcd-123456.hprof $(pidof java) ) || STATUS_CODE=$?; if [ ! -s /tmp/heapdump-abcd-123456.hprof ]; then echo >&2 ${OUTPUT}; exit 1; fi; if [ ${STATUS_CODE:-0} -gt 0 ]; then echo >&2 ${OUTPUT}; exit ${STATUS_CODE}; fi; cat /tmp/heapdump-abcd-123456.hprof'" ))
248+ Expect (cliOutput ).To (ContainSubstring (expectedOutput ))
241249
242250 Expect (commandExecutor .ExecuteCallCount ()).To (Equal (0 ))
243251 })
@@ -362,13 +370,13 @@ var _ = Describe("CfJavaPlugin", func() {
362370 return output , err
363371 })
364372
365- Expect ( output ). To ( Equal ( "cf ssh my_app --app-instance-index 4 --command '" + JavaDetectionCommand + "; " +
373+ expectedOutput := "cf ssh my_app --app-instance-index 4 --command '" + JavaDetectionCommand + "; " +
366374 "JSTACK_COMMAND=`find -executable -name jstack | head -1`; if [ -n \" ${JSTACK_COMMAND}\" ]; then ${JSTACK_COMMAND} $(pidof java); exit 0; fi; " +
367- "JVMMON_COMMAND=`find -executable -name jvmmon | head -1`; if [ -n \" ${JVMMON_COMMAND}\" ]; then ${JVMMON_COMMAND} -pid $(pidof java) -c \" print stacktrace\" ; fi'" ))
375+ "JVMMON_COMMAND=`find -executable -name jvmmon | head -1`; if [ -n \" ${JVMMON_COMMAND}\" ]; then ${JVMMON_COMMAND} -pid $(pidof java) -c \" print stacktrace\" ; fi'"
376+
377+ Expect (output ).To (Equal (expectedOutput ))
368378 Expect (err ).To (BeNil ())
369- Expect (cliOutput ).To (ContainSubstring ("cf ssh my_app --app-instance-index 4 --command '" + JavaDetectionCommand + "; " +
370- "JSTACK_COMMAND=`find -executable -name jstack | head -1`; if [ -n \" ${JSTACK_COMMAND}\" ]; then ${JSTACK_COMMAND} $(pidof java); exit 0; fi; " +
371- "JVMMON_COMMAND=`find -executable -name jvmmon | head -1`; if [ -n \" ${JVMMON_COMMAND}\" ]; then ${JVMMON_COMMAND} -pid $(pidof java) -c \" print stacktrace\" ; fi'" ))
379+ Expect (cliOutput ).To (ContainSubstring (expectedOutput ))
372380
373381 Expect (commandExecutor .ExecuteCallCount ()).To (Equal (0 ))
374382 })
0 commit comments