Executing Jmeter script using TestNG does not execute JMX script under Include controllers - jmeter

We are using TestNG framework to run JMeter script. Our Jmeter script includes few include controllers. When we execute using JMeter UI, the script gets executed successfully. But when script is executed using TestNG frame work either it throws error like path not found (for relative coded path) or include controller step is skipped (for Hard coded path)
Tried with Hard coded path as well as relative path to include the other test fragment
Relative Path for JMX file in include controller: "../../../lib/SM_TestFragments/XML/clearDBTables.jmx"
Absolute Path for JMX file in include controller: "/home/test/REMS_CI_Test/AutomationHome/lib/SM_TestFragments/XML/clearDBTables.jmx"
When include controller have "../../../lib/SM_TestFragments/XML/clearDBTables.jmx" path, it throws error as:
09:27:19.603 [StandardJMeterEngine] ERROR org.apache.jmeter.control.IncludeController - Include Controller 'Include Controller' can't load '../../../lib/SM_TestFragments/XML/clearDBTables.jmx' - see log for details
09:27:19.623 [StandardJMeterEngine] ERROR org.apache.jmeter.util.JMeterUtils - Including file "../../../lib/SM_TestFragments/XML/clearDBTables.jmx" failed for Include Controller "Include Controller", unexpected error - see log for details
Including file "../../../lib/SM_TestFragments/XML/clearDBTables.jmx" failed for Include Controller "Include Controller", unexpected error - see log for details
When include controller have "/home/test/REMS_CI_Test/AutomationHome/lib/SM_TestFragments/XML/clearDBTables.jmx" path, There is no entry in log. The step is skipped.

Consider checking jmeter.log file, it should contain more information regarding what went wrong.
One of possible reasons I can think of is that the .jmx script you're referencing using hte Include Controller has one or more JMeter Plugins and when you run the test using TestNG the plugin(s) is(are) not in Java Classpath
If you don't have jmeter.log file generated as the result of your test run consider setting log4j.configurationFile property pointing to the log4j2.xml file location

Related

How to read a resource file in bazel test?

I am migrating some integration tests from gradle to bazel for an application. As part of the integration test a resource is loaded like
final String resourcePath = SomeClass.class.getResource("/test.properties").getPath()
If I trace this code path, when I run this test from IntelliJ, for gradle, this path is an absolute path like
/Users/me/..../test.properties
However, in the case of bazel, it looks something like
file:/private/var/tmp/_bazel_me/4f1994ece960b360388a372b5e6aa4b2/execroot/project/bazel-out/darwin-fastbuild/bin/project/src/integrationTest/package/Test.jar!/test.properties
So this string resourcePath is provided to a framework that loads with
Files.exists(resourcePath)
This works for the absolute path but not for the jar based path. How do I get around this since I don't have any control over the framework code?
If you're using the resources attribute of java_test or java_library, then indeed the resources are packaged inside the jar for that target:
https://docs.bazel.build/versions/main/be/java.html#java_test.resources
It sounds like you might want to try the data attribute instead, which puts files in the runfiles directory (i.e., the directory where the test / binary is executed). See the answer here: how to find path to Java source code files from JUnit tests execution via Bazel

last block in decryption when running the jar file in jmeter

I am running my jmeter script.Inside one sampler,i have http request in that sampler's JSR223 Postprocess I run the main method from executable jar file(I convert my java code into runnable jar file and imported this jar file in the jmeter Testplan).When running this postprocessor i face the error "last block incomplete in decryption".But when i run this jar file in cmd or when running the java code in eclipse,everything works fine.
I can only think of different code page for "cmd" and "JSR223"
In general relying on the current operating system code page is not recommended, you should explicitly set the encoding while doing encryption/decryption and specify the charset to use (UTF-8 is a good choice)
If you don't have the possibility to amend the code in the "executable .jar" you can set file.encoding property in JMeter's system.properties file or pass it via -D command-line argument
jmeter -Dfile.encoding=UTF-8 ......
If you don't have the possibility to amend JMeter properties as well you can simulate running the "executble .jar" from "cmd" using OS Process Sampler, something like:

java.io.FileNotFoundException With jmeter testplan while running it from Jenkins-Maven build

I am using File Upload (Post) Rest API in jmeter. file Path in the file upload section I have given as "File name" directly as its in the same folder where jmx file is.
Its working fine in jmeter ui but when running it through Jenkins I am getting file not found Exception.
how ever I am not sure whether I need to update anything in POM file or my jmx file it self to make jenkins find file path.
Current Scenario Jmeter:
jmx file location: xyz/test.jmx
Fie upload location: xyz/abc.file
file path in Jmeter UI(HTTP POST request): abc.file
Result: Working Fine
Current Scenario Jenkins:
jmx file location: xyz/src/test/jmeter/test.jmx
Fie upload location: xyz/src/test/jmeter/abc.file
file path in Jmeter UI(HTTP POST request): abc.file
Result: getting file not found exception
please suggest me solution if any I have already checked many blogs/answers. but none of them result my situation.
Thanks,
Divyang Raval
I believe when JMeter is being run from Maven it tries to look for files under the following folder:
target\jmeter\bin
So the options are in:
use full path instead of relative
copy the file from its original location to target\jmeter\bin folder using i.e. OS Process Sampler from setUp Thread Group
given you don't execute mvn clean copy the file to target\jmeter\bin folder once
The best solution would be using Jenkins Parameterisation, i.e. pass WORKSPACE Jenkins Variable property value to Maven build and access it in JMeter via __P() function

How to use RCPTT Folder Context in Maven?

Let me know about how to mavinize Folder Context in RCPTT!
FYI: I have created a folder context (my_folder_context.ctx referring to a remote folder). First I click "Apply" button after opening the .ctx file in RCPTT tool to copy the contents to AUT location than execute the test cases to get the test data.
But while automating the same I don't find any entry for *.ctx file in RCPTT-maven-plugin. For suites we have below:
<suites>
<suite>MyTestSuite</suite>
</suites>
...but the same I didn't find for *.ctx files or any way to refer the folder context from ECL script .
Yes the short answer is this is NOT possible as the foldercontext is obviously not a testcase. You can only add the test case inside test suit.And it does not make any sense to execute a foldercontext file which is not doing any thing and no result or report can be generated out of it.
By the way let me share few of my learning here:
1)Folder context can be used while recording time in rcptt but runtime it's of no use. Basically it's like a mapped directory for a remote location available inside your rcptt tool.
2)I had provided the test data location at runtime and the same I achieved through below:
Go to RCPTT->Run configurations ->VM Arguments append -D"testdatalocation" (without double quote) and provide below
in ECL script :
set-dialog-result Folder [substitute-variables "${system_property:testdatalocation}"]
or in your maven pom.xml file :
<vmArgs>
<vmArg>-Dtestdatalocation=D:\InputsForAutomation</vmArg>
</vmArgs>

Create multiple jmeter.log files

I am using Jmeter for performance testing and running our tests via Jenkins build server.
We have Jmeter installed on our jenkins box and I am using an Ant build file to launch the jmx file and create the jtl report; which is then evaluated via the Performance plugin in Jenkins.
My problem is that we only have one instance of Jmeter and as such it only creates one jmeter.log file in the /bin directory.
As we will have multiple jobs calling the one Jmeter installation I don't want it, potentially, writing to the same log.
Is there a way of specifying multiple jmeter.log files per plan/job or amending the location?
Thanks for your suggestions. Using a Jmeter Ant Task and have managed to place the log file into the workspace of the jenkins job by the following:
jmeterlogfile="${basedir}/jmeter.log"
This sits within the JMeter tags within the build file.
Without changing .properties file, running jmeter from Windows cmd, simply navigate to bin folder and pass the argument -j[yourLogFileName.log], if you want log entries in a different log file.
C:\apache-jmeter-2.11\bin>jmeter.bat -j myLog.log

Resources