@@ -23,7 +23,7 @@ while true; do
23
23
--db-dump-path )
24
24
DB_DUMP_PATH=" $2 " ; shift 2 ;;
25
25
--after-db-init-code )
26
- # s3 url|filename +
26
+ # s3 url|filename|content
27
27
AFTER_DB_INIT_CODE=" $2 " ; shift 2 ;;
28
28
--workload-full-path )
29
29
# s3 url
@@ -32,18 +32,18 @@ while true; do
32
32
# Still unsuported
33
33
WORKLOAD_BASIS_PATH=" $2 " ; shift 2 ;;
34
34
--workload-custom-sql )
35
- # s3 url|filename +
35
+ # s3 url|filename|content
36
36
WORKLOAD_CUSTOM_SQL=" $2 " ; shift 2 ;;
37
37
--workload-replay-speed )
38
38
WORKLOAD_REPLAY_SPEED=" $2 " ; shift 2 ;;
39
39
--target-ddl-do )
40
- # s3 url|filename +
40
+ # s3 url|filename|content
41
41
TARGET_DDL_DO=" $2 " ; shift 2 ;;
42
42
--target-ddl-undo )
43
- # s3 url|filename +
43
+ # s3 url|filename|content
44
44
TARGET_DDL_UNDO=" $2 " ; shift 2 ;;
45
45
--target-config )
46
- # s3 url|filename +
46
+ # s3 url|filename|content
47
47
TARGET_CONFIG=" $2 " ; shift 2 ;;
48
48
--artifacts-destination )
49
49
ARTIFACTS_DESTINATION=" $2 " ; shift 2 ;;
@@ -125,13 +125,9 @@ function checkPath() {
125
125
eval " $1 =\" $path \" " # update original variable
126
126
return 0 # file found
127
127
else
128
- return 3 # file not found
128
+ return 2 # file not found
129
129
fi
130
130
fi
131
- if [ -f $path ]
132
- then
133
- return 0;
134
- fi
135
131
return -1 # incorrect path
136
132
}
137
133
@@ -206,6 +202,8 @@ function checkParams() {
206
202
exit 1
207
203
fi
208
204
205
+ [ -v DB_DUMP_PATH ] && ! checkPath DB_DUMP_PATH && >&2 echo " ERROR: file $DB_DUMP_PATH given by db_dump_path not found" && exit 1
206
+
209
207
if (( [ ! - v TARGET_DDL_UNDO ] && [ - v TARGET_DDL_DO ]) || ([ ! - v TARGET_DDL_DO ] && [ - v TARGET_DDL_UNDO ]))
210
208
then
211
209
>&2 echo " ERROR: DDL code must have do and undo part."
@@ -224,21 +222,76 @@ function checkParams() {
224
222
ARTIFACTS_FILENAME=$DOCKER_MACHINE
225
223
fi
226
224
227
- [ -v WORKLOAD_FULL_PATH ] && ! checkPath WORKLOAD_FULL_PATH && >&2 echo " WARNING : file $AFTER_DB_INIT_CODE not found"
225
+ [ -v WORKLOAD_FULL_PATH ] && ! checkPath WORKLOAD_FULL_PATH && >&2 echo " ERROR : file $WORKLOAD_FULL_PATH given by workload_full_path not found" && exit 1
228
226
229
- [ -v WORKLOAD_BASIS_PATH ] && ! checkPath WORKLOAD_BASIS_PATH && >&2 echo " WARNING: file $WORKLOAD_BASIS_PATH not found "
227
+ echo " WORKLOAD_FULL_PATH: $WORKLOAD_FULL_PATH "
230
228
231
- [ -v WORKLOAD_CUSTOM_SQL ] && ! checkPath WORKLOAD_CUSTOM_SQL && >&2 echo " WARNING: file $WORKLOAD_CUSTOM_SQL not found"
229
+ [ -v WORKLOAD_BASIS_PATH ] && ! checkPath WORKLOAD_BASIS_PATH && >&2 echo " WARNING: file $WORKLOAD_BASIS_PATH given by workload_basis_path not found"
232
230
233
- [ -v DB_DUMP_PATH ] && ! checkPath DB_DUMP_PATH && >&2 echo " WARNING: file $DB_DUMP_PATH not found"
231
+ if [ -v WORKLOAD_CUSTOM_SQL ]
232
+ then
233
+ checkPath WORKLOAD_CUSTOM_SQL
234
+ if [ " $? " -ne " 0" ]
235
+ then
236
+ >&2 echo " WARNING: Value given as workload-custom-sql: '$WORKLOAD_CUSTOM_SQL ' not found as file will use as content"
237
+ echo " $WORKLOAD_CUSTOM_SQL " > $TMP_PATH /workload_custom_sql_tmp.sql
238
+ WORKLOAD_CUSTOM_SQL=" $TMP_PATH /workload_custom_sql_tmp.sql"
239
+ else
240
+ [ " $DEBUG " -eq " 1" ] && echo " DEBUG: Value given as workload-custom-sql will use as filename"
241
+ fi
242
+ fi
234
243
235
- [ -v AFTER_DB_INIT_CODE ] && ! checkPath AFTER_DB_INIT_CODE && >&2 echo " WARNING: file $AFTER_DB_INIT_CODE not found"
244
+ if [ -v AFTER_DB_INIT_CODE ]
245
+ then
246
+ checkPath AFTER_DB_INIT_CODE
247
+ if [ " $? " -ne " 0" ]
248
+ then
249
+ >&2 echo " WARNING: Value given as after_db_init_code: '$AFTER_DB_INIT_CODE ' not found as file will use as content"
250
+ echo " $AFTER_DB_INIT_CODE " > $TMP_PATH /after_db_init_code_tmp.sql
251
+ AFTER_DB_INIT_CODE=" $TMP_PATH /after_db_init_code_tmp.sql"
252
+ else
253
+ [ " $DEBUG " -eq " 1" ] && echo " DEBUG: Value given as after_db_init_code will use as filename"
254
+ fi
255
+ fi
236
256
237
- [ -v TARGET_DDL_DO ] && ! checkPath TARGET_DDL_DO && >&2 echo " WARNING: file $TARGET_DDL_DO not found"
257
+ if [ -v TARGET_DDL_DO ]
258
+ then
259
+ checkPath TARGET_DDL_DO
260
+ if [ " $? " -ne " 0" ]
261
+ then
262
+ >&2 echo " WARNING: Value given as target_ddl_do: '$TARGET_DDL_DO ' not found as file will use as content"
263
+ echo " $TARGET_DDL_DO " > $TMP_PATH /target_ddl_do_tmp.sql
264
+ TARGET_DDL_DO=" $TMP_PATH /target_ddl_do_tmp.sql"
265
+ else
266
+ [ " $DEBUG " -eq " 1" ] && echo " DEBUG: Value given as target_ddl_do will use as filename"
267
+ fi
268
+ fi
238
269
239
- [ -v TARGET_DDL_UNDO ] && ! checkPath TARGET_DDL_UNDO && >&2 echo " WARNING: file $TARGET_DDL_UNDO not found"
270
+ if [ -v TARGET_DDL_UNDO ]
271
+ then
272
+ checkPath TARGET_DDL_UNDO
273
+ if [ " $? " -ne " 0" ]
274
+ then
275
+ >&2 echo " WARNING: Value given as target_ddl_undo: '$TARGET_DDL_UNDO ' not found as file will use as content"
276
+ echo " $TARGET_DDL_UNDO " > $TMP_PATH /target_ddl_undo_tmp.sql
277
+ TARGET_DDL_UNDO=" $TMP_PATH /target_ddl_undo_tmp.sql"
278
+ else
279
+ [ " $DEBUG " -eq " 1" ] && echo " DEBUG: Value given as target_ddl_undo will use as filename"
280
+ fi
281
+ fi
240
282
241
- [ -v TARGET_CONFIG ] && ! checkPath TARGET_CONFIG && >&2 echo " WARNING: file $TARGET_CONFIG not found"
283
+ if [ -v TARGET_CONFIG ]
284
+ then
285
+ checkPath TARGET_CONFIG
286
+ if [ " $? " -ne " 0" ]
287
+ then
288
+ >&2 echo " WARNING: Value given as target_config: '$TARGET_CONFIG ' not found as file will use as content"
289
+ echo " $TARGET_CONFIG " > $TMP_PATH /target_config_tmp.conf
290
+ TARGET_CONFIG=" $TMP_PATH /target_config_tmp.conf"
291
+ else
292
+ [ " $DEBUG " -eq " 1" ] && echo " DEBUG: Value given as target_config will use as filename"
293
+ fi
294
+ fi
242
295
}
243
296
244
297
checkParams;
@@ -258,7 +311,6 @@ function waitEC2Ready() {
258
311
(( STOP== 1 )) && return 0
259
312
if [ $checkPrice -eq 1 ]
260
313
then
261
- # status=$(aws ec2 describe-spot-instance-requests --filters="Name=launch.instance-type,Values=$AWS_EC2_TYPE" | jq '.SpotInstanceRequests[] | .Status.Code' | tail -n 1 )
262
314
status=$( aws ec2 describe-spot-instance-requests --filters=" Name=launch.instance-type,Values=$AWS_EC2_TYPE " | jq ' .SpotInstanceRequests | sort_by(.CreateTime) | .[] | .Status.Code' | tail -n 1)
263
315
if [ " $status " == " \" price-too-low\" " ]
264
316
then
@@ -337,11 +389,13 @@ else
337
389
fi
338
390
339
391
function cleanup {
340
- echo " Remove temp files..."
341
- rm -f " $TMP_PATH /conf_$DOCKER_MACHINE .tmp"
342
- rm -f " $TMP_PATH /ddl_do_$DOCKER_MACHINE .sql"
343
- rm -f " $TMP_PATH /ddl_undo_$DOCKER_MACHINE .sql"
344
- rm -f " $TMP_PATH /queries_custom_$DOCKER_MACHINE .sql"
392
+ echo " Remove temp files..." # if exists
393
+ rm -f " $TMP_PATH /after_db_init_code_tmp.sql"
394
+ rm -f " $TMP_PATH /workload_custom_sql_tmp.sql"
395
+ rm -f " $TMP_PATH /target_ddl_do_tmp.sql"
396
+ rm -f " $TMP_PATH /target_ddl_undo_tmp.sql"
397
+ rm -f " $TMP_PATH /target_config_tmp.conf"
398
+
345
399
if [ " $RUN_ON " = " localhost" ]; then
346
400
rm -rf " $TMP_PATH /pg_nancy_home_${CURRENT_TS} "
347
401
echo " Remove docker container"
@@ -390,6 +444,7 @@ sleep 1 # wait for postgres up&running
390
444
DB_DUMP_FILENAME=$( basename $DB_DUMP_PATH )
391
445
docker_exec bash -c " bzcat /machine_home/$DB_DUMP_FILENAME | psql --set ON_ERROR_STOP=on -U postgres test"
392
446
# After init database sql code apply
447
+ echo " Apply sql code after db init from $AFTER_DB_INIT_CODE "
393
448
if ([ -v AFTER_DB_INIT_CODE ] && [ " $AFTER_DB_INIT_CODE " != " " ])
394
449
then
395
450
AFTER_DB_INIT_CODE_FILENAME=$( basename $AFTER_DB_INIT_CODE )
@@ -407,7 +462,7 @@ if ([ -v TARGET_DDL_DO ] && [ "$TARGET_DDL_DO" != "" ]); then
407
462
docker_exec bash -c " psql -U postgres test -E -f /machine_home/$TARGET_DDL_DO_FILENAME "
408
463
fi
409
464
# Apply postgres configuration
410
- echo " Apply postgres conf from /machine_home/conf_ $DOCKER_MACHINE .tmp "
465
+ echo " Apply postgres conf from $TARGET_CONFIG "
411
466
if ([ -v TARGET_CONFIG ] && [ " $TARGET_CONFIG " != " " ]); then
412
467
TARGET_CONFIG_FILENAME=$( basename $TARGET_CONFIG )
413
468
docker_exec bash -c " cat /machine_home/$TARGET_CONFIG_FILENAME >> /etc/postgresql/$PG_VERSION /main/postgresql.conf"
0 commit comments