Skip to content

Commit

Permalink
Ensure accurate metadata inconsistency checks
Browse files Browse the repository at this point in the history
This commit addresses metadata inconsistency checks, ensuring they occur
in the appropriate places. Additionally, steps have been added to verify
the existence of the inconsistency checker function before performing
the metadata checks.

Task: BABEL-4139
Signed-off-by: Roshan Kanwar <[email protected]>
  • Loading branch information
roshan0708 committed May 20, 2024
1 parent eda23ea commit d623d5e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
28 changes: 25 additions & 3 deletions .github/composite-actions/check-babelfish-inconsistency/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,31 @@ description: Check for Babelfish metadata inconsistency before Major/Minor Versi
runs:
using: 'composite'
steps:
- name: Check if Babelfish metadata inconsistency function exists
id: check-function-existence
run: |
function_exists=$(sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "
SELECT CASE WHEN COUNT(*) > 0 THEN 'exists' ELSE 'not_exists' END
FROM pg_proc
WHERE proname = 'check_for_inconsistent_metadata';
GO" | grep 'exists')
if [[ -z "$function_exists" ]]; then
function_exists="not_exists"
fi
echo "babelfish_metadata_function_exists=$function_exists" >> "$GITHUB_OUTPUT"
shell: bash

- name: Check Babelfish metadata inconsistency
id: check-babelfish-inconsistency
if: always() && steps.check-function-existence.outputs.babelfish_metadata_function_exists == 'exists'
id: check-babelfish-metadata
run: |
output=$(sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "SELECT sys.check_for_inconsistent_metadata() GO" | tail -n +2)
echo "check_result=$output" >> "$GITHUB_OUTPUT"
output=$(sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "SELECT 'check_result=',sys.check_for_inconsistent_metadata() GO" | grep 'check_result' | sed 's/[[:blank:]]//g')
check_result=$(echo "$output" | grep -oP 'check_result=\K.+')
echo "$output" >> "$GITHUB_OUTPUT"
if [[ "$check_result" == "0" ]]; then
echo "Check Babelfish metadata inconsistency failed"
exit 1
else
echo "Check Babelfish metadata inconsistency succeeded"
fi
shell: bash
9 changes: 8 additions & 1 deletion .github/composite-actions/setup-base-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,15 @@ runs:
python3 upgrade_validation.py
shell: bash

- name: Run Babelfish metadata inconsistency check
id: check-babelfish-inconsistency
if: always() && steps.run-dependency-check.outcome == 'success'
uses: ./.github/composite-actions/check-babelfish-inconsistency

- name: Upload artifacts
if: always() && steps.run-dependency-check.outcome == 'failure'
if: |
always() && (steps.run-dependency-check.outcome == 'failure'
|| steps.check-babelfish-inconsistency.outcome == 'failure')
run: |
mkdir -p ~/upgrade
cp test/python/output/upgrade_validation/* ~/upgrade
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/major-version-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ jobs:
- name: Run pg_upgrade
id: run-pg_upgrade
if: |
always() && steps.setup-new-datadir.outcome == 'success'
&& steps.check-babelfish-inconsistency.outcome == 'success'
&& steps.check-babelfish-inconsistency.outputs.check_result == 0
always() && steps.setup-new-datadir.outcome == 'success'
&& steps.check-babelfish-inconsistency.outcome == 'success'
uses: ./.github/composite-actions/run-pg-upgrade

- name: Run JDBC Tests
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/singledb-version-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ jobs:
id: upgrade-and-verify
if: |
always() && steps.setup-base-version.outcome == 'success'
&& steps.check-babelfish-inconsistency.outcome == 'success'
&& steps.check-babelfish-inconsistency.outputs.check_result == 0
&& steps.check-babelfish-inconsistency.outcome == 'success'
uses: ./.github/composite-actions/major-version-upgrade-util
with:
engine_branch: latest
Expand Down

0 comments on commit d623d5e

Please sign in to comment.