Jmeter (18)_Ubuntu deploy jmeter and ant

**The third step of Docker deployment interface automation continuous integration environment, containerized Jmeter and ant! **

**Continue from above: **Docker_containerized jenkins

In order to integrate continuous integration tools for interface automation, I deployed both jmeter and ant in the Jenkins container and configured build.xml

One: ubuntu deploy jdk

1: First download jdk-8u74-linux-x64.tar.gz and upload it to the server. The upload file here uses **lrzsz under ubuntu. **

**Execute directly under ubuntu sudo apt-get install lrzsz **

lrzsz is split into two commands, sz and rz

**The sz command sends the file to the local: **

**   # sz filename**

rz command to upload files locally to the server

**   # rz**

I create a new java folder under the /user/local directory, execute the rz command under the java folder, and directly transfer the jdk package from the local to the server

2: Decompress the tar package.

Execute tar -xvf jdk-8u74-linux-x64.tar.gz to decompress the jdk package and generate the jdk1.8.0_74 directory

3: Configure environment variables

vi /etc/profile

Add two lines at the end

export JAVA_HOME=/usr/local/java/jdk1.8.0_74

export PATH=JAVA_HOME/bin:PATH

Execute command: source /etc/profile, the configured environment variables take effect

4: Check whether the installation is successful, execute the command: java-version

Two: install jmeter

  1. Pack the local Jmeter file into a zip file: apache-jmeter-3.2.zip, and upload it to the server using the rz command

  2. Unzip on the server to generate jmeter-3.0 directory

  3. Install unzip: apt-get install unzip

  4. Unzip: unzip apache-jmeter-3.0_json.zip

  5. Put the jmeter-3.0 directory under /usr/local

  6. Configure Jmeter environment variables. vi /etc/profile, then add the following variables

export JMETER= /usr/local/apache-jmeter-3.2

export PATH=JMETER/bin:PATH

  1. Execute the command: source /etc/profile, the configured environment variables take effect

  2. Check the installation result: jmeter -v

Three: script trial run

Execute the command: # jmeter -n -t /tmp/apache-jmeter-3.2/bin/lsmsp.jmx -l log.jtl, view the result

Parameter Description:

-n: Run the script in non-GUI mode

-t: followed by the script name

-l: followed by the log name, save the running results

View the result log through cat log.jtl

Four: ubuntu deployment Ant

1: Install apache-ant-1.9.9 to the /user/local directory on ubuntu, the method is the same as the jmeter deployment above

2: Configure Ant environment variables

vi /etc/profile

Add two sentences at the end

export Ant=/usr/local/apache-ant-1.9.9
    export PATH=Ant/bin:PATH

source /etc/profile makes the configured environment variables take effect

Enter ant -v to view the ant version

3: Copy the ant-jmeter-1.1.3.jar file in the jmeter/extras folder to the ant/lib path

Five: Configure the build.xml file

The purpose of the build.xml file configuration is to let ant fetch the code to execute the build. There are two ways to build

1 :The script is directly uploaded to the jmeter directory and built directly through the ant plug-in of jenkins. The content of the file is as follows

< project name="ant-jmeter-test" default="run" basedir=".">
< tstamp>
< format property="time" pattern="yyyyMMddhhmm" />
< /tstamp>
< property environment="env"/>
< property name="ReportName" value="TestReport" />
<!- - Local Jmeter directory -->
< property name="jmeter.home" value="/usr/local/apache-jmeter-3.2" />
<!- - The path where jmeter generates the report -->
< property name="jmeter.result.jtl.dir" value="/usr/local/apache-jmeter-3.2/bin/demo.jmx" />
<!- - Generate reports in jtl and html format, named after the build ID -->
< property name="jmeter.result.jtlName" value="{env.WORKSPACE}/results/{env.BUILD_ID}/{env.BUILD_ID}.jtl" /> < property name="jmeter.result.htmlName" value="{env.WORKSPACE}/results/{env.BUILD_ID}/{env.BUILD_ID}.html" />
< target name="run">
< echo message="start..."/>
< antcall target="clean" />
< antcall target="test" />
< antcall target="report" />
< /target>
< target name="clean">
< mkdir dir="{env.WORKSPACE}/results/{env.BUILD_ID}" />
< /target>
< target name="test">
< taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" />
< jmeter jmeterhome="{jmeter.home}" resultlog="{jmeter.result.jtlName}">
<!- - Declare the script to be run and the jmeter script in this directory -->
< testplans dir="/usr/local/apache-jmeter-3.2/bin/demo" includes="demo.jmx" />
< property name="jmeter.save.saveservice.output_format" value="xml"/>
< /jmeter>
< /target>
< target name="report">
< xslt in="{jmeter.result.jtlName}" out="{jmeter.result.htmlName}"
style="${jmeter.home}/extras/jmeter-results-detail-report_21.xsl" />
< /target>
< /project>

2 : Configure the path where gitlab takes the code in the xml file. Jenkins takes the script out of gitlab through the git plugin, saves it to a local path, and then executes the build

< project name="ant-jmeter-test" default="run" basedir=".">
< tstamp>
< format property="time" pattern="yyyyMMddhhmm" />
< /tstamp>

< property environment="env"/>
< property name="ReportName" value="TestReport" />
<!- - Need to change to your own local Jmeter directory -->
< property name="jmeter.home" value="/usr/local/apache-jmeter-3.2" />
<!- - The path where jmeter generates the result report in jtl and html format -->
< property name="jmeter.result.dir" value="/usr/local/apache-jmeter-3.2/resultLog/{env.BUILD_ID}" /> {jmeter.result.dir}/{ReportName}.jtl" /> < property name="jmeter.result.htmlName" value="{jmeter.result.dir}/{ReportName}.html" /> {env.WORKSPACE}" />**

< target name="run">
< echo message="start..."/>
< antcall target="clean" />
< antcall target="test" />
< antcall target="report" />
< /target>

< target name="clean">
< mkdir dir="{env.WORKSPACE}/results/{env.BUILD_ID}" />
< /target>

< target name="test">
< taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" />
< jmeter jmeterhome="{jmeter.home}" resultlog="{jmeter.result.jtlName}">
<!- - The script "*.jmx" declared to be run means to include all jmeter scripts in this directory. The files in includes can also be separated by commas -->
< testplans dir="${githome}" includes="demo.jmx" />

< property name="jmeter.save.saveservice.output_format" value="xml"/>
< /jmeter>
< /target>

< path id="xslt.classpath">
< fileset dir="{jmeter.home}/lib" includes="xalan*.jar"/> < fileset dir="{jmeter.home}/lib" includes="serializer*.jar"/>
< /path>

< target name="report">
< tstamp>
< xslt
classpathref="xslt.classpath"

force="true"
in="${jmeter.result.jtlName}"
out="${jmeter.result.htmlName}"
style="${jmeter.home}/extras/jmeter.results.shanhe.me.xsl">
< param name="dateReport" expression="${report.datestamp}"/>
< /xslt>

<!- - Because when the report is generated above, the relevant pictures will not be copied to the target directory together, so you need to copy manually -->
< copy todir="{jmeter.result.dir}"> < fileset dir="{jmeter.home}/extras">
< include name="collapse.png" />
< include name="expand.png" />
< /fileset>
< /copy>
< /target>
< /project>

Build result

**Join the QQ group: 317765580, let's discuss it together! **

Recommended Posts

Jmeter (18)_Ubuntu deploy jmeter and ant
Install and deploy Gerrit under Ubuntu
Deploy python3 and nginx projects on ubuntu18.04
Summary: Ubuntu Python2.x and
Ubuntu20.04 experience and beautification
Ubuntu introduction and installation
[python] python2 and python3 under ubuntu
Ubuntu backup and restore
Deploy FTP server under ubuntu
ubuntu16.04 build vim and pyt
Ubuntu 16.04 compile and install PHP 7.2
Ubuntu16.04 installation and simple configuration
ubuntu install and configure GitLab
Ubuntu deployment and experience Nexus3
Use virtualbox to deploy ubuntu
Ubuntu16.04 install SVN and configuration
Ubuntu16.04 install and uninstall VMware-Workstation 14
Ubuntu PostgreSQL installation and configuration
Ubuntu 18.04.1 build Java environment and HelloWorld
Ubuntu creates users adduser and useradd
Deploy JobConverter + Ibreoffice environment on Ubuntu
The difference between CentOS and Ubuntu
Ubuntu environment variables and ADB configuration
Netweaver and Windows, Ubuntu data sharing
Install and configure MySQL on Ubuntu
Deploy the mail system under Ubuntu 19.10
Install and configure Docker in Ubuntu
ubuntu modify and configure ip address
Ubuntu16.04 configuration OpenCV3.4.2 and basic use
Deploy and optimize Tomcat under Centos
Redis installation under ubuntu and windows
Install nodejs and npm under Ubuntu 16.04
How to deploy Django on Ubuntu 14.04
Ubuntu change password and username steps
Protect your eyes (ubuntu and chrome)
Ubuntu 19.1 installation and configuration Chinese environment
Configuration and beautification after Ubuntu installation (1)
Nginx installation and configuration load (ubuntu12.04)
Ubuntu upgrade software and ubuntu upgrade system commands
Ubuntu common instructions and usage details
Ubuntu18.04 installation Anaconda3 and VSCode guide
Coexistence of CUDA8.0 and CUDA9.0 under Ubuntu 16.04
Ubuntu configuration source and installation software
Compile and install QEMU under Ubuntu
Windows Ubuntu subsystem ssh and ftp
Linux basics (Ubuntu copy and paste)