Skip to content

Commit

Permalink
driver that can connect to both versions 1 and 2
Browse files Browse the repository at this point in the history
  • Loading branch information
alexradzin authored and alexradzin committed Nov 27, 2023
1 parent 07bea94 commit 7bceb3e
Show file tree
Hide file tree
Showing 47 changed files with 2,005 additions and 516 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/integration-test-v1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Run integration tests v1

on:
workflow_call:
inputs:
database:
description: 'Database - a new one will be created if not provided'
required: false
default: ''
type: string
engine:
description: 'Engine - a new one will be created if not provided'
required: false
type: string
environment:
description: 'Environment to run the tests against'
type: string
required: true
default: 'staging'
secrets:
FIREBOLT_USERNAME_STAGING:
required: true
FIREBOLT_PASSWORD_STAGING:
required: true
FIREBOLT_USERNAME_DEV:
required: true
FIREBOLT_PASSWORD_DEV:
required: true

jobs:
run-integration-tests:
runs-on: ubuntu-latest

steps:
- name: Validate database and engine
if: ${{ (github.event.inputs.database == '') != (github.event.inputs.engine == '') }}
uses: actions/github-script@v3
with:
script: |
core.setFailed("Database and Engine parameters should be provided simultaneously")
- name: Check out code
uses: actions/checkout@v3

- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'

- name: Determine env variables
run: |
if [ "${{ github.event.inputs.environment }}" == 'staging' ]; then
echo "USERNAME=${{ secrets.FIREBOLT_USERNAME_STAGING }}" >> "$GITHUB_ENV"
echo "PASSWORD=${{ secrets.FIREBOLT_PASSWORD_STAGING }}" >> "$GITHUB_ENV"
else
echo "USERNAME=${{ secrets.FIREBOLT_USERNAME_DEV }}" >> "$GITHUB_ENV"
echo "PASSWORD=${{ secrets.FIREBOLT_PASSWORD_DEV }}" >> "$GITHUB_ENV"
fi
- name: Setup database and engine
id: setup
if: ${{ github.event.inputs.database == '' }}
uses: firebolt-db/integration-testing-setup@v1
with:
firebolt-username: ${{ env.USERNAME }}
firebolt-password: ${{ env.PASSWORD }}
api-endpoint: "api.${{ github.event.inputs.environment }}.firebolt.io"
region: "us-east-1"
instance-type: "B2"

- name: Determine database name
id: find-database-name
run: |
if ! [[ -z "${{ github.event.inputs.database }}" ]]; then
echo "database_name=${{ github.event.inputs.database }}" >> $GITHUB_OUTPUT
else
echo "database_name=${{ steps.setup.outputs.database_name }}" >> $GITHUB_OUTPUT
fi
- name: Determine engine name
id: find-engine-name
run: |
if ! [[ -z "${{ github.event.inputs.engine }}" ]]; then
echo "engine_name=${{ github.event.inputs.engine }}" >> $GITHUB_OUTPUT
else
echo "engine_name=${{ steps.setup.outputs.engine_name }}" >> $GITHUB_OUTPUT
fi
- name: Run integration tests
run: ./gradlew integrationTest -Ddb=${{ steps.find-database-name.outputs.database_name }} -Dapi=api.${{ github.event.inputs.environment }}.firebolt.io -Dpassword="${{ env.PASSWORD }}" -Duser="${{ env.USERNAME }}" -Dengine="${{ steps.find-engine-name.outputs.engine_name }}" -DexcludeTags=v2
96 changes: 96 additions & 0 deletions .github/workflows/integration-test-v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Run integration tests v2

on:
workflow_call:
inputs:
database:
description: 'Database - a new one will be created if not provided'
required: false
default: ''
type: string
engine:
description: 'Engine - a new one will be created if not provided'
required: false
type: string
account:
description: 'Account'
required: true
default: 'developer'
type: string
environment:
description: 'Environment to run the tests against'
type: string
required: true
default: 'staging'
secrets:
FIREBOLT_CLIENT_ID_STG_NEW_IDN:
required: true
FIREBOLT_CLIENT_SECRET_STG_NEW_IDN:
required: true
FIREBOLT_CLIENT_ID_NEW_IDN:
required: true
FIREBOLT_CLIENT_SECRET_NEW_IDN:
required: true

jobs:
run-integration-tests:
runs-on: ubuntu-latest

steps:
- name: Validate database and engine
if: ${{ (github.event.inputs.database == '') != (github.event.inputs.engine == '') }}
uses: actions/github-script@v3
with:
script: |
core.setFailed("Database and Engine parameters should be provided simultaneously")
- name: Check out code
uses: actions/checkout@v3

- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'

- name: Determine env variables
run: |
if [ "${{ github.event.inputs.environment }}" == 'staging' ]; then
echo "SERVICE_ACCOUNT_ID=${{ secrets.FIREBOLT_CLIENT_ID_STG_NEW_IDN }}" >> "$GITHUB_ENV"
echo "SERVICE_ACCOUNT_SECRET=${{ secrets.FIREBOLT_CLIENT_SECRET_STG_NEW_IDN }}" >> "$GITHUB_ENV"
else
echo "SERVICE_ACCOUNT_ID=${{ secrets.FIREBOLT_CLIENT_ID_NEW_IDN }}" >> "$GITHUB_ENV"
echo "SERVICE_ACCOUNT_SECRET=${{ secrets.FIREBOLT_CLIENT_SECRET_NEW_IDN }}" >> "$GITHUB_ENV"
fi
- name: Setup database and engine
id: setup
if: ${{ github.event.inputs.database == '' }}
uses: firebolt-db/integration-testing-setup@v2
with:
firebolt-client-id: ${{ env.SERVICE_ACCOUNT_ID }}
firebolt-client-secret: ${{ env.SERVICE_ACCOUNT_SECRET }}
account: ${{ github.event.inputs.account }}
api-endpoint: "api.${{ github.event.inputs.environment }}.firebolt.io"
instance-type: "B2"

- name: Determine database name
id: find-database-name
run: |
if ! [[ -z "${{ github.event.inputs.database }}" ]]; then
echo "database_name=${{ github.event.inputs.database }}" >> $GITHUB_OUTPUT
else
echo "database_name=${{ steps.setup.outputs.database_name }}" >> $GITHUB_OUTPUT
fi
- name: Determine engine name
id: find-engine-name
run: |
if ! [[ -z "${{ github.event.inputs.engine }}" ]]; then
echo "engine_name=${{ github.event.inputs.engine }}" >> $GITHUB_OUTPUT
else
echo "engine_name=${{ steps.setup.outputs.engine_name }}" >> $GITHUB_OUTPUT
fi
- name: Run integration tests
run: ./gradlew integrationTest -Ddb=${{ steps.find-database-name.outputs.database_name }} -Denv=${{ github.event.inputs.environment }} -Dclient_secret="${{ env.SERVICE_ACCOUNT_SECRET }}" -Dclient_id="${{ env.SERVICE_ACCOUNT_ID }}" -Daccount="${{ github.event.inputs.account }}" -Dengine="${{ steps.find-engine-name.outputs.engine_name }}" -DexcludeTags=v1
128 changes: 52 additions & 76 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ name: Run integration tests
on:
workflow_dispatch:
inputs:
database:
description: 'Database - a new one will be created if not provided'
database1:
description: 'Database (v1) - a new one will be created if not provided'
required: false
default: ''
engine:
description: 'Engine - a new one will be created if not provided'
database2:
description: 'Database (v2) - a new one will be created if not provided'
required: false
default: ''
engine1:
description: 'Engine (v1) - a new one will be created if not provided'
required: false
engine2:
description: 'Engine (v2) - a new one will be created if not provided'
required: false
account:
description: 'Account'
Expand All @@ -22,79 +29,48 @@ on:
options:
- dev
- staging
run-v1:
description: 'Run tests against Firebolt DB v1'
required: true
default: true
type: choice
options:
- 'true'
- 'false'
run-v2:
description: 'Run tests against Firebolt DB v2'
required: true
default: true
type: choice
options:
- 'true'
- 'false'

jobs:
run-integration-tests:
runs-on: ubuntu-latest

steps:
- name: Validate database and engine
if: ${{ (github.event.inputs.database == '') != (github.event.inputs.engine == '') }}
uses: actions/github-script@v3
with:
script: |
core.setFailed("Database and Engine parameters should be provided simultaneously")
- name: "Foresight: Collect Workflow Telemetry"
uses: runforesight/foresight-workflow-kit-action@v1
if: ${{ always() }}
- name: Check out code
uses: actions/checkout@v3

- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
- name: Determine env variables
run: |
if [ "${{ github.event.inputs.environment }}" == 'staging' ]; then
echo "SERVICE_ACCOUNT_ID=${{ secrets.FIREBOLT_CLIENT_ID_STG_NEW_IDN }}" >> "$GITHUB_ENV"
echo "SERVICE_ACCOUNT_SECRET=${{ secrets.FIREBOLT_CLIENT_SECRET_STG_NEW_IDN }}" >> "$GITHUB_ENV"
else
echo "SERVICE_ACCOUNT_ID=${{ secrets.FIREBOLT_CLIENT_ID_NEW_IDN }}" >> "$GITHUB_ENV"
echo "SERVICE_ACCOUNT_SECRET=${{ secrets.FIREBOLT_CLIENT_SECRET_NEW_IDN }}" >> "$GITHUB_ENV"
fi
- name: Setup database and engine
id: setup
if: ${{ github.event.inputs.database == '' }}
uses: firebolt-db/integration-testing-setup@v2
with:
firebolt-client-id: ${{ env.SERVICE_ACCOUNT_ID }}
firebolt-client-secret: ${{ env.SERVICE_ACCOUNT_SECRET }}
account: ${{ github.event.inputs.account }}
api-endpoint: "api.${{ github.event.inputs.environment }}.firebolt.io"
instance-type: "B2"

- name: Determine database name
id: find-database-name
run: |
if ! [[ -z "${{ github.event.inputs.database }}" ]]; then
echo "database_name=${{ github.event.inputs.database }}" >> $GITHUB_OUTPUT
else
echo "database_name=${{ steps.setup.outputs.database_name }}" >> $GITHUB_OUTPUT
fi
- name: Determine engine name
id: find-engine-name
run: |
if ! [[ -z "${{ github.event.inputs.engine }}" ]]; then
echo "engine_name=${{ github.event.inputs.engine }}" >> $GITHUB_OUTPUT
else
echo "engine_name=${{ steps.setup.outputs.engine_name }}" >> $GITHUB_OUTPUT
fi
run-integration-tests1:
if: ${{ github.event.inputs.run-v1 }}
uses: ./.github/workflows/integration-test-v1.yml
with:
database: ${{ github.event.inputs.database1 }}
engine: ${{ github.event.inputs.engine1 }}
environment: ${{ github.event.inputs.environment }}
secrets:
FIREBOLT_USERNAME_STAGING: ${{ secrets.FIREBOLT_USERNAME_STAGING }}
FIREBOLT_PASSWORD_STAGING: ${{ secrets.FIREBOLT_PASSWORD_STAGING }}
FIREBOLT_USERNAME_DEV: ${{ secrets.FIREBOLT_USERNAME_DEV }}
FIREBOLT_PASSWORD_DEV: ${{ secrets.FIREBOLT_PASSWORD_DEV }}

- name: Run integration tests
run: ./gradlew integrationTest -Ddb=${{ steps.find-database-name.outputs.database_name }} -Denv=${{ github.event.inputs.environment }} -Dclient_secret="${{ env.SERVICE_ACCOUNT_SECRET }}" -Dclient_id="${{ env.SERVICE_ACCOUNT_ID }}" -Daccount="${{ github.event.inputs.account }}" -Dengine="${{ steps.find-engine-name.outputs.engine_name }}"
run-integration-tests2:
if: ${{ github.event.inputs.run-v2 }}
uses: ./.github/workflows/integration-test-v2.yml
with:
database: ${{ github.event.inputs.database2 }}
engine: ${{ github.event.inputs.engine2 }}
environment: ${{ github.event.inputs.environment }}
account: ${{ github.event.inputs.account }}
secrets:
FIREBOLT_CLIENT_ID_STG_NEW_IDN: ${{ secrets.FIREBOLT_CLIENT_ID_STG_NEW_IDN }}
FIREBOLT_CLIENT_SECRET_STG_NEW_IDN: ${{ secrets.FIREBOLT_CLIENT_SECRET_STG_NEW_IDN }}
FIREBOLT_CLIENT_ID_NEW_IDN: ${{ secrets.FIREBOLT_CLIENT_ID_NEW_IDN }}
FIREBOLT_CLIENT_SECRET_NEW_IDN: ${{ secrets.FIREBOLT_CLIENT_SECRET_NEW_IDN }}

- name: "Foresight: Analyze Test Results"
uses: runforesight/foresight-test-kit-action@v1
if: success() || failure()
with:
test_format: JUNIT
test_framework: JUNIT
test_path: ./build/test-results/
tags: |
type:"integration"
language:"Java"
35 changes: 34 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ test {

tasks.register('integrationTest', Test) {
description = 'Runs integration tests.'
useJUnitPlatform()
useJUnitPlatform() {
includeTags(System.getProperty("includeTags", "common").split(","))
excludeTags(System.getProperty("excludeTags", "nothing").split(","))
}
reports {
junitXml {
outputPerTestCase = true // defaults to false
Expand All @@ -126,8 +129,38 @@ tasks.register('integrationTest', Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
maxParallelForks = (int) (Runtime.runtime.availableProcessors() / 2 + 1)

testLogging {
events 'PASSED', 'FAILED', 'SKIPPED'
}
}

allprojects {
// add a collection to track failedTests
ext.failedTests = []

// add a testlistener to all tasks of type Test
tasks.withType(Test) {
afterTest { TestDescriptor descriptor, TestResult result ->
if(result.resultType == org.gradle.api.tasks.testing.TestResult.ResultType.FAILURE){
failedTests << ["${descriptor.className}::${descriptor.name}"]
}
}
}

// print out tracked failed tests when the build has finished
gradle.buildFinished {
if(!failedTests.empty){
println "Failed tests for ${project.name}:"
failedTests.each { failedTest ->
println failedTest
}
println "End of the list"
} else {
println "No failures found"
}
}
}

jacoco {
toolVersion = "0.8.10"
Expand Down
Loading

0 comments on commit 7bceb3e

Please sign in to comment.