diff --git a/tableau-server-GUI-tests/pom.xml b/tableau-server-GUI-tests/pom.xml index 7934f15..14b34f4 100644 --- a/tableau-server-GUI-tests/pom.xml +++ b/tableau-server-GUI-tests/pom.xml @@ -94,7 +94,6 @@ maven-failsafe-plugin 3.0.0-M5 - ${project.basedir}/src/test/resources/credentials.properties src/test/resources/logging.properties diff --git a/tableau-server-GUI-tests/src/test/java/com/exasol/tableau/TableauServerConfiguration.java b/tableau-server-GUI-tests/src/test/java/com/exasol/tableau/TableauServerConfiguration.java index 36c0a40..f9cdd3b 100644 --- a/tableau-server-GUI-tests/src/test/java/com/exasol/tableau/TableauServerConfiguration.java +++ b/tableau-server-GUI-tests/src/test/java/com/exasol/tableau/TableauServerConfiguration.java @@ -1,12 +1,32 @@ package com.exasol.tableau; +import java.io.*; +import java.util.Properties; + class TableauServerConfiguration { static final int TABLEAU_PORT = 8080; static final int TABLEAU_MAPPED_PORT = 33445; static final int EXASOL_PORT = 8563; static final int EXASOL_MAPPED_PORT = 33446; static final String TABLEAU_SERVER_DOCKER_IMAGE = "tablau_server_with_exasol_drivers:latest"; - static final String TABLEAU_USERNAME = System.getProperty("TABLEAU_USERNAME"); - static final String TABLEAU_PASSWORD = System.getProperty("TABLEAU_PASSWORD"); - static final String TABLEAU_LICENSE_KEY = System.getProperty("TABLEAU_LICENSE_KEY"); + + private static final Properties PROPERTIES = readProperties("/credentials.properties"); + + static final String TABLEAU_USERNAME = PROPERTIES.getProperty("TABLEAU_USERNAME"); + static final String TABLEAU_PASSWORD = PROPERTIES.getProperty("TABLEAU_PASSWORD"); + static final String TABLEAU_LICENSE_KEY = PROPERTIES.getProperty("TABLEAU_LICENSE_KEY"); + + private static Properties readProperties(final String resource) { + final Properties properties = new Properties(); + try (InputStream stream = TableauServerConfiguration.class.getResourceAsStream(resource)) { + if (stream == null) { + throw new AssertionError("Resource '" + resource + "' not found on classpath"); + } + properties.load(stream); + } catch (final IOException exception) { + throw new UncheckedIOException("Error reading resource " + resource + " from classpath", exception); + } + return properties; + } + } diff --git a/tableau-server-GUI-tests/src/test/java/com/exasol/tableau/TableauServerSetUp.java b/tableau-server-GUI-tests/src/test/java/com/exasol/tableau/TableauServerSetUp.java index c4ef6ef..d661a12 100644 --- a/tableau-server-GUI-tests/src/test/java/com/exasol/tableau/TableauServerSetUp.java +++ b/tableau-server-GUI-tests/src/test/java/com/exasol/tableau/TableauServerSetUp.java @@ -1,8 +1,10 @@ package com.exasol.tableau; import static com.exasol.tableau.TableauServerConfiguration.*; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; +import java.nio.file.*; import java.time.Duration; import java.util.logging.Logger; @@ -16,6 +18,9 @@ public class TableauServerSetUp { private static final Logger LOGGER = Logger.getLogger(TableauServerSetUp.class.getName()); private static final String REQUESTED_LEASE_TIME_IN_SECONDS = "60"; + private static final Path ODBC_CONNECTOR_FILE = Paths.get("target/exasol_odbc.taco").toAbsolutePath(); + private static final Path JDBC_CONNECTOR_FILE = Paths.get("target/exasol_jdbc.taco").toAbsolutePath(); + public static GenericContainer TABLEAU_SERVER_CONTAINER = new GenericContainer<>(TABLEAU_SERVER_DOCKER_IMAGE) .withExposedPorts(TABLEAU_PORT)// .withCreateContainerCmdModifier(cmd -> cmd.withHostConfig(new HostConfig().withPortBindings( @@ -25,14 +30,21 @@ public class TableauServerSetUp { .withEnv("LICENSE_KEY", TABLEAU_LICENSE_KEY) // .withEnv("REQUESTED_LEASE_TIME", REQUESTED_LEASE_TIME_IN_SECONDS) // .waitingFor(Wait.forLogMessage(".*INFO exited: run-tableau-server.*", 1)) // + // INFO exited: run-tableau-server (exit status 0; expected) .withStartupTimeout(Duration.ofMinutes(40)) // .withReuse(true); public static void setUpServer() throws UnsupportedOperationException, IOException, InterruptedException { + checkPreconditions(); startContainer(); setUpConnector(); } + private static void checkPreconditions() { + assertFileExists(ODBC_CONNECTOR_FILE); + assertFileExists(JDBC_CONNECTOR_FILE); + } + private static void startContainer() { TABLEAU_SERVER_CONTAINER.start(); } @@ -45,12 +57,19 @@ private static void setUpConnector() throws UnsupportedOperationException, IOExc private static void copyConnectorsToServer() { LOGGER.info("Copying the connectors to Tableau Server"); - TABLEAU_SERVER_CONTAINER.copyFileToContainer(MountableFile.forHostPath("target/exasol_odbc.taco"), + assertFileExists(ODBC_CONNECTOR_FILE); + assertFileExists(JDBC_CONNECTOR_FILE); + TABLEAU_SERVER_CONTAINER.copyFileToContainer(MountableFile.forHostPath(ODBC_CONNECTOR_FILE), "/var/opt/tableau/tableau_server/data/tabsvc/vizqlserver/Connectors/exasol_odbc.taco"); - TABLEAU_SERVER_CONTAINER.copyFileToContainer(MountableFile.forHostPath("target/exasol_jdbc.taco"), + TABLEAU_SERVER_CONTAINER.copyFileToContainer(MountableFile.forHostPath(JDBC_CONNECTOR_FILE), "/var/opt/tableau/tableau_server/data/tabsvc/vizqlserver/Connectors/exasol_jdbc.taco"); } + private static void assertFileExists(final Path path) { + assertTrue(Files.exists(path), + "Connector not found at " + path + ". Run 'package_connector.sh' to generate it."); + } + private static void disableConnectorSignatureVerification() throws IOException, InterruptedException { LOGGER.info("Disabling connectors signature"); TABLEAU_SERVER_CONTAINER.execInContainer("tsm", "configuration", "set", "-k",