zoukankan      html  css  js  c++  java
  • 如何通过源码生成Gatling可执行工具

    其实,这个对于不是很熟系sbt的人来说,或者对scala语言没有什么了解的人,接触Gatling这个开源的性能测试框架,还是有些茫然的。

    因为GitHub上提供的Gatling (最新版本:2.2.0 snapshot)是源码,而且,完整的Gatling被拆分为Gatling(Core,相当于测试引擎吧)和Gatling-highchats(主要是用来生成测试报告)两部分。不知到为何要拆分为两部分,也许是因为Gatling-highchats部分引用了特殊license的软件插件(HighCharts & HighStock, 来自于HighSoft公司。。。)

    1. 首先,从github上clone下gatling的源码。

    git clone http://github.com/gatling/gatling

    git clone http://github.com/gatling/gatling-highcharts

    待这些文件都下载到本地后,先进入gatling的目录,在命令行下执行 sbt compile (,若你的系统下没有安装SBT,请先自己安装,我是直接在SBT官网下载的0.13.9的版本,解压到local目录下,再在/etc/profile下配置一下环境变量,方便使用)。gatling文件列表如下:

    -rw-r--r-- 1 root root 3204 Jan  8 13:10 CONTRIBUTING.md
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-app
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-bundle
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-charts
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-commons
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-compiler
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-core
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-http
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-jdbc
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-jms
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-metrics
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-recorder
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-redis
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 gatling-test-framework
    -rwxr-xr-x 1 root root  246 Jan  8 13:10 make_credentials.sh
    -rw-r--r-- 1 root root  106 Jan  8 13:10 pgp.sbt
    drwxr-xr-x 4 root root 4096 Jan  8 13:12 project
    -rw-r--r-- 1 root root 2304 Jan  8 13:10 README.md
    drwxr-xr-x 4 root root 4096 Jan  8 13:10 src
    drwxr-xr-x 4 root root 4096 Jan  8 13:18 target
    -rwxr-xr-x 1 root root  720 Jan  8 13:10 trigger_build.py
    -rw-r--r-- 1 root root   40 Jan  8 13:10 version.sbt

    sbt compile执行完毕后(可能需要一段时间,因为有些依赖的库要下载),需要将其发布到ivy仓库中(你也可以发布到mave仓库):

    sbt publishLocal

      1 [root@CloudGame gatling]# sbt publishLocal
      2 [info] Loading global plugins from /root/.sbt/0.13/plugins
      3 [info] Loading project definition from /mnt/workwps/gatling2.1.7/gatling/project
      4 [info] Set current project to gatling-parent (in build file:/mnt/workwps/gatling2.1.7/gatling/)
      5 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-compiler/target/gatling-compiler-2.2.0-SNAPSHOT-sources.jar ...
      6 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-core/target/gatling-core-2.2.0-SNAPSHOT-sources.jar ...
      7 [info] Done packaging.
      8 [info] Done packaging.
      9 SLF4J: The following set of substitute loggers may have been accessed
     10 SLF4J: during the initialization phase. Logging calls during this
     11 SLF4J: phase were not honored. However, subsequent logging calls to these
     12 SLF4J: loggers will work as normally expected.
     13 SLF4J: See also http://www.slf4j.org/codes.html#substituteLogger
     14 SLF4J: org.eclipse.aether.internal.impl.DefaultRepositorySystem
     15 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-commons/target/gatling-commons-2.2.0-SNAPSHOT.pom
     16 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-compiler/target/gatling-compiler-2.2.0-SNAPSHOT.pom
     17 [info] :: delivering :: io.gatling#gatling-commons;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:08 CST 2016
     18 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-commons/target/ivy-2.2.0-SNAPSHOT.xml
     19 [info] :: delivering :: io.gatling#gatling-compiler;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:08 CST 2016
     20 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-compiler/target/ivy-2.2.0-SNAPSHOT.xml
     21 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-core/target/gatling-core-2.2.0-SNAPSHOT.pom
     22 [info] :: delivering :: io.gatling#gatling-core;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:08 CST 2016
     23 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-core/target/ivy-2.2.0-SNAPSHOT.xml
     24 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-metrics/target/gatling-metrics-2.2.0-SNAPSHOT.pom
     25 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-redis/target/gatling-redis-2.2.0-SNAPSHOT.pom
     26 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-charts/target/gatling-charts-2.2.0-SNAPSHOT.pom
     27 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-jms/target/gatling-jms-2.2.0-SNAPSHOT.pom
     28 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-http/target/gatling-http-2.2.0-SNAPSHOT.pom
     29 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-jdbc/target/gatling-jdbc-2.2.0-SNAPSHOT.pom
     30 [info] :: delivering :: io.gatling#gatling-metrics;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:08 CST 2016
     31 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-metrics/target/ivy-2.2.0-SNAPSHOT.xml
     32 [info] :: delivering :: io.gatling#gatling-jms;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:08 CST 2016
     33 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-jms/target/ivy-2.2.0-SNAPSHOT.xml
     34 [info] :: delivering :: io.gatling#gatling-charts;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:08 CST 2016
     35 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-charts/target/ivy-2.2.0-SNAPSHOT.xml
     36 [info] :: delivering :: io.gatling#gatling-redis;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:08 CST 2016
     37 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-redis/target/ivy-2.2.0-SNAPSHOT.xml
     38 [info] :: delivering :: io.gatling#gatling-jdbc;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:08 CST 2016
     39 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-jdbc/target/ivy-2.2.0-SNAPSHOT.xml
     40 [info] :: delivering :: io.gatling#gatling-http;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:08 CST 2016
     41 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-http/target/ivy-2.2.0-SNAPSHOT.xml
     42 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-bundle/target/gatling-bundle-2.2.0-SNAPSHOT.pom
     43 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/target/gatling-parent-2.2.0-SNAPSHOT.pom
     44 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-app/target/gatling-app-2.2.0-SNAPSHOT.pom
     45 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-recorder/target/gatling-recorder-2.2.0-SNAPSHOT.pom
     46 [info] :: delivering :: io.gatling#gatling-bundle;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:09 CST 2016
     47 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-bundle/target/ivy-2.2.0-SNAPSHOT.xml
     48 [info] :: delivering :: io.gatling#gatling-app;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:09 CST 2016
     49 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-app/target/ivy-2.2.0-SNAPSHOT.xml
     50 [info] :: delivering :: io.gatling#gatling-parent;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:09 CST 2016
     51 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/target/ivy-2.2.0-SNAPSHOT.xml
     52 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-compiler/target/gatling-compiler-2.2.0-SNAPSHOT.jar ...
     53 [info]     published gatling-bundle to /root/.ivy2/local/io.gatling/gatling-bundle/2.2.0-SNAPSHOT/poms/gatling-bundle.pom
     54 [info] Done packaging.
     55 [info]     published gatling-bundle to /root/.ivy2/local/io.gatling/gatling-bundle/2.2.0-SNAPSHOT/zips/gatling-bundle-bundle.zip
     56 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-bundle/2.2.0-SNAPSHOT/ivys/ivy.xml
     57 [info] :: delivering :: io.gatling#gatling-recorder;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:09 CST 2016
     58 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-recorder/target/ivy-2.2.0-SNAPSHOT.xml
     59 [info] Wrote /mnt/workwps/gatling2.1.7/gatling/gatling-test-framework/target/gatling-test-framework-2.2.0-SNAPSHOT.pom
     60 [info]     published gatling-parent to /root/.ivy2/local/io.gatling/gatling-parent/2.2.0-SNAPSHOT/poms/gatling-parent.pom
     61 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-parent/2.2.0-SNAPSHOT/ivys/ivy.xml
     62 [info]     published gatling-commons to /root/.ivy2/local/io.gatling/gatling-commons/2.2.0-SNAPSHOT/poms/gatling-commons.pom
     63 [info]     published gatling-commons to /root/.ivy2/local/io.gatling/gatling-commons/2.2.0-SNAPSHOT/jars/gatling-commons.jar
     64 [info]     published gatling-commons to /root/.ivy2/local/io.gatling/gatling-commons/2.2.0-SNAPSHOT/srcs/gatling-commons-sources.jar
     65 [info]     published gatling-commons to /root/.ivy2/local/io.gatling/gatling-commons/2.2.0-SNAPSHOT/docs/gatling-commons-javadoc.jar
     66 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-commons/2.2.0-SNAPSHOT/ivys/ivy.xml
     67 [info]     published gatling-compiler to /root/.ivy2/local/io.gatling/gatling-compiler/2.2.0-SNAPSHOT/poms/gatling-compiler.pom
     68 [info]     published gatling-compiler to /root/.ivy2/local/io.gatling/gatling-compiler/2.2.0-SNAPSHOT/jars/gatling-compiler.jar
     69 [info]     published gatling-compiler to /root/.ivy2/local/io.gatling/gatling-compiler/2.2.0-SNAPSHOT/srcs/gatling-compiler-sources.jar
     70 [info]     published gatling-compiler to /root/.ivy2/local/io.gatling/gatling-compiler/2.2.0-SNAPSHOT/docs/gatling-compiler-javadoc.jar
     71 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-compiler/2.2.0-SNAPSHOT/ivys/ivy.xml
     72 [info] :: delivering :: io.gatling#gatling-test-framework;2.2.0-SNAPSHOT :: 2.2.0-SNAPSHOT :: integration :: Fri Jan 08 14:32:09 CST 2016
     73 [info]     delivering ivy file to /mnt/workwps/gatling2.1.7/gatling/gatling-test-framework/target/ivy-2.2.0-SNAPSHOT.xml
     74 [info] Main Scala API documentation to /mnt/workwps/gatling2.1.7/gatling/gatling-jms/target/api...
     75 [info] Main Scala API documentation to /mnt/workwps/gatling2.1.7/gatling/gatling-jdbc/target/api...
     76 [info] Main Scala API documentation to /mnt/workwps/gatling2.1.7/gatling/gatling-charts/target/api...
     77 [info] Main Scala API documentation to /mnt/workwps/gatling2.1.7/gatling/gatling-metrics/target/api...
     78 model contains 7 documentable templates
     79 model contains 9 documentable templates
     80 [info] Main Scala API documentation successful.
     81 [info] Main Scala API documentation to /mnt/workwps/gatling2.1.7/gatling/gatling-redis/target/api...
     82 model contains 51 documentable templates
     83 [info] Main Scala API documentation successful.
     84 [info] Main Scala API documentation to /mnt/workwps/gatling2.1.7/gatling/gatling-http/target/api...
     85 model contains 9 documentable templates
     86 [info] Main Scala API documentation successful.
     87 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-jdbc/target/gatling-jdbc-2.2.0-SNAPSHOT-javadoc.jar ...
     88 [info] Done packaging.
     89 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-core/target/gatling-core-2.2.0-SNAPSHOT.jar ...
     90 [info] Done packaging.
     91 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-metrics/target/gatling-metrics-2.2.0-SNAPSHOT-javadoc.jar ...
     92 [info] Done packaging.
     93 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-redis/target/gatling-redis-2.2.0-SNAPSHOT-javadoc.jar ...
     94 [info] Done packaging.
     95 [info]     published gatling-core to /root/.ivy2/local/io.gatling/gatling-core/2.2.0-SNAPSHOT/poms/gatling-core.pom
     96 [info]     published gatling-core to /root/.ivy2/local/io.gatling/gatling-core/2.2.0-SNAPSHOT/jars/gatling-core.jar
     97 [info]     published gatling-core to /root/.ivy2/local/io.gatling/gatling-core/2.2.0-SNAPSHOT/srcs/gatling-core-sources.jar
     98 [info]     published gatling-core to /root/.ivy2/local/io.gatling/gatling-core/2.2.0-SNAPSHOT/docs/gatling-core-javadoc.jar
     99 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-core/2.2.0-SNAPSHOT/ivys/ivy.xml
    100 [info]     published gatling-jdbc to /root/.ivy2/local/io.gatling/gatling-jdbc/2.2.0-SNAPSHOT/poms/gatling-jdbc.pom
    101 [info]     published gatling-jdbc to /root/.ivy2/local/io.gatling/gatling-jdbc/2.2.0-SNAPSHOT/jars/gatling-jdbc.jar
    102 [info]     published gatling-jdbc to /root/.ivy2/local/io.gatling/gatling-jdbc/2.2.0-SNAPSHOT/srcs/gatling-jdbc-sources.jar
    103 [info]     published gatling-jdbc to /root/.ivy2/local/io.gatling/gatling-jdbc/2.2.0-SNAPSHOT/docs/gatling-jdbc-javadoc.jar
    104 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-jdbc/2.2.0-SNAPSHOT/ivys/ivy.xml
    105 [info]     published gatling-redis to /root/.ivy2/local/io.gatling/gatling-redis/2.2.0-SNAPSHOT/poms/gatling-redis.pom
    106 [info]     published gatling-redis to /root/.ivy2/local/io.gatling/gatling-redis/2.2.0-SNAPSHOT/jars/gatling-redis.jar
    107 [info]     published gatling-redis to /root/.ivy2/local/io.gatling/gatling-redis/2.2.0-SNAPSHOT/srcs/gatling-redis-sources.jar
    108 [info]     published gatling-redis to /root/.ivy2/local/io.gatling/gatling-redis/2.2.0-SNAPSHOT/docs/gatling-redis-javadoc.jar
    109 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-redis/2.2.0-SNAPSHOT/ivys/ivy.xml
    110 [info]     published gatling-metrics to /root/.ivy2/local/io.gatling/gatling-metrics/2.2.0-SNAPSHOT/poms/gatling-metrics.pom
    111 [info]     published gatling-metrics to /root/.ivy2/local/io.gatling/gatling-metrics/2.2.0-SNAPSHOT/jars/gatling-metrics.jar
    112 [info]     published gatling-metrics to /root/.ivy2/local/io.gatling/gatling-metrics/2.2.0-SNAPSHOT/srcs/gatling-metrics-sources.jar
    113 [info]     published gatling-metrics to /root/.ivy2/local/io.gatling/gatling-metrics/2.2.0-SNAPSHOT/docs/gatling-metrics-javadoc.jar
    114 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-metrics/2.2.0-SNAPSHOT/ivys/ivy.xml
    115 [info] Main Scala API documentation to /mnt/workwps/gatling2.1.7/gatling/gatling-app/target/api...
    116 model contains 17 documentable templates
    117 [info] Main Scala API documentation successful.
    118 [info] Main Scala API documentation to /mnt/workwps/gatling2.1.7/gatling/gatling-recorder/target/api...
    119 [info] Main Scala API documentation successful.
    120 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-jms/target/gatling-jms-2.2.0-SNAPSHOT-javadoc.jar ...
    121 [info] Done packaging.
    122 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-app/target/gatling-app-2.2.0-SNAPSHOT-javadoc.jar ...
    123 [info] Done packaging.
    124 [info]     published gatling-jms to /root/.ivy2/local/io.gatling/gatling-jms/2.2.0-SNAPSHOT/poms/gatling-jms.pom
    125 [info]     published gatling-jms to /root/.ivy2/local/io.gatling/gatling-jms/2.2.0-SNAPSHOT/jars/gatling-jms.jar
    126 [info]     published gatling-jms to /root/.ivy2/local/io.gatling/gatling-jms/2.2.0-SNAPSHOT/srcs/gatling-jms-sources.jar
    127 [info]     published gatling-jms to /root/.ivy2/local/io.gatling/gatling-jms/2.2.0-SNAPSHOT/docs/gatling-jms-javadoc.jar
    128 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-jms/2.2.0-SNAPSHOT/ivys/ivy.xml
    129 [info]     published gatling-app to /root/.ivy2/local/io.gatling/gatling-app/2.2.0-SNAPSHOT/poms/gatling-app.pom
    130 [info]     published gatling-app to /root/.ivy2/local/io.gatling/gatling-app/2.2.0-SNAPSHOT/jars/gatling-app.jar
    131 [info]     published gatling-app to /root/.ivy2/local/io.gatling/gatling-app/2.2.0-SNAPSHOT/srcs/gatling-app-sources.jar
    132 [info]     published gatling-app to /root/.ivy2/local/io.gatling/gatling-app/2.2.0-SNAPSHOT/docs/gatling-app-javadoc.jar
    133 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-app/2.2.0-SNAPSHOT/ivys/ivy.xml
    134 [info] Main Scala API documentation to /mnt/workwps/gatling2.1.7/gatling/gatling-test-framework/target/api...
    135 model contains 11 documentable templates
    136 [info] Main Scala API documentation successful.
    137 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-test-framework/target/gatling-test-framework-2.2.0-SNAPSHOT-javadoc.jar ...
    138 [info] Done packaging.
    139 [info]     published gatling-test-framework to /root/.ivy2/local/io.gatling/gatling-test-framework/2.2.0-SNAPSHOT/poms/gatling-test-framework.pom
    140 [info]     published gatling-test-framework to /root/.ivy2/local/io.gatling/gatling-test-framework/2.2.0-SNAPSHOT/jars/gatling-test-framework.jar
    141 [info]     published gatling-test-framework to /root/.ivy2/local/io.gatling/gatling-test-framework/2.2.0-SNAPSHOT/srcs/gatling-test-framework-sources.jar
    142 [info]     published gatling-test-framework to /root/.ivy2/local/io.gatling/gatling-test-framework/2.2.0-SNAPSHOT/docs/gatling-test-framework-javadoc.jar
    143 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-test-framework/2.2.0-SNAPSHOT/ivys/ivy.xml
    144 model contains 8 documentable templates
    145 [info] Main Scala API documentation successful.
    146 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-charts/target/gatling-charts-2.2.0-SNAPSHOT-javadoc.jar ...
    147 [info] Done packaging.
    148 [info]     published gatling-charts to /root/.ivy2/local/io.gatling/gatling-charts/2.2.0-SNAPSHOT/poms/gatling-charts.pom
    149 [info]     published gatling-charts to /root/.ivy2/local/io.gatling/gatling-charts/2.2.0-SNAPSHOT/jars/gatling-charts.jar
    150 [info]     published gatling-charts to /root/.ivy2/local/io.gatling/gatling-charts/2.2.0-SNAPSHOT/srcs/gatling-charts-sources.jar
    151 [info]     published gatling-charts to /root/.ivy2/local/io.gatling/gatling-charts/2.2.0-SNAPSHOT/docs/gatling-charts-javadoc.jar
    152 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-charts/2.2.0-SNAPSHOT/ivys/ivy.xml
    153 model contains 22 documentable templates
    154 [info] Main Scala API documentation successful.
    155 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-recorder/target/gatling-recorder-2.2.0-SNAPSHOT-javadoc.jar ...
    156 [info] Done packaging.
    157 [info]     published gatling-recorder to /root/.ivy2/local/io.gatling/gatling-recorder/2.2.0-SNAPSHOT/poms/gatling-recorder.pom
    158 [info]     published gatling-recorder to /root/.ivy2/local/io.gatling/gatling-recorder/2.2.0-SNAPSHOT/jars/gatling-recorder.jar
    159 [info]     published gatling-recorder to /root/.ivy2/local/io.gatling/gatling-recorder/2.2.0-SNAPSHOT/srcs/gatling-recorder-sources.jar
    160 [info]     published gatling-recorder to /root/.ivy2/local/io.gatling/gatling-recorder/2.2.0-SNAPSHOT/docs/gatling-recorder-javadoc.jar
    161 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-recorder/2.2.0-SNAPSHOT/ivys/ivy.xml
    162 model contains 347 documentable templates
    163 [info] Main Scala API documentation successful.
    164 [info] Packaging /mnt/workwps/gatling2.1.7/gatling/gatling-http/target/gatling-http-2.2.0-SNAPSHOT-javadoc.jar ...
    165 [info] Done packaging.
    166 [info]     published gatling-http to /root/.ivy2/local/io.gatling/gatling-http/2.2.0-SNAPSHOT/poms/gatling-http.pom
    167 [info]     published gatling-http to /root/.ivy2/local/io.gatling/gatling-http/2.2.0-SNAPSHOT/jars/gatling-http.jar
    168 [info]     published gatling-http to /root/.ivy2/local/io.gatling/gatling-http/2.2.0-SNAPSHOT/srcs/gatling-http-sources.jar
    169 [info]     published gatling-http to /root/.ivy2/local/io.gatling/gatling-http/2.2.0-SNAPSHOT/docs/gatling-http-javadoc.jar
    170 [info]     published ivy to /root/.ivy2/local/io.gatling/gatling-http/2.2.0-SNAPSHOT/ivys/ivy.xml
    171 [success] Total time: 59 s, completed Jan 8, 2016 2:33:05 PM
    View Code

    这个过程,比较像mvn install将生成的模块安装到本地.m2仓库中的过程。到此,gatling引擎部分编译和发布完成。

    然后,进入gatling-highchats,和上述编译gatling的过程类似,执行sbt compile,然后在发布到本地ivy仓库。注意,一定要先对gatling进行发布后再编译gatling-highchats,否则在编译gatling-highchats的时候会报错的,找不到依赖的库

    至此,编译部分都完成了,那么,问题来了,生成的工具(可执行文件)在什么地方呢?在什么地方可以执行刚才生成的工具呢?官网上说的比较清楚,我也倾向于用bundle的文件来执行。默认情况下,这个文件会在ivy的仓库里面。就拿我的环境来说,其目录如下:

    1 [root@CloudGame zips]# pwd
    2 /root/.ivy2/local/io.gatling.highcharts/gatling-charts-highcharts-bundle/2.2.0-SNAPSHOT/zips

    文件内容如下:

     1 [root@CloudGame gatling-charts-highcharts-bundle-2.2.0-SNAPSHOT]# ll
     2 total 28
     3 drwxr-xr-x 2 root root  4096 Jan  8 15:04 bin
     4 drwxr-xr-x 3 root root  4096 Jan  8 15:04 lib
     5 -rw-r--r-- 1 root root 11367 Jan  8 15:04 LICENSE
     6 drwxr-xr-x 2 root root  4096 Jan  8 15:04 results
     7 drwxr-xr-x 5 root root  4096 Jan  8 15:04 user-files
     8 [root@CloudGame gatling-charts-highcharts-bundle-2.2.0-SNAPSHOT]# cd bin/
     9 [root@CloudGame bin]# ll
    10 total 16
    11 -rwxr--r-- 1 root root 2898 Jan  8 15:04 gatling.bat
    12 -rwxr--r-- 1 root root 1946 Jan  8 15:04 gatling.sh
    13 -rwxr--r-- 1 root root 1992 Jan  8 15:04 recorder.bat
    14 -rwxr--r-- 1 root root 1134 Jan  8 15:04 recorder.sh

    上面加黑的目录,就是我们想要的被解压后的目录,里面有我们期待的内容:

     1 [root@CloudGame gatling-bundle-2.2.0-SNAPSHOT]# ll
     2 total 24
     3 drwxr-xr-x 2 root root  4096 Jan  8 13:26 bin
     4 -rw-r--r-- 1 root root 11367 Jan  8 13:10 LICENSE
     5 drwxr-xr-x 2 root root  4096 Jan  8 13:26 results
     6 drwxr-xr-x 5 root root  4096 Jan  8 13:26 user-files
     7 [root@CloudGame gatling-bundle-2.2.0-SNAPSHOT]# cd bin/
     8 [root@CloudGame bin]# ll
     9 total 16
    10 -rwxr-xr-x 1 root root 2898 Jan  8 13:10 gatling.bat
    11 -rwxr-xr-x 1 root root 1946 Jan  8 13:10 gatling.sh
    12 -rwxr-xr-x 1 root root 1992 Jan  8 13:10 recorder.bat
    13 -rwxr-xr-x 1 root root 1134 Jan  8 13:10 recorder.sh

    到这里,可以说从源码生成gatling的过程结束了!

    在此,我要说明一点就是,2.2.0-SNAPSHOT的版本,比较新,里面有些api是JDK8的,所以,在编译运行的时候,保证你的环境是jdk8哟,否则会出现下面的错误:

     1 [root@CloudGame bin]# ./recorder.sh 
     2 GATLING_HOME is set to /root/.ivy2/local/io.gatling.highcharts/gatling-charts-highcharts-bundle/2.2.0-SNAPSHOT/zips/gatling-charts-highcharts-bundle-2.2.0-SNAPSHOT
     3 Exception in thread "main" java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigRenderOptions : Unsupported major.minor version 52.0
     4     at java.lang.ClassLoader.defineClass1(Native Method)
     5     at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
     6     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
     7     at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
     8     at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
     9     at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    10     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    11     at java.security.AccessController.doPrivileged(Native Method)
    12     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    13     at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    14     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    15     at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    16     at io.gatling.recorder.config.RecorderConfiguration$.<init>(RecorderConfiguration.scala:48)
    17     at io.gatling.recorder.config.RecorderConfiguration$.<clinit>(RecorderConfiguration.scala)
    18     at io.gatling.recorder.GatlingRecorder$.io$gatling$recorder$GatlingRecorder$$initRecorder(GatlingRecorder.scala:37)
    19     at io.gatling.recorder.GatlingRecorder$$anonfun$fromArgs$1.apply(GatlingRecorder.scala:30)
    20     at io.gatling.recorder.GatlingRecorder$$anonfun$fromArgs$1.apply(GatlingRecorder.scala:30)
    21     at scala.Option.map(Option.scala:146)
    22     at io.gatling.recorder.GatlingRecorder$.fromArgs(GatlingRecorder.scala:30)
    23     at io.gatling.recorder.GatlingRecorder$.main(GatlingRecorder.scala:26)
    24     at io.gatling.recorder.GatlingRecorder.main(GatlingRecorder.scala)

    最后,测试一下源码来的工具是否可用,哈哈,看到recorder的启动界面了,如下图,说明一切正常!

    附加一下设置项目的javaHome的命令,即相关的操作!

     1 gatling-parent > set every javaHome := sys.env.get("JAVA_HOME") map file
     2 [info] Defining */*:javaHome
     3 [info] The new value will be used by gatling-app/*:compilers, gatling-app/*:console::compilers and 125 others.
     4 [info]     Run `last` for details.
     5 [info] Reapplying settings...
     6 [info] Set current project to gatling-parent (in build file:/mnt/workwps/gatling2.1.7/gatling/)
     7 gatling-parent > show javaHome
     8 [info] gatling-core/*:javaHome
     9 [info]     Some(/usr/java/jdk1.8.0_65)
    10 [info] gatling-compiler/*:javaHome
    11 [info]     Some(/usr/java/jdk1.8.0_65)
    12 [info] gatling-redis/*:javaHome
    13 [info]     Some(/usr/java/jdk1.8.0_65)
    14 [info] gatling-metrics/*:javaHome
    15 [info]     Some(/usr/java/jdk1.8.0_65)
    16 [info] gatling-commons/*:javaHome
    17 [info]     Some(/usr/java/jdk1.8.0_65)
    18 [info] gatling-recorder/*:javaHome
    19 [info]     Some(/usr/java/jdk1.8.0_65)
    20 [info] gatling-jms/*:javaHome
    21 [info]     Some(/usr/java/jdk1.8.0_65)
    22 [info] gatling-app/*:javaHome
    23 [info]     Some(/usr/java/jdk1.8.0_65)
    24 [info] gatling-test-framework/*:javaHome
    25 [info]     Some(/usr/java/jdk1.8.0_65)
    26 [info] gatling-http/*:javaHome
    27 [info]     Some(/usr/java/jdk1.8.0_65)
    28 [info] gatling-charts/*:javaHome
    29 [info]     Some(/usr/java/jdk1.8.0_65)
    30 [info] gatling-bundle/*:javaHome
    31 [info]     Some(/usr/java/jdk1.8.0_65)
    32 [info] gatling-jdbc/*:javaHome
    33 [info]     Some(/usr/java/jdk1.8.0_65)
    34 [info] gatling-parent/*:javaHome
    35 [info]     Some(/usr/java/jdk1.8.0_65)
    36 gatling-parent > 

    OK,完工!

  • 相关阅读:
    表字段出现oracle sql语句关键字时
    使用decode函数
    PL/SQL DEVELOPER 使用小技巧
    Linux静态IP设置修改配置文件
    在idea上使用maven搭建ssm,数据库为mysql
    作业
    SQL 简单的生成xml
    使用CppUnit
    tinyXml的使用
    NSIS 使用技巧
  • 原文地址:https://www.cnblogs.com/shihuc/p/5113643.html
Copyright © 2011-2022 走看看