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 @@ -18,11 +18,9 @@

package org.apache.hadoop.ozone.reconfig;

import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.conf.ReconfigurationHandler;
import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.security.UserGroupInformation;
import org.junit.jupiter.api.AfterAll;
import org.apache.ozone.test.NonHATests;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.Timeout;
Expand All @@ -40,32 +38,17 @@
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Timeout(300)
abstract class ReconfigurationTestBase {
abstract class ReconfigurationTestBase implements NonHATests.TestCase {

private MiniOzoneCluster cluster;
private String currentUser;

@BeforeAll
void setup() throws Exception {
cluster = MiniOzoneCluster.newBuilder(new OzoneConfiguration())
.build();
cluster.waitForClusterToBeReady();
currentUser = UserGroupInformation.getCurrentUser().getShortUserName();
}

@AfterAll
void shutdown() {
if (cluster != null) {
cluster.shutdown();
}
}

abstract ReconfigurationHandler getSubject();

MiniOzoneCluster getCluster() {
return cluster;
}

String getCurrentUser() {
return currentUser;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
/**
* Tests for Datanode reconfiguration.
*/
class TestDatanodeReconfiguration extends ReconfigurationTestBase {
public abstract class TestDatanodeReconfiguration extends ReconfigurationTestBase {
@Override
ReconfigurationHandler getSubject() {
return getFirstDatanode().getReconfigurationHandler();
Expand Down Expand Up @@ -108,7 +108,7 @@ void replicationStreamsLimit(int delta) throws ReconfigurationException {
}

private HddsDatanodeService getFirstDatanode() {
return getCluster().getHddsDatanodes().get(0);
return cluster().getHddsDatanodes().get(0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
/**
* Tests for OM reconfiguration.
*/
class TestOmReconfiguration extends ReconfigurationTestBase {
public abstract class TestOmReconfiguration extends ReconfigurationTestBase {

@Override
ReconfigurationHandler getSubject() {
return getCluster().getOzoneManager().getReconfigurationHandler();
return cluster().getOzoneManager().getReconfigurationHandler();
}

@Test
Expand All @@ -59,7 +59,7 @@ void adminUsernames() throws ReconfigurationException {

assertEquals(
ImmutableSet.of(newValue, getCurrentUser()),
getCluster().getOzoneManager().getOmAdminUsernames());
cluster().getOzoneManager().getOmAdminUsernames());
}

@Test
Expand All @@ -71,37 +71,37 @@ void readOnlyAdmins() throws ReconfigurationException {

assertEquals(
ImmutableSet.of(newValue),
getCluster().getOzoneManager().getOmReadOnlyAdminUsernames());
cluster().getOzoneManager().getOmReadOnlyAdminUsernames());
}

@Test
public void keyDeletingLimitPerTask() throws ReconfigurationException {
int originLimit = getCluster().getOzoneManager()
int originLimit = cluster().getOzoneManager()
.getKeyManager().getDeletingService().getKeyLimitPerTask();

getSubject().reconfigurePropertyImpl(OZONE_KEY_DELETING_LIMIT_PER_TASK,
String.valueOf(originLimit + 1));

assertEquals(originLimit + 1, getCluster().getOzoneManager()
assertEquals(originLimit + 1, cluster().getOzoneManager()
.getKeyManager().getDeletingService().getKeyLimitPerTask());
}

@Test
void allowListAllVolumes() throws ReconfigurationException {
final boolean newValue = !getCluster().getOzoneManager().getAllowListAllVolumes();
final boolean newValue = !cluster().getOzoneManager().getAllowListAllVolumes();

getSubject().reconfigurePropertyImpl(OZONE_OM_VOLUME_LISTALL_ALLOWED,
String.valueOf(newValue));

assertEquals(newValue, getCluster().getOzoneManager().getAllowListAllVolumes());
assertEquals(newValue, cluster().getOzoneManager().getAllowListAllVolumes());
}

@ParameterizedTest
@ValueSource(strings = {"", "invalid"})
void unsetAllowListAllVolumes(String newValue) throws ReconfigurationException {
getSubject().reconfigurePropertyImpl(OZONE_OM_VOLUME_LISTALL_ALLOWED, newValue);

assertEquals(OZONE_OM_VOLUME_LISTALL_ALLOWED_DEFAULT, getCluster().getOzoneManager().getAllowListAllVolumes());
assertEquals(OZONE_OM_VOLUME_LISTALL_ALLOWED_DEFAULT, cluster().getOzoneManager().getAllowListAllVolumes());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
/**
* Tests for SCM reconfiguration.
*/
class TestScmReconfiguration extends ReconfigurationTestBase {
public abstract class TestScmReconfiguration extends ReconfigurationTestBase {

@Override
ReconfigurationHandler getSubject() {
return getCluster().getStorageContainerManager()
return cluster().getStorageContainerManager()
.getReconfigurationHandler();
}

Expand All @@ -69,7 +69,7 @@ void adminUsernames() throws ReconfigurationException {

assertEquals(
ImmutableSet.of(newValue, getCurrentUser()),
getCluster().getStorageContainerManager().getScmAdminUsernames());
cluster().getStorageContainerManager().getScmAdminUsernames());
}

@Test
Expand All @@ -81,7 +81,7 @@ void readOnlyAdminUsernames() throws ReconfigurationException {

assertEquals(
ImmutableSet.of(newValue),
getCluster().getStorageContainerManager()
cluster().getStorageContainerManager()
.getScmReadOnlyAdminUsernames());
}

Expand All @@ -97,14 +97,14 @@ void replicationInterval() throws ReconfigurationException {
}

private ReplicationManagerConfiguration replicationManagerConfig() {
return getCluster().getStorageContainerManager().getReplicationManager()
return cluster().getStorageContainerManager().getReplicationManager()
.getConfig();
}

@Test
void blockDeletionPerInterval() throws ReconfigurationException {
SCMBlockDeletingService blockDeletingService =
getCluster().getStorageContainerManager().getScmBlockManager()
cluster().getStorageContainerManager().getScmBlockManager()
.getSCMBlockDeletingService();
int blockDeleteTXNum = blockDeletingService.getBlockDeleteTXNum();
int newValue = blockDeleteTXNum + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,28 @@ public MiniOzoneCluster cluster() {
}
}

@Nested
class DatanodeReconfiguration extends org.apache.hadoop.ozone.reconfig.TestDatanodeReconfiguration {
@Override
public MiniOzoneCluster cluster() {
return getCluster();
}
}

@Nested
class OmReconfiguration extends org.apache.hadoop.ozone.reconfig.TestOmReconfiguration {
@Override
public MiniOzoneCluster cluster() {
return getCluster();
}
}

@Nested
class ScmReconfiguration extends org.apache.hadoop.ozone.reconfig.TestScmReconfiguration {
@Override
public MiniOzoneCluster cluster() {
return getCluster();
}
}

}
Loading