Java 基础稳定性测试方法

(2017.02.09)

关于 Java 基础稳定性

龙芯机器上确保 Java 应用稳定运行的最基础的测试。根据应用场景,可分为两个等级:
  • 客户端级:至少通过 3 x 24 小时 Java 基础稳定性测试;
  • 服务器级:至少通过 7 x 24 小时 Java 基础稳定性测试。
龙芯所有运行 Java 应用的产品都必须经过上述基础稳定性的测试。硬件环境[list=1]
  • CPU :任意一款龙芯 3 号系列芯片;
  • 内 存: 4G 以上;
  • 硬 盘: 60G 以上。
  • 软件环境[list=1]
  • SPECjvm2008 测试集: 下载地址 http://www.loongnix.org/index.php/SpecJVM
  • 龙芯 JDK : 下载地址 http://www.loongnix.org/index.php/Java (建议下载最新版本)
  • 测试方法1. 安装龙芯 JDK2. 安装 SPECjvm2008 测试集3. 进入 SPECjvm2008 的安装目录,执行测试脚本 gc.sh (后附样例脚本)附:各系统推荐的测试脚本 gc.sh 。测试前,需要正确设置脚本中标红的变量 JDK 。1. 龙芯 3 号双路服务器测试脚本
    #!/bin/bash# Set your JAVA_HOME path# e.g. /opt/j2sdk-image# JDK="/opt/j2sdk-image"JDK="YOUR JAVA_HOME path"Threads="16"Heap="512M"Ben="compiler.compiler"Time=`date +"%Y%m%d%H%M%S"`Log="gc-${Time}.log"Num="0"JVM_ARGS="-Xmx${Heap} -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:ParallelGCThreads=8 "cat /proc/cpuinfo 1>>${Log}free -m 1>>${Log}cat /etc/issue 1>>${Log}uname -a 1>>${Log}echo -e "\nJVM_ARGS: ${JVM_ARGS}\n" 1>>${Log}echo -e "JAVA_VERSION: " 1>>${Log}{ ${JDK}/bin/java -version; } 1>>${Log} 2>>${Log}echo -e "\n\n\nTest Start ...\n\n\n " 1>>${Log}while(true);do  let Num++  echo "Num: ${Num}" | tee -a ${Log}  ${JDK}/bin/java \    ${JVM_ARGS} \    -jar SPECjvm2008.jar -ikv -coe -ict -bt ${Threads} ${Ben} | tee -a ${Log}done
    2. 龙芯 3 号四路服务器测试脚本
    #!/bin/bash# Set your JAVA_HOME path# e.g. /opt/j2sdk-image# JDK="/opt/j2sdk-image"JDK="YOUR JAVA_HOME path"Threads="32"Heap="1024M"Ben="compiler.compiler"Time=`date +"%Y%m%d%H%M%S"`Log="gc-${Time}.log"Num="0"JVM_ARGS="-Xmx${Heap} -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:ParallelGCThreads=16 "cat /proc/cpuinfo 1>>${Log}free -m 1>>${Log}cat /etc/issue 1>>${Log}uname -a 1>>${Log}echo -e "\nJVM_ARGS: ${JVM_ARGS}\n" 1>>${Log}echo -e "JAVA_VERSION: " 1>>${Log}{ ${JDK}/bin/java -version; } 1>>${Log} 2>>${Log}echo -e "\n\n\nTest Start ...\n\n\n " 1>>${Log}while(true);do  let Num++  echo "Num: ${Num}" | tee -a ${Log}  ${JDK}/bin/java \    ${JVM_ARGS} \    -jar SPECjvm2008.jar -ikv -coe -ict -bt ${Threads} ${Ben} | tee -a ${Log}done
    3. 龙芯 3 号单路测试脚本
    #!/bin/bash# Set your JAVA_HOME path# e.g. /opt/j2sdk-image# JDK="/opt/j2sdk-image"JDK="YOUR JAVA_HOME pPath"Threads="8"Heap="512M"Ben="compiler.compiler"Time=`date +"%Y%m%d%H%M%S"`Log="gc-${Time}.log"Num="0"JVM_ARGS="-Xmx${Heap} -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:ParallelGCThreads=4"cat /proc/cpuinfo 1>>${Log}free -m 1>>${Log}cat /etc/issue 1>>${Log}uname -a 1>>${Log}echo -e "\nJVM_ARGS: ${JVM_ARGS}\n" 1>>${Log}echo -e "JAVA_VERSION: " 1>>${Log}{ ${JDK}/bin/java -version; } 1>>${Log} 2>>${Log}echo -e "\n\n\nTest Start ...\n\n\n " 1>>${Log}while(true);do  let Num++  echo "Num: ${Num}" | tee -a ${Log}  ${JDK}/bin/java \    ${JVM_ARGS} \    -jar SPECjvm2008.jar -ikv -coe -ict -bt ${Threads} ${Ben} | tee -a ${Log}done
    正确性检验要求在规定的测试时间内同时满足以下条件:[list=1]
  • 不宕机
  • 不阻塞
  • 无崩溃
  • 无“ NOT VALID”


  • 设本测试生成的 Log 文件为 gc-20170209134605.log ,则第 3 , 4 条可以借助以下两条命令进行检验:
    # 检查是否发生崩溃
    # 正确时输出为 0,否则非零
    $ grep “hs_err_*.log” gc-20170209134605.log | wc -l

    # 检查是否存在“NOT VALID”
    # 正确时输出为 0,否则非零
    $ grep “NOT VALID” gc-20170209134605.log | wc -l

    1 个评论

    检查是否发生崩溃的grep命令应改为:
      grep “hs_err_” gc-20170209134605.log | wc -l

    要回复文章请先登录注册