Skip to content
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
20 changes: 16 additions & 4 deletions core/trino-server-rpm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>junit-extensions</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>units</artifactId>
Expand All @@ -50,14 +56,20 @@
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Execution;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.Container.ExecResult;
import org.testcontainers.containers.GenericContainer;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.io.File;
import java.sql.Connection;
Expand All @@ -36,17 +36,31 @@
import static java.util.Arrays.asList;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.MINUTES;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.parallel.ExecutionMode.SAME_THREAD;
import static org.testcontainers.containers.wait.strategy.Wait.forLogMessage;
import static org.testng.Assert.assertEquals;

@Test(singleThreaded = true)
@Execution(SAME_THREAD)
public class ServerIT
{
private static final String BASE_IMAGE_PREFIX = "eclipse-temurin:";
private static final String BASE_IMAGE_SUFFIX = "-jre-ubi9-minimal";

@Test(dataProvider = "rpmJavaTestDataProvider")
public void testInstall(String rpmHostPath, String javaVersion)
private final String rpmHostPath;

public ServerIT()
{
rpmHostPath = requireNonNull(System.getProperty("rpm"), "rpm is null");
}

@Test
public void testInstall()
{
testInstall("17");
testInstall("21");
}

private void testInstall(String javaVersion)
{
String rpm = "/" + new File(rpmHostPath).getName();
String command = "" +
Expand Down Expand Up @@ -80,17 +94,24 @@ public void testInstall(String rpmHostPath, String javaVersion)
.waitingFor(forLogMessage(".*SERVER STARTED.*", 1).withStartupTimeout(Duration.ofMinutes(5)))
.start();
QueryRunner queryRunner = new QueryRunner(container.getHost(), container.getMappedPort(8080));
assertEquals(queryRunner.execute("SHOW CATALOGS"), ImmutableSet.of(asList("system"), asList("hive"), asList("jmx")));
assertEquals(queryRunner.execute("SELECT node_id FROM system.runtime.nodes"), ImmutableSet.of(asList("test-node-id-injected-via-env")));
assertThat(queryRunner.execute("SHOW CATALOGS")).isEqualTo(ImmutableSet.of(asList("system"), asList("hive"), asList("jmx")));
assertThat(queryRunner.execute("SELECT node_id FROM system.runtime.nodes")).isEqualTo(ImmutableSet.of(asList("test-node-id-injected-via-env")));
// TODO remove usage of assertEventually once https://github.com/trinodb/trino/issues/2214 is fixed
assertEventually(
new io.airlift.units.Duration(1, MINUTES),
() -> assertEquals(queryRunner.execute("SELECT specversion FROM jmx.current.\"java.lang:type=runtime\""), ImmutableSet.of(asList(javaVersion))));
() -> assertThat(queryRunner.execute("SELECT specversion FROM jmx.current.\"java.lang:type=runtime\"")).isEqualTo(ImmutableSet.of(asList(javaVersion))));
}
}

@Test(dataProvider = "rpmJavaTestDataProvider")
public void testUninstall(String rpmHostPath, String javaVersion)
@Test
public void testUninstall()
throws Exception
{
testUninstall("17");
testUninstall("21");
}

private void testUninstall(String javaVersion)
throws Exception
{
String rpm = "/" + new File(rpmHostPath).getName();
Expand All @@ -113,7 +134,7 @@ public void testUninstall(String rpmHostPath, String javaVersion)
container.execInContainer("sh", "-xeuc", uninstallTrino);

ExecResult actual = container.execInContainer("rpm", "-q", "trino-server-rpm");
assertEquals(actual.getStdout(), "package trino-server-rpm is not installed\n");
assertThat(actual.getStdout()).isEqualTo("package trino-server-rpm is not installed\n");

assertPathDeleted(container, "/var/lib/trino");
assertPathDeleted(container, "/usr/lib/trino");
Expand All @@ -122,24 +143,15 @@ public void testUninstall(String rpmHostPath, String javaVersion)
}
}

@DataProvider
public static Object[][] rpmJavaTestDataProvider()
{
String rpmHostPath = requireNonNull(System.getProperty("rpm"), "rpm is null");
return new Object[][]{
{rpmHostPath, "17"},
{rpmHostPath, "21"}};
}

private static void assertPathDeleted(GenericContainer<?> container, String path)
throws Exception
{
ExecResult actualResult = container.execInContainer(
"sh",
"-xeuc",
format("test -d %s && echo -n 'path exists' || echo -n 'path deleted'", path));
assertEquals(actualResult.getStdout(), "path deleted");
assertEquals(actualResult.getExitCode(), 0);
assertThat(actualResult.getStdout()).isEqualTo("path deleted");
assertThat(actualResult.getExitCode()).isEqualTo(0);
}

private static class QueryRunner
Expand Down
10 changes: 8 additions & 2 deletions lib/trino-ignite-patched/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<groupId>io.airlift</groupId>
<artifactId>junit-extensions</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
package org.apache.ignite;

import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;

public class TestDummy
{
Expand Down
40 changes: 40 additions & 0 deletions lib/trino-matching/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,50 @@
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>junit-extensions</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<!-- allow both JUnit and TestNG -->
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit-platform</artifactId>
<version>${dep.plugin.surefire.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>${dep.plugin.surefire.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.trino.matching.example.rel.ProjectNode;
import io.trino.matching.example.rel.RelNode;
import io.trino.matching.example.rel.ScanNode;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.NoSuchElementException;
Expand Down
40 changes: 40 additions & 0 deletions lib/trino-memory-context/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>junit-extensions</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>testing</artifactId>
Expand All @@ -46,10 +52,44 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<!-- allow both JUnit and TestNG -->
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit-platform</artifactId>
<version>${dep.plugin.surefire.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>${dep.plugin.surefire.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import io.airlift.units.DataSize;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Test;

import static com.google.common.util.concurrent.Futures.immediateVoidFuture;
import static io.airlift.units.DataSize.Unit.MEGABYTE;
import static io.trino.memory.context.AggregatedMemoryContext.newRootAggregatedMemoryContext;
import static io.trino.memory.context.AggregatedMemoryContext.newSimpleAggregatedMemoryContext;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotEquals;
Expand Down Expand Up @@ -146,22 +147,30 @@ public void testGuaranteedMemoryDoesntBlock()
assertEquals(reservationHandler.getReservation(), maxMemory);
}

@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "SimpleLocalMemoryContext is already closed")
@Test
public void testClosedLocalMemoryContext()
{
AggregatedMemoryContext aggregateContext = newSimpleAggregatedMemoryContext();
LocalMemoryContext localContext = aggregateContext.newLocalMemoryContext("test");
localContext.close();
localContext.setBytes(100);
assertThatThrownBy(() -> {
AggregatedMemoryContext aggregateContext = newSimpleAggregatedMemoryContext();
LocalMemoryContext localContext = aggregateContext.newLocalMemoryContext("test");
localContext.close();
localContext.setBytes(100);
})
.isInstanceOf(IllegalStateException.class)
.hasMessage("SimpleLocalMemoryContext is already closed");
}

@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "SimpleAggregatedMemoryContext is already closed")
@Test
public void testClosedAggregateMemoryContext()
{
AggregatedMemoryContext aggregateContext = newSimpleAggregatedMemoryContext();
LocalMemoryContext localContext = aggregateContext.newLocalMemoryContext("test");
aggregateContext.close();
localContext.setBytes(100);
assertThatThrownBy(() -> {
AggregatedMemoryContext aggregateContext = newSimpleAggregatedMemoryContext();
LocalMemoryContext localContext = aggregateContext.newLocalMemoryContext("test");
aggregateContext.close();
localContext.setBytes(100);
})
.isInstanceOf(IllegalStateException.class)
.hasMessage("SimpleAggregatedMemoryContext is already closed");
}

private static class TestMemoryReservationHandler
Expand Down
Loading