Skip to content

Commit

Permalink
Merge branch 'master' into FIR-33849-close-connection-on-shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
stepansergeevitch authored Jul 29, 2024
2 parents c4170b5 + e967a62 commit d781d83
Show file tree
Hide file tree
Showing 75 changed files with 1,310 additions and 311 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/integration-test-v1.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
name: Run integration tests v1

on:
workflow_dispatch:
inputs:
database:
description: 'Database override'
required: false
default: ''
engine:
description: 'Engine override'
required: false
workflow_call:
inputs:
database:
description: 'Database - a new one will be created if not provided'
description: 'Database override'
required: false
default: ''
type: string
engine:
description: 'Engine - a new one will be created if not provided'
description: 'Engine override'
required: false
type: string
secrets:
Expand Down
36 changes: 30 additions & 6 deletions .github/workflows/integration-test-v2.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
name: Run integration tests v2

on:
workflow_dispatch:
inputs:
database:
description: 'Database override'
required: false
default: ''
engine:
description: 'Engine override'
required: false
account:
description: 'Account override'
required: false
type: string
workflow_call:
inputs:
database:
description: 'Database - a new one will be created if not provided'
description: 'Database override'
required: false
default: ''
type: string
engine:
description: 'Engine - a new one will be created if not provided'
description: 'Engine override'
required: false
type: string
account:
description: 'Account'
required: true
description: 'Account override'
required: false
type: string
secrets:
FIREBOLT_CLIENT_ID_STG_NEW_IDN:
Expand All @@ -34,6 +47,17 @@ jobs:
script: |
core.setFailed("Database and Engine parameters should be provided simultaneously")
- name: Resolve account
id: set-account
run: |
if ! [[ -z "${{ inputs.account }}" ]]; then
echo "account=${{ inputs.account }}" >> $GITHUB_OUTPUT
echo "account=${{ inputs.account }}"
else
echo "account=${{ vars.FIREBOLT_ACCOUNT }}" >> $GITHUB_OUTPUT
echo "account=${{ vars.FIREBOLT_ACCOUNT }}"
fi
- name: Check out code
uses: actions/checkout@v3

Expand All @@ -50,7 +74,7 @@ jobs:
with:
firebolt-client-id: ${{ secrets.FIREBOLT_CLIENT_ID_STG_NEW_IDN }}
firebolt-client-secret: ${{ secrets.FIREBOLT_CLIENT_SECRET_STG_NEW_IDN }}
account: ${{ inputs.account }}
account: ${{ steps.set-account.outputs.account }}
api-endpoint: "api.staging.firebolt.io"

- name: Determine database name
Expand All @@ -72,4 +96,4 @@ jobs:
fi
- name: Run integration tests
run: ./gradlew integrationTest -Ddb=${{ steps.find-database-name.outputs.database_name }} -Denv=staging -Dclient_secret="${{ secrets.FIREBOLT_CLIENT_SECRET_STG_NEW_IDN }}" -Dclient_id="${{ secrets.FIREBOLT_CLIENT_ID_STG_NEW_IDN }}" -Daccount="${{ inputs.account }}" -Dengine="${{ steps.find-engine-name.outputs.engine_name }}" -DexcludeTags=v1
run: ./gradlew integrationTest -Ddb=${{ steps.find-database-name.outputs.database_name }} -Denv=staging -Dclient_secret="${{ secrets.FIREBOLT_CLIENT_SECRET_STG_NEW_IDN }}" -Dclient_id="${{ secrets.FIREBOLT_CLIENT_ID_STG_NEW_IDN }}" -Daccount="${{ steps.set-account.outputs.account }}" -Dengine="${{ steps.find-engine-name.outputs.engine_name }}" -DexcludeTags=v1
41 changes: 1 addition & 40 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,17 @@ name: Run integration tests

on:
workflow_dispatch:
inputs:
database1:
description: 'Database (v1) - a new one will be created if not provided'
required: false
default: ''
database-with-engine-v2:
description: 'Database (v2) for Firebolt 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
engine_v2_fb_2_0:
description: 'Engine (v2) for Firebolt v2 - a new one will be created if not provided'
required: false
run-v1:
description: 'Run tests against Firebolt DB v1'
required: true
default: true
type: choice
options:
- 'true'
- 'false'
run-database-with-engine-v2:
description: 'Run tests against Firebolt DB v2 and Engine V2'
required: true
default: true
type: choice
options:
- 'true'
- 'false'
workflow_call:

jobs:
run-integration-tests1:
if: ${{ inputs.run-v1 == 'true' }}
uses: ./.github/workflows/integration-test-v1.yml
with:
database: ${{ inputs.database1 }}
engine: ${{ inputs.engine1 }}
secrets:
FIREBOLT_STG_USERNAME: ${{ secrets.FIREBOLT_STG_USERNAME }}
FIREBOLT_STG_PASSWORD: ${{ secrets.FIREBOLT_STG_PASSWORD }}

run-integration-tests-engine2:
if: ${{ inputs.run-database-with-engine-v2 == 'true' }}
uses: ./.github/workflows/integration-test-v2.yml
with:
database: ${{ inputs.database-with-engine-v2 }}
engine: ${{ inputs.engine_v2_fb_2_0 }}
account: ${{ vars.FIREBOLT_ACCOUNT_V2 }}
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 }}
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: Release new version
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name to publish'
required: true

jobs:
build:
Expand All @@ -15,7 +20,7 @@ jobs:
- name: Check out code
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}
ref: ${{ github.event.release.tag_name || github.event.inputs.tag_name}}
- name: Download uber-jar
uses: actions/download-artifact@v3
with:
Expand All @@ -31,8 +36,10 @@ jobs:
file: ${{ needs.build.outputs.uber-jar }}
tags: true
draft: false
- name: Deploy to Repsy repository
- name: Deploy to Maven Central repository
run: ./gradlew publish
env:
MAVEN_REPO_USERNAME: ${{ secrets.MAVEN_REPO_USERNAME }}
MAVEN_REPO_PASSWORD: ${{ secrets.MAVEN_REPO_PASSWORD }}
GRADLE_SIGNING_KEY: ${{ secrets.GRADLE_SIGNING_KEY }}
GRADLE_SIGNING_PASSWORD: ${{ secrets.GRADLE_SIGNING_PASSWORD }}
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
id "org.sonarqube" version "5.0.0.4638"
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.0.0'
id 'org.quiltmc.gradle.licenser' version '2.0.2'
id 'signing'
}

Expand Down Expand Up @@ -66,7 +65,6 @@ dependencies {
implementation 'net.jodah:expiringmap:0.5.11'
implementation 'org.apache.commons:commons-text:1.12.0'
implementation 'org.lz4:lz4-java:1.8.0'
implementation 'org.slf4j:jul-to-slf4j:2.0.13'

implementation fileTree(dir: 'libs', includes: ['*.jar'])

Expand Down Expand Up @@ -336,8 +334,11 @@ task generateJavadoc(type: Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}


signing {
def signingKey = System.getenv("GRADLE_SIGNING_KEY")
def signingPassword = System.getenv("GRADLE_SIGNING_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPassword)

sign publishing.publications
}

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=3.0.4-SNAPSHOT
jdbcVersion=4.3
version=3.1.1
jdbcVersion=4.3
1 change: 1 addition & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lombok.anyConstructor.addConstructorProperties = true
config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true
lombok.log.custom.declaration = com.firebolt.jdbc.log.FireboltLogger com.firebolt.jdbc.util.LoggerUtil.getLogger(NAME)
2 changes: 2 additions & 0 deletions src/integrationTest/java/integration/IntegrationTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package integration;

import com.firebolt.jdbc.client.HttpClientConfig;
import lombok.CustomLog;
import lombok.SneakyThrows;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.TestInstance;
Expand All @@ -16,6 +17,7 @@
import static com.firebolt.jdbc.connection.FireboltConnectionUserPassword.SYSTEM_ENGINE_NAME;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@CustomLog
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Tag("common")
public abstract class IntegrationTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.firebolt.jdbc.type.FireboltDataType;
import com.firebolt.jdbc.type.array.FireboltArray;
import integration.IntegrationTest;
import lombok.CustomLog;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -26,6 +27,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;

@CustomLog
class PreparedStatementArrayTest extends IntegrationTest {
enum PreparedStatementValueSetter {
ARRAY {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import integration.ConnectionInfo;
import integration.IntegrationTest;
import lombok.Builder;
import lombok.CustomLog;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.junit.jupiter.api.AfterEach;
Expand All @@ -32,6 +33,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -49,6 +51,7 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

@CustomLog
class PreparedStatementTest extends IntegrationTest {

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.firebolt.jdbc.statement.FireboltStatement;
import integration.EnvironmentCondition;
import integration.IntegrationTest;
import lombok.CustomLog;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
Expand All @@ -16,15 +17,13 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

import static integration.EnvironmentCondition.Attribute.databaseVersion;
import static integration.EnvironmentCondition.Comparison.GE;
import static org.junit.jupiter.api.Assertions.assertEquals;

@CustomLog
class StatementCancelTest extends IntegrationTest {
private static final Logger log = Logger.getLogger(StatementCancelTest.class.getName());

@BeforeEach
void beforeEach() {
Expand Down Expand Up @@ -92,11 +91,11 @@ private void verifyThatNoMoreRecordsAreAdded(Connection connection, String table
// data is available.
long waitForResultTime = insertTime / 2;
long waitForResultDelay = waitForResultTime / 10;
log.log(Level.INFO, "verifyThatNoMoreRecordsAreAdded insertTime={0}, waitForResultTime={0}", new Object[] {insertTime, waitForResultTime});
log.info("verifyThatNoMoreRecordsAreAdded insertTime={}, waitForResultTime={}", insertTime, waitForResultTime);
int count0;
int i = 0;
for (count0 = count(connection, tableName); i < 10; count0 = count(connection, tableName), i++) {
log.log(Level.INFO, "verifyThatNoMoreRecordsAreAdded count0={0}", count0);
log.info("verifyThatNoMoreRecordsAreAdded count0={}", count0);
if (count0 > 0) {
break;
}
Expand All @@ -109,7 +108,7 @@ private void verifyThatNoMoreRecordsAreAdded(Connection connection, String table
int count1 = count(connection, tableName);
Thread.sleep(insertTime); // waiting to see if more records are being added
int count2 = count(connection, tableName);
log.log(Level.INFO, "verifyThatNoMoreRecordsAreAdded count1={0}, count2={1}", new Object[] {count1, count2});
log.info("verifyThatNoMoreRecordsAreAdded count1={}, count2={}", count1, count2);
assertEquals(count1, count2);
}

Expand Down
22 changes: 22 additions & 0 deletions src/integrationTest/java/integration/tests/StatementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.firebolt.jdbc.connection.FireboltConnection;
import com.firebolt.jdbc.exception.FireboltException;
import integration.ConnectionInfo;
import integration.EnvironmentCondition;
import integration.IntegrationTest;
import kotlin.collections.ArrayDeque;
import lombok.CustomLog;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -41,6 +43,7 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

@CustomLog
class StatementTest extends IntegrationTest {

@BeforeEach
Expand Down Expand Up @@ -99,6 +102,25 @@ void shouldThrowExceptionWhenTryingToReuseStatementClosedOnCompletion() throws S
}
}

@Test
void shouldThrowExceptionWhenExecutingWrongQuery() throws SQLException {
try (Connection connection = createConnection(); Statement statement = connection.createStatement()) {
String errorMessage = assertThrows(FireboltException.class, () -> statement.executeQuery("select wrong query")).getMessage();
assertTrue(errorMessage.contains("Column 'wrong' does not exist."));
}
}

@Test
@EnvironmentCondition(value = "4.2.0", comparison = EnvironmentCondition.Comparison.GE)
void shouldThrowExceptionWhenExecutingWrongQueryWithJsonError() throws SQLException {
try (Connection connection = createConnection(); Statement statement = connection.createStatement()) {
statement.execute("set advanced_mode=1");
statement.execute("set enable_json_error_output_format=true");
String errorMessage = assertThrows(FireboltException.class, () -> statement.executeQuery("select wrong query")).getMessage();
assertTrue(errorMessage.contains("Column 'wrong' does not exist."));
}
}

@Test
void shouldReturnTrueWhenExecutingAStatementThatReturnsAResultSet() throws SQLException {
try (Connection connection = createConnection(); Statement statement = connection.createStatement()) {
Expand Down
Loading

0 comments on commit d781d83

Please sign in to comment.