Skip to content

Commit

Permalink
Skip integration tests with Exasol 8
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklakariada committed Nov 10, 2023
1 parent ff43070 commit 3f60c9c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.exasol.adapter.dialects.oracle;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import java.sql.*;

class ExasolVersionCheck {

private ExasolVersionCheck() {
// Not instantiable
}

/**
* This is a temporary workaround until integration tests work with Exasol 8.
*/
static void assumeExasolVersion7(final Connection connection) {
final String version = getExasolMajorVersion(connection);
assumeTrue("7".equals(version), "Expected Exasol version 7 but got '" + version + "'");
}

static String getExasolMajorVersion(final Connection connection) {
try (Statement stmt = connection.createStatement()) {
final ResultSet result = stmt
.executeQuery("SELECT PARAM_VALUE FROM SYS.EXA_METADATA WHERE PARAM_NAME='databaseMajorVersion'");
assertTrue(result.next(), "no result");
return result.getString(1);
} catch (final SQLException exception) {
throw new IllegalStateException("Failed to query Exasol version: " + exception.getMessage(), exception);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ protected static String getUniqueIdentifier() {
return "ID" + idCounter;
}

@BeforeAll
static void assumeExasol71() throws SQLException {
ExasolVersionCheck.assumeExasolVersion7(SETUP.getExasolContainer().createConnection());
}

@Override
protected TestSetup getTestSetup() {
final OracleObjectFactory oracleFactory = SETUP.getOracleFactory();
Expand All @@ -42,11 +47,11 @@ protected TestSetup getTestSetup() {

private static class OracleSingleTableVirtualSchemaTestSetup implements VirtualSchemaTestSetup {
private final VirtualSchema virtualSchema;
private final Schema OracleSchema;
private final Schema oracleSchema;

private OracleSingleTableVirtualSchemaTestSetup(final VirtualSchema virtualSchema, final Schema OracleSchema) {
private OracleSingleTableVirtualSchemaTestSetup(final VirtualSchema virtualSchema, final Schema oracleSchema) {
this.virtualSchema = virtualSchema;
this.OracleSchema = OracleSchema;
this.oracleSchema = oracleSchema;
}

@Override
Expand All @@ -57,7 +62,7 @@ public String getFullyQualifiedName() {
@Override
public void close() {
this.virtualSchema.drop();
this.OracleSchema.drop();
this.oracleSchema.drop();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class OracleSqlDialectIT {
@BeforeAll
static void beforeAll()
throws BucketAccessException, TimeoutException, SQLException, FileNotFoundException, InterruptedException {
setupOracleDbContainer();
setupExasolContainer();
setupOracleDbContainer();
}

private static void uploadInstantClientToBucket()
Expand All @@ -82,7 +82,7 @@ private static String getTestHostIpFromInsideExasol(final ExasolContainer<?> exa
final Map<String, ContainerNetwork> networks = exasolContainer.getContainerInfo().getNetworkSettings()
.getNetworks();
if (networks.size() == 0) {
return null;
throw new IllegalStateException("Failed to get host IP from container network settings");
}
return networks.values().iterator().next().getGateway();
}
Expand All @@ -94,6 +94,7 @@ private static void setupExasolContainer()
uploadInstantClientToBucket();
final Connection exasolConnection = exasolContainer.createConnectionForUser(exasolContainer.getUsername(),
exasolContainer.getPassword());
ExasolVersionCheck.assumeExasolVersion7(exasolConnection);
statementExasol = exasolConnection.createStatement();

final UdfTestSetup udfTestSetup = new UdfTestSetup(getTestHostIpFromInsideExasol(exasolContainer),
Expand Down

0 comments on commit 3f60c9c

Please sign in to comment.