1 # 2 # Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 # 5 # This code is free software; you can redistribute it and/or modify it 6 # under the terms of the GNU General Public License version 2 only, as 7 # published by the Free Software Foundation. 8 # 9 # This code is distributed in the hope that it will be useful, but WITHOUT 10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 # version 2 for more details (a copy is included in the LICENSE file that 13 # accompanied this code). 14 # 15 # You should have received a copy of the GNU General Public License version 16 # 2 along with this work; if not, write to the Free Software Foundation, 17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 # 19 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 # or visit www.oracle.com if you need additional information or have any 21 # questions. 22 # 23 24 # @test 25 # @bug 4990825 26 # @run shell/timeout=90 jstatdServerName.sh 27 # @summary Test functionality of 'jstatd -p <port> -n <servername>&' 28 29 . ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh 30 31 setup 32 verify_os 33 34 cleanup() { 35 kill_proc ${JSTATD_1_PID} 36 kill_proc ${JSTATD_2_PID} 37 } 38 39 trap 'cleanup' 0 HUP INT QUIT TERM 40 41 JSTATD="${TESTJAVA}/bin/jstatd" 42 JPS="${TESTJAVA}/bin/jps" 43 JSTAT="${TESTJAVA}/bin/jstat" 44 45 HOSTNAME=`uname -n` 46 PORT_1=2098 47 PORT_2=2099 48 SERVERNAME="SecondJstatdServer" 49 50 JSTATD_1_OUT="jstatd_$$_1.out" 51 JSTATD_2_OUT="jstatd_$$_2.out" 52 53 ${JSTATD} -J-Djava.security.policy=${TESTSRC}/all.policy -p ${PORT_1} 2>&1 > ${JSTATD_1_OUT} & 54 JSTATD_1_PID=$! 55 56 echo "first jstatd started as pid ${JSTATD_1_PID} on port ${PORT_1} with default server name" 57 sleep 3 58 59 ${JSTATD} -J-Djava.security.policy=${TESTSRC}/all.policy -p ${PORT_2} -n ${SERVERNAME} 2>&1 > ${JSTATD_2_OUT} & 60 JSTATD_2_PID=$! 61 62 echo "second jstatd started as pid ${JSTATD_2_PID} on port ${PORT_2} with name ${SERVERNAME}" 63 sleep 3 64 65 echo "running: ${JPS} ${HOSTNAME}:${PORT_1}" 66 ${JPS} ${HOSTNAME}:${PORT_1} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk 67 68 if [ $? -ne 0 ] 69 then 70 echo "Output of jps differs from expected output. Failed." 71 exit 1 72 fi 73 74 echo "running: ${JPS} ${HOSTNAME}:${PORT_2}/${SERVERNAME}" 75 ${JPS} ${HOSTNAME}:${PORT_2}/${SERVERNAME} 2>&1 | awk -f ${TESTSRC}/jpsOutput1.awk 76 77 if [ $? -ne 0 ] 78 then 79 echo "Output of jps differs from expected output. Failed." 80 exit 1 81 fi 82 83 TARGET_PID=`${JPS} | grep "Jstatd" | cut -d" " -f1 | head -1` 84 85 echo "running: ${JSTAT} -gcutil ${TARGET_PID}@${HOSTNAME}:${PORT_1} 250 5" 86 ${JSTAT} -gcutil ${TARGET_PID}@${HOSTNAME}:${PORT_1} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk 87 RC=$? 88 89 if [ ${RC} -ne 0 ] 90 then 91 echo "jstat output differs from expected output" 92 fi 93 94 echo "running: ${JSTAT} -gcutil ${TARGET_PID}@${HOSTNAME}:${PORT_2}/${SERVERNAME} 250 5" 95 ${JSTAT} -gcutil ${TARGET_PID}@${HOSTNAME}:${PORT_2}/${SERVERNAME} 250 5 2>&1 | awk -f ${TESTSRC}/jstatGcutilOutput1.awk 96 RC=$? 97 98 if [ ${RC} -ne 0 ] 99 then 100 echo "jstat output differs from expected output" 101 fi 102 103 if [ -s ${JSTATD_1_OUT} ] 104 then 105 echo "first jstatd generated the following, unexpected output:" 106 RC=1 107 fi 108 109 if [ -s ${JSTATD_2_OUT} ] 110 then 111 echo "second jstatd generated the following, unexpected output:" 112 RC=1 113 fi 114 115 exit ${RC}