Skip to content

Commit

Permalink
Remove redundant AbstractTestAlluxioFileSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Oct 3, 2024
1 parent 88cf4c2 commit bd22909
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 130 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,22 @@
*/
package io.trino.filesystem.alluxio;

import alluxio.AlluxioURI;
import alluxio.client.file.FileSystem;
import alluxio.client.file.FileSystemContext;
import alluxio.client.file.URIStatus;
import alluxio.conf.Configuration;
import alluxio.conf.InstancedConfiguration;
import alluxio.exception.AlluxioException;
import alluxio.grpc.DeletePOptions;
import io.trino.filesystem.AbstractTestTrinoFileSystem;
import io.trino.filesystem.Location;
import io.trino.filesystem.TrinoFileSystem;
import io.trino.spi.security.ConnectorIdentity;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
Expand All @@ -24,19 +39,104 @@
import java.io.IOException;
import java.time.Duration;

import static org.assertj.core.api.Assertions.assertThat;

@Testcontainers
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class TestAlluxioFileSystem
extends AbstractTestAlluxioFileSystem
extends AbstractTestTrinoFileSystem
{
private static final String IMAGE_NAME = "alluxio/alluxio:2.9.5";
public static final DockerImageName ALLUXIO_IMAGE = DockerImageName.parse(IMAGE_NAME);
private static final DockerImageName ALLUXIO_IMAGE = DockerImageName.parse(IMAGE_NAME);

@Container
private static final GenericContainer<?> ALLUXIO_MASTER_CONTAINER = createAlluxioMasterContainer();

@Container
private static final GenericContainer<?> ALLUXIO_WORKER_CONTAINER = createAlluxioWorkerContainer();

private TrinoFileSystem fileSystem;
private Location rootLocation;
private FileSystem alluxioFs;
private AlluxioFileSystemFactory alluxioFileSystemFactory;

@BeforeAll
void setup()
{
this.rootLocation = Location.of("alluxio:///");
InstancedConfiguration conf = Configuration.copyGlobal();
FileSystemContext fsContext = FileSystemContext.create(conf);
this.alluxioFs = FileSystem.Factory.create(fsContext);
this.alluxioFileSystemFactory = new AlluxioFileSystemFactory(conf);
this.fileSystem = alluxioFileSystemFactory.create(ConnectorIdentity.ofUser("alluxio"));
// the SSHD container will be stopped by TestContainers on shutdown
// https://github.com/trinodb/trino/discussions/21969
System.setProperty("ReportLeakedContainers.disabled", "true");
}

@AfterAll
void tearDown()
{
fileSystem = null;
alluxioFs = null;
rootLocation = null;
alluxioFileSystemFactory = null;
}

@AfterEach
void afterEach()
throws IOException, AlluxioException
{
AlluxioURI root = new AlluxioURI(getRootLocation().toString());

for (URIStatus status : alluxioFs.listStatus(root)) {
alluxioFs.delete(new AlluxioURI(status.getPath()), DeletePOptions.newBuilder().setRecursive(true).build());
}
}

@Override
protected boolean isHierarchical()
{
return true;
}

@Override
protected TrinoFileSystem getFileSystem()
{
return fileSystem;
}

@Override
protected Location getRootLocation()
{
return rootLocation;
}

@Override
protected void verifyFileSystemIsEmpty()
{
AlluxioURI bucket =
AlluxioUtils.convertToAlluxioURI(rootLocation, ((AlluxioFileSystem) fileSystem).getMountRoot());
try {
assertThat(alluxioFs.listStatus(bucket)).isEmpty();
}
catch (IOException | AlluxioException e) {
throw new RuntimeException(e);
}
}

@Override
protected final boolean supportsCreateExclusive()
{
return false;
}

@Override
protected boolean supportsIncompleteWriteNoClobber()
{
return false;
}

private static GenericContainer<?> createAlluxioMasterContainer()
{
GenericContainer<?> container = new GenericContainer<>(ALLUXIO_IMAGE);
Expand Down Expand Up @@ -76,14 +176,4 @@ private static GenericContainer<?> createAlluxioWorkerContainer()
.waitingFor(Wait.forLogMessage(".*Alluxio worker started.*\n", 1));
return container;
}

@BeforeAll
void setup()
throws IOException
{
initialize();
// the SSHD container will be stopped by TestContainers on shutdown
// https://github.com/trinodb/trino/discussions/21969
System.setProperty("ReportLeakedContainers.disabled", "true");
}
}

0 comments on commit bd22909

Please sign in to comment.