diff --git a/.github/composite-actions/build-extensions/action.yml b/.github/composite-actions/build-extensions/action.yml new file mode 100644 index 0000000000..f9761c8e35 --- /dev/null +++ b/.github/composite-actions/build-extensions/action.yml @@ -0,0 +1,18 @@ +name: 'Build Extensions' +runs: + using: "composite" + steps: + - name: Build Extensions + run: | + export PG_CONFIG=~/postgres/bin/pg_config + export PG_SRC=~/work/babelfish_extensions/postgresql_modified_for_babelfish + export cmake=$(which cmake) + cd contrib/babelfishpg_money + make && make install + cd ../babelfishpg_common + make && make install + cd ../babelfishpg_tds + make && make install + cd ../babelfishpg_tsql + make && make install + shell: bash diff --git a/.github/composite-actions/build-modified-postgres/action.yml b/.github/composite-actions/build-modified-postgres/action.yml new file mode 100644 index 0000000000..142e7a592a --- /dev/null +++ b/.github/composite-actions/build-modified-postgres/action.yml @@ -0,0 +1,16 @@ +name: 'Build Modified Postgres' + +runs: + using: "composite" + steps: + - name: Checkout, Build, and Install the Modified PostgreSQL Instance and Run Tests + run: | + cd .. + git clone https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish.git + cd postgresql_modified_for_babelfish + ./configure --prefix=$HOME/postgres/ --with-python PYTHON=/usr/bin/python2.7 --enable-debug CFLAGS="-ggdb" --with-libxml --with-uuid=ossp --with-icu + make -j 4 2>error.txt + make install + make check + cd contrib && make && sudo make install + shell: bash diff --git a/.github/composite-actions/compile-antlr/action.yml b/.github/composite-actions/compile-antlr/action.yml new file mode 100644 index 0000000000..a7e6b95532 --- /dev/null +++ b/.github/composite-actions/compile-antlr/action.yml @@ -0,0 +1,22 @@ +name: 'Compile ANTLR' + +runs: + using: "composite" + steps: + + - name: Compile ANTLR + run: | + ANTLR_VERSION=4.9.3 + + cd contrib/babelfishpg_tsql/antlr/thirdparty/antlr/ + sudo cp "antlr-$ANTLR_VERSION-complete.jar" /usr/local/lib + cd .. + wget "http://www.antlr.org/download/antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" + unzip -d antlr4 "antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" + cd antlr4 + mkdir build && cd build + cmake .. -D ANTLR_JAR_LOCATION="/usr/local/lib/antlr-$ANTLR_VERSION-complete.jar" -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True + make -j 4 + sudo make install + cp "/usr/local/lib/libantlr4-runtime.so.$ANTLR_VERSION" ~/postgres/lib/ + shell: bash diff --git a/.github/composite-actions/install-dependencies/action.yml b/.github/composite-actions/install-dependencies/action.yml new file mode 100644 index 0000000000..3763db93c7 --- /dev/null +++ b/.github/composite-actions/install-dependencies/action.yml @@ -0,0 +1,12 @@ +name: 'Install Dependencies' +runs: + using: "composite" + steps: + - name: Install Dependencies + run: | + cd ~ + sudo apt-get update + curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - + curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list + sudo apt-get install uuid-dev openjdk-8-jre libicu-dev libxml2-dev openssl libssl-dev python-dev libossp-uuid-dev libpq-dev cmake pkg-config g++ build-essential bison mssql-tools unixodbc-dev + shell: bash diff --git a/.github/composite-actions/install-extensions/action.yml b/.github/composite-actions/install-extensions/action.yml new file mode 100644 index 0000000000..e8d96b94e2 --- /dev/null +++ b/.github/composite-actions/install-extensions/action.yml @@ -0,0 +1,21 @@ +name: 'Install Extensions' + +runs: + using: "composite" + steps: + - name: Install Extensions + run: | + cd ~ + export PATH=/opt/mssql-tools/bin:$PATH + ~/postgres/bin/initdb -D ~/postgres/data/ + ~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile start + cd postgres/data + sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" postgresql.conf + sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'babelfishpg_tds'/g" postgresql.conf + ipaddress=$(ifconfig eth0 | grep 'inet ' | cut -d: -f2 | awk '{ print $2}') + sudo echo "host all all $ipaddress/32 trust" >> pg_hba.conf + ~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile restart + cd ~/work/babelfish_extensions/babelfish_extensions/ + sudo ~/postgres/bin/psql -d postgres -U runner -v user="jdbc_user" -v db="jdbc_testdb" -f .github/scripts/create_extension.sql + sqlcmd -S localhost -U "jdbc_user" -P 12345678 -Q "SELECT @@version GO" + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 220706b314..0000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,116 +0,0 @@ -name: JDBC Unit Tests -on: - push: - branches: - - BABEL_1_X_DEV - pull_request: - branches: - - BABEL_1_X_DEV - -jobs: - extension-tests: - name: Build and test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Clone, build, and run tests for Postgres engine - run: | - cd .. - git clone https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish.git - sudo apt-get update - sudo apt-get install uuid-dev openjdk-8-jre libicu-dev libxml2-dev openssl libssl-dev python-dev libossp-uuid-dev libpq-dev cmake pkg-config g++ build-essential bison - cd postgresql_modified_for_babelfish - ./configure --prefix=$HOME/postgres/ --with-python PYTHON=/usr/bin/python2.7 --enable-debug CFLAGS="-ggdb" --with-libxml --with-uuid=ossp --with-icu - make -j 4 2>error.txt - make install - make check - cd contrib && make && sudo make install - - name: Compile ANTLR - id: compile-antlr - if: always() && steps.postgres.outcome == 'success' - run: | - ANTLR_VERSION=4.9.3 - - cd contrib/babelfishpg_tsql/antlr/thirdparty/antlr/ - sudo cp "antlr-$ANTLR_VERSION-complete.jar" /usr/local/lib - cd .. - wget "http://www.antlr.org/download/antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" - unzip -d antlr4 "antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" - cd antlr4 - mkdir build && cd build - cmake .. -D ANTLR_JAR_LOCATION="/usr/local/lib/antlr-$ANTLR_VERSION-complete.jar" -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True - make - sudo make install - cp "/usr/local/lib/libantlr4-runtime.so.$ANTLR_VERSION" ~/postgres/lib/ - - name: Set env variables and build extensions - run: | - export PG_CONFIG=~/postgres/bin/pg_config - export PG_SRC=~/work/babelfish_extensions/postgresql_modified_for_babelfish - export cmake=$(which cmake) - cd contrib/babelfishpg_money - make && make install - cd ../babelfishpg_common - make && make install - cd ../babelfishpg_tds - make && make install - echo Now building bbf_tsql - cd ../babelfishpg_tsql - make && make install - - name: Install extensions - run: | - cd ~ - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list - sudo apt-get install mssql-tools unixodbc-dev - export PATH=/opt/mssql-tools/bin:$PATH - ~/postgres/bin/initdb -D ~/postgres/data/ - ~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile start - cd postgres/data - sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" postgresql.conf - sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'babelfishpg_tds'/g" postgresql.conf - ipaddress=$(ifconfig eth0 | grep 'inet ' | cut -d: -f2 | awk '{ print $2}') - sudo echo "host all all $ipaddress/32 trust" >> pg_hba.conf - ~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile restart - sudo ~/postgres/bin/psql -d postgres -U runner -c "CREATE USER jdbc_user WITH SUPERUSER CREATEDB CREATEROLE PASSWORD '12345678' INHERIT;" - sudo ~/postgres/bin/psql -d postgres -U runner -c "DROP DATABASE IF EXISTS jdbc_testdb;" - sudo ~/postgres/bin/psql -d postgres -U runner -c "CREATE DATABASE jdbc_testdb OWNER jdbc_user;" - sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "set allow_system_table_mods = on;" - sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "CREATE EXTENSION IF NOT EXISTS "babelfishpg_tds" CASCADE;" - sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "GRANT ALL ON SCHEMA sys to jdbc_user;" - sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "ALTER USER jdbc_user CREATEDB;" - sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.database_name = 'jdbc_testdb';" - sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "SELECT pg_reload_conf();" - sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "CALL sys.initialize_babelfish('jdbc_user');" - sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "SELECT @@version GO" - - name: Run JDBC test framework - timeout-minutes: 15 - run: | - cd test/JDBC/ - mvn test - - name: Upload log - if: ${{ failure() }} - uses: actions/upload-artifact@v2 - with: - name: postgres-log - path: ~/postgres/data/logfile - # The test summary files contain paths with ':' characters, which is not allowed with the upload-artifact actions - - name: Rename test summary files - if: ${{ failure() }} - run: | - cd test/JDBC/Info - timestamp=`ls -Art | tail -n 1` - cd $timestamp - mv $timestamp.diff ../output-diff.diff - mv "$timestamp"_runSummary.log ../run-summary.log - - name: Upload run summary - if: ${{ failure() }} - uses: actions/upload-artifact@v2 - with: - name: run-summary.log - path: test/JDBC/Info/run-summary.log - - name: Upload output diff - if: ${{ failure() }} - uses: actions/upload-artifact@v2 - with: - name: output-diff.diff - path: test/JDBC/Info/output-diff.diff diff --git a/.github/workflows/dotnet-framework.yml b/.github/workflows/dotnet-framework.yml deleted file mode 100644 index e21fd6230a..0000000000 --- a/.github/workflows/dotnet-framework.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: .NET Tests -on: [push, pull_request] - -jobs: - dotnet: - name: Dotnet - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Clone, build, and run tests for Postgres engine - id: postgres - if: always() - run: | - cd .. - git clone https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish.git - sudo apt-get update - sudo apt-get install uuid-dev openjdk-8-jre libicu-dev libxml2-dev openssl libssl-dev python-dev libossp-uuid-dev libpq-dev cmake pkg-config g++ build-essential bison - cd postgresql_modified_for_babelfish - ./configure --prefix=$HOME/postgres/ --with-python PYTHON=/usr/bin/python2.7 --enable-debug CFLAGS="-ggdb" --with-libxml --with-uuid=ossp --with-icu - make -j 4 2>error.txt - make install - cd contrib && make && sudo make install - - name: Compile ANTLR - id: compile-antlr - if: always() && steps.postgres.outcome == 'success' - run: | - ANTLR_VERSION=4.9.3 - - cd contrib/babelfishpg_tsql/antlr/thirdparty/antlr/ - sudo cp "antlr-$ANTLR_VERSION-complete.jar" /usr/local/lib - cd .. - wget "http://www.antlr.org/download/antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" - unzip -d antlr4 "antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" - cd antlr4 - mkdir build && cd build - cmake .. -D ANTLR_JAR_LOCATION="/usr/local/lib/antlr-$ANTLR_VERSION-complete.jar" -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True - make - sudo make install - cp "/usr/local/lib/libantlr4-runtime.so.$ANTLR_VERSION" ~/postgres/lib/ - - name: Set env variables and build extensions - run: | - export PG_CONFIG=~/postgres/bin/pg_config - export PG_SRC=~/work/babelfish_extensions/postgresql_modified_for_babelfish - export cmake=$(which cmake) - cd contrib/babelfishpg_money - make && make install - cd ../babelfishpg_common - make && make install - cd ../babelfishpg_tds - make && make install - cd ../babelfishpg_tsql - make && make install - - name: Install extensions - run: | - cd ~ - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list - sudo apt-get install mssql-tools unixodbc-dev - export PATH=/opt/mssql-tools/bin:$PATH - ~/postgres/bin/initdb -D ~/postgres/data/ - ~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile start - cd postgres/data - sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" postgresql.conf - sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'babelfishpg_tds'/g" postgresql.conf - ipaddress=$(ifconfig eth0 | grep 'inet ' | cut -d: -f2 | awk '{ print $2}') - sudo echo "host all all $ipaddress/32 trust" >> pg_hba.conf - ~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile restart - cd ~/work/babelfish_extensions/babelfish_extensions/ - sudo ~/postgres/bin/psql -d postgres -U runner -v user="dotnet_user" -v db="dotnet_testdb" -f .github/scripts/create_extension.sql - sqlcmd -S localhost -U dotnet_user -P 12345678 -Q "SELECT @@version GO" - - name: Install dotnet - run: | - cd ~ - wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb - sudo dpkg -i packages-microsoft-prod.deb - rm packages-microsoft-prod.deb - sudo apt-get update - sudo apt-get install -y apt-transport-https - sudo apt-get update - sudo apt-get install -y dotnet-sdk-5.0 - sudo apt-get update - sudo apt-get install -y apt-transport-https - sudo apt-get update - sudo apt-get install -y aspnetcore-runtime-5.0 - - name: Run dotnet tests - run: | - cd test/dotnet - dotnet build - babel_URL=localhost \ - babel_port=1433 \ - babel_databaseName=master \ - babel_user=dotnet_user \ - babel_password=12345678 \ - testName="all---TestUDD.txt;TestChar.txt;TestSqlVariant.txt;TestVarChar.txt;TestTvp.txt;TestAuthentication.txt;TestText.txt" \ - dotnet test diff --git a/.github/workflows/dotnet-tests.yml b/.github/workflows/dotnet-tests.yml new file mode 100644 index 0000000000..5ff0a6668b --- /dev/null +++ b/.github/workflows/dotnet-tests.yml @@ -0,0 +1,60 @@ +name: Dotnet Framework Tests +on: [push, pull_request] + +jobs: + run-babelfish-dotnet-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + id: checkout + + - name: Install Dependencies + id: install-dependencies + if: always() + uses: ./.github/composite-actions/install-dependencies + + - name: Build Modified Postgres + id: build-modified-postgres + if: always() && steps.install-dependencies.outcome == 'success' + uses: ./.github/composite-actions/build-modified-postgres + + - name: Compile ANTLR + id: compile-antlr + if: always() && steps.build-modified-postgres.outcome == 'success' + uses: ./.github/composite-actions/compile-antlr + + - name: Build Extensions + id: build-extensions + if: always() && steps.compile-antlr.outcome == 'success' + uses: ./.github/composite-actions/build-extensions + + - name: Install Extensions + id: install-extensions + if: always() && steps.build-extensions.outcome == 'success' + uses: ./.github/composite-actions/install-extensions + + - name: Install Dotnet + id: install-dotnet + if: always() && steps.install-extensions.outcome == 'success' + run: | + cd ~ + wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb + sudo dpkg -i packages-microsoft-prod.deb + rm packages-microsoft-prod.deb + sudo apt-get install -y apt-transport-https + sudo apt-get install -y dotnet-sdk-5.0 + sudo apt-get install -y apt-transport-https + sudo apt-get install -y aspnetcore-runtime-5.0 + + - name: Run Dotnet Tests + if: always() && steps.install-dotnet.outcome == 'success' + run: | + cd test/dotnet + dotnet build + babel_URL=localhost \ + babel_port=1433 \ + babel_databaseName=master \ + babel_user=jdbc_user \ + babel_password=12345678 \ + testName="all---TestUDD.txt;TestChar.txt;TestSqlVariant.txt;TestVarChar.txt;TestTvp.txt;TestAuthentication.txt;TestText.txt" \ + dotnet test diff --git a/.github/workflows/isolation-tests.yml b/.github/workflows/isolation-tests.yml index baabcb7bc5..72cebb0d8e 100644 --- a/.github/workflows/isolation-tests.yml +++ b/.github/workflows/isolation-tests.yml @@ -11,72 +11,38 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Clone, build, and run tests for Postgres engine - id: postgres + id: checkout + + - name: Install Dependencies + id: install-dependencies if: always() - run: | - cd .. - git clone https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish.git - sudo apt-get update - sudo apt-get install uuid-dev openjdk-8-jre libicu-dev libxml2-dev openssl libssl-dev python-dev libossp-uuid-dev libpq-dev cmake pkg-config g++ build-essential bison - cd postgresql_modified_for_babelfish - ./configure --prefix=$HOME/postgres/ --with-python PYTHON=/usr/bin/python2.7 --enable-debug CFLAGS="-ggdb" --with-libxml --with-uuid=ossp --with-icu - make -j 4 2>error.txt - make install - cd contrib && make && sudo make install + uses: ./.github/composite-actions/install-dependencies + + - name: Build Modified Postgres + id: build-modified-postgres + if: always() && steps.install-dependencies.outcome == 'success' + uses: ./.github/composite-actions/build-modified-postgres + - name: Compile ANTLR id: compile-antlr - if: always() && steps.postgres.outcome == 'success' - run: | - ANTLR_VERSION=4.9.3 - - cd contrib/babelfishpg_tsql/antlr/thirdparty/antlr/ - sudo cp "antlr-$ANTLR_VERSION-complete.jar" /usr/local/lib - cd .. - wget "http://www.antlr.org/download/antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" - unzip -d antlr4 "antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" - cd antlr4 - mkdir build && cd build - cmake .. -D ANTLR_JAR_LOCATION="/usr/local/lib/antlr-$ANTLR_VERSION-complete.jar" -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True - make - sudo make install - cp "/usr/local/lib/libantlr4-runtime.so.$ANTLR_VERSION" ~/postgres/lib/ - - name: Set env variables and build extensions - run: | - export PG_CONFIG=~/postgres/bin/pg_config - export PG_SRC=~/work/babelfish_extensions/postgresql_modified_for_babelfish - export cmake=$(which cmake) - cd contrib/babelfishpg_money - make && make install - cd ../babelfishpg_common - make && make install - cd ../babelfishpg_tds - make && make install - cd ../babelfishpg_tsql - make && make install - - name: Install extensions - run: | - cd ~ - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list - sudo apt-get update - sudo apt-get install -y mssql-tools unixodbc-dev - export PATH=/opt/mssql-tools/bin:$PATH - ~/postgres/bin/initdb -D ~/postgres/data/ - ~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile start - cd postgres/data - sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" postgresql.conf - sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'babelfishpg_tds'/g" postgresql.conf - ipaddress=$(ifconfig eth0 | grep 'inet ' | cut -d: -f2 | awk '{ print $2}') - sudo echo "host all all $ipaddress/32 trust" >> pg_hba.conf - ~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile restart - cd ~/work/babelfish_extensions/babelfish_extensions/ - sudo ~/postgres/bin/psql -d postgres -U runner -v user="python_user" -v db="python_testdb" -f .github/scripts/create_extension.sql - sqlcmd -S localhost -U python_user -P 12345678 -Q "SELECT @@version GO" + if: always() && steps.build-modified-postgres.outcome == 'success' + uses: ./.github/composite-actions/compile-antlr + + - name: Build Extensions + id: build-extensions + if: always() && steps.compile-antlr.outcome == 'success' + uses: ./.github/composite-actions/build-extensions + + - name: Install Extensions + id: install-extensions + if: always() && steps.build-extensions.outcome == 'success' + uses: ./.github/composite-actions/install-extensions + - name: Install Python uses: actions/setup-python@v2 with: python-version: 3.7 + - name: Configure Python environment run: | cd ~ @@ -84,6 +50,7 @@ jobs: cd ~/work/babelfish_extensions/babelfish_extensions/test/python sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17 python3-dev pip3 install pyodbc pymssql pytest pytest-xdist antlr4-python3-runtime + - name: Generate .spec file parser run: | cd ~/work/babelfish_extensions/babelfish_extensions/test/python/isolationtest/ @@ -100,7 +67,7 @@ jobs: fileGenerator_URL=localhost \ fileGenerator_port=1433 \ fileGenerator_databaseName=master \ - fileGenerator_user=python_user \ + fileGenerator_user=jdbc_user \ fileGenerator_password=12345678 \ inputFilesPath=./input/isolation \ runIsolationTests=true \ diff --git a/.github/workflows/jdbc-tests.yml b/.github/workflows/jdbc-tests.yml new file mode 100644 index 0000000000..28d74a7700 --- /dev/null +++ b/.github/workflows/jdbc-tests.yml @@ -0,0 +1,74 @@ +name: JDBC Tests +on: [push, pull_request] + +jobs: + run-babelfish-jdbc-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + id: checkout + + - name: Install Dependencies + id: install-dependencies + if: always() + uses: ./.github/composite-actions/install-dependencies + + - name: Build Modified Postgres + id: build-modified-postgres + if: always() && steps.install-dependencies.outcome == 'success' + uses: ./.github/composite-actions/build-modified-postgres + + - name: Compile ANTLR + id: compile-antlr + if: always() && steps.build-modified-postgres.outcome == 'success' + uses: ./.github/composite-actions/compile-antlr + + - name: Build Extensions + id: build-extensions + if: always() && steps.compile-antlr.outcome == 'success' + uses: ./.github/composite-actions/build-extensions + + - name: Install Extensions + id: install-extensions + if: always() && steps.build-extensions.outcome == 'success' + uses: ./.github/composite-actions/install-extensions + + - name: Run JDBC Tests + id: jdbc + if: always() && steps.install-extensions.outcome == 'success' + timeout-minutes: 15 + run: | + cd test/JDBC/ + mvn test + + - name: Upload Log + if: always() && steps.jdbc.outcome == 'failure' + uses: actions/upload-artifact@v2 + with: + name: postgres-log + path: ~/postgres/data/logfile + + # The test summary files contain paths with ':' characters, which is not allowed with the upload-artifact actions + - name: Rename Test Summary Files + id: test-file-rename + if: always() && steps.jdbc.outcome == 'failure' + run: | + cd test/JDBC/Info + timestamp=`ls -Art | tail -n 1` + cd $timestamp + mv $timestamp.diff ../output-diff.diff + mv "$timestamp"_runSummary.log ../run-summary.log + + - name: Upload Run Summary + if: always() && steps.test-file-rename == 'success' + uses: actions/upload-artifact@v2 + with: + name: run-summary.log + path: test/JDBC/Info/run-summary.log + + - name: Upload Output Diff + if: always() && steps.jdbc.outcome == 'failure' + uses: actions/upload-artifact@v2 + with: + name: output-diff.diff + path: test/JDBC/Info/output-diff.diff diff --git a/.github/workflows/odbc-framework.yml b/.github/workflows/odbc-framework.yml deleted file mode 100644 index 277469a9fe..0000000000 --- a/.github/workflows/odbc-framework.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: ODBC Tests -on: [push, pull_request] - -jobs: - odbc: - name: ODBC - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Clone, build, and run tests for Postgres engine - id: postgres - if: always() - run: | - cd .. - git clone https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish.git - sudo apt-get update - sudo apt-get install uuid-dev openjdk-8-jre libicu-dev libxml2-dev openssl libssl-dev python-dev libossp-uuid-dev libpq-dev cmake pkg-config g++ build-essential bison - cd postgresql_modified_for_babelfish - ./configure --prefix=$HOME/postgres/ --with-python PYTHON=/usr/bin/python2.7 --enable-debug CFLAGS="-ggdb" --with-libxml --with-uuid=ossp --with-icu - make -j 4 2>error.txt - make install - cd contrib && make && sudo make install - - name: Compile ANTLR - id: compile-antlr - if: always() && steps.postgres.outcome == 'success' - run: | - ANTLR_VERSION=4.9.3 - - cd contrib/babelfishpg_tsql/antlr/thirdparty/antlr/ - sudo cp "antlr-$ANTLR_VERSION-complete.jar" /usr/local/lib - cd .. - wget "http://www.antlr.org/download/antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" - unzip -d antlr4 "antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" - cd antlr4 - mkdir build && cd build - cmake .. -D ANTLR_JAR_LOCATION="/usr/local/lib/antlr-$ANTLR_VERSION-complete.jar" -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True - make - sudo make install - cp "/usr/local/lib/libantlr4-runtime.so.$ANTLR_VERSION" ~/postgres/lib/ - - name: Set env variables and build extensions - run: | - export PG_CONFIG=~/postgres/bin/pg_config - export PG_SRC=~/work/babelfish_extensions/postgresql_modified_for_babelfish - export cmake=$(which cmake) - cd contrib/babelfishpg_money - make && make install - cd ../babelfishpg_common - make && make install - cd ../babelfishpg_tds - make && make install - cd ../babelfishpg_tsql - make && make install - - name: Install extensions - run: | - cd ~ - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list - sudo apt-get install mssql-tools unixodbc-dev - export PATH=/opt/mssql-tools/bin:$PATH - ~/postgres/bin/initdb -D ~/postgres/data/ - ~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile start - cd postgres/data - sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" postgresql.conf - sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'babelfishpg_tds'/g" postgresql.conf - ipaddress=$(ifconfig eth0 | grep 'inet ' | cut -d: -f2 | awk '{ print $2}') - sudo echo "host all all $ipaddress/32 trust" >> pg_hba.conf - ~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile restart - cd ~/work/babelfish_extensions/babelfish_extensions/ - sudo ~/postgres/bin/psql -d postgres -U runner -v user="odbc_user" -v db="odbc_testdb" -f .github/scripts/create_extension.sql - sqlcmd -S localhost -U odbc_user -P 12345678 -Q "SELECT @@version GO" - - name: Install ODBC driver - run: | - cd ~ - sudo apt-get install msodbcsql17 - - name: Run ODBC tests - run: | - cd test/odbc - cmake -S . -B build - cmake --build build - BABEL_DB_SERVER=localhost \ - BABEL_DB_PORT=1433 \ - BABEL_DB_USER=odbc_user \ - BABEL_DB_PASSWORD=12345678 \ - BABEL_DB_NAME=master \ - ./build/main diff --git a/.github/workflows/odbc-tests.yml b/.github/workflows/odbc-tests.yml new file mode 100644 index 0000000000..fcea2a5efc --- /dev/null +++ b/.github/workflows/odbc-tests.yml @@ -0,0 +1,54 @@ +name: ODBC Tests +on: [push, pull_request] + +jobs: + run-babelfish-odbc-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + id: checkout + + - name: Install Dependencies + id: install-dependencies + if: always() + uses: ./.github/composite-actions/install-dependencies + + - name: Build Modified Postgres + id: build-modified-postgres + if: always() && steps.install-dependencies.outcome == 'success' + uses: ./.github/composite-actions/build-modified-postgres + + - name: Compile ANTLR + id: compile-antlr + if: always() && steps.build-modified-postgres.outcome == 'success' + uses: ./.github/composite-actions/compile-antlr + + - name: Build Extensions + id: build-extensions + if: always() && steps.compile-antlr.outcome == 'success' + uses: ./.github/composite-actions/build-extensions + + - name: Install Extensions + id: install-extensions + if: always() && steps.build-extensions.outcome == 'success' + uses: ./.github/composite-actions/install-extensions + + - name: Install ODBC Driver + id: install-odbc-driver + if: always() && steps.install-extensions.outcome == 'success' + run: | + cd ~ + sudo apt-get install msodbcsql17 + + - name: Run ODBC Tests + if: always() && steps.install-odbc-driver.outcome == 'success' + run: | + cd test/odbc + cmake -S . -B build + cmake --build build + BABEL_DB_SERVER=localhost \ + BABEL_DB_PORT=1433 \ + BABEL_DB_USER=jdbc_user \ + BABEL_DB_PASSWORD=12345678 \ + BABEL_DB_NAME=master \ + ./build/main diff --git a/.github/workflows/python-framework.yml b/.github/workflows/python-framework.yml deleted file mode 100644 index d80005a8a0..0000000000 --- a/.github/workflows/python-framework.yml +++ /dev/null @@ -1,96 +0,0 @@ -name: Python Tests -on: [push, pull_request] - -jobs: - python: - name: Python - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Clone, build, and run tests for Postgres engine - id: postgres - if: always() - run: | - cd .. - git clone https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish.git - sudo apt-get update - sudo apt-get install uuid-dev openjdk-8-jre libicu-dev libxml2-dev openssl libssl-dev python-dev libossp-uuid-dev libpq-dev cmake pkg-config g++ build-essential bison - cd postgresql_modified_for_babelfish - ./configure --prefix=$HOME/postgres/ --with-python PYTHON=/usr/bin/python2.7 --enable-debug CFLAGS="-ggdb" --with-libxml --with-uuid=ossp --with-icu - make -j 4 2>error.txt - make install - cd contrib && make && sudo make install - - name: Compile ANTLR - id: compile-antlr - if: always() && steps.postgres.outcome == 'success' - run: | - ANTLR_VERSION=4.9.3 - - cd contrib/babelfishpg_tsql/antlr/thirdparty/antlr/ - sudo cp "antlr-$ANTLR_VERSION-complete.jar" /usr/local/lib - cd .. - wget "http://www.antlr.org/download/antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" - unzip -d antlr4 "antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" - cd antlr4 - mkdir build && cd build - cmake .. -D ANTLR_JAR_LOCATION="/usr/local/lib/antlr-$ANTLR_VERSION-complete.jar" -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True - make - sudo make install - cp "/usr/local/lib/libantlr4-runtime.so.$ANTLR_VERSION" ~/postgres/lib/ - - name: Set env variables and build extensions - run: | - export PG_CONFIG=~/postgres/bin/pg_config - export PG_SRC=~/work/babelfish_extensions/postgresql_modified_for_babelfish - export cmake=$(which cmake) - cd contrib/babelfishpg_money - make && make install - cd ../babelfishpg_common - make && make install - cd ../babelfishpg_tds - make && make install - cd ../babelfishpg_tsql - make && make install - - name: Install extensions - run: | - cd ~ - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list - sudo apt-get update - sudo apt-get install -y mssql-tools unixodbc-dev - export PATH=/opt/mssql-tools/bin:$PATH - ~/postgres/bin/initdb -D ~/postgres/data/ - ~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile start - cd postgres/data - sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" postgresql.conf - sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'babelfishpg_tds'/g" postgresql.conf - ipaddress=$(ifconfig eth0 | grep 'inet ' | cut -d: -f2 | awk '{ print $2}') - sudo echo "host all all $ipaddress/32 trust" >> pg_hba.conf - ~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile restart - cd ~/work/babelfish_extensions/babelfish_extensions/ - sudo ~/postgres/bin/psql -d postgres -U runner -v user="python_user" -v db="python_testdb" -f .github/scripts/create_extension.sql - sqlcmd -S localhost -U python_user -P 12345678 -Q "SELECT @@version GO" - - name: Install Python - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - name: Configure Python environment - run: | - cd ~ - curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list - cd ~/work/babelfish_extensions/babelfish_extensions/test/python - sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17 python3-dev - pip3 install pyodbc pymssql pytest pytest-xdist - - name: Run Python tests - run: | - cd test/python - compareWithFile=true \ - driver=pyodbc \ - runInParallel=false \ - testName=all \ - provider="ODBC Driver 17 for SQL Server" \ - fileGenerator_URL=localhost \ - fileGenerator_port=1433 \ - fileGenerator_databaseName=master \ - fileGenerator_user=python_user \ - fileGenerator_password=12345678 \ - pytest -s --tb=long -q . diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml new file mode 100644 index 0000000000..858eca296f --- /dev/null +++ b/.github/workflows/python-tests.yml @@ -0,0 +1,67 @@ +name: Python Tests +on: [push, pull_request] + +jobs: + run-babelfish-python-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + id: checkout + + - name: Install Dependencies + id: install-dependencies + if: always() + uses: ./.github/composite-actions/install-dependencies + + - name: Build Modified Postgres + id: build-modified-postgres + if: always() && steps.install-dependencies.outcome == 'success' + uses: ./.github/composite-actions/build-modified-postgres + + - name: Compile ANTLR + id: compile-antlr + if: always() && steps.build-modified-postgres.outcome == 'success' + uses: ./.github/composite-actions/compile-antlr + + - name: Build Extensions + id: build-extensions + if: always() && steps.compile-antlr.outcome == 'success' + uses: ./.github/composite-actions/build-extensions + + - name: Install Extensions + id: install-extensions + if: always() && steps.build-extensions.outcome == 'success' + uses: ./.github/composite-actions/install-extensions + + - name: Install Python + id: install-python + if: always() && steps.install-extensions.outcome == 'success' + uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Configure Python Environment + id: configure-python-environment + if: always() && steps.install-python.outcome == 'success' + run: | + cd ~ + curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list + cd ~/work/babelfish_extensions/babelfish_extensions/test/python + sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17 python3-dev + pip3 install pyodbc pymssql pytest pytest-xdist + + - name: Run Python Tests + if: always() && steps.configure-python-environment.outcome == 'success' + run: | + cd test/python + compareWithFile=true \ + driver=pyodbc \ + runInParallel=false \ + testName=all \ + provider="ODBC Driver 17 for SQL Server" \ + fileGenerator_URL=localhost \ + fileGenerator_port=1433 \ + fileGenerator_databaseName=master \ + fileGenerator_user=jdbc_user \ + fileGenerator_password=12345678 \ + pytest -s --tb=long -q .