先介绍一下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

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

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

[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/
sudo: ./jmeter: command not found
[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/
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

  

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates. pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
} if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`id -u`
UID=`id -ru`
fi
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi # Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
pathmunge /sbin after
fi HOSTNAME=`/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL # By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 002
else
umask 022
fi for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done unset i
unset pathmunge
HISTTIMEFORMAT="%F %R "
export HISTSIZE=10000
export TMOUT=0 #set Ant enviroment export ANT_HOME=/home/jasqia/apache-ant-1.10.3
export PATH=$PATH:$ANT_HOME/bin #set jmeter enviroment
export JMETER_HOME=home/jasqia/apache-jmeter4.0
export CLASSPATH=$JMETER_HOME/lib/ext/ApacheJMeter_core.jar:$JMETER_HOME/lib/jorphan.jar:$JMETER_HOME/lib/logkit-2.0.jar:$CLASSPATH export JAVA_HOME=/opt/jdk1.8.0_131
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar alias vi='vim'

  

目前的Jmeter文件

#! /bin/sh

##   Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License. ## ==============================================
## Environment variables:
## JVM_ARGS - optional java args, e.g. -Dprop=val
##
## e.g.
## JVM_ARGS="-Xms1g -Xmx1g" jmeter etc.
##
## Do not set the variables in this script. Instead put them into a script
## setenv.sh in JMETER_HOME/bin to keep your customizations separate.
##
## JAVA_HOME Must point at your Java Development Kit installation.
## Required to run the with the "debug" argument.
##
## JRE_HOME Must point at your Java Runtime installation.
## Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME
## are both empty, JMeter will try to guess JAVA_HOME.
## If JRE_HOME and JAVA_HOME are both set, JAVA_HOME is used.
##
## GC_ALGO (Optional) Java runtime options to specify JVM garbage collection
## algorithm
## Defaults to "-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20"
##
## HEAP (Optional) Java runtime options for memory management
## used when JMeter is started.
## Defaults to "-Xms1g -Xmx1g -X:MaxMetaspaceSize=256m"
##
## JMETER_HOME (Optional) May point to your JMeter install dir. If empty
## it will be set relativ to this script.
##
## JMETER_LANGUAGE (Optional) Java runtime options to specify used language
## Defaults to "-Duser.language=en -Duser.region=EN"
##
## JMETER_OPTS (Optional) Java runtime options used when JMeter is started.
## Special options for operating systems might be added by JMeter.
##
## ============================================== # resolve links - $0 may be a softlink (code as used by Tomcat)
# N.B. readlink would be a lot simpler but is not supported on Solaris
PRG="$0" while [ -h "$PRG" ]; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`/"$link"
fi
done PRGDIR=`dirname "$PRG"` # Only set JMETER_HOME if not already set
[ -z "$JMETER_HOME" ] && JMETER_HOME=`cd "$PRGDIR/.." >/dev/null; pwd` if [ -r "${JMETER_HOME}/bin/setenv.sh" ]; then
. "${JMETER_HOME}/bin/setenv.sh"
fi # Make sure prerequisite environment variables are set
if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
if [ "`uname`" = "Darwin" ]; then
#
if [ -x '/usr/libexec/java_home' ] ; then
export JAVA_HOME=`/opt/jdk1.8.0_131`
#
elif [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" ]; then
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home"
fi
else
JAVA_PATH=`which java 2>/dev/null`
if [ "x$JAVA_PATH" != "x" ]; then
JAVA_PATH=`dirname $JAVA_PATH 2>/dev/null`
JRE_HOME=`dirname $JAVA_PATH 2>/dev/null`
fi
if [ "x$JRE_HOME" = "x" ]; then
# XXX: Should we try other locations?
if [ -x /usr/bin/java ]; then
JRE_HOME=/usr
fi
fi
fi
if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then
echo "Neither the JAVA_HOME nor the JRE_HOME environment variable is defined"
echo "At least one of these environment variable is needed to run this program"
exit 1
fi
fi
if [ -z "$JAVA_HOME" -a "$1" = "debug" ]; then
echo "JAVA_HOME should point to a JDK in order to run in debug mode."
exit 1
fi
if [ -z "$JRE_HOME" ]; then
JRE_HOME="$JAVA_HOME"
fi
if [ -z "$JAVA_HOME" ]; then
JAVA_HOME="$JRE_HOME"
fi #--add-modules java.activation if JAVA 9
JAVA9_OPTS= # Minimal version to run JMeter
MINIMAL_VERSION=8 # Check if version is from OpenJDK or Oracle Hotspot JVM prior to 9 containing 1.${version}.x
CURRENT_VERSION=`"${JAVA_HOME}/bin/java" -version 2>&1 | awk -F'"' '/version/ {gsub("^1[.]", "", $2); gsub("[^0-9].*$", "", $2); print $2}'` # Check if Java is present and the minimal version requirement
if [ "$CURRENT_VERSION" -gt "$MINIMAL_VERSION" ]; then
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"
fi : "${JMETER_OPTS:=""}"
case `uname` in
Darwin*)
# Add Mac-specific property - should be ignored elsewhere (Bug 47064)
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"
;;
esac #
# Original page has disappeared, it is now only available at:
# https://web.archive.org/web/20060614151434/http://www.atg.com/portal/myatg/developer?paf_dm=full&paf_gear_id=1100010&detailArticle=true&id=9606
#
# JMeter objects can generally be grouped into three life-length groups:
#
# - Per-sample objects (results, DOMs,...). An awful lot of those.
# Life length of milliseconds to a few seconds.
#
# - Per-run objects (threads, listener data structures,...). Not that many
# of those unless we use the table or tree listeners on heavy runs.
# Life length of minutes to several hours, from creation to start of next run.
#
# - Per-work-session objects (test plans, GUIs,...).
# Life length: for the life of the JVM. # This is the base heap size -- you may increase or decrease it to fit your
# system's memory availability:
: "${HEAP:="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=512m"}" # Set language
# Default to en_EN
: "${JMETER_LANGUAGE:="-Duser.language=en -Duser.region=EN"}" # Uncomment this to generate GC verbose file with Java prior to 9
# 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" # Uncomment this to generate GC verbose file with Java 9 and above
# VERBOSE_GC="-Xlog:gc*,gc+age=trace,gc+heap=debug:file=gc_jmeter_%p.log" # Uncomment this if you run JMeter in DOCKER (need Java SE 8u131 or JDK 9)
# see https://blogs.oracle.com/java-platform-group/java-se-support-for-docker-cpu-and-memory-limits
# RUN_IN_DOCKER="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap" # Finally, some tracing to help in case things go astray:
# You may want to add those settings:
# -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem
: "${GC_ALGO:="-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20"}" # Always dump on OOM (does not cost anything unless triggered)
DUMP="-XX:+HeapDumpOnOutOfMemoryError"
SYSTEM_PROPS="-Djava.security.egd=file:/dev/urandom"
SERVER="-server" if [ -z "${JMETER_COMPLETE_ARGS}" ]; then
ARGS="$JAVA9_OPTS $SERVER $DUMP $HEAP $VERBOSE_GC $GC_ALGO $SYSTEM_PROPS $JMETER_LANGUAGE $RUN_IN_DOCKER"
else
ARGS=""
fi "$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. [LeetCode] 787. Cheapest Flights Within K Stops_Medium tag: Dynamic Programming, BFS, Heap

    There are n cities connected by m flights. Each fight starts from city u and arrives at v with a pri ...

  2. [LeetCode] 680. Valid Palindrome II_Easy tag: Two Pointers

    Given a non-empty string s, you may delete at most one character. Judge whether you can make it a pa ...

  3. 机器学习理论基础学习12---MCMC

    作为一种随机采样方法,马尔科夫链蒙特卡罗(Markov Chain Monte Carlo,以下简称MCMC)在机器学习,深度学习以及自然语言处理等领域都有广泛的应用,是很多复杂算法求解的基础.比如分 ...

  4. C:\WINDOWS\system32\drivers\etc\hosts 文件的作用

    先来看一看C:\WINDOWS\system32\drivers\etc\hosts 系统原来的hosts文件(未经过改动) 打开原来的hosts文件,查看原来的内容 host是一个没有扩展名的系统文 ...

  5. css 文本超出容器长度后自动省略的方法!

    我们在给用户显示文本内容的时候,往往需要避免文本内容超出容器宽度,防止换行溢出,小弟在网上找了下发现网上的实现仅仅只是实现了用 ...省略了的功能! 而并没有获取光标提示的功能,所有小弟就结合网上的代 ...

  6. CMPXCHG指令

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

  7. only_full_group_by问题而引发的对group by的深入思考

    问题背景 最近在项目中使用mysql的group by进行分组查询的场景比较多,其中一次遇到了一个问题,即在开发环境执行一个如下sql时是正确且可执行的, select a,b,max(c) from ...

  8. zw版【转发·台湾nvp系列Delphi例程】HALCON SmallestRectangle1

    zw版[转发·台湾nvp系列Delphi例程]HALCON SmallestRectangle1 procedure TForm1.Button1Click(Sender: TObject);var ...

  9. python中repr和eval可以用来在数据结构和字符串间互转

    在这个功能上,repr和str的作用一样,把一个数据结构转换成字符串,例如: >>> str([1,2,3,4])'[1, 2, 3, 4]' >>> repr([ ...

  10. tomcat 9.0.4 性能调优

    参考了网上的一些优化参数,但是在启动中发现 有2个报错: 11-Feb-2018 15:57:23.293 警告 [main] org.apache.catalina.startup.SetAllPr ...