Skip to content

Commit 9b0b715

Browse files
committed
Handles gatling runner fail scenario
Signed-off-by: Yoichi Kawasaki <[email protected]>
1 parent 780bf3d commit 9b0b715

File tree

8 files changed

+39
-6
lines changed

8 files changed

+39
-6
lines changed

pkg/cloudstorages/aws.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ func (p *AWSCloudStorageProvider) GetGatlingTransferResultCommand(resultsDirecto
2929
RESULTS_DIR_PATH=%s
3030
rclone config create s3 s3 env_auth=true region %s
3131
while true; do
32+
if [ -f "${RESULTS_DIR_PATH}/FAILED" ]; then
33+
echo "Skip transfering gatling results"
34+
break
35+
fi
3236
if [ -f "${RESULTS_DIR_PATH}/COMPLETED" ]; then
3337
for source in $(find ${RESULTS_DIR_PATH} -type f -name *.log)
3438
do

pkg/cloudstorages/aws_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ var _ = Describe("GetGatlingTransferResultCommand", func() {
8585
RESULTS_DIR_PATH=testResultsDirectoryPath
8686
rclone config create s3 s3 env_auth=true region ap-northeast-1
8787
while true; do
88+
if [ -f "${RESULTS_DIR_PATH}/FAILED" ]; then
89+
echo "Skip transfering gatling results"
90+
break
91+
fi
8892
if [ -f "${RESULTS_DIR_PATH}/COMPLETED" ]; then
8993
for source in $(find ${RESULTS_DIR_PATH} -type f -name *.log)
9094
do

pkg/cloudstorages/azure.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ export RCLONE_AZUREBLOB_SAS_URL=${AZUREBLOB_SAS_URL}
4444
RESULTS_DIR_PATH=%s
4545
rclone config create az azureblob env_auth=true
4646
while true; do
47+
if [ -f "${RESULTS_DIR_PATH}/FAILED" ]; then
48+
echo "Skip transfering gatling results"
49+
break
50+
fi
4751
if [ -f "${RESULTS_DIR_PATH}/COMPLETED" ]; then
4852
for source in $(find ${RESULTS_DIR_PATH} -type f -name *.log)
4953
do

pkg/cloudstorages/azure_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ export RCLONE_AZUREBLOB_SAS_URL=${AZUREBLOB_SAS_URL}
105105
RESULTS_DIR_PATH=%s
106106
rclone config create az azureblob env_auth=true
107107
while true; do
108+
if [ -f "${RESULTS_DIR_PATH}/FAILED" ]; then
109+
echo "Skip transfering gatling results"
110+
break
111+
fi
108112
if [ -f "${RESULTS_DIR_PATH}/COMPLETED" ]; then
109113
for source in $(find ${RESULTS_DIR_PATH} -type f -name *.log)
110114
do

pkg/cloudstorages/gcp.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ RESULTS_DIR_PATH=%s
3131
# assumes gcs bucket using uniform bucket-level access control
3232
rclone config create gs "google cloud storage" bucket_policy_only true --non-interactive
3333
while true; do
34+
if [ -f "${RESULTS_DIR_PATH}/FAILED" ]; then
35+
echo "Skip transfering gatling results"
36+
break
37+
fi
3438
if [ -f "${RESULTS_DIR_PATH}/COMPLETED" ]; then
3539
# assumes each pod only contain single gatling log file but use for loop to use find command result
3640
for source in $(find ${RESULTS_DIR_PATH} -type f -name *.log)

pkg/cloudstorages/gcp_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ RESULTS_DIR_PATH=testResultsDirectoryPath
8686
# assumes gcs bucket using uniform bucket-level access control
8787
rclone config create gs "google cloud storage" bucket_policy_only true --non-interactive
8888
while true; do
89+
if [ -f "${RESULTS_DIR_PATH}/FAILED" ]; then
90+
echo "Skip transfering gatling results"
91+
break
92+
fi
8993
if [ -f "${RESULTS_DIR_PATH}/COMPLETED" ]; then
9094
# assumes each pod only contain single gatling log file but use for loop to use find command result
9195
for source in $(find ${RESULTS_DIR_PATH} -type f -name *.log)

pkg/commands/commands.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ TEMP_SIMULATIONS_DIR_PATH=%s
4141
RESOURCES_DIR_PATH=%s
4242
RESULTS_DIR_PATH=%s
4343
START_TIME="%s"
44+
RUN_STATUS_FILE="${RESULTS_DIR_PATH}/COMPLETED"
4445
if [ -z "${START_TIME}" ]; then
4546
START_TIME=$(date +"%%Y-%%m-%%d %%H:%%M:%%S" --utc)
4647
fi
@@ -67,9 +68,11 @@ if [ ! -d ${RESULTS_DIR_PATH} ]; then
6768
fi
6869
gatling.sh -sf ${SIMULATIONS_DIR_PATH} -s %s -rsf ${RESOURCES_DIR_PATH} -rf ${RESULTS_DIR_PATH} %s
6970
70-
if [ $? -eq 0 ]; then
71-
touch ${RESULTS_DIR_PATH}/COMPLETED
71+
if [ $? -ne 0 ]; then
72+
RUN_STATUS_FILE="${RESULTS_DIR_PATH}/FAILED"
73+
echo "gatling.sh has failed!" 1>&2
7274
fi
75+
touch ${RUN_STATUS_FILE}
7376
`
7477
generateLocalReportOption := "-nr"
7578
if generateLocalReport {

pkg/commands/commands_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ TEMP_SIMULATIONS_DIR_PATH=testTempSimulationsDirectoryPath
5858
RESOURCES_DIR_PATH=testResourcesDirectoryPath
5959
RESULTS_DIR_PATH=testResultsDirectoryPath
6060
START_TIME="2021-09-10 08:45:31"
61+
RUN_STATUS_FILE="${RESULTS_DIR_PATH}/COMPLETED"
6162
if [ -z "${START_TIME}" ]; then
6263
START_TIME=$(date +"%Y-%m-%d %H:%M:%S" --utc)
6364
fi
@@ -84,9 +85,11 @@ if [ ! -d ${RESULTS_DIR_PATH} ]; then
8485
fi
8586
gatling.sh -sf ${SIMULATIONS_DIR_PATH} -s testSimulationClass -rsf ${RESOURCES_DIR_PATH} -rf ${RESULTS_DIR_PATH}
8687
87-
if [ $? -eq 0 ]; then
88-
touch ${RESULTS_DIR_PATH}/COMPLETED
88+
if [ $? -ne 0 ]; then
89+
RUN_STATUS_FILE="${RESULTS_DIR_PATH}/FAILED"
90+
echo "gatling.sh has failed!" 1>&2
8991
fi
92+
touch ${RUN_STATUS_FILE}
9093
`
9194
Expect(GetGatlingRunnerCommand(simulationsDirectoryPath, tempSimulationsDirectoryPath, resourcesDirectoryPath, resultsDirectoryPath, startTime, simulationClass, generateLocalReport)).To(Equal(expectedValue))
9295
})
@@ -99,6 +102,7 @@ TEMP_SIMULATIONS_DIR_PATH=testTempSimulationsDirectoryPath
99102
RESOURCES_DIR_PATH=testResourcesDirectoryPath
100103
RESULTS_DIR_PATH=testResultsDirectoryPath
101104
START_TIME="2021-09-10 08:45:31"
105+
RUN_STATUS_FILE="${RESULTS_DIR_PATH}/COMPLETED"
102106
if [ -z "${START_TIME}" ]; then
103107
START_TIME=$(date +"%Y-%m-%d %H:%M:%S" --utc)
104108
fi
@@ -125,9 +129,11 @@ if [ ! -d ${RESULTS_DIR_PATH} ]; then
125129
fi
126130
gatling.sh -sf ${SIMULATIONS_DIR_PATH} -s testSimulationClass -rsf ${RESOURCES_DIR_PATH} -rf ${RESULTS_DIR_PATH} -nr
127131
128-
if [ $? -eq 0 ]; then
129-
touch ${RESULTS_DIR_PATH}/COMPLETED
132+
if [ $? -ne 0 ]; then
133+
RUN_STATUS_FILE="${RESULTS_DIR_PATH}/FAILED"
134+
echo "gatling.sh has failed!" 1>&2
130135
fi
136+
touch ${RUN_STATUS_FILE}
131137
`
132138
Expect(GetGatlingRunnerCommand(simulationsDirectoryPath, tempSimulationsDirectoryPath, resourcesDirectoryPath, resultsDirectoryPath, startTime, simulationClass, generateLocalReport)).To(Equal(expectedValue))
133139
})

0 commit comments

Comments
 (0)