After upgrading from Gatling v3.6 to v3.9 I am not able to run Gatling scripts outside of the root folder.
I made a temporary solution by replacing the new “gatling.bat” (v3.9) with the old one (v3.6).
is there any other fix?
I tried to manually edit the “gatling.bat” file but have no experience with Windows batching scripts
Is there any other solution? like even terminal is way different when I changes the “gatling.bat”
Here are the contents of the new “gatling.bat”
@ECHO OFF
@REM
@REM Copyright 2011-2022 GatlingCorp (http://gatling.io)
@REM
@REM Licensed under the Apache License, Version 2.0 (the "License");
@REM you may not use this file except in compliance with the License.
@REM You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing, software
@REM distributed under the License is distributed on an "AS IS" BASIS,
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@REM See the License for the specific language governing permissions and
@REM limitations under the License.
@REM
setlocal
set USER_ARGS=%*
rem set GATLING_HOME automatically if possible
set "OLD_DIR=%cd%"
cd ..
set "DEFAULT_GATLING_HOME=%cd%"
cd %OLD_DIR%
rem if gatling home is correctly set
if exist "%GATLING_HOME%\bin\gatling.bat" goto gotHome
rem if gatling home is not correctly set
if not "%GATLING_HOME%" == "" goto badHome
rem if not try current folder
if exist "%OLD_DIR%\bin\gatling.bat" set "GATLING_HOME=%OLD_DIR%" && goto gotHome
rem if not try parent folder
if exist "%DEFAULT_GATLING_HOME%\bin\gatling.bat" set "GATLING_HOME=%DEFAULT_GATLING_HOME%" && goto gotHome
rem else tell user to set GATLING_HOME
goto :noHome
:gotHome
echo GATLING_HOME is set to "%GATLING_HOME%"
set JAVA_OPTS=%JAVA_OPTS% -Xms32M -Xmx128M
set CLASSPATH="%GATLING_HOME%"\lib\*
set JAVA=java
if exist "%JAVA_HOME%\bin\java.exe" goto setJavaHome
goto run
:setJavaHome
set JAVA="%JAVA_HOME%\bin\java.exe"
:run
echo JAVA = %JAVA%
%JAVA% %JAVA_OPTS% -cp %CLASSPATH% io.gatling.bundle.GatlingCLI %USER_ARGS%
goto exit
:badHome
echo The GATLING_HOME environment variable points to the wrong directory.
echo Please set it to the correct folder and try to launch Gatling again.
goto exit
:noHome
echo GATLING_HOME environment variable is not set and could not be guessed automatically.
echo Please set GATLING_HOME and try to launch Gatling again.
goto exit
:exit
if not defined NO_PAUSE pause
endlocal
exit /b 0
and here are the contents of the old one:
@ECHO OFF
@REM
@REM Copyright 2011-2017 GatlingCorp (http://gatling.io)
@REM
@REM Licensed under the Apache License, Version 2.0 (the "License");
@REM you may not use this file except in compliance with the License.
@REM You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing, software
@REM distributed under the License is distributed on an "AS IS" BASIS,
@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@REM See the License for the specific language governing permissions and
@REM limitations under the License.
@REM
setlocal
set USER_ARGS=%*
rem set GATLING_HOME automatically if possible
set "OLD_DIR=%cd%"
cd ..
set "DEFAULT_GATLING_HOME=%cd%"
cd %OLD_DIR%
rem if gatling home is correctly set
if exist "%GATLING_HOME%\bin\gatling.bat" goto gotHome
rem if gatling home is not correctly set
if not "%GATLING_HOME%" == "" goto badHome
rem if not try current folder
if exist "%OLD_DIR%\bin\gatling.bat" set "GATLING_HOME=%OLD_DIR%" && goto gotHome
rem if not try parent folder
if exist "%DEFAULT_GATLING_HOME%\bin\gatling.bat" set "GATLING_HOME=%DEFAULT_GATLING_HOME%" && goto gotHome
rem else tell user to set GATLING_HOME
goto :noHome
:gotHome
if not defined GATLING_CONF set GATLING_CONF="%GATLING_HOME%"\conf
echo GATLING_HOME is set to "%GATLING_HOME%"
set JAVA_OPTS=-Xmx1G -XX:+UseG1GC -XX:MaxGCPauseMillis=30 -XX:G1HeapRegionSize=16m -XX:InitiatingHeapOccupancyPercent=75 -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem -XX:+HeapDumpOnOutOfMemoryError -XX:MaxInlineLevel=20 -XX:MaxTrivialSize=12 -XX:-UseBiasedLocking %JAVA_OPTS%
if "%PROCESSOR_ARCHITECTURE%" == "x86" if "%PROCESSOR_ARCHITEW6432%" == "" goto skipServer
set JAVA_OPTS=-server %JAVA_OPTS%
:skipServer
set COMPILER_OPTS=-Xss100M %JAVA_OPTS%
rem Setup classpaths
set COMPILER_CLASSPATH="%GATLING_HOME%"\lib\*;%GATLING_CONF%;
set GATLING_CLASSPATH="%GATLING_HOME%"\lib\*;"%GATLING_HOME%"\user-files\resources;%GATLING_CONF%;
set JAVA=java
if exist "%JAVA_HOME%\bin\java.exe" goto setJavaHome
goto run
:setJavaHome
set JAVA="%JAVA_HOME%\bin\java.exe"
:run
echo JAVA = "%JAVA%"
rem Run the compiler
%JAVA% %COMPILER_OPTS% -cp %COMPILER_CLASSPATH% io.gatling.compiler.ZincCompiler %USER_ARGS% 2>NUL
rem Run Gatling
%JAVA% %JAVA_OPTS% -cp %GATLING_CLASSPATH% io.gatling.app.Gatling %USER_ARGS%
if %errorlevel% neq 0 (
if not defined NO_PAUSE pause
exit /b %errorlevel%
)
rem The above line will forward any potential exit codes from Java if Gatling failed
goto exit
:badHome
echo The GATLING_HOME environment variable points to the wrong directory.
echo Please set it to the correct folder and try to launch Gatling again.
goto exit
:noHome
echo GATLING_HOME environment variable is not set and could not be guessed automatically.
echo Please set GATLING_HOME and try to launch Gatling again.
goto exit
:exit
if not defined NO_PAUSE pause
endlocal
exit /b 0
I did my edits and I think those lines are the ones that have the effect, could you help please?
I’m wondering what you mean by “outside of the root folder”. If it is running Gatling from outside the bundle folder (or the bin folder inside the same folder), I tried reproducing the issue and, from what I see, it actually never worked. The only cases it can handle are running from the root folder of the bundle, or from the bin folder itself.
We checked a bit and it looks like it can be handled by replacing these lines:
rem set GATLING_HOME automatically if possible
set "OLD_DIR=%cd%"
cd ..
set "DEFAULT_GATLING_HOME=%cd%"
cd %OLD_DIR%
With the following lines:
rem set GATLING_HOME automatically if possible
set "OLD_DIR=%cd%"
set "SCRIPT_DIR=%~dp0"
cd "%SCRIPT_DIR%.."
set "DEFAULT_GATLING_HOME=%cd%"
cd %OLD_DIR%
I’ll need to check if there are no drawbacks to this before considering it a proper fix.
Yes I can’t run Simulations outside the bundle for example:
I open the terminal in user files and run the command Gatling to run any simulation but it only detects the main Simulation that comes with the bundle.
I didn’t face this s issue with gatling v3.6 but this issue present in v3.7/3.8/ 3.9.
Simulations should be put inside user-files/simulations. If it is the case, could you show us a concrete example of your folders layout and the content of the simulation file that is not read by Gatling?
Here is the Gatling bundle path “C:\gatling-charts-highcharts-bundle-3.9.0”
Here is the Simulation path I want to run “C:\Users\fkhaleel\Downloads\Faris\1_Faris\Tests\Programms\Git_Repos\Digital-Load-Test\E-Commerce_Shop\user-files\simulations”
Based on your gifs, it seems you’re trying to run gatling in two different folders (one inside root folder of the bundle, one in a folder that seems that have simulations inside?), so I tried the same kind of layouts to test:
I added bundle_dir in my PATH as you showed, using both GATLING_HOME to bundle_dir and PATH to %GATLING_HOME%\bin, allowing me to use the shortcut gatling anywhere I am.
Whether I use 3.6.1, 3.9.0, running gatling from bundle_dir or other_dir, the output is always:
Choose a simulation number:
[0] ExampleSimulation
[1] computerdatabase.ComputerDatabaseSimulation
The bundle will always scan simulations from within it’s own folder (using GATLING_HOME), the only way to have it scan somewhere else is by using --simulation-folder.
Are you saying it used to show the simulations that are from the folder you where running the command before? If so, can you show me the content of user-files/simulations in the bundle folder and the E-Commerce_Shop folder?
Oh, having a different configuration is actually a big difference. There was some modification on this part so that might actually be it. Let me check.
Still can’t reproduce, the only conf folder that is read is the one that is inside GATLING_HOME. What we did was to move the handling of all the folders and configuration from the bash/batch scripts to the Gatling CLI code. It’s still possible to override GATLING_CONF but I don’t see it in your screenshots.
The way I see it is that there was some kind of bug before 3.6.1 that could be used as a way to read files outside of the defined bundle folder without using any parameters (–simulation-folders or gatling.conf inside the bundle folder) and it was fixed when we moved the handling inside the CLI code.
Do you have any other environment variables defined that are related to Gatling? Do you have any other modifications?
@notdryft No, I don’t have any other modifications on the Gatling.
To be honest, if running scripts outside the root folder with the normal Gatling command is considered wrong, then it’s a big downside for us, as for the last few years to construct a Gatling script its essential to run outside the root folder, also this issue happens on more than OS we tried Windows and Linux and issue is present.
So we won’t be able to run the scripts properly on the AWS server with the new versions of Gatling.
The bundle is not meant to be use as a CLI but a a self-contained “bundle”. Usually people can start with the bundle and then go to Maven/Gradle/SBT to industrialize. It’s still possible to use the bundle as a CLI and have it read stuff outside the bundle folder by using:
Possible way: GATLING_CONF defined with the target conf folder with proper configuration inside (
Best way: calling gatling.sh/bat with --simulations-folder /full/path/to/simulations/folder
Overriding GATLING_CONF would still be needed if reading local configuration is required.
Hi, @notdryft I recorded a video to demonstrate more about the issue, and why aren’t we moving to Maven or Gradle because of too many issues with configurations and versioning issues…
If we are running the Load test from our laptops I wouldn’t mind but when running on an AWS server its more difficult.