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

Support for user provided plugins #2

Merged
merged 8 commits into from
Aug 31, 2023
13 changes: 11 additions & 2 deletions contrib/executor/jmeterd/pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/pkg/errors"

"github.com/kubeshop/testkube/contrib/executor/jmeterd/pkg/jmeter_env"
"github.com/kubeshop/testkube/contrib/executor/jmeter/pkg/parser"
"github.com/kubeshop/testkube/contrib/executor/jmeterd/pkg/jmeter_env"
"github.com/kubeshop/testkube/contrib/executor/jmeterd/pkg/slaves"
"github.com/kubeshop/testkube/pkg/api/v1/testkube"
"github.com/kubeshop/testkube/pkg/envs"
Expand Down 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,6 +114,16 @@ func (r *JMeterRunner) Run(ctx context.Context, execution testkube.Execution) (r
runPath = workingDir
}

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
_, err = os.Stat(outputDir)
Expand Down
15 changes: 15 additions & 0 deletions contrib/executor/jmeterd/scripts/jmeter-master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ else
fi
echo



if [ -d $JMETER_USER_PLUGINS_FOLDER ]
then
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/"
cp $plugin ${JMETER_HOME}/lib/ext
done;
else
echo "No user plugins found in ${JMETER_USER_PLUGINS_FOLDER}"
fi
echo


echo "********************************************************"
echo "* Initializing JMeter Master *"
echo "********************************************************"
Expand Down
14 changes: 14 additions & 0 deletions contrib/executor/jmeterd/scripts/jmeter-slaves.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ else
fi
echo

if [ -d $JMETER_USER_PLUGINS_FOLDER ]
then
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/"
cp $plugin ${JMETER_HOME}/lib/ext
done;
else
echo "No user plugins found in ${JMETER_USER_PLUGINS_FOLDER}"
fi
echo

echo

echo "********************************************************"
echo "* Initializing JMeter Master *"
echo "********************************************************"
Expand Down