Build executable JAR for Gatling load test

后端 未结 6 1131
感动是毒
感动是毒 2020-12-30 02:01

I am new to Gatling (2.1.2) and want to do a small prototype project to show to my colleagues.

According to the quick start page, there are several ways I can run a

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 02:53

    I had a similar issue, I fixed it as following:

    Inside Gatling package there is bin/ and take a look at gatling.sh. You see that it simply adds certain configurations into classpath and then runs io.gatling.app.Gatling class in gatling-compiler-.jar. So, all you need to do is to make a jar that includes compiler, add configurations and tests to classpath and run io.gatling.app.Gatling. steps:

    add compiler dependency:

    
            io.gatling
            gatling-compiler
            ${gatling.version}
        

    create jar with dependencies:

      
                org.apache.maven.plugins
                maven-assembly-plugin
                2.4.1
                
                    
                        jar-with-dependencies
                    
                    ${project.build.finalName}
                
                
                    
                        package
                        
                            single
                        
                    
                
            
    

    create test jar (this includes your gatling tests)

     
                org.apache.maven.plugins
                maven-jar-plugin
                2.4
                
                    
                        
                            test-jar
                        
                        
                            
                                src/test/resources/*
                            
                            ${project.build.finalName}
                        
                    
                
            
    

    create a package out of your configuration. You can use maven assembly for that. What I usually do, is to create a separate module that handles creating the package for different environments. This package contains your gatling.conf, logback.xmland all the other resources you application wants including test data. Now you basically have three packages: application.jar, application-tests.jar and application-conf.zip. Unzip application-conf.zip, copy application.jarand application-tests.jarin the same folder.

    In this folder, You need to create target/test-classes/ folder, just leave it empty. In my case, it was required. I think you can some how change that in gatling.conf. But I am not sure how.

    Run

    java -cp ".:application-test.jar:application.jar" io.gatling.app.Gatling  
    

提交回复
热议问题