先介绍一下Ant+Jmeter

我的另一篇文章有讲在linux上部署ant + jmeter以满足CI持续化集成

https://www.cnblogs.com/qianjinyan/p/9067212.html

##########################################################################################################################################################

今天琢磨了一下,可以不用ant吗?

直接Jmeter执行jmx工程,然后发送测试结果到指定邮箱

从理论上讲感觉是可行的,

毕竟windows下进入jmeter的bin目录后,用下面N0-GUI屡试不爽啊

jmeter -n -t /home/jasqia/apache-jmeter4.0/jmxfile/ikea/*.jmx -l /home/jasqia/apache-jmeter4.0/jmxfile/ikea  -e -o /home/jasqia/apache-jmeter4.0/jmxfile/ikea02/

  • -h 帮助 -> 打印出有用的信息并退出
  • -n 非 GUI 模式 -> 在非 GUI 模式下运行 JMeter
  • -t 测试文件 -> 要运行的 JMeter 测试脚本文件
  • -l 日志文件 -> 记录结果的文件
  • -r 远程执行 -> 启动远程服务
  • -H 代理主机 -> 设置 JMeter 使用的代理主机
  • -P 代理端口 -> 设置 JMeter 使用的代理主机的端口号

例如:jmeter -n -t test1.jmx -l logfile1.jtl -H xx.xx.xx.xx -P 8080

为什么不能在Linux上试一下呢

Step1: 设置了Linux上的环境变量,jdk8以上,因为我用的Jmter4.0,必须高版本的JDK

  1. [root@ntgsrv11 etc]# java -version
  2. java version "1.8.0_131"
  3. Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
  4. Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Step2: 我遇到的各种问题,目前正在填坑中

  1. [root@ntgsrv11 bin]# sudo ./jmeter -n -t /home/jasqia/apache-jmeter4.0/jmxfile/ikea/*.jmx -l /home/jasqia/apache-jmeter4.0/jmxfile/ikea -e -o /home/jasqia/apache-jmeter4.0/jmxfile/ikea02/
  2. sudo: ./jmeter: command not found
  3. [root@ntgsrv11 bin]# sudo ./jmeter.sh -n -t /home/jasqia/apache-jmeter4.0/jmxfile/ikea/*.jmx -l /home/jasqia/apache-jmeter4.0/jmxfile/ikea -e -o /home/jasqia/apache-jmeter4.0/jmxfile/ikea02/
  4. Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
  5. At least one of these environment variable is needed to run this program

  

  1. # /etc/profile
  2.  
  3. # System wide environment and startup programs, for login setup
  4. # Functions and aliases go in /etc/bashrc
  5.  
  6. # It's NOT a good idea to change this file unless you know what you
  7. # are doing. It's much better to create a custom.sh shell script in
  8. # /etc/profile.d/ to make custom changes to your environment, as this
  9. # will prevent the need for merging in future updates.
  10.  
  11. pathmunge () {
  12. case ":${PATH}:" in
  13. *:"$1":*)
  14. ;;
  15. *)
  16. if [ "$2" = "after" ] ; then
  17. PATH=$PATH:$1
  18. else
  19. PATH=$1:$PATH
  20. fi
  21. esac
  22. }
  23.  
  24. if [ -x /usr/bin/id ]; then
  25. if [ -z "$EUID" ]; then
  26. # ksh workaround
  27. EUID=`id -u`
  28. UID=`id -ru`
  29. fi
  30. USER="`id -un`"
  31. LOGNAME=$USER
  32. MAIL="/var/spool/mail/$USER"
  33. fi
  34.  
  35. # Path manipulation
  36. if [ "$EUID" = "0" ]; then
  37. pathmunge /sbin
  38. pathmunge /usr/sbin
  39. pathmunge /usr/local/sbin
  40. else
  41. pathmunge /usr/local/sbin after
  42. pathmunge /usr/sbin after
  43. pathmunge /sbin after
  44. fi
  45.  
  46. HOSTNAME=`/bin/hostname 2>/dev/null`
  47. HISTSIZE=1000
  48. if [ "$HISTCONTROL" = "ignorespace" ] ; then
  49. export HISTCONTROL=ignoreboth
  50. else
  51. export HISTCONTROL=ignoredups
  52. fi
  53.  
  54. export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
  55.  
  56. # By default, we want umask to get set. This sets it for login shell
  57. # Current threshold for system reserved uid/gids is 200
  58. # You could check uidgid reservation validity in
  59. # /usr/share/doc/setup-*/uidgid file
  60. if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
  61. umask 002
  62. else
  63. umask 022
  64. fi
  65.  
  66. for i in /etc/profile.d/*.sh ; do
  67. if [ -r "$i" ]; then
  68. if [ "${-#*i}" != "$-" ]; then
  69. . "$i"
  70. else
  71. . "$i" >/dev/null 2>&1
  72. fi
  73. fi
  74. done
  75.  
  76. unset i
  77. unset pathmunge
  78. HISTTIMEFORMAT="%F %R "
  79. export HISTSIZE=10000
  80. export TMOUT=0
  81.  
  82. #set Ant enviroment
  83.  
  84. export ANT_HOME=/home/jasqia/apache-ant-1.10.3
  85. export PATH=$PATH:$ANT_HOME/bin
  86.  
  87. #set jmeter enviroment
  88. export JMETER_HOME=home/jasqia/apache-jmeter4.0
  89. export CLASSPATH=$JMETER_HOME/lib/ext/ApacheJMeter_core.jar:$JMETER_HOME/lib/jorphan.jar:$JMETER_HOME/lib/logkit-2.0.jar:$CLASSPATH
  90.  
  91. export JAVA_HOME=/opt/jdk1.8.0_131
  92. export PATH=$JAVA_HOME/bin:$PATH
  93. export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
  94.  
  95. alias vi='vim'

  

目前的Jmeter文件

  1. #! /bin/sh
  2.  
  3. ## Licensed to the Apache Software Foundation (ASF) under one or more
  4. ## contributor license agreements. See the NOTICE file distributed with
  5. ## this work for additional information regarding copyright ownership.
  6. ## The ASF licenses this file to You under the Apache License, Version 2.0
  7. ## (the "License"); you may not use this file except in compliance with
  8. ## the License. You may obtain a copy of the License at
  9. ##
  10. ## http://www.apache.org/licenses/LICENSE-2.0
  11. ##
  12. ## Unless required by applicable law or agreed to in writing, software
  13. ## distributed under the License is distributed on an "AS IS" BASIS,
  14. ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. ## See the License for the specific language governing permissions and
  16. ## limitations under the License.
  17.  
  18. ## ==============================================
  19. ## Environment variables:
  20. ## JVM_ARGS - optional java args, e.g. -Dprop=val
  21. ##
  22. ## e.g.
  23. ## JVM_ARGS="-Xms1g -Xmx1g" jmeter etc.
  24. ##
  25. ## Do not set the variables in this script. Instead put them into a script
  26. ## setenv.sh in JMETER_HOME/bin to keep your customizations separate.
  27. ##
  28. ## JAVA_HOME Must point at your Java Development Kit installation.
  29. ## Required to run the with the "debug" argument.
  30. ##
  31. ## JRE_HOME Must point at your Java Runtime installation.
  32. ## Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
  33. ## are both empty, JMeter will try to guess JAVA_HOME.
  34. ## If JRE_HOME and JAVA_HOME are both set, JAVA_HOME is used.
  35. ##
  36. ## GC_ALGO (Optional) Java runtime options to specify JVM garbage collection
  37. ## algorithm
  38. ## Defaults to "-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20"
  39. ##
  40. ## HEAP (Optional) Java runtime options for memory management
  41. ## used when JMeter is started.
  42. ## Defaults to "-Xms1g -Xmx1g -X:MaxMetaspaceSize=256m"
  43. ##
  44. ## JMETER_HOME (Optional) May point to your JMeter install dir. If empty
  45. ## it will be set relativ to this script.
  46. ##
  47. ## JMETER_LANGUAGE (Optional) Java runtime options to specify used language
  48. ## Defaults to "-Duser.language=en -Duser.region=EN"
  49. ##
  50. ## JMETER_OPTS (Optional) Java runtime options used when JMeter is started.
  51. ## Special options for operating systems might be added by JMeter.
  52. ##
  53. ## ==============================================
  54.  
  55. # resolve links - $0 may be a softlink (code as used by Tomcat)
  56. # N.B. readlink would be a lot simpler but is not supported on Solaris
  57. PRG="$0"
  58.  
  59. while [ -h "$PRG" ]; do
  60. ls=`ls -ld "$PRG"`
  61. link=`expr "$ls" : '.*-> \(.*\)$'`
  62. if expr "$link" : '/.*' > /dev/null; then
  63. PRG="$link"
  64. else
  65. PRG=`dirname "$PRG"`/"$link"
  66. fi
  67. done
  68.  
  69. PRGDIR=`dirname "$PRG"`
  70.  
  71. # Only set JMETER_HOME if not already set
  72. [ -z "$JMETER_HOME" ] && JMETER_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
  73.  
  74. if [ -r "${JMETER_HOME}/bin/setenv.sh" ]; then
  75. . "${JMETER_HOME}/bin/setenv.sh"
  76. fi
  77.  
  78. # Make sure prerequisite environment variables are set
  79. if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
  80. if [ "`uname`" = "Darwin" ]; then
  81. #
  82. if [ -x '/usr/libexec/java_home' ] ; then
  83. export JAVA_HOME=`/opt/jdk1.8.0_131`
  84. #
  85. elif [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" ]; then
  86. export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home"
  87. fi
  88. else
  89. JAVA_PATH=`which java 2>/dev/null`
  90. if [ "x$JAVA_PATH" != "x" ]; then
  91. JAVA_PATH=`dirname $JAVA_PATH 2>/dev/null`
  92. JRE_HOME=`dirname $JAVA_PATH 2>/dev/null`
  93. fi
  94. if [ "x$JRE_HOME" = "x" ]; then
  95. # XXX: Should we try other locations?
  96. if [ -x /usr/bin/java ]; then
  97. JRE_HOME=/usr
  98. fi
  99. fi
  100. fi
  101. if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
  102. echo "Neither the JAVA_HOME nor the JRE_HOME environment variable is defined"
  103. echo "At least one of these environment variable is needed to run this program"
  104. exit 1
  105. fi
  106. fi
  107. if [ -z "$JAVA_HOME" -a "$1" = "debug" ]; then
  108. echo "JAVA_HOME should point to a JDK in order to run in debug mode."
  109. exit 1
  110. fi
  111. if [ -z "$JRE_HOME" ]; then
  112. JRE_HOME="$JAVA_HOME"
  113. fi
  114. if [ -z "$JAVA_HOME" ]; then
  115. JAVA_HOME="$JRE_HOME"
  116. fi
  117.  
  118. #--add-modules java.activation if JAVA 9
  119. JAVA9_OPTS=
  120.  
  121. # Minimal version to run JMeter
  122. MINIMAL_VERSION=8
  123.  
  124. # Check if version is from OpenJDK or Oracle Hotspot JVM prior to 9 containing 1.${version}.x
  125. CURRENT_VERSION=`"${JAVA_HOME}/bin/java" -version 2>&1 | awk -F'"' '/version/ {gsub("^1[.]", "", $2); gsub("[^0-9].*$", "", $2); print $2}'`
  126.  
  127. # Check if Java is present and the minimal version requirement
  128. if [ "$CURRENT_VERSION" -gt "$MINIMAL_VERSION" ]; then
  129. JAVA9_OPTS="--add-modules java.activation --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED"
  130. fi
  131.  
  132. : "${JMETER_OPTS:=""}"
  133. case `uname` in
  134. Darwin*)
  135. # Add Mac-specific property - should be ignored elsewhere (Bug 47064)
  136. JMETER_OPTS="${JMETER_OPTS} -Xdock:name=JMeter -Xdock:icon=\"${PRGDIR}/../docs/images/jmeter_square.png\" -Dapple.laf.useScreenMenuBar=true -Dapple.eawt.quitStrategy=CLOSE_ALL_WINDOWS"
  137. ;;
  138. esac
  139.  
  140. #
  141. # Original page has disappeared, it is now only available at:
  142. # https://web.archive.org/web/20060614151434/http://www.atg.com/portal/myatg/developer?paf_dm=full&paf_gear_id=1100010&detailArticle=true&id=9606
  143. #
  144. # JMeter objects can generally be grouped into three life-length groups:
  145. #
  146. # - Per-sample objects (results, DOMs,...). An awful lot of those.
  147. # Life length of milliseconds to a few seconds.
  148. #
  149. # - Per-run objects (threads, listener data structures,...). Not that many
  150. # of those unless we use the table or tree listeners on heavy runs.
  151. # Life length of minutes to several hours, from creation to start of next run.
  152. #
  153. # - Per-work-session objects (test plans, GUIs,...).
  154. # Life length: for the life of the JVM.
  155.  
  156. # This is the base heap size -- you may increase or decrease it to fit your
  157. # system's memory availability:
  158. : "${HEAP:="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=512m"}"
  159.  
  160. # Set language
  161. # Default to en_EN
  162. : "${JMETER_LANGUAGE:="-Duser.language=en -Duser.region=EN"}"
  163.  
  164. # Uncomment this to generate GC verbose file with Java prior to 9
  165. # VERBOSE_GC="-verbose:gc -Xloggc:gc_jmeter_%p.log -XX:+PrintGCDetails -XX:+PrintGCCause -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintAdaptiveSizePolicy -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps"
  166.  
  167. # Uncomment this to generate GC verbose file with Java 9 and above
  168. # VERBOSE_GC="-Xlog:gc*,gc+age=trace,gc+heap=debug:file=gc_jmeter_%p.log"
  169.  
  170. # Uncomment this if you run JMeter in DOCKER (need Java SE 8u131 or JDK 9)
  171. # see https://blogs.oracle.com/java-platform-group/java-se-support-for-docker-cpu-and-memory-limits
  172. # RUN_IN_DOCKER="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
  173.  
  174. # Finally, some tracing to help in case things go astray:
  175. # You may want to add those settings:
  176. # -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem
  177. : "${GC_ALGO:="-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20"}"
  178.  
  179. # Always dump on OOM (does not cost anything unless triggered)
  180. DUMP="-XX:+HeapDumpOnOutOfMemoryError"
  181. SYSTEM_PROPS="-Djava.security.egd=file:/dev/urandom"
  182. SERVER="-server"
  183.  
  184. if [ -z "${JMETER_COMPLETE_ARGS}" ]; then
  185. ARGS="$JAVA9_OPTS $SERVER $DUMP $HEAP $VERBOSE_GC $GC_ALGO $SYSTEM_PROPS $JMETER_LANGUAGE $RUN_IN_DOCKER"
  186. else
  187. ARGS=""
  188. fi
  189.  
  190. "$JAVA_HOME/bin/java" $ARGS $JVM_ARGS $JMETER_OPTS -jar "$PRGDIR/ApacheJMeter.jar" "$@"

  

[xslt] /home/jasqia/apache-jmeter4.0/jmxfile/ikea/Test.jtl:1:1: Fatal Error! Premature end of file.

如果我活过来,我会补上我的埋坑神药

2018年5月22日 10:43:51  还没有活过来

这个时间点还没有搞清楚,最近活儿多,一个测试好多开发,

目前项目又增加里两个开发,只有我一个测试,心累。

Jenkins 对项目持续集成的配置之二 API接口自动化 Ant+Jmeter的更多相关文章

  1. Jenkins .NET项目持续集成配置

    基本步骤 1. 安装并配置MSBUILD 在系统管理->插件管理->添加MSBuild插件 在系统管理->系统设置->找到MSBuild配置部分,配置不同的MSbuild版本 ...

  2. Jenkins+VS项目持续集成

    软件安装 安装包下载连接:https://jenkins.io/download/ 安装步奏:略 账户名:admin 密码:C:\Program Files (x86)\Jenkins\secrets ...

  3. [Jenkins][centos]1 持续集成 之 配置VNC,部署Jenkins

    痛点:上一篇的AWS部署的VNC不知为啥挂了,死活连不上,因此改申请京东云做部署Jenkins 预计阅读时间:20分钟 更新软件,安装桌面 yum -y update yum -y groupinst ...

  4. Jenkins的CI持续集成

    Jenkins的CI持续集成 全局配置 系统管理->全局工具配置,配置Git,JDK和Maven 1)解压maven到当前目录 tar zxf apache-maven-3.5.4-bin.ta ...

  5. Jenkins构建Android项目持续集成之findbugs的使用

    Findbugs简介 关于findbugs的介绍,可以自行百度下,这里贴下百度百科的介绍.findbugs是一个静态分析工具,它检查类或者 JAR 文件,将字节码与一组缺陷模式进行对比以发现可能的问题 ...

  6. Jenkins Jenkins结合GIT Maven持续集成环境配置

    Jenkins结合GIT Maven持续集成环境配置   by:授客 QQ:1033553122 安装Git插件 1 安装Git客户端 1 安装JAVA JDK及MAVEN 2 Jenkins JDK ...

  7. Jenkins +Maven+Tomcat+SVN +Apache项目持续集成构建

    详解Jenkins +Maven+Tomcat+SVN +Apache项目持续集成 一:前言 1. Jenkins jenkins版本大全http://mirrors.jenkins-ci.org/ ...

  8. 使用Jenkins与Docker持续集成与发布NetCore项目(实操篇)

    使用Jenkins与Docker持续集成与发布NetCore项目(教程一) 原文地址:https://www.cnblogs.com/Jackyye/p/12588182.html 基本环境 该教程的 ...

  9. Framework项目持续集成(jenkins)及集合SonarQube

    目录 Framework项目持续集成及集合SonarQube - 前言 CI/CD是什么 -- jenkins 什么是sonarqube?什么是CodeReview? 什么是sonarqube? 什么 ...

随机推荐

  1. nodejs+express的(前端跨域请求)

    1.后端代码 var dp = 456; var back = 'callback(\{\dp\ : \ ' + dp + '\ }\)'; res.send(back); 2.前端代码 <sc ...

  2. 4.keras实现-->生成式深度学习之DeepDream

    DeepDream是一种艺术性的图像修改技术,它用到了卷积神经网络学到的表示,DeepDream由Google于2015年发布.这个算法与卷积神经网络过滤器可视化技术几乎相同,都是反向运行一个卷积神经 ...

  3. 【设置】Nginx配置文件具体配置解释

    #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_processes 8; #全局错误日志定义类型,[ debug | ...

  4. CMPXCHG指令

    一.CMPXCHG汇编指令详解. 这条指令将al\ax\eax\rax中的值与首操作数比较: 1.如果相等,第2操作数的直装载到首操作数,zf置1.(相当于相减为0,所以0标志位置位) 2.如果不等, ...

  5. mysql回滚日志

    一.回滚日志(undo log) 1.作用 保存了事务发生之前的数据的一个版本,可以用于回滚,同时可以提供多版本并发控制下的读(MVCC),也即非锁定读 2.内容 逻辑格式的日志,在执行undo的时候 ...

  6. Object-C-block

    块是对c语言的一种扩展语法 块看起来像函数,不同的是,快可以直接写在函数内部 块能够作为参数传递给函数或者方法 void sayHello(){NSLog(@"hello!");} ...

  7. python 展开嵌套的序列

    将一个多层嵌套的序列展开成一个单层列表 可以写一个包含yield from 语句的递归生成器来轻松解决这个问题. from collections import Iterable def flatte ...

  8. Python: 正则表达式匹配反斜杠 "\"

    Python正则表达式匹配反斜杠 "\" eg: >>>a='w\w\w' 'w\\w\\w' #  打印出来的 "\\" 被转义成 一个反斜 ...

  9. linux测试带宽命令,Linux服务器网络带宽测试iperf

    linux测试带宽命令,Linux服务器网络带宽测试iperf必须先运行iperf serveriperf -s -i 2客户端iperf -c 服务端IP地址 iperf原理解析 iperf工具可以 ...

  10. WireShark学习

    1.打开wireshark->Capture->Interface->选择你的网卡(选中)->Start 2.OK抓包开始,工具栏上有stop,点击停止抓包 3.过滤,这个你可 ...