Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-16423][e2e] Introduce timeouts for HA tests #11831

Closed

Conversation

rmetzger
Copy link
Contributor

@rmetzger rmetzger commented Apr 20, 2020

What is the purpose of the change

Before this change, HA tests were waiting indefinitely for certain conditions to be met.
This change introduces a timeout (10 minutes) in the test scripts that kills the test and prints the Flink logs for debugging.

Brief change log

  • Change the HA watchdogs to store their state in files rather than variables (so that different bash processes can access them)
  • launch HA test and a watchdog that sleeps for 10 minutes. If the test doesn't finish in 10, the watchdog will kill the test.

@flinkbot
Copy link
Collaborator

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit 8c3475f (Mon Apr 20 14:36:20 UTC 2020)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.


The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@flinkbot
Copy link
Collaborator

flinkbot commented Apr 20, 2020

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run travis re-run the last Travis build
  • @flinkbot run azure re-run the last Azure build

@rmetzger
Copy link
Contributor Author

Since this error can happen also on travis, we should probably set the timeout to 9 minutes (as Travis has a timeout of 10 minutes)

Copy link
Contributor

@ifndef-SleePy ifndef-SleePy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for opening this PR. It would help a lot to find the failure cause of e2e test.
I'm not an expert of Bash programming. I tried to review the PR with the help of Google. I left a couple of comments. Correct me if I was wrong :)

@@ -23,10 +23,9 @@ source "${END_TO_END_DIR}"/test-scripts/common.sh
# flag indicating if we have already cleared up things after a test
CLEARED=0

JM_WATCHDOG_PID=0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a curiosity, what's the reason of this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JM_WATCHDOG_PID is used in the stop_watchdogs function, which is called from different bash-processes.
Because of that, if the variable is set in one process, it's not available in the other one.

That's why I decided to store the PID in a file.

on_exit kill_test_watchdog

(
cmdpid=$BASHPID;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BASHPID does not work on my Mac. It's introduced in Bash 4, however the version of Bash on my Mac is 3.2. Maybe we could use $$ when BASHPID is not supported? $$ is more general, however sometimes it does not work well as expected, like executing in background.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these changes require bash 4. Bash on mac is pretty outdated sadly.

I think $$ won't work, as it will return the PID of the bash-process, not of the subshell I'm launching there:

When you want to find out the PID of your current shell session, even from subshells, that’s when you use $$. Any subshell has its own PID as well, and you can access it via the $BASHPID variable.

https://bashwizard.com/shells-subshells-pids/

But I will add a warning to the script, that is requires at least bash 4

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you are right. It's in another sub-process.

I come up with a work-around way. It probably works that executing the watchdog in original main process and executing the testing scripts in sub-process. We can get the sub-process pid in main process.

But I guess it's not a big deal, as MacOS is not a main scenario. I hope this PR could be merged asap. I would help a lot.

echo "Test (pid: $cmdpid) did not finish after $TEST_TIMEOUT_SECONDS seconds."
echo "Printing Flink logs and killing it:"
cat ${FLINK_DIR}/log/*
kill "$cmdpid") & watchdog_pid=$!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another curiosity, is there any magic of inline watchdog_pid=$!?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question. I don't know if this has to be in the same line or not. Probably not.
It is okay for you, I would not change this, because it would mean that I have to test the scripts again (I manually tested that they are behaving as expected in failure / timeout / success cases.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's OK for me :)

Before this change, HA tests were waiting indefinetly for certain conditions to be met.
This change introduces a timeout in the test scripts that kills the test and prints the Flink logs for debugging.
@rmetzger rmetzger force-pushed the FLINK-16423-ha-e2e-timeout-pr branch from 8c3475f to 9632975 Compare April 27, 2020 06:45
@rmetzger
Copy link
Contributor Author

Thanks a lot for your review. I rebased to current master and added a comment for the Bash 4+ requirement.

Copy link
Contributor

@ifndef-SleePy ifndef-SleePy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for response and updating. LGTM

echo "Test (pid: $cmdpid) did not finish after $TEST_TIMEOUT_SECONDS seconds."
echo "Printing Flink logs and killing it:"
cat ${FLINK_DIR}/log/*
kill "$cmdpid") & watchdog_pid=$!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's OK for me :)

on_exit kill_test_watchdog

(
cmdpid=$BASHPID;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you are right. It's in another sub-process.

I come up with a work-around way. It probably works that executing the watchdog in original main process and executing the testing scripts in sub-process. We can get the sub-process pid in main process.

But I guess it's not a big deal, as MacOS is not a main scenario. I hope this PR could be merged asap. I would help a lot.

@rmetzger
Copy link
Contributor Author

Thanks for the review. Let's wait till Azure is green, then I'll merge it.

@rmetzger rmetzger closed this in 1855bf3 Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants