Skip to content

Commit

Permalink
Cleanup tests: remove unused ports
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklakariada committed Oct 20, 2021
1 parent f7a9a80 commit 9049e72
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ class TableauServerConfiguration {
static final int TABLEAU_MAPPED_PORT = 33445;
static final int EXASOL_PORT = 8563;
static final int EXASOL_MAPPED_PORT = 33446;
static final int EXASOL_BUCKETFS_PORT = 2580;
static final int EXASOL_BUCKETFS_MAPPED_PORT = 33447;
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.logging.Logger;

import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
Expand All @@ -20,18 +21,20 @@
* Gateway for interacting with Tableau Server.
*/
public class TableauServerGUIGateway {
private static final Logger LOGGER = Logger.getLogger(TableauServerGUIGateway.class.getName());
private final WebDriver driver;
private final String httpHostAddress;

private TableauServerGUIGateway(final String httpHostAddress) {
this.httpHostAddress = httpHostAddress;
WebDriverManager.chromedriver().setup();
final ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
options.setHeadless(false);
this.driver = new ChromeDriver(options);
}

public static TableauServerGUIGateway connectTo(final String httpHostAddress) {
LOGGER.info(() -> "Connecting to '" + httpHostAddress + "'");
final TableauServerGUIGateway gateway = new TableauServerGUIGateway(httpHostAddress);
gateway.openSession(httpHostAddress);
return gateway;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.testcontainers.junit.jupiter.Testcontainers;

import com.exasol.containers.ExasolContainer;
import com.exasol.containers.ExasolService;
import com.github.dockerjava.api.model.*;

@Testcontainers
Expand All @@ -33,11 +34,10 @@ class TableauServerGUITestIT {
protected static final ExasolContainer<? extends ExasolContainer<?>> EXASOL = new ExasolContainer<>(
DEFAULT_DOCKER_DB_REFERENCE)//
.withCreateContainerCmdModifier(cmd -> cmd.getHostConfig().withPortBindings(List.of( //
new PortBinding(Ports.Binding.bindPort(EXASOL_MAPPED_PORT), new ExposedPort(EXASOL_PORT)), //
new PortBinding(Ports.Binding.bindPort(EXASOL_BUCKETFS_MAPPED_PORT),
new ExposedPort(EXASOL_BUCKETFS_PORT)) //
new PortBinding(Ports.Binding.bindPort(EXASOL_MAPPED_PORT), new ExposedPort(EXASOL_PORT))
))) //
.withExposedPorts(EXASOL_PORT, EXASOL_BUCKETFS_PORT) //
.withExposedPorts(EXASOL_PORT) //
.withRequiredServices(ExasolService.JDBC) //
.withReuse(true);

@BeforeAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.utility.MountableFile;

import com.github.dockerjava.api.model.*;
Expand All @@ -17,7 +16,6 @@ public class TableauServerSetUp {
private static final Logger LOGGER = Logger.getLogger(TableauServerSetUp.class.getName());
private static final String REQUESTED_LEASE_TIME_IN_SECONDS = "60";

@Container
public static GenericContainer<?> TABLEAU_SERVER_CONTAINER = new GenericContainer<>(TABLEAU_SERVER_DOCKER_IMAGE)
.withExposedPorts(TABLEAU_PORT)//
.withCreateContainerCmdModifier(cmd -> cmd.withHostConfig(new HostConfig().withPortBindings(
Expand All @@ -27,7 +25,7 @@ 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)) //
.withStartupTimeout(Duration.ofSeconds(2400)) //
.withStartupTimeout(Duration.ofMinutes(40)) //
.withReuse(true);

public static void setUpServer() throws UnsupportedOperationException, IOException, InterruptedException {
Expand All @@ -40,15 +38,17 @@ private static void startContainer() {
}

private static void setUpConnector() throws UnsupportedOperationException, IOException, InterruptedException {
copyConnectorToServer();
copyConnectorsToServer();
disableConnectorSignatureVerification();
applyChanges();
}

private static void copyConnectorToServer() {
LOGGER.info("Copying the connector to Tableau Server");
private static void copyConnectorsToServer() {
LOGGER.info("Copying the connectors to Tableau Server");
TABLEAU_SERVER_CONTAINER.copyFileToContainer(MountableFile.forHostPath("target/exasol_odbc.taco"),
"/var/opt/tableau/tableau_server/data/tabsvc/vizqlserver/Connectors/exasol_odbc.taco");
TABLEAU_SERVER_CONTAINER.copyFileToContainer(MountableFile.forHostPath("target/exasol_jdbc.taco"),
"/var/opt/tableau/tableau_server/data/tabsvc/vizqlserver/Connectors/exasol_jdbc.taco");
}

private static void disableConnectorSignatureVerification() throws IOException, InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
handlers=java.util.logging.ConsoleHandler
.level=INFO
java.util.logging.ConsoleHandler.level=ALL
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=%1$tF %1$tT.%1$tL [%4$-7s] %5$s %n
com.exasol.level=ALL

0 comments on commit 9049e72

Please sign in to comment.