JMeter Functions are not evaluating while running JMX files using Java - jmeter

I am running the JMeter Scripts (.jmx files) using Java code. But it doesn's evaluate any of the JMeter Functions. I have tried multiple approaches and nothing worked.
In the logs, i could see the JMeter Functions are not evaluated. Functions like ${__property()}, {__TestPlanName()}, ${__threadNum}, ${__javaScript()} are not executed.

Did you add ApacheJMeter_functions.jar to your classpath ?
If not , please do.
Otherwise, show more about your project.

Related

taurus tests running out of order?

I am new to taurus testing. I have a set of tests inside of a taurus project.
Within the scenario 1300_Azuresubscriptions.yaml I have the following list of labels:
0100-Authorization
1300_ListAzureSubscriptions
1310_CreateAzureSubscriptions
1320_UpdateAzureSubscriptions
1330_FetchAzureSubscription
1340_CreateAVWGateway
1341_CreateVirtualWanSite
1342_ListVirtualWanSites
1343_UpdateVirtualWanSite
1344_FetchVirtualWanSite
1345_DeleteVirtualWanSite
1346_DeleteAVWGateway
1350_DeleteAzureSubscription
1351_ListADSubscription
1352_CreateAzureSubscriptions
1353_FetchADSubscription
1354_ValidateADSubscriptions
1355_GetADGroups
1356_ADSyncConfigurations
1357_ADSync
1358_CheckADCLientCreation
1359_DeleteADSubscription
1360_CheckADCLientDeletion
1361_ListAzureSubscriptionsWithInvalidAuthHeader
1362_ListAzureSubscriptionsWithNoAuthHeader
1363_CreateAzureSubscriptionsWithInvalidAuthHeader
1364_CreateAzureSubscriptionsWithNoAuthHeader
1365_UpdateAzureSubscriptionsWithInvalidAuthHeader
1366_UpdateAzureSubscriptionsWithNoAuthHeader
1367_FetchAzureSubscriptionWithInvalidAuthHeader
1368_FetchAzureSubscriptionWithNoAuthHeader
1369_CreateAVWGatewayWithInvalidAuthHeader
1370_CreateAVWGatewayWithNoAuthHeader
However when I run bzt test-cases/1300_AzureSubscriptions.yaml, only the following list of labels are actually getting tested:
0100-Authorization
1300_ListAzureSubscriptions
1310_CreateAzureSubscriptions
1320_UpdateAzureSubscriptions
1330_FetchAzureSubscription
1340_CreateAVWGateway
1341_CreateVirtualWanSite
1342_ListVirtualWanSites
1343_UpdateVirtualWanSite
1344_FetchVirtualWanSite
1345_DeleteVirtualWanSite
1346_DeleteAVWGateway
1350_DeleteAzureSubscription
1351_ListADSubscription
1352_CreateAzureSubscriptions
1353_FetchADSubscription
1354_ValidateADSubscriptions
1355_GetADGroups
1356_ADSyncConfigurations
1357_ADSync
1358_CheckADCLientCreation
1359_DeleteADSubscription
1363_CreateAzureSubscriptionsWithInvalidAuthHeader
1364_CreateAzureSubscriptionsWithNoAuthHeader
1365_UpdateAzureSubscriptionsWithInvalidAuthHeader
1366_UpdateAzureSubscriptionsWithNoAuthHeader
1367_FetchAzureSubscriptionWithInvalidAuthHeader
1368_FetchAzureSubscriptionWithNoAuthHeader
1369_CreateAVWGatewayWithInvalidAuthHeader
1370_CreateAVWGatewayWithNoAuthHeader
Why isn't it running the labels 1360-1362? I don't understand the problem. Any help would be greatly appreciated. Thanks!
Taurus is just a wrapper for underlying load and functional testing tools, if something is not executed there could be various reasons for this, for example:
The particular request is not enabled in YAML configuration file
The underlying test executor is failing on attempt to run the particular request
There is a lack of test data for the requests
Check out bzt.log file and any logs generated by the underlying tool. By default Taurus uses JMeter executor so if it's your case the reason could be found in jmeter.log file (it also worth checking jmeter.out and jmeter.err for any suspicious entries)
More information: Navigating your First Steps Using Taurus
You can also reach out to Taurus developers, maintainers and users at Taurus support forum
The issue was the indentation in the yaml. I would recommend that if you're running these tests you'd better install a linter to check your yaml formatting. One tab off and the error is invisible. It just ignores the tests.

JMeter Beanshell listner script sometimes get ignore in non-GUI mode

I created JMeter Test and under first "HTTP Request" I created a Beanshell listner script which works fine when using GUI but 8 out of 10 times the script totally get ignored in non-GUI mode.
I am also running these test in Gitlab CI using Docker Image "justb4/jmeter:latest" and Beanshell script also get ignored there. I don't know whats wrong there it is working fine with GUI
There is no such thing as "get ignored" in JMeter world, it either passes or fails, in case of failure you should see the relevant message(s) in the jmeter.log file
Also be aware that you should not be using Beanshell at all, starting from JMeter 3.1 you should be using JSR223 Listener and Groovy language for scripting, one of Beanshell's disadvantages is that it's being interpreted each time while Groovy scripts can be compiled and cached providing the most optimal performance. See Apache Groovy - Why and How You Should Use It article for more details.
Also be informed that we cannot efficiently help without seeing your code and the aforementioned jmeter.log file.

Exception: java.lang.ClassCastException: com.blazemeter.jmeter.threads.DynamicThread cannot be cast to org.apache.jmeter.samplers.SampleResult

I am currently using Blazemeter to run load (performance) tests for a Java application, but I am getting this error. When I run it locally on my machine, this error does not occur.
Under 'scenario definition' my test starts off with a standard jmeter thread group. I did a bit of searching and realised that com.blazemeter.jmeter.threads.DynamicThread comes from the CustomThreadGroups plugin, so I have also uploaded the appropriate jar file plugin jmeter-plugins-casutg-2.9.jar file.
Screenshot of scenario definition
Screenshot of error
Would just like to check if there is some other jar file that I need to upload to solve this error, or if there is another method to solve this issue? Thank you.
Normally you should raise this form of questions to BlazeMeter Support as they should have better understanding of their infrastructure.
With regards to your question itself, most probably you're suffering from a form of a Jar Hell as:
BlazeMeter uses Taurus under the hood for kicking off JMeter tests which automatically downloads JMeter Plugins so it might be the case your plugins versions clash with the plugins at their end
You need to remove one of joda-time libraries as you cannot tell for sure which one will be loaded into classpath and in case of API inconsistency you can get unpredictable errors.

Jmeter Cross-Platform Path config issue

I am working on master-slave Jmeter configuration, my data set exist on each machine on a different path for (macOS, Windows).
I use a global data set to fetch data for multiple thread groups.
However, the variable/property can be different across platforms.
I also tried the JSR223 to check the, but still no luck. check out the below snapshot.
I am trying to make sure that once I ran my test from Master (Mac), it also run on Windows.
Any thoughts how to do that on multiple platform setup.
The best solution is placing your test data under the same path which will be relative to JMeter working directory, this way you will not have to change anything in your script.
If for some reason you cannot afford this you can add a JSR223 Sampler to your Test Plan and use the code like:
if (org.apache.commons.lang3.StringUtils.containsIgnoreCase(System.getProperty('os.name'), 'Windows')) {
vars.put('data-path', 'c:/windows/specific/path')
} else {
vars.put('data-path', '/macos/specific/path')
}
It will detect the operating system name in the runtime and you will be able to define an OS-specific paths using the above approach.
vars is a shorthand for JMeterVariables class instance, the above code defines ${data-path} JMeter Variable which you can use later on for specifying data files locations. See Top 8 JMeter Java Classes You Should Be Using with Groovy to learn more about JMeter API shortcuts exposed to JSR223 Test Elements

JMeterTest and JMeterTestManager dependencies

I am trying to exeucte a .jmx file through the java class, but JMeterTest and JMeterTestManager are not getting imported.
JMeter, as per my knowledge is itself a bundle of jar.
can anyone tell me if i need dependency(ies) for these two or not, iif yes the please do provide.
Thanks in advance.
As far as I can see you need to include org.wso2.carbon.automation.extensions to your project as these classes don't come with JMeter API
Check out Five Ways To Launch a JMeter Test without Using the JMeter GUI guide to get started with creating a JMeter test purely in Java. You can also use jmeter-from-code project as a reference

Resources