Skip to content

Commit

Permalink
[OSS-ONLY] Drop and recreate babelfish database before running dotnet…
Browse files Browse the repository at this point in the history
… tests in scheduled github actions (babelfish-for-postgresql#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 [email protected]
  • Loading branch information
tanscorpio7 authored Mar 3, 2025
1 parent 1676b52 commit 935b7df
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/jdbc-tests-pgaudit-enable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 935b7df

Please sign in to comment.