Skip to content

Commit

Permalink
Support for user.properties file (#3)
Browse files Browse the repository at this point in the history
* Support for user provided plugins

Signed-off-by: Aman Parauliya <[email protected]>

* Add secret refs for git username and token for slave pods

Signed-off-by: hiteshwani <[email protected]>

* Modified logic for adding JMETER_USER_PLUGINS_FOLDER  env var

Signed-off-by: hiteshwani <[email protected]>

* Added the support for user.properties file

---------

Signed-off-by: Aman Parauliya <[email protected]>
Signed-off-by: hiteshwani <[email protected]>
Co-authored-by: hiteshwani <[email protected]>
  • Loading branch information
parauliya and hiteshwani authored Sep 7, 2023
1 parent 73cc659 commit 69c5b29
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
8 changes: 4 additions & 4 deletions contrib/executor/jmeterd/pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ func (r *JMeterRunner) Run(ctx context.Context, execution testkube.Execution) (r
runPath = workingDir
}

pluginPath := filepath.Join(filepath.Dir(path), "plugins")
parentTestFolder := filepath.Join(filepath.Dir(path))
// 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)
err = os.Setenv("JMETER_PARENT_TEST_FOLDER", parentTestFolder)
if err != nil {
output.PrintLogf("%s Failed to set user plugin directory %s", ui.IconWarning, pluginPath)
output.PrintLogf("%s Failed to set parent test folder directory %s", ui.IconWarning, parentTestFolder)
}
// Add user plugins folder in slaves env variables
slavesEnvVariables["JMETER_USER_PLUGINS_FOLDER"] = testkube.NewBasicVariable("JMETER_USER_PLUGINS_FOLDER", pluginPath)
slavesEnvVariables["JMETER_PARENT_TEST_FOLDER"] = testkube.NewBasicVariable("JMETER_PARENT_TEST_FOLDER", parentTestFolder)

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



if [ -d $JMETER_USER_PLUGINS_FOLDER ]

if [ -d ${JMETER_PARENT_TEST_FOLDER}/plugins ]
then
echo "Installing user plugins from ${JMETER_USER_PLUGINS_FOLDER}"
for plugin in ${JMETER_USER_PLUGINS_FOLDER}/*.jar; do
echo "Installing user plugins from ${JMETER_PARENT_TEST_FOLDER}/plugins"
for plugin in ${JMETER_PARENT_TEST_FOLDER}/plugins/*.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}"
echo "No user plugins provided as directory ${JMETER_PARENT_TEST_FOLDER}/plugins is not present"
fi
echo

if [ -f ${JMETER_PARENT_TEST_FOLDER}/user.properties ]
then
echo "Copying user properties file from ${JMETER_PARENT_TEST_FOLDER}/user.properties"
cp ${JMETER_PARENT_TEST_FOLDER}/user.properties ${JMETER_HOME}/bin/
else
echo "File user.properties not present in ${JMETER_PARENT_TEST_FOLDER}"
fi
echo

Expand Down
8 changes: 4 additions & 4 deletions contrib/executor/jmeterd/scripts/jmeter-slaves.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ else
fi
echo

if [ -d $JMETER_USER_PLUGINS_FOLDER ]
if [ -d ${JMETER_PARENT_TEST_FOLDER}/plugins ]
then
echo "Installing user plugins from ${JMETER_USER_PLUGINS_FOLDER}"
for plugin in ${JMETER_USER_PLUGINS_FOLDER}/*.jar; do
echo "Installing user plugins from ${JMETER_PARENT_TEST_FOLDER}/plugins"
for plugin in ${JMETER_PARENT_TEST_FOLDER}/plugins/*.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}"
echo "No user plugins provided as directory ${JMETER_PARENT_TEST_FOLDER}/plugins is not present"
fi
echo

Expand Down

0 comments on commit 69c5b29

Please sign in to comment.