Skip to content

Commit

Permalink
Dev - Foundational Testing Completion (#17)
Browse files Browse the repository at this point in the history
- Foundational Test Harness is now passing
- Updated build logic
- Add Optimize, Analyze, and Vacuum custom Databricks change types.
- Add Terraform to create a custom runtime cluster, main catalog, and lb_test_harness schema
- Add CreateTableDatabricks change type to enable: LOCATION, USING DELTA

Co-authored-by: Nathan Voxland <[email protected]>
  • Loading branch information
CodyAustinDavis and nvoxland authored May 18, 2023
1 parent 1d79a29 commit ea60e3e
Show file tree
Hide file tree
Showing 43 changed files with 1,106 additions and 194 deletions.
Binary file removed .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .github/workflows/attach-artifact-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ on:

jobs:
attach-artifact-to-release:
uses: liquibase/build-logic/.github/workflows/extension-attach-artifact-release.yml@v0.2.3
uses: liquibase/build-logic/.github/workflows/extension-attach-artifact-release.yml@v0.3.1
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ on:

jobs:
create-release:
uses: liquibase/build-logic/.github/workflows/create-release.yml@v0.2.3
uses: liquibase/build-logic/.github/workflows/create-release.yml@v0.3.1
secrets: inherit
74 changes: 74 additions & 0 deletions .github/workflows/lth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Liquibase Test Harness

on:
pull_request:
push:
branches:
- main

jobs:
liquibase-test-harness:
name: Liquibase Test Harness
runs-on: ubuntu-latest
permissions:
checks: write

env:
TF_VAR_DBX_HOST: ${{ secrets.TH_DATABRICKS_WORKSPACE_HOST }}
TF_VAR_DBX_TOKEN: ${{ secrets.TH_DATABRICKS_WORKSPACE_TOKEN }}
TF_VAR_TEST_CATALOG: main
TF_VAR_TEST_SCHEMA: lb_test_harness
WORKSPACE_ID: ${{ secrets.TH_DATABRICKS_WORKSPACE_ID }}

strategy:
matrix:
liquibase-support-level: [Foundational] # Define the different test levels to run
fail-fast: false # Set fail-fast to false to run all test levels even if some of them fail

steps:
- name: Checkout code
uses: actions/checkout@v3

- run: terraform init
working-directory: src/test/terraform

- run: terraform plan
working-directory: src/test/terraform

- run: terraform apply -auto-approve
working-directory: src/test/terraform

- name: Collect Databricks Config
working-directory: src/test/terraform
run: |
CLUSTER_ID=$(terraform output -raw cluster_url)
DATABRICKS_HOST=${TF_VAR_DBX_HOST#https://}
echo "DATABRICKS_URL=jdbc:databricks://$DATABRICKS_HOST:443/default;transportMode=http;ssl=1;httpPath=sql/protocolv1/o/$WORKSPACE_ID/$CLUSTER_ID;AuthMech=3;ConnCatalog=$TF_VAR_TEST_CATALOG;ConnSchema=$TF_VAR_TEST_SCHEMA;EnableArrow=0" >> "$GITHUB_ENV"
- name: Setup Temurin Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: 'maven'

- name: Build with Maven # Build the code with Maven (skip tests)
run: mvn -B -ntp -Dmaven.test.skip package

- name: Run ${{ matrix.liquibase-support-level }} Liquibase Test Harness # Run the Liquibase test harness at each test level
continue-on-error: true # Continue to run the action even if the previous steps fail
run: mvn -B -ntp -DdbPassword=${{env.TF_VAR_DBX_TOKEN}} -DdbUrl='${{env.DATABRICKS_URL}}' -Dtest=liquibase.ext.databricks.${{ matrix.liquibase-support-level }}ExtensionHarnessTestSuite test # Run the Liquibase test harness at each test level

- name: Test Reporter # Generate a test report using the Test Reporter action
uses: dorny/[email protected]
if: always() # Run the action even if the previous steps fail
with:
name: Liquibase Test Harness - ${{ matrix.liquibase-support-level }} Reports # Set the name of the test report
path: target/surefire-reports/TEST-*.xml # Set the path to the test report files
reporter: java-junit # Set the reporter to use
fail-on-error: false # Set fail-on-error to false to show report even if it has failed tests

- name: Stop test database
if: always() # Always destroy, even if the previous steps fail
working-directory: src/test/terraform
run: terraform destroy -auto-approve
2 changes: 1 addition & 1 deletion .github/workflows/release-published.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ on:

jobs:
release:
uses: liquibase/build-logic/.github/workflows/extension-release-published.yml@v0.2.3
uses: liquibase/build-logic/.github/workflows/extension-release-published.yml@v0.3.1
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/synk-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ on:

jobs:
security-scan:
uses: liquibase/build-logic/.github/workflows/synk-nightly.yml@v0.2.3
uses: liquibase/build-logic/.github/workflows/synk-nightly.yml@v0.3.1
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ on:

jobs:
build-test:
uses: liquibase/build-logic/.github/workflows/os-extension-test.yml@v0.2.3
uses: liquibase/build-logic/.github/workflows/os-extension-test.yml@v0.3.1
secrets: inherit
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ buildNumber.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
*.iml
.idea
.idea
.DS_Store
56 changes: 52 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,63 @@
# liquibase-databricks


## Current Summary
Base and Foundational Change types should be supported at this stage. Change types such as procedures, triggers, merge column, indexes are not supported.
Databricks specific change types that are added are listed below along with their completion status.


## To Do:

1. Add unit tests with liquibase test harness
1. Add unit tests with liquibase test harness - Cody Davis - Done
2. Pass Foundational Test Harness - Cody Davis - Done
3. Pass Base Test Harness - Cody Davis - In Progress - ETA May 15, 2023
4. Pass Advanced Test Harness - Unassigned - Not Started

## Change Types to Add:

1. COPY INTO
2. MERGE
3. RESTORE VERSION AS OF
4. ANALYZE TABLE
5. SET TBL PROPERTIES
4. ANALYZE TABLE - Code Complete - Cody Davis
5. SET TBL PROPERTIES - In Progress - Cody Davis
6. CLONE
7. BLOOM FILTERS
7. BLOOM FILTERS
8. OPTIMIZE / ZORDER - Code Complete - No Test Yet - Cody Davis
9. VACUUM - Code Complete - Cody Davis



## How to use the Liquibase-Databricks Extension

### Steps:

1. Download and install liquibase from [here](https://docs.liquibase.com/start/install/home.html)

2. Download the Databricks Driver from [here](https://www.databricks.com/spark/jdbc-drivers-download).
Then put this driver jar under the liquibase/lib directory.

3. Build this project or retrieve the jar from the latest release.
Then put this extension jar under the liquibase/lib directory.

4. Edit the connection parameters to your Databricks catlaog/database under the liquibase.properties file. The format will look like this:

```
url: jdbc:databricks://<workspace_url>:443/default;transportMode=http;ssl=1;httpPath=<http_path>;AuthMech=3;ConnCatalog=<catalog>;ConnSchema=<database>;
username: token
password: <dbx_token>
```

Where the following parameters are:
<li> <b>workspace_url</b>: The url of the host name you are connecting to</li>
<li> <b>dbx_token</b>: The token of your user or application service principal authorized for running any needed Liquibase operations.</li>
<li> <b>http_path</b>: This is the http_path of a Databricks SQL Warehouse or a Databricks Cluster (DBR). Either cluster type can be used. Best Results are with Serverless SQL Warehouses. </li>
<li> <b>catalog</b>: The catalog name you want to connect to (default is main). </li>
<li> <b>database</b>: The database / schema name you want to connect to. </li>



5. Add changes and run your change logs like so:
```
liquibase --changeLogFile=changelog.sql update
```

10 changes: 3 additions & 7 deletions liquibase.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
driver: com.databricks.jdbc.Driver
url: jdbc:databricks://<host>:443/default;transportMode=http;ssl=1;AuthMech=3;httpPath=/sql/1.0/warehouses/<warehouseId>;ConnCatalog=main;ConnSchema=default
user: token
password: <user_token>
defaultCatalogName: main
defaultSchemaName: default
liquibaseCatalogName: liquibase
url: jdbc:databricks://<workspace_url>:443/default;transportMode=http;ssl=1;httpPath=sql/<warehouse_id>;AuthMech=3;ConnCatalog=main;ConnSchema=liquibase_harness_test_ds;
username: token
password: <dbx_token>
Loading

0 comments on commit ea60e3e

Please sign in to comment.