Skip to content

Commit

Permalink
test DBMS support with Posit Pro Drivers (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch authored Jun 17, 2024
1 parent 3bdcf11 commit 4090f0a
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 4 deletions.
41 changes: 39 additions & 2 deletions .github/odbc/odbc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ BoolsAsChar = No
ConnSettings = set time zone 'UTC'; set client_encoding to 'UTF-8';
UseDeclareFetch = 1

[ProPostgreSQL]
Driver = /home/runner/work/odbc/odbc/.github/odbc/pro_drivers/postgresql/bin/lib/libpostgresqlodbc_sb64.so
Database = test
Servername = localhost
UserName = postgres
Password = password
Port = 5432
UseServerSidePrepare = 1
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
BoolsAsChar = No
ConnSettings = set time zone 'UTC'; set client_encoding to 'UTF-8';
UseDeclareFetch = 1

[MySQL]
Driver = MySQL Driver
Database = test
Expand All @@ -27,6 +44,15 @@ password = root
Port = 3306
charset=utf8mb4

[ProMySQL]
Driver = /home/runner/work/odbc/odbc/.github/odbc/pro_drivers/mysql/bin/lib/libmysqlodbc_sb64.so
Database = test
Server = 127.0.0.1
User = root
password = root
Port = 3306
charset=utf8mb4

[SQLite]
Description = Test db
Driver = SQLite Driver
Expand All @@ -38,15 +64,26 @@ Driver = ODBC Driver 17 for SQL Server
Server = localhost
Port = 1433

[ProMicrosoftSQLServer]
Driver = /home/runner/work/odbc/odbc/.github/odbc/pro_drivers/sql_server/bin/lib/libsqlserverodbc_sb64.so
Server = localhost
Port = 1433

[Oracle]
Description = Oracle
Driver = Oracle 21 ODBC driver
Port = 1521

; note that db.yaml GHA requires that this is the last DSN entry
[ProOracle]
Driver = /home/runner/work/odbc/odbc/.github/odbc/pro_drivers/oracle/bin/lib/liboracleodbc_sb64.so
Port = 1521
Host = localhost
SVC = FREEPDB1

; note that db.yaml / dp-pro.yaml GHA requires that this is the last DSN entry.
; `Driver=` entry is programmatically written.
[snowflake]
Description=SnowflakeDB
Driver=SnowflakeDSIIDriver
Locale=en-US
SERVER=duloftf-posit-software-pbc-dev.snowflakecomputing.com
uid=SVC_RDBI_ODBC
Expand Down
128 changes: 128 additions & 0 deletions .github/workflows/db-pro.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

name: DBs + Posit Pro Drivers (Linux)

jobs:
database:
runs-on: ubuntu-latest

services:
oracle:
image: gvenzl/oracle-xe:21.3.0
ports:
- 1521:1521
env:
ORACLE_RANDOM_PASSWORD: true
ORACLE_DATABASE: test
APP_USER: RodbcR
APP_USER_PASSWORD: Password12
options: >-
--health-cmd healthcheck.sh
--health-interval 10s
--health-timeout 5s
--health-retries 10
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: test
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
sqlserver:
image: mcr.microsoft.com/mssql/server:2017-latest-ubuntu
ports:
- 1433:1433
env:
ACCEPT_EULA: Y
SA_PASSWORD: Password12

env:
CRAN: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"
ODBCSYSINI: ${{ github.workspace }}/.github/odbc
TNS_ADMIN: ${{ github.workspace }}/.github/odbc
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2

- name: Install MySQL Driver
run: |
sudo systemctl start mysql.service
mysql -uroot -h127.0.0.1 -proot -e 'CREATE DATABASE `test`;'
echo "ODBC_CS_MYSQL=dsn=ProMySQL" >> $GITHUB_ENV
mkdir -p $ODBCSYSINI/pro_drivers/mysql
touch $ODBCSYSINI/pro_drivers/mysql.tar.gz
curl ${{ secrets.PRO_DRIVER_MYSQL }} --output $ODBCSYSINI/pro_drivers/mysql.tar.gz
tar -xvzf $ODBCSYSINI/pro_drivers/mysql.tar.gz -C $ODBCSYSINI/pro_drivers/mysql
- name: Install SQL Server Driver
run: |
echo "ODBC_CS_SQLSERVER=dsn=ProMicrosoftSQLServer;UID=SA;PWD=Password12" >> $GITHUB_ENV
mkdir -p $ODBCSYSINI/pro_drivers/sql_server
touch $ODBCSYSINI/pro_drivers/sql_server.tar.gz
curl ${{ secrets.PRO_DRIVER_SQL_SERVER }} --output $ODBCSYSINI/pro_drivers/sql_server.tar.gz
tar -xvzf $ODBCSYSINI/pro_drivers/sql_server.tar.gz -C $ODBCSYSINI/pro_drivers/sql_server
- name: Install Oracle Driver
run: |
echo "ODBC_CS_ORACLE=dsn=ProOracle;UID=RodbcR;PWD=Password12;DBQ=test" >> $GITHUB_ENV
.github/odbc/install-oracle-driver.sh
echo "LD_LIBRARY_PATH=/opt/oracle/instantclient_21_12:$LD_LIBRARY_PATH" >> $GITHUB_ENV
mkdir -p $ODBCSYSINI/pro_drivers/oracle
touch $ODBCSYSINI/pro_drivers/oracle.tar.gz
curl ${{ secrets.PRO_DRIVER_ORACLE }} --output $ODBCSYSINI/pro_drivers/oracle.tar.gz
tar -xvzf $ODBCSYSINI/pro_drivers/oracle.tar.gz -C $ODBCSYSINI/pro_drivers/oracle
- name: Install PostgreSQL Driver
run: |
echo "ODBC_CS_POSTGRES=dsn=ProPostgreSQL" >> $GITHUB_ENV
mkdir -p $ODBCSYSINI/pro_drivers/postgresql
touch $ODBCSYSINI/pro_drivers/postgresql.tar.gz
curl ${{ secrets.PRO_DRIVER_POSTGRESQL }} --output $ODBCSYSINI/pro_drivers/postgresql.tar.gz
tar -xvzf $ODBCSYSINI/pro_drivers/postgresql.tar.gz -C $ODBCSYSINI/pro_drivers/postgresql
- name: Install Snowflake Driver
run: |
echo "ODBC_CS_SNOWFLAKE=dsn=Snowflake" >> $GITHUB_ENV
mkdir -p $ODBCSYSINI/pro_drivers/snowflake
touch $ODBCSYSINI/pro_drivers/snowflake.tar.gz
curl ${{ secrets.PRO_DRIVER_SNOWFLAKE }} --output $ODBCSYSINI/pro_drivers/snowflake.tar.gz
tar -xvzf $ODBCSYSINI/pro_drivers/snowflake.tar.gz -C $ODBCSYSINI/pro_drivers/snowflake
echo "Driver=$ODBCSYSINI/pro_drivers/snowflake/bin/lib/libsnowflakeodbc_sb64.so" | tee -a $ODBCSYSINI/odbc.ini
# note that this assumes Snowflake is the last odbc.ini entry
- name: Prepare Snowflake private key
run: |
echo "${{ secrets.SNOWFLAKE_PRIVATE_KEY }}" > $ODBCSYSINI/private_key.pem
echo "PRIV_KEY_FILE=$ODBCSYSINI/private_key.pem" | tee -a $ODBCSYSINI/odbc.ini
export SNOWFLAKE_PRIVATE_KEY_EXISTS=TRUE
- name: Install dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
needs: check

- name: Install locally to avoid error with test_local()
run: |
R CMD INSTALL .
env:
LIB_DIR: /usr/lib/x86_64-linux-gnu/
INCLUDE_DIR: /usr/include

- name: Test
run: |
options("odbc.interruptible"=TRUE);testthat::test_local(reporter = testthat::ProgressReporter$new(max_failures = Inf, update_interval = Inf))
shell: Rscript {0}
4 changes: 2 additions & 2 deletions .github/workflows/db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ jobs:
- name: Install Snowflake Driver
run: |
echo "ODBC_CS_SNOWFLAKE=dsn=Snowflake;pwd=${{ secrets.SNOWFLAKE_PWD }}" >> $GITHUB_ENV
echo "ODBC_PWD_SNOWFLAKE=${{ secrets.SNOWFLAKE_PWD }}" >> $GITHUB_ENV
echo "ODBC_CS_SNOWFLAKE=dsn=Snowflake" >> $GITHUB_ENV
curl https://sfc-repo.snowflakecomputing.com/odbc/linux/3.2.0/snowflake_linux_x8664_odbc-3.2.0.tgz --output snowflake_linux_x8664_odbc-3.2.0.tgz
gunzip snowflake_linux_x8664_odbc-3.2.0.tgz
tar -xvf snowflake_linux_x8664_odbc-3.2.0.tar
Expand All @@ -103,6 +102,7 @@ jobs:
cp .github/odbc/simba.snowflake.ini .github/odbc/snowflake_odbc/lib/simba.snowflake.ini
echo "CABundleFile=$ODBCSYSINI/snowflake_odbc/lib/cacert.pem" >> .github/odbc/snowflake_odbc/lib/simba.snowflake.ini
echo "ErrorMessagesPath=$ODBCSYSINI/snowflake_odbc/ErrorMessages/" >> .github/odbc/snowflake_odbc/lib/simba.snowflake.ini
echo "Driver=SnowflakeDSIIDriver" | tee -a $ODBCSYSINI/odbc.ini
# note that this assumes Snowflake is the last odbc.ini entry
- name: Prepare Snowflake private key
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-driver-mysql.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ test_that("MySQL", {
"roundtrip_timestamp", # We explicitly want to set tzone to UTC regardless of input
"roundtrip_time",
"roundtrip_raw", # TODO
# TODO: fails with Pro Driver with shuffled names
"list_fields",
"list_tables",
".*_table_name",
"write_table_error", # TODO
Expand Down Expand Up @@ -101,6 +103,9 @@ test_that("odbcPreviewObject", {
test_that("sproc result retrieval", {
con <- test_con("MYSQL")

# TODO: resolve the issue requiring this skip
skip_if(grepl("libmysqlodbc_sb64", dbGetInfo(con)$drivername), "Pro Drivers fail this test.")

sprocName <- "testSproc"
DBI::dbExecute(
con,
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-driver-postgres.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ test_that("PostgreSQL", {
"data_64_bit_numeric_warning", # TODO
"data_64_bit_lossless", # TODO
"data_integer", # Fails, unreliably on Windows
# TODO: fails with Pro Driver with "a statement is already in progress"
"send_query_immediate",
# TODO: fails with Pro Driver with "a statement is already in progress"
"send_query_only_one_result_set",
"send_query_syntax_error", # TODO
"get_query_syntax_error", # TODO
"send_query_params", # TODO
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-driver-sql-server.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ test_that("SQLServer", {
DBItest::test_result(c(
"get_query_n_zero_rows",
"get_query_n_incomplete",
# TODO: fails with Pro Driver due to no "good" results returned
"fetch_n_good_after_bad",
"fetch_no_return_value", # TODO
"clear_result_return_statement",
"cannot_clear_result_twice_statement",
Expand Down Expand Up @@ -230,6 +232,8 @@ test_that("odbcPreviewObject doesn't warn about pending rows", {

test_that("dates should always be interpreted in the system time zone (#398)", {
con <- test_con("SQLSERVER")
# TODO: resolve the issue requiring this skip
skip_if(grepl("RStudio", dbGetInfo(con)$drivername), "Pro Drivers fail this test.")
res <- dbGetQuery(con, "SELECT CAST(? AS date)", params = as.Date("2019-01-01"))
expect_equal(res[[1]], as.Date("2019-01-01"))
})
Expand Down

0 comments on commit 4090f0a

Please sign in to comment.