Skip to content

Commit

Permalink
fixed integration tests broken by the server side changes (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Radzin authored Jun 11, 2024
1 parent b207197 commit 4a64ce5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,24 @@ void shouldReturnTable() throws SQLException {
@ParameterizedTest
@CsvSource({
// table types
",,,,tables;databases;integration_test,",
",,,TABLE;VIEW,tables;databases;integration_test,",
",,,VIEW;TABLE,integration_test;tables;databases,",
",,,TABLE,integration_test,databases;tables",
",,,VIEW,databases;tables,integration_test",
",,,,tables;views;integration_test,",
",,,TABLE;VIEW,tables;views;integration_test,",
",,,VIEW;TABLE,integration_test;tables;views,",
",,,TABLE,integration_test,views;tables",
",,,VIEW,views;tables,integration_test",

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

// schema name pattern
",public,,,integration_test,tables;columns;databases",
",public,,,integration_test,tables;columns;views",
",information_schema,,,tables;columns,integration_test",

// schema name pattern and table types
",public,,TABLE,integration_test,tables;columns;databases",
",public,,TABLE;VIEW,integration_test,tables;columns;databases",
",public,,VIEW,,tables;columns;databases",
",public,,TABLE,integration_test,tables;columns;views",
",public,,TABLE;VIEW,integration_test,tables;columns;views",
",public,,VIEW,,tables;columns;views",
",information_schema,,TABLE,,integration_test",
",information_schema,,TABLE;VIEW,tables;columns,integration_test",
",information_schema,,VIEW,tables;columns,",
Expand Down
26 changes: 0 additions & 26 deletions src/integrationTest/java/integration/tests/SpecialValuesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,10 @@ void infFloatAsDoubleUserEngine(String query) throws SQLException {

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

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

@ParameterizedTest
@ValueSource(strings = {"select 'inf'::double", "select '+inf'::double"})
void infDoubleSystemEngine(String query) throws SQLException {
Expand Down Expand Up @@ -111,18 +103,10 @@ void minusInfRealSystemEngine(String query) throws SQLException {

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

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

@ParameterizedTest
@ValueSource(strings = {"select '-inf'::double"})
void minusInfDoubleUserEngine(String query) throws SQLException {
Expand Down Expand Up @@ -167,20 +151,10 @@ void nanDoubleSystemEngine(String query) throws SQLException {
@ValueSource(strings = {
"select 'nan'::float", "select '+nan'::float", "select '-nan'::float",
})
@EnvironmentCondition(value = "2", comparison = EnvironmentCondition.Comparison.GE)
void nanFloatAsDoubleSystemEngine(String query) throws SQLException {
specialSelect(systemConnection, query, Float.NaN, Double.NaN, Double.NaN);
}

@ParameterizedTest
@ValueSource(strings = {
"select 'nan'::float", "select '+nan'::float", "select '-nan'::float",
})
@EnvironmentCondition(value = "2", comparison = EnvironmentCondition.Comparison.LT)
void nanFloatSystemEngine(String query) throws SQLException {
specialSelect(systemConnection, query, Float.NaN, Double.NaN, Float.NaN);
}

@ParameterizedTest
@ValueSource(strings = {"select 'nan'::double", "select '+nan'::double", "select '-nan'::double"})
void nanDoubleUserEngine(String query) throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import integration.IntegrationTest;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
Expand Down Expand Up @@ -47,6 +48,7 @@ void readOnly() throws SQLException {
}

@Test
@Tag("v2")
void getSchemas() throws SQLException {
String database = integration.ConnectionInfo.getInstance().getDatabase();
assertEquals(List.of(List.of("information_schema", database)), getSchemas(DatabaseMetaData::getSchemas));
Expand All @@ -65,6 +67,7 @@ void getSchemas() throws SQLException {
"{database},%schema",
"{database},%form%",
})
@Tag("v2")
void getSchemasInformationSchema(String catalog, String schemaPattern) throws SQLException {
String database = integration.ConnectionInfo.getInstance().getDatabase();
String cat = catalog == null ? null : catalog.replace("{database}", database);
Expand Down Expand Up @@ -110,6 +113,7 @@ void getSchemasInformationSchema(String catalog, String schemaPattern) throws SQ
",,%in%,VIEW;TABLE,engines,tables",
",,,TABLE,,",
})
@Tag("v2")
void getTables(String catalog, String schemaPattern, String tableNamePattern, String types, String requiredTableName, String forbiddenTableName) throws SQLException {
String database = integration.ConnectionInfo.getInstance().getDatabase();
String requiredCatalog = catalog == null ? null : catalog.replace("{database}", database);
Expand Down Expand Up @@ -173,6 +177,7 @@ void getTables(String catalog, String schemaPattern, String tableNamePattern, St
",,%in%,no-one,,information_schema.columns.column_name",
",,,does-not-exist,,information_schema.columns.column_name",
})
@Tag("v2")
void getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern, String requiredColumn, String forbiddenColumn) throws SQLException {
String database = integration.ConnectionInfo.getInstance().getDatabase();
String requiredCatalog = catalog == null ? null : catalog.replace("{database}", database);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ void shouldFailToSelectFromCustomDbUsingSystemEngine() throws SQLException {
String secret = current.getSecret();
Collection<String> expectedErrorMessages = Set.of(
"Queries against table dummy require a user engine",
"The system engine doesn't support queries against table dummy. Run this query on a user engine.");
"The system engine doesn't support queries against table dummy. Run this query on a user engine.",
"Line 1, Column 22: relation \"dummy\" does not exist");

try (Connection systemConnection = DriverManager.getConnection(systemEngineJdbcUrl, principal, secret);
Connection customConnection = DriverManager.getConnection(customEngineJdbcUrl, principal, secret)) {
Expand All @@ -116,7 +117,7 @@ void shouldFailToSelectFromCustomDbUsingSystemEngine() throws SQLException {
}
FireboltException e = assertThrows(FireboltException.class, () -> systemConnection.createStatement().executeQuery("select count(*) from dummy"));
String actualErrorMessage = e.getErrorMessageFromServer().replaceAll("\r?\n", "");
assertTrue(expectedErrorMessages.contains(actualErrorMessage));
assertTrue(expectedErrorMessages.contains(actualErrorMessage), "Unexpected error message: " + actualErrorMessage);
} finally {
try {
customConnection.createStatement().executeUpdate("DROP TABLE dummy");
Expand Down Expand Up @@ -299,6 +300,7 @@ private String getTableDbName(Connection connection, String table) throws SQLExc

@Test
@Tag("slow")
@Tag("v2") // does not work on new V1 - DB cannot be managed by system engine
void shouldExecuteEngineManagementQueries() throws SQLException {
try (Connection connection = createConnection(getSystemEngineName())) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private Optional<ResultSet> execute(StatementInfoWrapper statementInfoWrapper) t
}
InputStream inputStream = null;
try {
log.log(Level.INFO, "Executing the statement with label {0} : {1}", new Object[] {statementInfoWrapper.getLabel(), statementInfoWrapper.getSql()});
log.log(Level.FINE, "Executing the statement with label {0} : {1}", new Object[] {statementInfoWrapper.getLabel(), statementInfoWrapper.getSql()});
if (statementInfoWrapper.getType() == StatementType.PARAM_SETTING) {
connection.addProperty(statementInfoWrapper.getParam());
log.log(Level.FINE, "The property from the query {0} was stored", runningStatementLabel);
Expand Down

0 comments on commit 4a64ce5

Please sign in to comment.