From 935b7df79cc460058383334baaebf6038e4b6944 Mon Sep 17 00:00:00 2001 From: Tanzeel Khan <140405735+tanscorpio7@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:24:02 +0530 Subject: [PATCH] [OSS-ONLY] Drop and recreate babelfish database before running dotnet tests in scheduled github actions (#3539) Drop and recreate babelfish database before running dotnet tests in scheduled github actions. We need to do this since JDBC tests leaves behind uncleaned objects which causes dotnet tests to fail. Issues Resolved [NO JIRA] Sign Off Signed-off-by: Tanzeel Khan tzlkhan@amazon.com --- .github/workflows/code-coverage.yml | 14 +++++++++++--- .github/workflows/jdbc-tests-pgaudit-enable.yml | 11 ++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index c039fb6b2e5..1ec9e7f3380 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -66,10 +66,18 @@ jobs: if: always() && steps.install-extensions.outcome == 'success' timeout-minutes: 60 uses: ./.github/composite-actions/run-jdbc-tests + + - name: Drop and re-create Babelfish database + id: re-install-extensions-1 + if: always() && steps.install-extensions.outcome == 'success' + run: | + sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -f .github/scripts/cleanup_babelfish_database.sql + sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -v migration_mode="multi-db" -v tsql_port=1433 -v parallel_query_mode=false -f .github/scripts/create_extension.sql + sqlcmd -S localhost -U "jdbc_user" -P 12345678 -Q "SELECT @@version GO" - name: Run Dotnet Tests id: install-and-run-dotnet - if: always() && steps.install-extensions.outcome == 'success' + if: always() && steps.re-install-extensions-1.outcome == 'success' uses: ./.github/composite-actions/install-and-run-dotnet - name: Run ODBC Tests @@ -78,7 +86,7 @@ jobs: uses: ./.github/composite-actions/install-and-run-odbc - name: Drop and re-create Babelfish database - id: re-install-extensions + id: re-install-extensions-2 if: always() && steps.install-extensions.outcome == 'success' run: | sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -f .github/scripts/cleanup_babelfish_database.sql @@ -87,7 +95,7 @@ jobs: - name: Run Python Tests id: install-and-run-python - if: always() && steps.re-install-extensions.outcome == 'success' + if: always() && steps.re-install-extensions-2.outcome == 'success' uses: ./.github/composite-actions/install-and-run-python - name: Generate code coverage HTML report diff --git a/.github/workflows/jdbc-tests-pgaudit-enable.yml b/.github/workflows/jdbc-tests-pgaudit-enable.yml index 05910884602..49d338b6a5f 100644 --- a/.github/workflows/jdbc-tests-pgaudit-enable.yml +++ b/.github/workflows/jdbc-tests-pgaudit-enable.yml @@ -129,9 +129,18 @@ jobs: timeout-minutes: 60 uses: ./.github/composite-actions/run-jdbc-tests + - name: Drop and re-create Babelfish database with pgaudit installed + id: re-install-extensions + if: always() && steps.install-extensions.outcome == 'success' + run: | + sudo ~/psql/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -f .github/scripts/cleanup_babelfish_database.sql + sudo ~/psql/bin/psql -v ON_ERROR_STOP=1 -d postgres -U runner -v user="jdbc_user" -v db="babelfish_db" -v migration_mode="multi-db" -v tsql_port=1433 -v parallel_query_mode=false -f .github/scripts/create_extension.sql + sudo PGPASSWORD=12345678 ~/${{ env.INSTALL_DIR }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user -c "CREATE EXTENSION pgaudit;" + sqlcmd -S localhost -U "jdbc_user" -P 12345678 -Q "SELECT @@version GO" + - name: Run Dotnet Tests id: run-dotnet-tests - if: always() && steps.install-extensions.outcome == 'success' + if: always() && steps.re-install-extensions.outcome == 'success' uses: ./.github/composite-actions/install-and-run-dotnet - name: Start secondary server