-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/ Runtime SQL storage for import & export jobs (#463)
* Move test models for unit testing into test resources package * Model API for data storage (experimental) * New plugin API for data storage (not public yet) * First pass on unit tests for data storage API * First pass on context impl for new data storage wrapper API * Do not expose stdlib in new storage plugin interface * Use new internal storage plugin interface in _impl.storage * Generalise SQL integration testing in CI * Test suite for the new IDataStorageBase interface * First implementation of SQL data plugin (works with MySQL) * Update SQL plugin and alchemy driver to accept URL credentials * Move alchemy driver into the main storage_sql plugin module * Skip data context tests for now (local implementation needed) * Python integration test hook, run data storage suite for SQL storage * Apply commit to create table statement (required for Postgres) * Optional SQL dependency for the dist package (SQL Alchemy only) * Plugin requirements for SQL testing * Add storage integration tests for external SQL storage in Python - MySQL, MariaDB and Postgres * Disable cloud integration tests while testing SQL CI * Fix sed command in SQL CI workflow * Do not install mariadb driver yet (binary dependencies) * Fix max varchar size for MySQL * Fix CI configs for MariaDB and Postgresql * Do not write float NaN to postgres backend (not supported) * Reduce varchar max when creating MySQL tables * Fix dialect in MySQL CI config * Fix type for boolean fields in MySQL dialect * Try using pymysql to talk to MariaDB in CI * Exceptions for MariaDB in the storage suite * Add internal extensions module to setup.cfg * Try to run CI for SQL Server external storage * Install ODBC package for SQL server integration testing * Update SQL Server driver in config file to match version installed in CI * Skips / exclusions for SQL Server in the data storage suite * Use ANSI Standard as the base SQL dialect * Example of a selective import using the data storage API * Add helpers to define ARRAY / MAP types for model parameters * Use DB API description to get field names for SQL responses * Fix base class for SQL Server dialect * Add tests for illegal SQL queries (DML, DDL) * Add some extra checks / protections in SQL storage impl * Fix one IDE warning * Allow dev-mode config parser to handle lists (for model parameters) * Wire up new external storage to make it available in the context for import / export jobs * Add some validation for set_source_metadata() * Delay guard rail protections until after plugin loading is complete * Re-enable cloud storage CI jobs * Add MIT-0 variation of MIT license to Python licenses config * Remove unneeded vars mapping in SQL CI job * Update result set processing * Update result set processing
- Loading branch information
Martin Traverse
authored
Oct 29, 2024
1 parent
84bc9bc
commit c6cd697
Showing
30 changed files
with
2,552 additions
and
175 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,14 @@ | ||
|
||
|
||
storage: | ||
|
||
external: | ||
|
||
data_integration: | ||
protocol: SQL | ||
properties: | ||
dialect: MARIADB | ||
driver.python: alchemy | ||
alchemy.url: mariadb+pymysql://metadb:3306/trac | ||
alchemy.username: trac_admin | ||
alchemy.password: DB_SECRET |
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,14 @@ | ||
|
||
|
||
storage: | ||
|
||
external: | ||
|
||
data_integration: | ||
protocol: SQL | ||
properties: | ||
dialect: MYSQL | ||
driver.python: alchemy | ||
alchemy.url: mysql+pymysql://metadb:3306/trac | ||
alchemy.username: trac_admin | ||
alchemy.password: DB_SECRET |
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,14 @@ | ||
|
||
|
||
storage: | ||
|
||
external: | ||
|
||
data_integration: | ||
protocol: SQL | ||
properties: | ||
dialect: POSTGRESQL | ||
driver.python: alchemy | ||
alchemy.url: postgresql+pg8000://metadb:5432/trac | ||
alchemy.username: trac_admin | ||
alchemy.password: DB_SECRET |
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,14 @@ | ||
|
||
|
||
storage: | ||
|
||
external: | ||
|
||
data_integration: | ||
protocol: SQL | ||
properties: | ||
dialect: SQLSERVER | ||
driver.python: alchemy | ||
alchemy.url: mssql+pyodbc://metadb:1433/master?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes | ||
alchemy.username: sa | ||
alchemy.password: DB_SECRET |
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,190 @@ | ||
name: Integration (SQL) | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
matrix: | ||
required: true | ||
type: string | ||
dialect: | ||
required: true | ||
type: string | ||
db_image: | ||
required: true | ||
type: string | ||
db_port: | ||
required: true | ||
type: number | ||
db_options: | ||
required: false | ||
type: string | ||
|
||
|
||
# Use latest supported language versions for integration testing | ||
env: | ||
JAVA_VERSION: "21" | ||
JAVA_DISTRIBUTION: "zulu" | ||
PYTHON_VERSION: "3.12" | ||
NODE_VERSION: "22" | ||
|
||
|
||
jobs: | ||
|
||
int-metadb: | ||
|
||
name: int-metadb-java-${{ inputs.dialect }} | ||
|
||
env: | ||
BUILD_sql_${{ inputs.dialect }}: true | ||
TRAC_CONFIG_FILE: ".github/config/int-metadb-${{ inputs.dialect }}.yaml" | ||
TRAC_SECRET_KEY: "testing_secret" | ||
|
||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
|
||
container: | ||
image: ubuntu:latest | ||
|
||
services: | ||
|
||
metadb: | ||
|
||
image: ${{ inputs.db_image }} | ||
ports: | ||
- ${{ inputs.db_port }}:${{ inputs.db_port }} | ||
options: ${{ inputs.db_options }} | ||
|
||
# DB container needs various env vars defined in the matrix | ||
env: ${{ fromJson( inputs.matrix ) }} | ||
|
||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: ${{ env.JAVA_DISTRIBUTION }} | ||
java-version: ${{ env.JAVA_VERSION }} | ||
|
||
- name: Build | ||
run: ./gradlew trac-svc-meta:testClasses | ||
|
||
# Auth tool will also create the secrets file if it doesn't exist | ||
- name: Prepare secrets | ||
env: ${{ fromJson( inputs.matrix ) }} | ||
run: | | ||
./gradlew secret-tool:run --args="--config ${{ env.TRAC_CONFIG_FILE }} --task init_secrets" | ||
./gradlew secret-tool:run --args="--config ${{ env.TRAC_CONFIG_FILE }} --task create_root_auth_key EC 256" | ||
echo "${DB_SECRET}" | ./gradlew secret-tool:run --args="--config ${{ env.TRAC_CONFIG_FILE }} --task add_secret metadb_secret" | ||
# The name and description of the test tenant are verified in one of the test cases so they need to match | ||
# MetadataReapApiTest listTenants() | ||
- name: Prepare database | ||
run: | | ||
./gradlew deploy-metadb:run --args="\ | ||
--config ${{ env.TRAC_CONFIG_FILE }} \ | ||
--secret-key ${{ env.TRAC_SECRET_KEY }} \ | ||
--task deploy_schema \ | ||
--task add_tenant ACME_CORP 'Test tenant [ACME_CORP]'" | ||
- name: Integration tests | ||
run: ./gradlew trac-svc-meta:integration -DintegrationTags="int-metadb" | ||
|
||
# If the tests fail, make the output available for download | ||
- name: Store failed test results | ||
uses: actions/upload-artifact@v4 | ||
if: failure() | ||
with: | ||
name: junit-test-results | ||
path: build/modules/*/reports/** | ||
retention-days: 7 | ||
|
||
int-storage--python: | ||
|
||
name: int-storage-python-${{ inputs.dialect }} | ||
|
||
env: | ||
BUILD_sql_${{ inputs.dialect }}: true | ||
TRAC_RT_SYS_CONFIG: ".github/config/rt-storage-ext-${{ inputs.dialect }}.yaml" | ||
|
||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
|
||
container: | ||
image: ubuntu:latest | ||
|
||
services: | ||
|
||
metadb: | ||
|
||
image: ${{ inputs.db_image }} | ||
ports: | ||
- ${{ inputs.db_port }}:${{ inputs.db_port }} | ||
options: ${{ inputs.db_options }} | ||
|
||
# DB container needs various env vars defined in the matrix | ||
env: ${{ fromJson( inputs.matrix ) }} | ||
|
||
steps: | ||
|
||
# https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server | ||
- name: Install ODBC (if required) | ||
if: ${{ inputs.dialect == 'sqlserver' }} | ||
run: | | ||
apt-get update | ||
apt-get install -y curl gpg lsb-release | ||
LSB_RELEASE=`lsb_release -rs` | ||
curl "https://packages.microsoft.com/keys/microsoft.asc" | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg | ||
curl "https://packages.microsoft.com/config/ubuntu/${LSB_RELEASE}/prod.list" | tee /etc/apt/sources.list.d/mssql-release.list | ||
apt-get update | ||
ACCEPT_EULA=Y apt-get install -y msodbcsql18 | ||
ACCEPT_EULA=Y apt-get install -y mssql-tools18 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Pre-process config | ||
env: ${{ fromJson( inputs.matrix ) }} | ||
run: | | ||
sed -i "s#DB_SECRET#${DB_SECRET}#" ${TRAC_RT_SYS_CONFIG} | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- name: Upgrade PIP | ||
run: | | ||
python -m venv ./venv | ||
. ./venv/bin/activate | ||
python -m pip install --upgrade pip | ||
# Filter plugin dependencies, only install for the plugin being tested | ||
# This prevents dependency issues in one plugin affecting all the others | ||
- name: Select plugin dependencies | ||
run: | | ||
cd tracdap-runtime/python | ||
sed -n '/BEGIN_PLUGIN sql/, /END_PLUGIN sql/p' requirements_plugins.txt > requirements_selected.txt | ||
- name: Install dependencies | ||
run: | | ||
. ./venv/bin/activate | ||
cd tracdap-runtime/python | ||
pip install -r requirements.txt | ||
pip install -r requirements_selected.txt | ||
- name: Protoc code generation | ||
run: | | ||
. ./venv/bin/activate | ||
python tracdap-runtime/python/build_runtime.py --target codegen | ||
- name: Integration tests | ||
run: | | ||
. ./venv/bin/activate | ||
python tracdap-runtime/python/build_runtime.py --target integration --pattern int_storage_sql*.py |
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
Oops, something went wrong.