Skip to content

Commit

Permalink
Modified logic for adding JMETER_USER_PLUGINS_FOLDER env var
Browse files Browse the repository at this point in the history
Signed-off-by: hiteshwani <[email protected]>
  • Loading branch information
hiteshwani authored and parauliya committed Aug 31, 2023
1 parent fb969da commit a095f73
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
14 changes: 9 additions & 5 deletions contrib/executor/jmeterd/pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func (r *JMeterRunner) Run(ctx context.Context, execution testkube.Execution) (r
// compose parameters passed to JMeter with -J
params := make([]string, 0, len(envManager.Variables))
for _, value := range envManager.Variables {

if value.Name == jmeter_env.MasterOverrideJvmArgs || value.Name == jmeter_env.MasterAdditionalJvmArgs {
//Skip JVM ARGS to be appended in the command
continue
Expand All @@ -115,10 +114,15 @@ func (r *JMeterRunner) Run(ctx context.Context, execution testkube.Execution) (r
runPath = workingDir
}

// The below three lines is required to add support for user plugins required to run the test
pluginPath := filepath.Join(runPath, "plugins")
envManager.Variables["JMETER_USER_PLUGINS_FOLDER"] = testkube.Variable{Name: "JMETER_USER_PLUGINS_FOLDER", Value: pluginPath}
slavesEnvVariables["JMETER_USER_PLUGINS_FOLDER"] = testkube.Variable{Name: "JMETER_USER_PLUGINS_FOLDER", Value: pluginPath}
pluginPath := filepath.Join(filepath.Dir(path), "plugins")
// Set env plugin env variable to set custom plugin directory
// with this path custom plugin will be copied to jmeter's plugin directory
err = os.Setenv("JMETER_USER_PLUGINS_FOLDER", pluginPath)
if err != nil {
output.PrintLogf("%s Failed to set user plugin directory %s", ui.IconWarning, pluginPath)
}
// Add user plugins folder in slaves env variables
slavesEnvVariables["JMETER_USER_PLUGINS_FOLDER"] = testkube.NewBasicVariable("JMETER_USER_PLUGINS_FOLDER", pluginPath)

outputDir := filepath.Join(runPath, "output")
// clean output directory it already exists, only useful for local development
Expand Down
8 changes: 5 additions & 3 deletions contrib/executor/jmeterd/scripts/jmeter-master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ else
fi
echo



if [ -d $JMETER_USER_PLUGINS_FOLDER ]
then
echo "Installing custom plugins from ${JMETER_USER_PLUGINS_FOLDER}"
echo "Installing user plugins from ${JMETER_USER_PLUGINS_FOLDER}"
for plugin in ${JMETER_USER_PLUGINS_FOLDER}/*.jar; do
echo "Copying plugin $plugin to ${JMETER_HOME}/lib/ext/${plugin}"
echo "Copying plugin $plugin to ${JMETER_HOME}/lib/ext/"
cp $plugin ${JMETER_HOME}/lib/ext
done;
else
echo "No custom plugins found in ${JMETER_USER_PLUGINS_FOLDER}"
echo "No user plugins found in ${JMETER_USER_PLUGINS_FOLDER}"
fi
echo

Expand Down
6 changes: 3 additions & 3 deletions contrib/executor/jmeterd/scripts/jmeter-slaves.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ echo

if [ -d $JMETER_USER_PLUGINS_FOLDER ]
then
echo "Installing custom plugins from ${JMETER_USER_PLUGINS_FOLDER}"
echo "Installing user plugins from ${JMETER_USER_PLUGINS_FOLDER}"
for plugin in ${JMETER_USER_PLUGINS_FOLDER}/*.jar; do
echo "Copying plugin $plugin to ${JMETER_HOME}/lib/ext/${plugin}"
echo "Copying plugin $plugin to ${JMETER_HOME}/lib/ext/"
cp $plugin ${JMETER_HOME}/lib/ext
done;
else
echo "No custom plugins found in ${JMETER_USER_PLUGINS_FOLDER}"
echo "No user plugins found in ${JMETER_USER_PLUGINS_FOLDER}"
fi
echo

Expand Down

0 comments on commit a095f73

Please sign in to comment.