I have a path location called "qe/performance" and want to copy "jmx" files to S3 Bucket in AWS. Once file copied, i want to use while loop to list down the converted files(.jtl) in the results folder into s3 bucket. If files are present (successful), it will update the ECS cluster and remove the ec2 instance to decrease the load and send message to the group that file has uploaded.
on the other hand, if converted files are not presented to the results folder into s3 bucket, i want to put "Timeoutthreshold for 10 minutes and use iteration and sleep for 60 seconds to wait for files to be uploaded to s3 bucket. If iteration period crosses the timeoutthreshold, it will send email notification that file hasnt uploaded....
#/bin/bash
TimeoutThreshold=10
holder="qe/performance/"
echo $holder
for files in $holder; do
aws s3 cp $files s3://$JMeterFilesBucket/scripts/ --recursive
i=0
while [ true ]; do
aws s3 ls s3://$JMeterFilesBucket/results/ --recursive |grep .jtl
if [ "$?" -ne "0" ]; then \
sleep 60
iterator=$i + 1
if [ iterator -eq "$TimeoutThreshold" ]; then
aws sns publish --topic-arn ${Subscription} --message "files (HTML Reports/.jtl) failed to load to the s3 bucket: s3://$JMeterFilesBucket/results/";
else
sleep 60
fi
exit 0
else [ "$?" -eq "0" ]; then \
aws ecs update-service --cluster $Cluster --service $Service --desired-count $CURRENT_DESIRED_COUNT --region ${AWS::Region}
echo "publishing SNS Notification for the files that have been uploaded successfully"
aws sns publish --topic-arn ${Subscription} --message "files (HTML Reports/.jtl) have successfully loaded to the s3 bucket: s3://$JMeterFilesBucket/results/";
break
fi
done
done
here is the result after running this command, it still continuing showing the list of files like this and break
Also no email notifications are going thru in either condition
qe/performance/
21:49:50
Completed 14.7 KiB/14.7 KiB (86.3 KiB/s) with 1 file(s) remaining upload: qe/performance/ContribAccl_Dev.jmx to s3://retqa-jmeterfiles/scripts/ContribAccl_Dev.jmx
21:49:52
2019-09-11 17:41:12 1460 results/ContribAccl_Dev.jmx.jtl
21:49:52
2019-09-06 03:16:32 1653 results/Sample13.jmx.jtl
21:49:52
2019-09-09 15:19:40 163 results/Sample15.jmx.jtl
21:49:52
2019-09-11 17:41:12 1460 results/ContribAccl_Dev.jmx.jtl
21:49:52
2019-09-06 03:16:32 1653 results/Sample13.jmx.jtl
21:49:52
2019-09-09 15:19:40 163 results/Sample15.jmx.jtl
21:49:52
2019-09-11 17:41:12 1460 results/ContribAccl_Dev.jmx.jtl
21:49:52
2019-09-06 03:16:32 1653 results/Sample13.jmx.jtl
21:49:52
2019-09-09 15:19:40 163 results/Sample15.jmx.jtl
21:49:52
2019-09-11 17:41:12 1460 results/ContribAccl_Dev.jmx.jtl
21:49:52
2019-09-06 03:16:32 1653 results/Sample13.jmx.jtl
21:49:52
2019-09-09 15:19:40 163 results/Sample15.jmx.jtl
21:49:54
2019-09-11 17:41:12 1460 results/ContribAccl_Dev.jmx.jtl
21:49:54
2019-09-06 03:16:32 1653 results/Sample13.jmx.jtl
21:49:54
2019-09-09 15:19:40 163 results/Sample15.jmx.jtl
21:49:54
2019-09-11 17:41:12 1460 results/ContribAccl_Dev.jmx.jtl
21:49:54
2019-09-06 03:16:32 1653 results/Sample13.jmx.jtl
21:49:54
2019-09-09 15:19:40 163 results/Sample15.jmx.jtl
while [ true ]; doshould bewhile true; do. But that's not the problem.