Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Fix integration tests #467

Merged
merged 6 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void connectToNotExistingDb(EngineType engineType) {
String url = format("jdbc:firebolt:%s?env=%s&account=%s%s", database, params.getEnv(), params.getAccount(), engineSuffix);
FireboltException e = assertThrows(FireboltException.class, () -> DriverManager.getConnection(url, params.getPrincipal(), params.getSecret()));
if (infraVersion >= 2) {
assertEquals(ExceptionType.ERROR, e.getType());
assertEquals(ExceptionType.INVALID_REQUEST, e.getType());
String expectedMessage = format("Database '%s' does not exist or not authorized", database);
assertTrue(e.getMessage().contains(expectedMessage), format("Error message '%s' does not match '%s'", e.getMessage(), expectedMessage));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void shouldReturnTable() throws SQLException {
",,,VIEW,views;tables,integration_test",

// table name pattern
",,%account%,,service_account_users;service_accounts,tables;columns;views",
",,%account%,,accounts;service_accounts,tables;columns;views",
",,%test,,integration_test,tables;columns;views",

// schema name pattern
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package integration.tests;

import integration.EnvironmentCondition;
import integration.IntegrationTest;
import lombok.CustomLog;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

Expand All @@ -15,25 +16,34 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

@CustomLog
public class SpecialValuesTest extends IntegrationTest {
private Connection systemConnection;
private Connection userConnection;

@BeforeAll
void beforeAll() throws SQLException {
systemConnection = createConnection(getSystemEngineName());
try {
systemConnection = createConnection(getSystemEngineName());
} catch (Exception e) {
log.warn("Could not create system engine connection", e);
}
userConnection = createConnection();
}

@AfterAll
void afterAll() throws SQLException {
systemConnection.close();
try {
systemConnection.close();
} catch (Exception e) {
log.warn("Could not create system engine connection", e);
}
userConnection.close();
}

@ParameterizedTest
@ValueSource(strings = {"select 'inf'::float", "select '+inf'::float"})
@EnvironmentCondition(value = "2", comparison = EnvironmentCondition.Comparison.LT)
@Tag("v1")
void infFloatUserEngine(String query) throws SQLException {
specialSelect(userConnection, query, Float.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Float.POSITIVE_INFINITY);
}
Expand All @@ -46,25 +56,28 @@ void infRealUserEngine(String query) throws SQLException {

@ParameterizedTest
@ValueSource(strings = {"select 'inf'::real", "select '+inf'::real"})
@Tag("v2")
void infRealSystemEngine(String query) throws SQLException {
specialSelect(userConnection, query, Float.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Float.POSITIVE_INFINITY);
}

@ParameterizedTest
@ValueSource(strings = {"select 'inf'::float", "select '+inf'::float"})
@EnvironmentCondition(value = "2", comparison = EnvironmentCondition.Comparison.GE)
@Tag("v2")
void infFloatAsDoubleUserEngine(String query) throws SQLException {
specialSelect(userConnection, query, Float.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
}

@ParameterizedTest
@ValueSource(strings = {"select 'inf'::float", "select '+inf'::float"})
@Tag("v2")
void infFloatAsDoubleSystemEngine(String query) throws SQLException {
specialSelect(systemConnection, query, Float.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
}

@ParameterizedTest
@ValueSource(strings = {"select 'inf'::double", "select '+inf'::double"})
@Tag("v2")
void infDoubleSystemEngine(String query) throws SQLException {
specialSelect(systemConnection, query, Float.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
}
Expand All @@ -77,14 +90,14 @@ void infDoubleUserEngine(String query) throws SQLException {

@ParameterizedTest
@ValueSource(strings = {"select '-inf'::float"})
@EnvironmentCondition(value = "2", comparison = EnvironmentCondition.Comparison.LT)
@Tag("v1")
void minusInfFloatUserEngine(String query) throws SQLException {
specialSelect(userConnection, query, Float.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY);
}

@ParameterizedTest
@ValueSource(strings = {"select '-inf'::float"})
@EnvironmentCondition(value = "2", comparison = EnvironmentCondition.Comparison.GE)
@Tag("v2")
void minusInfFloatAsDoubleUserEngine(String query) throws SQLException {
specialSelect(userConnection, query, Float.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
}
Expand All @@ -97,12 +110,14 @@ void minusInfRealUserEngine(String query) throws SQLException {

@ParameterizedTest
@ValueSource(strings = {"select '-inf'::real"})
@Tag("v2")
void minusInfRealSystemEngine(String query) throws SQLException {
specialSelect(systemConnection, query, Float.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY);
}

@ParameterizedTest
@ValueSource(strings = {"select '-inf'::float"})
@Tag("v2")
void minusInfFloatAsDoubleSystemEngine(String query) throws SQLException {
specialSelect(systemConnection, query, Float.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
}
Expand All @@ -115,7 +130,7 @@ void minusInfDoubleUserEngine(String query) throws SQLException {

@ParameterizedTest
@ValueSource(strings = {"select 'nan'::float", "select '+nan'::float", "select '-nan'::float"})
@EnvironmentCondition(value = "2", comparison = EnvironmentCondition.Comparison.LT)
@Tag("v1")
void nanFloatUserEngine(String query) throws SQLException {
specialSelect(userConnection, query, Float.NaN, Double.NaN, Float.NaN);
}
Expand All @@ -128,13 +143,14 @@ void nanRealUserEngine(String query) throws SQLException {

@ParameterizedTest
@ValueSource(strings = {"select 'nan'::real", "select '+nan'::real", "select '-nan'::real"})
@Tag("v2")
void nanRealSystemEngine(String query) throws SQLException {
specialSelect(systemConnection, query, Float.NaN, Double.NaN, Float.NaN);
}

@ParameterizedTest
@ValueSource(strings = {"select 'nan'::float", "select '+nan'::float", "select '-nan'::float"})
@EnvironmentCondition(value = "2", comparison = EnvironmentCondition.Comparison.GE)
@Tag("v2")
void nanFloatAsDoubleUserEngine(String query) throws SQLException {
specialSelect(userConnection, query, Float.NaN, Double.NaN, Double.NaN);
}
Expand All @@ -143,6 +159,7 @@ void nanFloatAsDoubleUserEngine(String query) throws SQLException {
@ValueSource(strings = {
"select 'nan'::double", "select '+nan'::double", "select '-nan'::double"
})
@Tag("v2")
void nanDoubleSystemEngine(String query) throws SQLException {
specialSelect(systemConnection, query, Float.NaN, Double.NaN, Double.NaN);
}
Expand All @@ -151,6 +168,7 @@ void nanDoubleSystemEngine(String query) throws SQLException {
@ValueSource(strings = {
"select 'nan'::float", "select '+nan'::float", "select '-nan'::float",
})
@Tag("v2")
void nanFloatAsDoubleSystemEngine(String query) throws SQLException {
specialSelect(systemConnection, query, Float.NaN, Double.NaN, Double.NaN);
}
Expand Down
19 changes: 11 additions & 8 deletions src/integrationTest/java/integration/tests/StatementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void shouldThrowExceptionWhenTryingToReuseStatementClosedOnCompletion() throws S
}
}

@Tag("v2")
@Test
void shouldThrowExceptionWhenExecutingWrongQuery() throws SQLException {
try (Connection connection = createConnection(); Statement statement = connection.createStatement()) {
Expand All @@ -110,7 +111,17 @@ void shouldThrowExceptionWhenExecutingWrongQuery() throws SQLException {
}
}

@Tag("v1")
@Test
void shouldThrowExceptionWhenExecutingWrongQueryV1() throws SQLException {
try (Connection connection = createConnection(); Statement statement = connection.createStatement()) {
String errorMessage = assertThrows(FireboltException.class, () -> statement.executeQuery("select wrong query")).getMessage();
assertTrue(errorMessage.contains("wrong"));
}
}

@Test
@Tag("v2")
@EnvironmentCondition(value = "4.2.0", comparison = EnvironmentCondition.Comparison.GE)
void shouldThrowExceptionWhenExecutingWrongQueryWithJsonError() throws SQLException {
try (Connection connection = createConnection(); Statement statement = connection.createStatement()) {
Expand Down Expand Up @@ -337,14 +348,6 @@ void empty(String sql) throws SQLException {
}
}

@Test
@Tag("v1")
void divisionByZero() throws SQLException {
try (Connection connection = createConnection(); Statement statement = connection.createStatement()) {
assertThrows(SQLException.class, () -> statement.executeQuery("SELECT 1/0"));
}
}

/**
* This test validates that null values are sorted last.
* @throws SQLException if something is going wrong
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

@CustomLog
@Tag("v2")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class SystemEngineTest extends IntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@CustomLog
class TimeoutTest extends IntegrationTest {
private static final int MIN_TIME_SECONDS = 350;
private static final Map<Integer, Long> SERIES_SIZE = Map.of(1, 80000000000L, 2, 600000000000L);
private static final Map<Integer, Long> SERIES_SIZE = Map.of(1, 80000000000L, 2, 700000000000L);
private long startTime;

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class FireboltConnectionServiceSecret extends FireboltConnection {
super(url, connectionSettings, PROTOCOL_VERSION);
OkHttpClient httpClient = getHttpClient(loginProperties);
this.fireboltGatewayUrlService = new FireboltGatewayUrlService(createFireboltAccountRetriever(httpClient, GatewayUrlResponse.class));
// initialization of fireboltEngineService depends on the infraVersion (the version of engine)
connect();
}

Expand Down
Loading