{"id":3304,"date":"2019-12-15T10:49:11","date_gmt":"2019-12-15T10:49:11","guid":{"rendered":"https:\/\/blog.paranoidprofessor.com\/?p=3304"},"modified":"2019-12-15T22:01:17","modified_gmt":"2019-12-15T22:01:17","slug":"running-a-gatling-test-script","status":"publish","type":"post","link":"https:\/\/blog.paranoidprofessor.com\/index.php\/2019\/12\/15\/running-a-gatling-test-script\/","title":{"rendered":"Running a Gatling test script"},"content":{"rendered":"\n<p>If\nyou create a test script using the recorder or even if you use your\nfavorite editor the scala test code will need to be stored in the\nsimulations directory (ie %gatling_home%\\user-files\\simulations). \nThe gatling.bat script (ie %gatling_home%\\bin) will look in this\ndirectory to compile all classes so you can run your test.  If the\ngatling.bat script is run without any parameters then Gatling will\ndisplay a list of tests that have been compiled and are available to\nbe run.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> Example\n Choose a simulation number:\n      [0] RecordedSimulation\n      [1] gapiv5\n      [2] bigfootv13\n      [3] gpv10 <\/pre>\n\n\n\n<p>This is a list of the available \u201cclasses\u201d, one for each test.  Just like with Java each class name of each object must be unique.  The class in the recorded example is called \u201cRecordedSimulation\u201d.  This actually matches the name of the file that we saw in the recorder dialog.  Simply press the number 0 (in this case) to run our recorded simulation.  <\/p>\n\n\n\n<p>Gatling test scripts are actually small command line programs that once compiled are run with all of the output going to the terminal screen.  Below is the output from running our recorded simulation.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> Choose a simulation number:\n      [0] RecordedSimulation\n      [1] gapiv5\n      [2] bigfootv13\n      [3] gpv10\n 0\n Select run description (optional)\n my first script\n Simulation RecordedSimulation started...\n \n \n =================================================================\n 2019-11-07 14:30:27                            5s elapsed\n ---- Requests ---------------------------------------------------\n > Global                                    (OK=1      KO=0     )\n > search asrock                             (OK=1      KO=0     )\n \n \n ---- RecordedSimulation -----------------------------------------\n [---------------------------------------------------------------]  0%\n           waiting: 0      \/ active: 1      \/ done: 0\n ==================================================================\n \n==================================================================\n 2019-11-07 14:30:33                           11s elapsed\n ---- Requests ---------------------------------------------------\n > Global                                    (OK=5      KO=0     )\n > search asrock                             (OK=1      KO=0     )\n > search mac                                (OK=1      KO=0     )\n > fetch computer                            (OK=1      KO=0     )\n > update computer                           (OK=1      KO=0     )\n > update computer Redirect 1                (OK=1      KO=0     )\n \n \n ---- RecordedSimulation -----------------------------------------\n [###########################################################]100%\n           waiting: 0      \/ active: 0      \/ done: 1\n ==================================================================\n \n \n Simulation RecordedSimulation completed in 11 seconds\n Parsing log file(s)...\n Parsing log file(s) done\n Generating reports...\n \n \n ==================================================================\n ---- Global Information -----------------------------------------\n > request count                           5 (OK=5      KO=0     )\n > min response time                     176 (OK=176    KO=-     )\n > max response time                    3069 (OK=3069   KO=-     )\n > mean response time                    815 (OK=815    KO=-     )\n > std deviation                        1130 (OK=1130   KO=-     )\n > response time 50th percentile         240 (OK=240    KO=-     )\n > response time 75th percentile         400 (OK=400    KO=-     )\n > response time 95th percentile        2535 (OK=2535   KO=-     )\n > response time 99th percentile        2962 (OK=2962   KO=-     )\n > mean requests\/sec                   0.417 (OK=0.417  KO=-     )\n ---- Response Time Distribution ---------------------------------\n > t &lt; 800 ms                              4 ( 80%)\n > 800 ms &lt; t &lt; 1200 ms                    0 (  0%)\n > t > 1200 ms                             1 ( 20%)\n > failed                                  0 (  0%)\n ==================================================================\n\n Reports generated in 1s.\n Please open the following file: C:\\Users\\chris\\gatling-charts-highcharts-bundle-3.3.0\\results\\recordedsimulation-20191107133020038\\index.html <\/pre>\n\n\n\n<p>This output actually does tell us some information about our test.  Because some meaningful comments were inserted into our test script.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>  .exec(http(&#8220;search mac&#8221;) <\/p><\/blockquote>\n\n\n\n<p>We can see those meaningful names as the script progresses.  At the end of the output we can see that there was four calls that were processed in less than 800 milliseconds while a fifth call took longer than 1200 milliseconds.  We can also see that there were no failures.   <\/p>\n\n\n\n<p>Despite the fact that this output does indeed tell us about how the run went it is actually much easier to look at the html page that we created to see a graphical representation of our script.  The last line of the run output gives us the path to the index.html file which has been generated.  If we view that html file with our web browser we will see something similar to the following.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"769\" src=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/12\/gatling-report-1024x769.png\" alt=\"\" class=\"wp-image-3305\" srcset=\"https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/12\/gatling-report-1024x769.png 1024w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/12\/gatling-report-300x225.png 300w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/12\/gatling-report-768x577.png 768w, https:\/\/blog.paranoidprofessor.com\/wp-content\/uploads\/2019\/12\/gatling-report.png 1148w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Gatling generated report<\/figcaption><\/figure>\n\n\n\n<p>This\nimage is just part of the web page that is created but it does\ncontain all of the statistics.  We can see which of our calls\nsucceeded and how long it took (min, max and average).  In this case\nall of our numbers are the same but if we did run this script\nmultiple times we would be able to see how many were in the 50, 75<sup>th<\/sup>\nand 95<sup>th<\/sup>\npercentiles.<\/p>\n\n\n\n<p>Each\none of our steps only perform one task so there is little reason to\nlook much deeper but if each of these performed more than one call or\nloaded some important resources we could get a better look at the\ntimes by examining the details of each one of these steps.<\/p>\n\n\n\n<p>If\nwe look in the upper right hand corner of the picture we can see the\nname of the class, the runtime and the description that we gave when\nrunning it (ie my first run script)<\/p>\n\n\n\n<p>Our script was generated by the recorder as pure Scala code.  In my next blog I will clarify a bit of the Scala syntax.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you create a test script using the recorder or even if you use your favorite editor the scala test code will need to be stored in the simulations directory (ie %gatling_home%\\user-files\\simulations). The gatling.bat script (ie %gatling_home%\\bin) will look in &hellip; <a href=\"https:\/\/blog.paranoidprofessor.com\/index.php\/2019\/12\/15\/running-a-gatling-test-script\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[106],"_links":{"self":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/3304"}],"collection":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/comments?post=3304"}],"version-history":[{"count":2,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/3304\/revisions"}],"predecessor-version":[{"id":3316,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/posts\/3304\/revisions\/3316"}],"wp:attachment":[{"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/media?parent=3304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/categories?post=3304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.paranoidprofessor.com\/index.php\/wp-json\/wp\/v2\/tags?post=3304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}