forked from babelfish-for-postgresql/babelfish_extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run Isolation tests as part of GitHub actions
This framework will be able to: 1. Parse and understand PG isolation level test(.spec) file. 2. Maintain multiple connections and get their status: active, blocked(waiting for lock) or error. 3. Execute SQL commands on any connection without blocking the main thread and other connections. 4. Cancel or Terminate the test/SQL command in case some long running step or deadlock condition is encountered. 5. Generate an output file with SQL results and compare it with expected file provided. Above functionality will ensure that it’ll be able to test isolation behaviour. Added tests for foreign key related isolation tests : fk-contention and fk-deadlock Task:BABEL-2836,2021 Author: Harsh Lunagariya lunharsh@amazon.com Signed-off-by: Harsh Lunagariya lunharsh@amazon.com
- Loading branch information
1 parent
5cdc4e7
commit 2d70e54
Showing
21 changed files
with
1,086 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: Babelfish Smoke Tests | ||
on: | ||
push: | ||
branches: | ||
pull_request: | ||
branches: | ||
|
||
jobs: | ||
isolation-tests: | ||
name: Isolation-Tests | ||
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 | ||
cd contrib && make && sudo make install | ||
- name: Copy ANTLR jar file | ||
run: | | ||
cd contrib/babelfishpg_tsql/antlr/thirdparty/antlr/ | ||
sudo cp antlr-4.9.3-complete.jar /usr/local/lib | ||
- name: Compile ANTLR | ||
run: | | ||
cd .. | ||
wget http://www.antlr.org/download/antlr4-cpp-runtime-4.9.3-source.zip | ||
unzip -d antlr4 antlr4-cpp-runtime-4.9.3-source.zip | ||
cd antlr4 | ||
mkdir build && cd build | ||
cmake .. -D ANTLR_JAR_LOCATION=/usr/local/lib/antlr-4.9.3-complete.jar -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True | ||
make | ||
sudo make install | ||
cp /usr/local/lib/libantlr4-runtime.so.4.9.3 ~/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 antlr4-python3-runtime | ||
- name: Generate .spec file parser | ||
run: | | ||
cd ~/work/babelfish_extensions/babelfish_extensions/test/python/isolationtest/ | ||
java -Xmx500M -cp /usr/local/lib/antlr-4.9.3-complete.jar org.antlr.v4.Tool -Dlanguage=Python3 ./parser/*.g4 -visitor -no-listener | ||
- name: Run Isolation 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 \ | ||
inputFilesPath=./input/isolation \ | ||
runIsolationTests=true \ | ||
stepTimeLimit=30 \ | ||
pytest -s --tb=long -q . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Ignore everything in the following directories except .gitkeep | ||
/output/*/* | ||
/logs/* | ||
!/**/.gitkeep | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
starting permutation : { ins com upd } | ||
step ins: INSERT INTO bar VALUES (42); | ||
~~ROW COUNT: 1~~ | ||
|
||
step com: COMMIT; | ||
step upd: UPDATE foo SET b = 'Hello World'; | ||
~~ROW COUNT: 1~~ | ||
|
||
|
||
starting permutation : { ins upd com } | ||
step ins: INSERT INTO bar VALUES (42); | ||
~~ROW COUNT: 1~~ | ||
|
||
step upd: UPDATE foo SET b = 'Hello World'; | ||
~~ROW COUNT: 1~~ | ||
|
||
step com: COMMIT; | ||
|
||
starting permutation : { upd ins com } | ||
step upd: UPDATE foo SET b = 'Hello World'; | ||
~~ROW COUNT: 1~~ | ||
|
||
step ins: INSERT INTO bar VALUES (42); | ||
~~ROW COUNT: 1~~ | ||
|
||
step com: COMMIT; |
Oops, something went wrong.