< prev index next >

test/sun/management/jmxremote/bootstrap/LocalManagementTest.sh

Print this page
rev 1541 : 8003890: corelibs test scripts should pass TESTVMOPTS
Reviewed-by: chegar, alanb
Contributed-by: Mark Sheppard <mark.sheppard@oracle.com>


  26 
  27 # @test
  28 # @bug 5016507 6173612 6319776 6342019 6484550
  29 # @summary Start a managed VM and test that a management tool can connect
  30 #          without connection or username/password details.
  31 #          TestManager will attempt a connection to the address obtained from 
  32 #          both agent properties and jvmstat buffer.
  33 #
  34 # @build TestManager TestApplication
  35 # @run shell/timeout=300 LocalManagementTest.sh
  36 
  37 
  38 doTest()
  39 {
  40     echo ''
  41 
  42     outputfile=${TESTCLASSES}/Test.out
  43     rm -f ${outputfile}
  44 
  45     # Start VM with given options
  46     echo "+ $JAVA $1 Test"
  47     $JAVA $1 TestApplication > ${outputfile}&
  48     pid=$!
  49  
  50     # Wait for managed VM to startup
  51     echo "Waiting for VM to startup..."
  52     attempts=0
  53     while true; do
  54         sleep 1
  55         port=`tail -1 ${outputfile}`
  56         if [ ! -z "$port" ]; then
  57             # In case of errors wait time for output to be flushed
  58             sleep 1
  59             cat ${outputfile}
  60             break
  61         fi
  62       attempts=`expr $attempts + 1`
  63       echo "Waiting $attempts second(s) ..."
  64     done
  65 
  66     # Start the manager - this should connect to VM
  67     sh -xc "$JAVA -classpath ${TESTCLASSES}:${TESTJAVA}/lib/tools.jar \
  68         TestManager $pid $port"  2>&1
  69     if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
  70 }
  71 
  72 
  73 # Check we are run from jtreg
  74 if [ -z "${TESTCLASSES}" ]; then
  75     echo "Test is designed to be run from jtreg only"
  76     exit 0
  77 fi
  78 
  79 # For now this test passes silently on Windows - there are 2 reasons
  80 # to skip it :-
  81 #
  82 # 1. No jstat instrumentation buffers if FAT32 so need
  83 #    -XX:+PerfBypassFileSystemCheck 
  84 # 2. $! is used to get the pid of the created process but it's not
  85 #    reliable on older versions of MKS. Also negative pids are returned
  86 #    on Windows 98.
  87 


  95 CLASSPATH=${TESTCLASSES}
  96 export CLASSPATH
  97 
  98 failures=0
  99 
 100 # Test 1 
 101 doTest "-Dcom.sun.management.jmxremote" 
 102 
 103 # Test 2
 104 AGENT="${TESTJAVA}/jre/lib/management-agent.jar"
 105 if [ ! -f ${AGENT} ]; then
 106   AGENT="${TESTJAVA}/lib/management-agent.jar"
 107 fi
 108 doTest "-javaagent:${AGENT}" 
 109 
 110 # Test 3 - no args (blank) - manager should attach and start agent
 111 doTest " " 
 112 
 113 # Test 4 - sanity check arguments to management-agent.jar
 114 echo ' '
 115 sh -xc "${JAVA} -javaagent:${AGENT}=com.sun.management.jmxremote.port=7775,\
 116 com.sun.management.jmxremote.authenticate=false,com.sun.management.jmxremote.ssl=false \
 117   TestApplication -exit" 2>&1
 118 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 119 
 120 # Test 5 - use DNS-only name service
 121 doTest "-Dsun.net.spi.namservice.provider.1=\"dns,sun\"" 
 122 
 123 #
 124 # Results
 125 #
 126 echo ''
 127 if [ $failures -gt 0 ];
 128   then echo "$failures test(s) failed";
 129   else echo "All test(s) passed"; fi
 130 exit $failures
 131 


  26 
  27 # @test
  28 # @bug 5016507 6173612 6319776 6342019 6484550
  29 # @summary Start a managed VM and test that a management tool can connect
  30 #          without connection or username/password details.
  31 #          TestManager will attempt a connection to the address obtained from 
  32 #          both agent properties and jvmstat buffer.
  33 #
  34 # @build TestManager TestApplication
  35 # @run shell/timeout=300 LocalManagementTest.sh
  36 
  37 
  38 doTest()
  39 {
  40     echo ''
  41 
  42     outputfile=${TESTCLASSES}/Test.out
  43     rm -f ${outputfile}
  44 
  45     # Start VM with given options
  46     echo "+ $JAVA ${TESTVMOPTS} $1 Test"
  47     $JAVA ${TESTVMOPTS} $1 TestApplication > ${outputfile}&
  48     pid=$!
  49  
  50     # Wait for managed VM to startup
  51     echo "Waiting for VM to startup..."
  52     attempts=0
  53     while true; do
  54         sleep 1
  55         port=`tail -1 ${outputfile}`
  56         if [ ! -z "$port" ]; then
  57             # In case of errors wait time for output to be flushed
  58             sleep 1
  59             cat ${outputfile}
  60             break
  61         fi
  62       attempts=`expr $attempts + 1`
  63       echo "Waiting $attempts second(s) ..."
  64     done
  65 
  66     # Start the manager - this should connect to VM
  67     sh -xc "$JAVA ${TESTVMOPTS} -classpath ${TESTCLASSES}:${TESTJAVA}/lib/tools.jar \
  68         TestManager $pid $port"  2>&1
  69     if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
  70 }
  71 
  72 
  73 # Check we are run from jtreg
  74 if [ -z "${TESTCLASSES}" ]; then
  75     echo "Test is designed to be run from jtreg only"
  76     exit 0
  77 fi
  78 
  79 # For now this test passes silently on Windows - there are 2 reasons
  80 # to skip it :-
  81 #
  82 # 1. No jstat instrumentation buffers if FAT32 so need
  83 #    -XX:+PerfBypassFileSystemCheck 
  84 # 2. $! is used to get the pid of the created process but it's not
  85 #    reliable on older versions of MKS. Also negative pids are returned
  86 #    on Windows 98.
  87 


  95 CLASSPATH=${TESTCLASSES}
  96 export CLASSPATH
  97 
  98 failures=0
  99 
 100 # Test 1 
 101 doTest "-Dcom.sun.management.jmxremote" 
 102 
 103 # Test 2
 104 AGENT="${TESTJAVA}/jre/lib/management-agent.jar"
 105 if [ ! -f ${AGENT} ]; then
 106   AGENT="${TESTJAVA}/lib/management-agent.jar"
 107 fi
 108 doTest "-javaagent:${AGENT}" 
 109 
 110 # Test 3 - no args (blank) - manager should attach and start agent
 111 doTest " " 
 112 
 113 # Test 4 - sanity check arguments to management-agent.jar
 114 echo ' '
 115 sh -xc "${JAVA} ${TESTVMOPTS} -javaagent:${AGENT}=com.sun.management.jmxremote.port=7775,\
 116 com.sun.management.jmxremote.authenticate=false,com.sun.management.jmxremote.ssl=false \
 117   TestApplication -exit" 2>&1
 118 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 119 
 120 # Test 5 - use DNS-only name service
 121 doTest "-Dsun.net.spi.namservice.provider.1=\"dns,sun\"" 
 122 
 123 #
 124 # Results
 125 #
 126 echo ''
 127 if [ $failures -gt 0 ];
 128   then echo "$failures test(s) failed";
 129   else echo "All test(s) passed"; fi
 130 exit $failures
 131 
< prev index next >