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
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,28 @@
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FsShell;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdds.HddsConfigKeys;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.MiniOzoneHAClusterImpl;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.client.ObjectStore;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneClientFactory;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.ha.ConfUtils;
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.om.helpers.BucketLayout;
import org.apache.ozone.test.GenericTestUtils;
import org.apache.hadoop.util.ToolRunner;
import org.apache.ozone.test.GenericTestUtils;
import org.apache.ozone.test.HATests;
import org.apache.ratis.util.LifeCycle;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.io.TempDir;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.Optional;
import java.util.OptionalInt;

Expand All @@ -62,8 +57,9 @@
/**
* Test client-side URI handling with Ozone Manager HA.
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Timeout(300)
public class TestOzoneFsHAURLs {
public abstract class TestOzoneFsHAURLs implements HATests.TestCase {

/**
* Set a timeout for each test.
Expand All @@ -72,10 +68,9 @@ public class TestOzoneFsHAURLs {
TestOzoneFsHAURLs.class);

private OzoneConfiguration conf;
private static MiniOzoneHAClusterImpl cluster;
private static String omServiceId;
private static OzoneManager om;
private static int numOfOMs;
private MiniOzoneHAClusterImpl cluster;
private String omServiceId;
private OzoneManager om;

private String volumeName;
private String bucketName;
Expand All @@ -85,7 +80,7 @@ public class TestOzoneFsHAURLs {
"fs." + OzoneConsts.OZONE_URI_SCHEME + ".impl";
private static final String O3FS_IMPL_VALUE =
"org.apache.hadoop.fs.ozone.OzoneFileSystem";
private static OzoneClient client;
private OzoneClient client;

private static final String OFS_IMPL_KEY =
"fs." + OzoneConsts.OZONE_OFS_URI_SCHEME + ".impl";
Expand All @@ -95,25 +90,10 @@ public class TestOzoneFsHAURLs {


@BeforeAll
static void initClass(@TempDir File tempDir) throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
omServiceId = "om-service-test1";
numOfOMs = 3;
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, tempDir.getAbsolutePath());
conf.setInt(ScmConfigKeys.OZONE_DATANODE_PIPELINE_LIMIT, 3);

conf.set(OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT,
BucketLayout.LEGACY.name());
conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS, true);

// Start the cluster
MiniOzoneHAClusterImpl.Builder builder = MiniOzoneCluster.newHABuilder(conf);
builder.setOMServiceId(omServiceId)
.setNumOfOzoneManagers(numOfOMs)
.setNumDatanodes(5);
cluster = builder.build();
cluster.waitForClusterToBeReady();
client = OzoneClientFactory.getRpcClient(omServiceId, conf);
void initClass() throws Exception {
cluster = cluster();
omServiceId = cluster.getOzoneManager().getOMServiceId();
client = cluster.newClient();

om = cluster.getOzoneManager();
}
Expand Down Expand Up @@ -149,11 +129,8 @@ public void init() throws Exception {
}

@AfterAll
public static void shutdown() {
void cleanup() {
IOUtils.closeQuietly(client);
if (cluster != null) {
cluster.shutdown();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,18 @@
import org.apache.hadoop.fs.contract.AbstractContractSeekTest;
import org.apache.hadoop.fs.contract.AbstractContractUnbufferTest;
import org.apache.hadoop.fs.contract.AbstractFSContract;
import org.apache.hadoop.hdds.conf.DatanodeRatisServerConfig;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.ratis.conf.RatisClientConfig;
import org.apache.hadoop.hdds.utils.IOUtils;
import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.om.helpers.BucketLayout;
import org.apache.hadoop.tools.contract.AbstractContractDistCpTest;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.apache.ozone.test.ClusterForTests;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;

import java.io.IOException;
import java.time.Duration;

import static org.apache.hadoop.fs.contract.ContractTestUtils.cleanup;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_FS_HSYNC_ENABLED;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_HBASE_ENHANCEMENTS_ALLOWED;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_OFS_URI_SCHEME;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT;
import static org.assertj.core.api.Assumptions.assumeThat;
Expand All @@ -62,67 +55,28 @@
* but can tweak configuration by also overriding {@link #createOzoneConfig()}.
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
abstract class AbstractOzoneContractTest {
abstract class AbstractOzoneContractTest extends ClusterForTests<MiniOzoneCluster> {

private static final String CONTRACT_XML = "contract/ozone.xml";

private MiniOzoneCluster cluster;

/**
* This must be implemented by all subclasses.
* @return the FS contract
*/
abstract AbstractFSContract createOzoneContract(Configuration conf);

/**
* Creates the base configuration for contract tests. This can be tweaked
* in subclasses by overriding {@link #createOzoneConfig()}.
*/
protected static OzoneConfiguration createBaseConfiguration() {
OzoneConfiguration conf = new OzoneConfiguration();
DatanodeRatisServerConfig ratisServerConfig =
conf.getObject(DatanodeRatisServerConfig.class);
ratisServerConfig.setRequestTimeOut(Duration.ofSeconds(3));
ratisServerConfig.setWatchTimeOut(Duration.ofSeconds(10));
conf.setFromObject(ratisServerConfig);

RatisClientConfig.RaftConfig raftClientConfig =
conf.getObject(RatisClientConfig.RaftConfig.class);
raftClientConfig.setRpcRequestTimeout(Duration.ofSeconds(3));
raftClientConfig.setRpcWatchRequestTimeout(Duration.ofSeconds(10));
conf.setFromObject(raftClientConfig);

@Override
protected OzoneConfiguration createOzoneConfig() {
OzoneConfiguration conf = createBaseConfiguration();
conf.addResource(CONTRACT_XML);

conf.setBoolean(OZONE_HBASE_ENHANCEMENTS_ALLOWED, true);
conf.setBoolean("ozone.client.hbase.enhancements.allowed", true);
conf.setBoolean(OZONE_FS_HSYNC_ENABLED, true);

return conf;
}

/**
* Hook method that allows tweaking the configuration.
*/
OzoneConfiguration createOzoneConfig() {
return createBaseConfiguration();
}

MiniOzoneCluster getCluster() {
return cluster;
}

@BeforeAll
void setup() throws Exception {
cluster = MiniOzoneCluster.newBuilder(createOzoneConfig())
@Override
protected MiniOzoneCluster createCluster() throws Exception {
return MiniOzoneCluster.newBuilder(createOzoneConfig())
.setNumDatanodes(5)
.build();
cluster.waitForClusterToBeReady();
}

@AfterAll
void teardown() {
IOUtils.closeQuietly(cluster);
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
class TestOzoneContractFSO extends AbstractOzoneContractTest {

@Override
OzoneConfiguration createOzoneConfig() {
OzoneConfiguration conf = createBaseConfiguration();
protected OzoneConfiguration createOzoneConfig() {
OzoneConfiguration conf = super.createOzoneConfig();
conf.set(OZONE_DEFAULT_BUCKET_LAYOUT, FILE_SYSTEM_OPTIMIZED.name());
return conf;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
class TestOzoneContractLegacy extends AbstractOzoneContractTest {

@Override
OzoneConfiguration createOzoneConfig() {
OzoneConfiguration conf = createBaseConfiguration();
protected OzoneConfiguration createOzoneConfig() {
OzoneConfiguration conf = super.createOzoneConfig();
conf.set(OZONE_DEFAULT_BUCKET_LAYOUT, LEGACY.name());
return conf;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,37 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.scm.protocolPB.StorageContainerLocationProtocolClientSideTranslatorPB;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.container.common.SCMTestUtils;
import org.apache.ozone.test.NonHATests;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.Timeout;

/**
* Test allocate container calls.
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Timeout(300)
public class TestAllocateContainer {
public abstract class TestAllocateContainer implements NonHATests.TestCase {

private static MiniOzoneCluster cluster;
private static OzoneConfiguration conf;
private static StorageContainerLocationProtocolClientSideTranslatorPB
private OzoneConfiguration conf;
private StorageContainerLocationProtocolClientSideTranslatorPB
storageContainerLocationClient;
private static XceiverClientManager xceiverClientManager;

@BeforeAll
public static void init() throws Exception {
conf = new OzoneConfiguration();
cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(3).build();
cluster.waitForClusterToBeReady();
void init() throws Exception {
conf = cluster().getConf();
storageContainerLocationClient =
cluster.getStorageContainerLocationClient();
xceiverClientManager = new XceiverClientManager(conf);
cluster().getStorageContainerLocationClient();
}

@AfterAll
public static void shutdown() throws InterruptedException {
if (cluster != null) {
cluster.shutdown();
}
void cleanup() {
IOUtils.cleanupWithLogger(null, storageContainerLocationClient);
}

Expand Down
Loading