I am using the justb4/jmeter image as docker-compose service and the scenario is like the aws-cli should download the jmx file and those jmx file will be used by the justb4/jmeter container. So till the aws-cli container download the files, jmeter have to wait. And I implemented it by checking flag file existance in shared volume. i.e. when aws-cli is download is done, I make one file in the shared container, till then jmeter have to wait in the while loop till the file is not present. The problem is the jmeter script is not running properly and it is yeilding warnings and errors like #!/bin/bash: not found and error is syntax error: unexpected end of file (expecting "do")
services:
jmeterclidemo:
image: ${DOCKER_REGISTRY-}jmeterclidemo
build:
context: .
dockerfile: JmeterCLIDemo/Dockerfile
ports:
- "5001:80"
- "5000:443"
awscli:
image: amazon/aws-cli:latest
environment:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}
entrypoint: /app/aws-script/entrypoint.sh
volumes:
- ./aws-script:/app/aws-script
- test-scripts:/app/test-scripts
- results:/app/results
- flag:/app/flag
jmeter:
image: justb4/jmeter:latest
volumes:
- test-scripts:/jmeter/test-scripts
- results:/jmeter/results
- flag:/jmeter/flag
#- ./test-scripts:/jmeter/test-scripts
- ./results:/jmeter/results
entrypoint: ["sh", "-c","/jmeter/test-scripts/entrypoint.sh"]
depends_on:
- jmeterclidemo
- awscli
And in the jmeter script file i wrote
#!/bin/bash
echo "execution started"
while [ ! -e "/app/flag/download_done.txt" ];
do
:
done;
jmeter -n -t /jmeter/test-scripts/TestFileGet.jmx -l /jmeter/results/TestFileGetByID-detail.jtl
echo "execution completed successfully."
touch "/app/flag/upload_start.txt"
exit 0;
It is printing #!/bin/bash: not found and error is syntax error: unexpected end of file (expecting "do") as the log message.
Let me answer my question.
All the code is rightly written and no error in syntax as well. But the thing is docker container will use the linux operating system, so it will look for linux line endings (LF) inside all files(including above .sh file).
But the .sh file above has windows line ending(CRLF) so it will not recogize the file ending properly.
Changing the file ending to LF(linux file ending) of the script(.sh file) from notepad++ or vscode and then running docker-compose up -d
is working fine and as expected.