jenkins:应用篇(Gatling plugin的使用)

时间:2023-03-09 13:08:59
jenkins:应用篇(Gatling plugin的使用)

Jenkins的功能强大,在于它的插件式框架,能扩展功能,自动化当中,很容易想到的是对提交的新代码做测试,这里gatling主要是负责压力测试,也就是所谓的性能。关于gatling,可以参考我前面的博文。

在jenkins下,首先要安装gatling的插件,可以直接在Jenkins>Manage Jenkins>Manage Plugins>Available下点击安装,也可以在Advance里面通过上传安装。由于我这里两个浏览器设置的代理不同,在测试jenkins的浏览器中不能直接点击Available里面的gatling安装,网络无法联通。所以,我在另外一个带有*代理的浏览器中,先下载了gatling.hpi(我这里是1.1.1版本)插件文件到本地。再通过advance的tab下上传文件的方式进行安装。

jenkins:应用篇(Gatling plugin的使用)

按照上图,只需要关注红色框部分即可,其他就默认吧,点击submit,然后将jenkins重启,gatling plugin就安装好了。

现在可以看看jenkins下的gatling是如何集成在maven项目里,做一个自动化性能测试的。还是基于前面博文的项目mueas,由于之前,mueas项目下,没有gatling的支持。所以,要在mueas工程的pom文件添加依赖和plugin的配置。

下面先看看依赖的配置:

     <!-- Add Gatling maven plugin to support gatling startup to test performance -->
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>2.1.</version>
</dependency>

再就是在pom文件的build部分添加plugin的配置:

 <build>
<plugins>
。。。。。  #此处是其他相关的plugin的内容,省略了
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>2.1.</version>
<configuration>  #此configuration部分的配置,要结合自己的项目的结构来填写信息
<configFolder>src/test/resources</configFolder>
<dataFolder>src/test/resources/data</dataFolder>
<resultsFolder>target/gatling/results</resultsFolder>
<bodiesFolder>src/test/resources/bodies</bodiesFolder>
<simulationsFolder>src/test/scala</simulationsFolder>
</configuration>
<executions>
<execution>
<id>execution-</id>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<simulationClass>simple/MueasSimulation_Simple</simulationClass>
</configuration>
</execution>
<!-- Here, can repeat the above execution segment to do another test -->
</executions>
</plugin>
</plugins>
</build>

附带着将eclipse中maven工程的文件结构也展示一下:

jenkins:应用篇(Gatling plugin的使用)

由于gatling的压力测试脚本是基于scala语言写的,所以,目录中simulationFolder部分src/test/scala下面,是一个scala的程序。

那这里,看看这个scala脚本程序是什么样子吧,很简单:

 package simple

 import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._ class MueasSimulation extends Simulation{
val httpConf = http.baseURL("http://localhost:8080")
var scn = scenario("Search mueas home page")
.exec(http("Redirect Login").get("/").check(currentLocation.saveAs("post_url")))
.pause( seconds)
.exec(http("Try login").post("${post_url}")
.formParam("username", "你的用户名")
.formParam("password", “你的密码").check(currentLocation.is("http://localhost:8080/")))
.pause( seconds)
setUp(scn.inject(atOnceUsers()).protocols(httpConf))
}

mueas工程修改好了,通过git将新修改提交到远程仓库,方便jenkins管理。

到此,可以配置jenkins了,创建一个新的Job,配置基本信息可以参考前面Jenkins的基础篇,这里,主要是强调一下,关于这个gatling集成应用的配置。主要在build部分。下面这个图,主要是Pre Steps里面的Execute shell的编写,用来清除环境,主要是杀掉可能存在的应用。脚本很简单,自己看看就明白。

jenkins:应用篇(Gatling plugin的使用)

再就是Post Steps的配置,完成两步工作,第一步是启动mueas应用,第二步,就是启用gatling来进行压力测试。

jenkins:应用篇(Gatling plugin的使用)

到这里,所有的配置,关于gatling在jenkins的集成,全部完成。现在可以启动jenkins的job了。直接Build。完成后,可以看到下面的日志信息。

 Started by user anonymous
Building in workspace /root/.jenkins/jobs/mueas-gatling/workspace
> git rev-parse --is-inside-work-tree # timeout=
Fetching changes from the remote Git repository
> git config remote.origin.url git@109.105.5.108:/data/git/mueas.git # timeout=
Fetching upstream changes from git@109.105.5.108:/data/git/mueas.git
> git --version # timeout=
using GIT_SSH to set credentials root private key
> git -c core.askpass=true fetch --tags --progress git@109.105.5.108:/data/git/mueas.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision b9dc8261faf8d172c9ee689048b232b9b7c698d2 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f b9dc8261faf8d172c9ee689048b232b9b7c698d2
> git rev-list 7ae96f26da0f7b1ff289b6008d3531872938bd17 # timeout=10
> git tag -a -f -m Jenkins Build #15 jenkins-mueas-gatling-15 # timeout=10
[workspace] $ /bin/bash /tmp/hudson7254261757720827244.sh
================= PRE STEPS TRACKING BEGIN =================
WORKSPACE: /root/.jenkins/jobs/mueas-gatling/workspace
target dir: /root/.jenkins/jobs/mueas-gatling/workspace/target
war file: /root/.jenkins/jobs/mueas-gatling/workspace/target/mueas-0.0.1-SNAPSHOT.war
specified running instance: mueas-0.0.1-SNAPSHOT.war --server.port=8080
runningpid:
There is no running instance as specified
================= PRE STEPS TRACKING END ===================
Parsing POMs
[workspace] $ /usr/java/jdk1.8.0_65/bin/java -cp /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.5.jar:/usr/local/apache-maven-3.3.3/boot/plexus-classworlds-2.5.2.jar:/usr/local/apache-maven-3.3.3/conf/logging jenkins.maven3.agent.Maven31Main /usr/local/apache-maven-3.3.3 /root/.jenkins/war/WEB-INF/lib/remoting-2.53.2.jar /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.5.jar /root/.jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.5.jar 48577
<===[JENKINS REMOTING CAPACITY]===>???channel started
Executing Maven: -B -f /root/.jenkins/jobs/mueas-gatling/workspace/pom.xml -s /root/.m2/settings.xml -gs /usr/local/apache-maven-3.3.3/conf/settings.xml package -Dmaven.test.skip=true
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - Scanning for projects...
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - Building mueas 0.0.1-SNAPSHOT
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - --- maven-resources-plugin:2.6:resources (default-resources) @ mueas ---
[pool-1-thread-1 for channel] INFO org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering - Using 'UTF-8' encoding to copy filtered resources.
[pool-1-thread-1 for channel] INFO org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering - Copying 0 resource
[pool-1-thread-1 for channel] INFO org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering - Copying 863 resources
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - --- maven-compiler-plugin:3.1:compile (default-compile) @ mueas ---
[pool-1-thread-1 for channel] INFO org.apache.maven.plugin.compiler.CompilerMojo - Nothing to compile - all classes are up to date
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - --- maven-resources-plugin:2.6:testResources (default-testResources) @ mueas ---
[pool-1-thread-1 for channel] INFO org.apache.maven.plugin.resources.TestResourcesMojo - Not copying test resources
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ mueas ---
[pool-1-thread-1 for channel] INFO org.apache.maven.plugin.compiler.TestCompilerMojo - Not compiling test sources
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - --- maven-surefire-plugin:2.17:test (default-test) @ mueas ---
[pool-1-thread-1 for channel] INFO org.apache.maven.plugin.surefire.SurefirePlugin - Tests are skipped.
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - --- maven-war-plugin:2.5:war (default-war) @ mueas ---
[pool-1-thread-1 for channel] INFO org.apache.maven.plugin.war.WarMojo - Packaging webapp
[pool-1-thread-1 for channel] INFO org.apache.maven.plugin.war.WarMojo - Assembling webapp [mueas] in [/root/.jenkins/jobs/mueas-gatling/workspace/target/mueas-0.0.1-SNAPSHOT]
[pool-1-thread-1 for channel] INFO org.apache.maven.plugin.war.WarMojo - Processing war project
[pool-1-thread-1 for channel] INFO org.apache.maven.plugin.war.WarMojo - Copying webapp resources [/root/.jenkins/jobs/mueas-gatling/workspace/src/main/webapp]
[pool-1-thread-1 for channel] INFO org.apache.maven.plugin.war.WarMojo - Webapp assembled in [470 msecs]
[pool-1-thread-1 for channel] INFO org.codehaus.plexus.archiver.war.WarArchiver - Building war: /root/.jenkins/jobs/mueas-gatling/workspace/target/mueas-0.0.1-SNAPSHOT.war
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - --- spring-boot-maven-plugin:1.2.7.RELEASE:repackage (default) @ mueas ---
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - BUILD SUCCESS
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - Total time: 11.598 s
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - Finished at: 2016-01-22T11:51:28+08:00
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - Final Memory: 34M/381M
[pool-1-thread-1 for channel] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /root/.jenkins/jobs/mueas-gatling/workspace/pom.xml to com.tinguish/mueas/0.0.1-SNAPSHOT/mueas-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving /root/.jenkins/jobs/mueas-gatling/workspace/target/mueas-0.0.1-SNAPSHOT.war to com.tinguish/mueas/0.0.1-SNAPSHOT/mueas-0.0.1-SNAPSHOT.war
channel stopped
[workspace] $ /bin/bash /tmp/hudson1088999714714478379.sh
================= POST STEPS TRACKING BEGIN =================
WORKSPACE: /root/.jenkins/jobs/mueas-gatling/workspace
target dir: /root/.jenkins/jobs/mueas-gatling/workspace/target
war file: /root/.jenkins/jobs/mueas-gatling/workspace/target/mueas-0.0.1-SNAPSHOT.war
BEGIN TO DO GATLING SIMULATION....
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/.jenkins/jobs/mueas-gatling/workspace/target/mueas-0.0.1-SNAPSHOT.war!/WEB-INF/lib/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/.jenkins/jobs/mueas-gatling/workspace/target/mueas-0.0.1-SNAPSHOT.war!/WEB-INF/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] . ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.7.RELEASE) 2016-01-22 11:51:31.766 INFO 6660 --- [ main] com.tinguish.mueas.Application : Starting Application on CloudGame with PID 6660 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
这里省略了mueas项目启动的日志,和这个博文的重点不相干,且涉及到项目机密
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 2016-01-22 11:51:55.192 INFO 6660 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-01-22 11:51:55.194 INFO 6660 --- [ main] com.tinguish.mueas.Application : Started Application in 24.398 seconds (JVM running for 25.896)
Simulation simple.MueasSimulation started...
[2016-01-22 11:52:00.499] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-2] --- HttpProtocol:123: Start warm up
[2016-01-22 11:52:06.012] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-2] --- HttpProtocol:169: Warm up done
[2016-01-22 11:52:06.030] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-2] --- Controller:91: Total number of users : 2
[2016-01-22 11:52:06.042] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-3] --- FileDataWriter:90: Initializing
[2016-01-22 11:52:06.042] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-9] --- ConsoleDataWriter:90: Initializing
[2016-01-22 11:52:06.052] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-9] --- ConsoleDataWriter:92: Initialized
[2016-01-22 11:52:06.065] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-3] --- FileDataWriter:92: Initialized
[2016-01-22 11:52:06.094] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-2] --- Controller:216: Start user #1295396986639070879-0
[2016-01-22 11:52:06.100] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-2] --- Controller:216: Start user #1295396986639070879-1
[2016-01-22 11:52:06.143] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-3] --- HttpEngine:270: Sending request=Redirect Login uri=http://localhost:8080/: scenario=Search mueas home page, userId=1295396986639070879-0
[2016-01-22 11:52:06.180] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-3] --- HttpEngine:270: Sending request=Redirect Login uri=http://localhost:8080/: scenario=Search mueas home page, userId=1295396986639070879-1 ================================================================================
2016-01-22 11:52:06 0s elapsed
---- Search mueas home page ----------------------------------------------------
[ ] 0%
waiting: 2 / active: 0 / done:0
---- Requests ------------------------------------------------------------------
> Global (OK=0 KO=0 ) ================================================================================ 2016-01-22 11:52:06.291 INFO 6660 --- [nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-01-22 11:52:06.291 INFO 6660 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2016-01-22 11:52:06.332 INFO 6660 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 41 ms
[2016-01-22 11:52:06.450] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-3] --- HttpEngine:270: Sending request=Redirect Login uri=http://localhost:8080/login: scenario=Search mueas home page, userId=1295396986639070879-0
[2016-01-22 11:52:06.451] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-9] --- HttpEngine:270: Sending request=Redirect Login uri=http://localhost:8080/login: scenario=Search mueas home page, userId=1295396986639070879-1
[2016-01-22 11:52:07.057] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-3] --- Pause:46: Pausing for 10000ms (real=9970ms)
[2016-01-22 11:52:07.059] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-3] --- Pause:46: Pausing for 10000ms (real=9955ms) ================================================================================
2016-01-22 11:52:11 5s elapsed
---- Search mueas home page ----------------------------------------------------
[--------------------------------------------------------------------------] 0%
waiting: 0 / active: 2 / done:0
---- Requests ------------------------------------------------------------------
> Global (OK=4 KO=0 )
> Redirect Login (OK=2 KO=0 )
> Redirect Login Redirect 1 (OK=2 KO=0 )
================================================================================ ================================================================================
2016-01-22 11:52:16 10s elapsed
---- Search mueas home page ----------------------------------------------------
[--------------------------------------------------------------------------] 0%
waiting: 0 / active: 2 / done:0
---- Requests ------------------------------------------------------------------
> Global (OK=4 KO=0 )
> Redirect Login (OK=2 KO=0 )
> Redirect Login Redirect 1 (OK=2 KO=0 )
================================================================================ [2016-01-22 11:52:17.035] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-9] --- HttpEngine:270: Sending request=Try login uri=http://localhost:8080/login: scenario=Search mueas home page, userId=1295396986639070879-1
[2016-01-22 11:52:17.059] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-9] --- HttpEngine:270: Sending request=Try login uri=http://localhost:8080/login: scenario=Search mueas home page, userId=1295396986639070879-0
[2016-01-22 11:52:17.198] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-9] --- HttpEngine:270: Sending request=Try login uri=http://localhost:8080/login: scenario=Search mueas home page, userId=1295396986639070879-1
[2016-01-22 11:52:17.210] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-3] --- HttpEngine:270: Sending request=Try login uri=http://localhost:8080/login: scenario=Search mueas home page, userId=1295396986639070879-0
[2016-01-22 11:52:17.269] log4j - ???? WARN [GatlingSystem-akka.actor.default-dispatcher-3] --- AsyncHandlerActor:119: Request 'Try login Redirect 1' failed: currentLocation.find.is(http://localhost:8080/), but actually found http://localhost:8080/login
[2016-01-22 11:52:17.271] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-7] --- Pause:46: Pausing for 10000ms (real=9980ms)
[2016-01-22 11:52:17.273] log4j - ???? WARN [GatlingSystem-akka.actor.default-dispatcher-2] --- AsyncHandlerActor:119: Request 'Try login Redirect 1' failed: currentLocation.find.is(http://localhost:8080/), but actually found http://localhost:8080/login
[2016-01-22 11:52:17.274] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-2] --- Pause:46: Pausing for 10000ms (real=9968ms) ================================================================================
2016-01-22 11:52:21 15s elapsed
---- Search mueas home page ----------------------------------------------------
[--------------------------------------------------------------------------] 0%
waiting: 0 / active: 2 / done:0
---- Requests ------------------------------------------------------------------
> Global (OK=6 KO=2 )
> Redirect Login (OK=2 KO=0 )
> Redirect Login Redirect 1 (OK=2 KO=0 )
> Try login (OK=2 KO=0 )
> Try login Redirect 1 (OK=0 KO=2 )
---- Errors --------------------------------------------------------------------
> currentLocation.find.is(http://localhost:8080/), but actually 2 (100.0%)
found http://localhost:8080/login
================================================================================ ================================================================================
2016-01-22 11:52:26 20s elapsed
---- Search mueas home page ----------------------------------------------------
[--------------------------------------------------------------------------] 0%
waiting: 0 / active: 2 / done:0
---- Requests ------------------------------------------------------------------
> Global (OK=6 KO=2 )
> Redirect Login (OK=2 KO=0 )
> Redirect Login Redirect 1 (OK=2 KO=0 )
> Try login (OK=2 KO=0 )
> Try login Redirect 1 (OK=0 KO=2 )
---- Errors --------------------------------------------------------------------
> currentLocation.find.is(http://localhost:8080/), but actually 2 (100.0%)
found http://localhost:8080/login
================================================================================ [2016-01-22 11:52:27.263] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-9] --- Controller:203: End user #1295396986639070879-0
[2016-01-22 11:52:27.265] log4j - ???? INFO [GatlingSystem-akka.actor.default-dispatcher-9] --- Controller:203: End user #1295396986639070879-1 ================================================================================
2016-01-22 11:52:27 21s elapsed
---- Search mueas home page ----------------------------------------------------
[##########################################################################]100%
waiting: 0 / active: 0 / done:2
---- Requests ------------------------------------------------------------------
> Global (OK=6 KO=2 )
> Redirect Login (OK=2 KO=0 )
> Redirect Login Redirect 1 (OK=2 KO=0 )
> Try login (OK=2 KO=0 )
> Try login Redirect 1 (OK=0 KO=2 )
---- Errors --------------------------------------------------------------------
> currentLocation.find.is(http://localhost:8080/), but actually 2 (100.0%)
found http://localhost:8080/login
================================================================================ Simulation finished
Parsing log file(s)...
[2016-01-22 11:52:27.503] log4j - ???? INFO [main] --- FileDataReader:56: Collected List(/root/.jenkins/jobs/mueas-gatling/workspace/target/gatling/results/mueassimulation-1453434726032/simulation.log) from mueassimulation-1453434726032
[2016-01-22 11:52:27.509] log4j - ???? INFO [main] --- FileDataReader:73: First pass
[2016-01-22 11:52:27.514] log4j - ???? INFO [main] --- FileDataReader:118: First pass done: read 13 lines
[2016-01-22 11:52:27.517] log4j - ???? INFO [main] --- FileDataReader:132: Second pass
[2016-01-22 11:52:27.544] log4j - ???? INFO [main] --- FileDataReader:157: Second pass: read 13 lines
Parsing log file(s) done
Generating reports... ================================================================================
---- Global Information --------------------------------------------------------
> request count 8 (OK=6 KO=2 )
> min response time 62 (OK=148 KO=62 )
> max response time 573 (OK=573 KO=68 )
> mean response time 258 (OK=322 KO=65 )
> std deviation 189 (OK=176 KO=3 )
> response time 50th percentile 194 (OK=250 KO=65 )
> response time 75th percentile 339 (OK=485 KO=66 )
> mean requests/sec 0.378 (OK=0.283 KO=0.094 )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms 6 ( 75%)
> 800 ms < t < 1200 ms 0 ( 0%)
> t > 1200 ms 0 ( 0%)
> failed 2 ( 25%)
---- Errors --------------------------------------------------------------------
> currentLocation.find.is(http://localhost:8080/), but actually 2 (100.0%)
found http://localhost:8080/login
================================================================================ Reports generated in 0s.
Please open the following file: /root/.jenkins/jobs/mueas-gatling/workspace/target/gatling/results/mueassimulation-1453434726032/index.html
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - BUILD SUCCESS
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Total time: 55.110 s
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Finished at: 2016-01-22T11:52:27+08:00
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - Final Memory: 13M/228M
[main] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
================= POST STEPS TRACKING END ===================
Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information
Archiving Gatling reports...
2016-01-22 11:52:38.063 INFO 6660 --- [ Thread-2] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3e795823: startup date [Fri Jan 22 11:51:32 CST 2016]; root of context hierarchy
2016-01-22 11:52:38.065 INFO 6660 --- [ Thread-2] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 2147483647
Adding report 'mueassimulation-1453434726032'
Finished: SUCCESS

从上面的log日志中可以发现,gatling的测试结果是一个逻辑正常的测试,虽然check点失败(因为我给的用户名和密码都不对,所以登录失败,不可能进入到项目的主目录,只会停留在login的页面。),但是gatling的测试流程是没有问题的。

我执行了两次,没有做任何修改,因为一次测试,gatling的结果图上只有一个点,看不出差别。两次之间,有时间上的差别。。。

jenkins:应用篇(Gatling plugin的使用)

关于gatling和jenkins的集成的官方信息,可以参考一下下面的链接:

http://gatling.io/docs/2.1.7/extensions/jenkins_plugin.html

http://gatling.io/docs/2.1.7/extensions/maven_plugin.html?highlight=maven%20plugin

到此完