zentol commented on a change in pull request #13419:
URL: https://github.com/apache/flink/pull/13419#discussion_r492588052
##########
File path: flink-end-to-end-tests/test-scripts/common.sh
##########
@@ -830,3 +830,30 @@ run_test_with_timeout() {
$TEST_COMMAND
)
}
+
+run_with_timeout() {
+ local timeout="$1"
+ shift
+ local pidFile="$1"
+ shift
+ local command="$@"
+
+ # invoke command
+ (eval "$command"; rm $pidFile; ) &
+ pid=$!
+ echo $pid > $pidFile
+
+ # invoke timeout guard
+ (
+ sleep $timeout
+ if [[ -e $pidFile ]]; then
Review comment:
We should be able to re-use `run_test_with_timeout`. All we basically
need to do is move this
```
echo "Printing Flink logs and killing it:"
cat ${FLINK_DIR}/log/*
```
into a separate function, and add a new `run_with_timeout` that accepts a
timeout, run-command, and on-failure-command.
```
run_test_with_timeout() {
local TEST_TIMEOUT_SECONDS=$1
shift
local TEST_COMMAND=$@
internal_run_with_timeout $TEST_TIMEOUT_SECONDS $TEST_COMMAND print_logs
}
run_with_timeout() {
internal_run_with_timeout $1 $2 ""
}
internal_run_with_timeout() {
local timeout=$1
local runCommand=$2
local onFailureCommand=$3
// do stuff
}
print_logs() {
echo "Printing Flink logs and killing it:"
cat ${FLINK_DIR}/log/*
}
```
##########
File path: flink-end-to-end-tests/test-scripts/common.sh
##########
@@ -830,3 +830,30 @@ run_test_with_timeout() {
$TEST_COMMAND
)
}
+
+run_with_timeout() {
+ local timeout="$1"
+ shift
+ local pidFile="$1"
+ shift
+ local command="$@"
+
+ # invoke command
+ (eval "$command"; rm $pidFile; ) &
+ pid=$!
+ echo $pid > $pidFile
+
+ # invoke timeout guard
+ (
+ sleep $timeout
+ if [[ -e $pidFile ]]; then
Review comment:
We should be able to re-use `run_test_with_timeout`. All we basically
need to do is move this
```
echo "Printing Flink logs and killing it:"
cat ${FLINK_DIR}/log/*
```
into a separate function, and add a new `run_with_timeout` that accepts a
timeout, run-command, and on-failure-command.
```
run_test_with_timeout() {
local TEST_TIMEOUT_SECONDS=$1
shift
local TEST_COMMAND=$@
internal_run_with_timeout $TEST_TIMEOUT_SECONDS "$TEST_COMMAND" print_logs
}
run_with_timeout() {
internal_run_with_timeout $1 "$2" ""
}
internal_run_with_timeout() {
local timeout=$1
local runCommand=$2
local onFailureCommand=$3
// do stuff
}
print_logs() {
echo "Printing Flink logs and killing it:"
cat ${FLINK_DIR}/log/*
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]