Skip to content

Commit

Permalink
[BEAM-9150] Fix beam_PostRelease_Python_Candidate (python RC validati…
Browse files Browse the repository at this point in the history
…on scripts) (#16955)
  • Loading branch information
emilymye authored Mar 1, 2022
1 parent 6b06cbb commit 6aafcfd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
35 changes: 31 additions & 4 deletions release/src/main/python-release/python_release_automation_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function cleanup_pubsub() {
# $2 - pid: the pid of running pipeline
# $3 - running_job (DataflowRunner only): the job id of streaming pipeline running on DataflowRunner
#######################################
function verify_steaming_result() {
function verify_streaming_result() {
retry=3
should_see="Python: "
while(( $retry > 0 )); do
Expand Down Expand Up @@ -295,9 +295,11 @@ function verify_user_score() {
function verify_hourly_team_score() {
retry=3
should_see='AntiqueBrassPlatypus'
runner=$1

while(( $retry >= 0 )); do
if [[ $retry > 0 ]]; then
bq_pull_result=$(bq head -n 500 $DATASET.hourly_team_score_python_$1)
bq_pull_result=$(bq head -n 500 ${DATASET}.${HOURLY_TEAM_SCORE_TABLE_PREFIX}_${runner})
if [[ $bq_pull_result = *"$should_see"* ]]; then
echo "SUCCEED: hourly_team_score example successful run on $1-runner"
break
Expand All @@ -307,14 +309,38 @@ function verify_hourly_team_score() {
sleep 15
fi
else
echo "FAILED: HourlyTeamScore example failed running on $1-runner. \
Did not found scores of team $should_see in $DATASET.leader_board"
echo "FAILED: HourlyTeamScore example failed running on $runner runner. \
Did not found scores of team $should_see in ${DATASET}.${HOURLY_TEAM_SCORE_TABLE_PREFIX}_${runner}"
complete "FAILED"
exit 1
fi
done
}

function cleanup_hourly_team_score() {
retry=3
runner=$1

echo "Removing previously created table ${DATASET}.${HOURLY_TEAM_SCORE_TABLE_PREFIX}_${runner}..."
bq rm -q -f -t "${DATASET}.${HOURLY_TEAM_SCORE_TABLE_PREFIX}_${runner}"

while(( $retry >= 0 )); do
if [[ $retry > 0 ]]; then
bq_ls_result=$(bq ls $DATASET)
if [[ $bq_ls_result = *"${HOURLY_TEAM_SCORE_TABLE_PREFIX}_${runner}"* ]]; then
retry=$(($retry-1))
echo "${DATASET}.${HOURLY_TEAM_SCORE_TABLE_PREFIX}_${runner} not cleaned up yet, waiting"
sleep 1000
else
echo "Confirmed ${DATASET}.${HOURLY_TEAM_SCORE_TABLE_PREFIX}_${runner} removed before running new test."
break
fi
else
echo "WARNING: Unable to clean up table ${DATASET}.${HOURLY_TEAM_SCORE_TABLE_PREFIX}_${runner}. \
You may need to manually run 'bq rm -r -t ${DATASET}.${HOURLY_TEAM_SCORE_TABLE_PREFIX}_${runner}'."
fi
done
}

# Python RC configurations
VERSION=$(get_version)
Expand All @@ -336,4 +362,5 @@ PUBSUB_SUBSCRIPTION='wordstream-python-sub2'
# Mobile Gaming Configurations
DATASET='beam_postrelease_mobile_gaming'
USERSCORE_OUTPUT_PREFIX='python-userscore_result'
HOURLY_TEAM_SCORE_TABLE_PREFIX='hourly_team_score_python'
GAME_INPUT_DATA='gs://dataflow-samples/game/5000_gaming_data.csv'
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,15 @@ function verify_userscore_dataflow() {
#######################################
function verify_hourlyteamscore_direct() {
print_separator "Running HourlyTeamScore example with DirectRunner"
# Clean up old bq tables
cleanup_hourly_team_score "direct"

python -m apache_beam.examples.complete.game.hourly_team_score \
--project=$PROJECT_ID \
--dataset=$DATASET \
--input=$GAME_INPUT_DATA \
--temp_location=gs://$BUCKET_NAME/temp/ \
--table="hourly_team_score_python_direct"
--table="${HOURLY_TEAM_SCORE_TABLE_PREFIX}_direct"

verify_hourly_team_score "direct"
}
Expand All @@ -121,6 +124,9 @@ function verify_hourlyteamscore_direct() {
#######################################
function verify_hourlyteamscore_dataflow() {
print_separator "Running HourlyTeamScore example with DataflowRunner"
# Clean up old bq tables
cleanup_hourly_team_score "dataflow"

python -m apache_beam.examples.complete.game.hourly_team_score \
--project=$PROJECT_ID \
--region=$REGION_ID \
Expand All @@ -129,7 +135,7 @@ function verify_hourlyteamscore_dataflow() {
--temp_location=gs://$BUCKET_NAME/temp/ \
--sdk_location $BEAM_PYTHON_SDK \
--input=$GAME_INPUT_DATA \
--table="hourly_team_score_python_dataflow"
--table="${HOURLY_TEAM_SCORE_TABLE_PREFIX}_dataflow"

verify_hourly_team_score "dataflow"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function verify_streaming_wordcount_direct() {

# verify result
run_pubsub_publish
verify_steaming_result "DirectRunner" $pid
verify_streaming_result "DirectRunner" $pid

kill -9 $pid
sleep 10
Expand Down Expand Up @@ -194,7 +194,7 @@ function verify_streaming_wordcount_dataflow() {
# verify result
run_pubsub_publish
sleep 420
verify_steaming_result "DataflowRunner" $pid $running_job
verify_streaming_result "DataflowRunner" $pid $running_job

kill -9 $pid
gcloud dataflow jobs cancel $running_job
Expand Down

0 comments on commit 6aafcfd

Please sign in to comment.