Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin is not passing "-D" args from Gradle to the JVM running Jmeter? #55

Open
djangofan opened this issue Jun 29, 2015 · 11 comments
Open

Comments

@djangofan
Copy link

What appears to me happening for me is that the jmeter-gradle-plugin is not passing "-D" args that were passed to Gradle on the command line to the JVM running Jmeter. I believe this should work since the 'maven-jmeter-plugin' has this behavior. It appears that this jmeter-gradle-plugin is somehow filtering out the args? I created an example project which I think demonstrates this problem.

https://github.com/djangofan/JmeterExample-withGradle

In this project I run with this command:
gradlew.bat printBuildScriptClasspath jmeterCleanReport jmeterRun -Penv=dev -DuserThreads=2 -DrampupSeconds=10 -DthreadLoops=1 -DtestInt=999 -DtestString=BlahBlah

And I am expecting to look at the report and see a 'testInt' value of '999' but if you run this project yourself, you will see that the system property does not seem to pass through to Jmeter at all and it assumes a default value instead.

If the intention was to only allow '-P' args and then forward them to the Jmeter process via the 'jmeterUserProperties' argument, I could accept that but I DO NOT know the format of what the key-val args need to look like when passed as 'jmeterUserProperties' .

@foragerr
Copy link
Contributor

Can you try -J as well please?

ref: http://jmeter.apache.org/usermanual/get-started.html#override

@djangofan
Copy link
Author

Yes, I tried it. Gradle complains that "-J" is not a valid argument format. So, it needs to be in the form of "-D" arg evidently, from the point of view of Gradle (not Jmeter of course).

@foragerr
Copy link
Contributor

From a quick look, it seems like a very small subset of system properties are picked up explicitly. That might need to change to pick up all system properties.

specs.getSystemProperties().put("search_paths", System.getProperty("search_paths"));
specs.getSystemProperties().put("saveservice_properties", System.getProperty("saveservice_properties"));
specs.getSystemProperties().put("upgrade_properties", System.getProperty("upgrade_properties"));
specs.getSystemProperties().put("log_file", System.getProperty("log_file"));

From here

As a possible workaround, what happens if you add the following text to the file specified in jmeterUserProperties?

userThreads=2 
rampupSeconds=10 
threadLoops=1 
testInt=999 
testString=BlahBlah

@djangofan
Copy link
Author

Yes, adding the props to a properties file does work but I didn't say that was a problem. I need to parameterize these tests from Jenkins, which requires system properties, preferrably passed as "-D" args. I'll have to keep using Maven until I figure this out. If I knew what format that env key-val pairs could be passed to 'jmeterUserProperties' then that would be a good workaround (by passing a -P arg and then have Gradle set the jmeterUserProperties variable) but the documentation on that is non-existent and my best guesses didn't work. Also, I couldn't find where the code even reads in that value, as if it were not ever implemented?

@foragerr
Copy link
Contributor

I think I get what you're asking now - also saw your wiki edit. Sorry, I'm a bit slow today. The relevant code is here:

protected void initUserProperties(List<String> jmeterArgs) {
    if (jmeterUserProperties != null) {
        jmeterUserProperties.each {property -> jmeterArgs.add("-J" + property)}
    }
}

Link

looks like it expects a List of strings, which are then added as -JstringHere. So I would try adding:

jmeterUserProperties= ["userThreads=2", 
        "rampupSeconds=10",
        "threadLoops=1",
        "testInt=999",
        "testString=BlahBlah"]

@djangofan
Copy link
Author

Thanks "foragerr". That worked as a great workaround. I'll update my Git project. It works now. I can't pass "-D" args but I sure can parse "-P" args and then set them on the 'jmeterUserProperties' variable.

For example:
jmeterUserProperties << "userThreads=" + project.property('userThreads')

@foragerr
Copy link
Contributor

foragerr commented Jul 1, 2015

Happy that works, but that is one ugly workaround. Definitely need to pick up all -D arguments and pass them to the jmeter execute call. Will take a look at this.

@djangofan
Copy link
Author

Yes, it's critical to get all the "-D" args because if you use Jenkins and if you want to parameterize the job, then using -P wont work. Parameterized builds pass only "-D" args.

@lourish
Copy link

lourish commented Nov 6, 2015

Did anything happen with this? I've got to pass JVM parameters to jmeter (to set up a keystore) and I see no way to pass them either by -D or in gradle

@foragerr
Copy link
Contributor

foragerr commented Nov 6, 2015

Hi @lourish I maintain a fork of this project over here. If you're willing to use that plugin, I'm happy to help you out over there. Please raise a new issue for that project.

If you prefer to use this version of the plugin, does the workaround posted above not work for you?

@lourish
Copy link

lourish commented Nov 9, 2015

Thanks foragerr, this workaround allows you to set jmeter properties but I need to pass properties to the underlying JVM (see http://jmeter.apache.org/usermanual/component_reference.html#Keystore_Configuration). I'm happy to use the other plugin and will raise an issue. Is this kulya plugin dead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants