1

I am somewhat new to using docker and the author mentioned that it is possible to run karate-gatling tests using docker for running distributed tests: https://github.com/intuit/karate/wiki/Distributed-Testing#gatling Can anyone provide me an example that I can use to do this or direct me to github repo if someone already tried this? The karate author provided a nice example to run web ui tests using docker so I am looking for something similar to this: https://github.com/intuit/karate/tree/master/examples/jobserver

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
dk8080
  • 11
  • 2

1 Answers1

0

This is actually part of the examples/gatling sample project, and look at the GatlingDockerJobRunner unit test.

I will edit the wiki to make this more clear. Yes, this may not be the best example, please please try it out and we will be happy to incorporate any changes you suggest.

EDIT: more info at this ticket: https://github.com/intuit/karate/issues/1220

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • You mentioned in the wiki like this: "You should be able to use the same approach to "scale-out" across multiple hardware nodes.Just start multiple JobExecutor-s once the server jobUrl is known" I have like 2 Windows VMs that I installed docker on so how can I use them to run the tests like can you give example using JobExectutor-s and how to call them in this main() method: https://github.com/intuit/karate/blob/develop/examples/gatling/src/test/java/jobtest/GatlingDockerJobRunner.java – dk8080 Jul 09 '20 at 16:53
  • @dk8080 this is REALLY hard to explain if you are new to Docker. I'll just say this. the jenkins section has an example on how to start the docker container and pass the JobUrl: https://github.com/intuit/karate/wiki/Distributed-Testing#jenkins-config - the rest is up to you. – Peter Thomas Jul 09 '20 at 16:56
  • I was able to run the test locally in docker using the GatlingDockerJobRunner but at the end I get this warning related to JobServerHandler `19:32:41.649 [nioEventLoopGroup-3-2] WARN i.n.k.channel.DefaultChannelPipeline - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.` The reports are generated in two folders i.e. 1 and 2 but they are not unzipped and then combined to one aggregate report. – dk8080 Jul 10 '20 at 00:37
  • This error message shows up `java.lang.RuntimeException: java.io.FileNotFoundException: target\1594341059681\1\1\ (The system cannot find the path specified) at com.intuit.karate.job.JobUtils.unzip(JobUtils.java:113)` When I checked the zip file was in the target\1594341059681\1\. Why it is checking in another level i.e. 1\1 could be bug in the code – dk8080 Jul 10 '20 at 00:41
  • @dk8080 absolutely could be a bug in the code. do you think you can fix it and submit a PR ? the docs do say that this is experimental. – Peter Thomas Jul 10 '20 at 02:12
  • I am not a java engineer but I think the path need to be changed here: `protected void handleUpload(byte[] bytes, String executorId, String chunkId) { String chunkBasePath = basePath + File.separator + executorId + File.separator + chunkId; File zipFile = new File(chunkBasePath + ".zip"); FileUtils.writeToFile(zipFile, bytes); File upload = new File(chunkBasePath); JobUtils.unzip(zipFile, upload); handleUpload(upload, executorId, chunkId); }` I think the zip file is not placed in the right path for the JobUtils.unzip method to find it – dk8080 Jul 10 '20 at 16:04
  • follow this process please: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Jul 10 '20 at 16:16
  • I think I am not running the test in the right way using the mvn command how can I run the GatlingDockerJobRunner.java. In the examples-gatling you have given pom.xml. So how can I modify that so that it runs the above java main method. In the instructions you provided(https://github.com/intuit/karate/tree/develop/examples/gatling#instructions) you mentioned to do mvn clean test so would this command work for distributed mode too or what I should I change in the pom.xml and what mvn command I need to run? – dk8080 Jul 13 '20 at 23:04
  • mvn clean test -Dtest=GatlingDockerJobRunner – Peter Thomas Jul 14 '20 at 02:27
  • [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project examples-gatling: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project examples-gatling: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) – dk8080 Jul 15 '20 at 16:17
  • @dk8080 that does it, I give up. unless you are willing to dig into the code and fix it - or get help from someone who knows maven + docker, kindly assume that this feature is not production ready. all the best – Peter Thomas Jul 15 '20 at 16:35
  • I think I need to change the pom.xml to use the right plugin to run the java main() method. I just used your example i.e. pom.xml you provided on the karate-gatling examples on github. I am just curious on how you were able to run the test on mac as you mentioned here: https://github.com/intuit/karate/wiki/Distributed-Testing#gatling. Better documentation would be nice for anyone to get started since I am trying to demo running distributed test using karate-gatling to my team here and I was able to successfully demo running karate-gatling test standalone using your example – dk8080 Jul 15 '20 at 20:16
  • If I just take your example i.e. https://github.com/intuit/karate/tree/develop/examples/gatling and run mvn clean test it only runs the mock.CatsKarateSimulation. Question is what do I update in the pom.xml to run the GatlingDockerJobRunner using your example ? – dk8080 Jul 15 '20 at 21:13
  • 1
    I figured out after reading more about using maven and I was able to run your example using this: `mvn exec:java -Dexec.mainClass="jobtest.GatlingDockerJobRunner" -Dexec.classpathScope="test"` but I am getting the same error i.e. the bug I mentioned above with unzip(see comments above) so I submitted a bug in karate with more details - https://github.com/intuit/karate/issues/1220 – dk8080 Jul 15 '20 at 22:18
  • I was able to run this successfully on a mac btw @peter-thomas so the issue is with windows handling unzip – dk8080 Jul 16 '20 at 15:47