Skip to content

Commit

Permalink
remove all OZONE_SCM_HA_ENABLE_KEY from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chungen0126 committed Jan 7, 2025
1 parent 5da0c9c commit caaa0a7
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.ozone.test.GenericTestUtils;
import org.apache.ozone.test.tag.Unhealthy;
import org.apache.ratis.conf.RaftProperties;
import org.apache.ratis.protocol.RaftGroupId;
import org.apache.ratis.server.RaftServerConfigKeys;
Expand Down Expand Up @@ -162,7 +161,6 @@
* Test class that exercises the StorageContainerManager.
*/
@Timeout(900)
@Unhealthy("HDDS-12022")
public class TestStorageContainerManager {
private static final String LOCALHOST_IP = "127.0.0.1";
private static XceiverClientManager xceiverClientManager;
Expand Down Expand Up @@ -190,13 +188,11 @@ public void cleanupDefaults() {
public void testRpcPermission() throws Exception {
// Test with default configuration
OzoneConfiguration defaultConf = new OzoneConfiguration();
defaultConf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
testRpcPermissionWithConf(defaultConf, any -> false, "unknownUser");

// Test with ozone.administrators defined in configuration
String admins = "adminUser1, adminUser2";
OzoneConfiguration ozoneConf = new OzoneConfiguration();
ozoneConf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
ozoneConf.setStrings(OzoneConfigKeys.OZONE_ADMINISTRATORS, admins);
// Non-admin user will get permission denied.
// Admin user will pass the permission check.
Expand Down Expand Up @@ -268,7 +264,6 @@ private void verifyPermissionDeniedException(Exception e, String userName) {
public void testBlockDeletionTransactions() throws Exception {
int numKeys = 5;
OzoneConfiguration conf = new OzoneConfiguration();
conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
conf.setTimeDuration(OZONE_BLOCK_DELETING_SERVICE_INTERVAL, 100,
TimeUnit.MILLISECONDS);
DatanodeConfiguration datanodeConfiguration = conf.getObject(
Expand Down Expand Up @@ -360,7 +355,6 @@ public void testBlockDeletionTransactions() throws Exception {
@Test
public void testOldDNRegistersToReInitialisedSCM() throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
conf.setTimeDuration(HDDS_HEARTBEAT_INTERVAL, 1000, TimeUnit.MILLISECONDS);
conf.setTimeDuration(ScmConfigKeys.OZONE_SCM_HEARTBEAT_PROCESS_INTERVAL, 3000, TimeUnit.MILLISECONDS);

Expand Down Expand Up @@ -407,46 +401,50 @@ public void testOldDNRegistersToReInitialisedSCM() throws Exception {
assertThat(scmDnHBDispatcherLog.getOutput()).isEmpty();
assertThat(versionEndPointTaskLog.getOutput()).isEmpty();
// start the new SCM
scm.start();
// Initially DatanodeStateMachine will be in Running state
assertEquals(DatanodeStateMachine.DatanodeStates.RUNNING,
dsm.getContext().getState());
// DN heartbeats to new SCM, SCM doesn't recognize the node, sends the
// command to DN to re-register. Wait for SCM to send re-register command
String expectedLog = String.format(
"SCM received heartbeat from an unregistered datanode %s. "
+ "Asking datanode to re-register.",
datanode.getDatanodeDetails());
GenericTestUtils.waitFor(
() -> scmDnHBDispatcherLog.getOutput().contains(expectedLog), 100,
30000);
ExitUtil.disableSystemExit();
// As part of processing response for re-register, DN EndpointStateMachine
// goes to GET-VERSION state which checks if there is already existing
// version file on the DN & if the clusterID matches with that of the SCM
// In this case, it won't match and gets InconsistentStorageStateException
// and DN shuts down.
String expectedLog2 = "Received SCM notification to register."
+ " Interrupt HEARTBEAT and transit to GETVERSION state.";
GenericTestUtils.waitFor(
() -> heartbeatEndpointTaskLog.getOutput().contains(expectedLog2),
100, 5000);
GenericTestUtils.waitFor(() -> dsm.getContext().getShutdownOnError(), 100,
5000);
assertEquals(DatanodeStateMachine.DatanodeStates.SHUTDOWN,
dsm.getContext().getState());
assertThat(versionEndPointTaskLog.getOutput()).contains(
"org.apache.hadoop.ozone.common" +
".InconsistentStorageStateException: Mismatched ClusterIDs");
scm.stop();
try {
scm.start();
// Initially DatanodeStateMachine will be in Running state
assertEquals(DatanodeStateMachine.DatanodeStates.RUNNING,
dsm.getContext().getState());
// DN heartbeats to new SCM, SCM doesn't recognize the node, sends the
// command to DN to re-register. Wait for SCM to send re-register command
String expectedLog = String.format(
"SCM received heartbeat from an unregistered datanode %s. "
+ "Asking datanode to re-register.",
datanode.getDatanodeDetails());
GenericTestUtils.waitFor(
() -> scmDnHBDispatcherLog.getOutput().contains(expectedLog), 100,
30000);
ExitUtil.disableSystemExit();
// As part of processing response for re-register, DN EndpointStateMachine
// goes to GET-VERSION state which checks if there is already existing
// version file on the DN & if the clusterID matches with that of the SCM
// In this case, it won't match and gets InconsistentStorageStateException
// and DN shuts down.
String expectedLog2 = "Received SCM notification to register."
+ " Interrupt HEARTBEAT and transit to GETVERSION state.";
GenericTestUtils.waitFor(
() -> heartbeatEndpointTaskLog.getOutput().contains(expectedLog2),
100, 5000);
GenericTestUtils.waitFor(() -> dsm.getContext().getShutdownOnError(), 100,
5000);
assertEquals(DatanodeStateMachine.DatanodeStates.SHUTDOWN,
dsm.getContext().getState());
assertThat(versionEndPointTaskLog.getOutput()).contains(
"org.apache.hadoop.ozone.common" +
".InconsistentStorageStateException: Mismatched ClusterIDs");
} finally {
if (scm != null) {
scm.stop();
}
}
}
}

@Test
public void testBlockDeletingThrottling() throws Exception {
int numKeys = 15;
OzoneConfiguration conf = new OzoneConfiguration();
conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
conf.setTimeDuration(HDDS_CONTAINER_REPORT_INTERVAL, 1, TimeUnit.SECONDS);
conf.setInt(ScmConfigKeys.OZONE_SCM_BLOCK_DELETION_MAX_RETRY, 5);
conf.setTimeDuration(OZONE_BLOCK_DELETING_SERVICE_INTERVAL,
Expand Down Expand Up @@ -557,7 +555,6 @@ private Map<Long, List<Long>> createDeleteTXLog(
@Test
public void testSCMInitialization(@TempDir Path tempDir) throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
Path scmPath = tempDir.resolve("scm-meta");
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());

Expand All @@ -579,7 +576,6 @@ public void testSCMInitialization(@TempDir Path tempDir) throws Exception {
@Test
public void testSCMReinitialization(@TempDir Path tempDir) throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
Path scmPath = tempDir.resolve("scm-meta");
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
//This will set the cluster id in the version file
Expand Down Expand Up @@ -641,7 +637,6 @@ public static void validateRatisGroupExists(OzoneConfiguration conf,
@Test
void testSCMInitializationFailure(@TempDir Path tempDir) {
OzoneConfiguration conf = new OzoneConfiguration();
conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
Path scmPath = tempDir.resolve("scm-meta");
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());

Expand All @@ -654,7 +649,6 @@ public void testScmInfo(@TempDir Path tempDir) throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
Path scmPath = tempDir.resolve("scm-meta");

conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
SCMStorageConfig scmStore = new SCMStorageConfig(conf);
String clusterId = UUID.randomUUID().toString();
Expand All @@ -668,15 +662,21 @@ public void testScmInfo(@TempDir Path tempDir) throws Exception {
SCMHANodeDetails.loadSCMHAConfig(conf, scmStore)
.getLocalNodeDetails(), conf);
StorageContainerManager scm = HddsTestUtils.getScmSimple(conf);
scm.start();
//Reads the SCM Info from SCM instance
ScmInfo scmInfo = scm.getClientProtocolServer().getScmInfo();
assertEquals(clusterId, scmInfo.getClusterId());
assertEquals(scmId, scmInfo.getScmId());

String expectedVersion = HddsVersionInfo.HDDS_VERSION_INFO.getVersion();
String actualVersion = scm.getSoftwareVersion();
assertEquals(expectedVersion, actualVersion);
try {
scm.start();
//Reads the SCM Info from SCM instance
ScmInfo scmInfo = scm.getClientProtocolServer().getScmInfo();
assertEquals(clusterId, scmInfo.getClusterId());
assertEquals(scmId, scmInfo.getScmId());

String expectedVersion = HddsVersionInfo.HDDS_VERSION_INFO.getVersion();
String actualVersion = scm.getSoftwareVersion();
assertEquals(expectedVersion, actualVersion);
} finally {
if (scmStore != null) {
scm.stop();
}
}
}

/**
Expand All @@ -686,7 +686,6 @@ public void testScmInfo(@TempDir Path tempDir) throws Exception {
public void testScmProcessDatanodeHeartbeat() throws Exception {
String rackName = "/rack1";
OzoneConfiguration conf = new OzoneConfiguration();
conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
conf.setClass(NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
StaticMapping.class, DNSToSwitchMapping.class);
StaticMapping.addNodeToRack(NetUtils.normalizeHostName(HddsUtils.getHostName(conf)),
Expand Down Expand Up @@ -729,7 +728,6 @@ public void testScmProcessDatanodeHeartbeat() throws Exception {
public void testCloseContainerCommandOnRestart() throws Exception {
int numKeys = 15;
OzoneConfiguration conf = new OzoneConfiguration();
conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
conf.setTimeDuration(HDDS_CONTAINER_REPORT_INTERVAL, 1, TimeUnit.SECONDS);
conf.setInt(ScmConfigKeys.OZONE_SCM_BLOCK_DELETION_MAX_RETRY, 5);
conf.setTimeDuration(OZONE_BLOCK_DELETING_SERVICE_INTERVAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
import org.apache.ozone.test.GenericTestUtils;
import org.apache.ozone.test.tag.Unhealthy;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
Expand Down Expand Up @@ -127,7 +126,6 @@
/**
* This class tests container commands on EC containers.
*/
@Unhealthy("HDDS-12023")
public class TestContainerCommandsEC {

private static final String ANY_USER = "any";
Expand Down Expand Up @@ -173,7 +171,6 @@ public class TestContainerCommandsEC {
@BeforeAll
public static void init() throws Exception {
config = new OzoneConfiguration();
config.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
config.setInt(ScmConfigKeys.OZONE_SCM_PIPELINE_OWNER_CONTAINER_COUNT, 1);
config.setTimeDuration(ScmConfigKeys.OZONE_SCM_STALENODE_INTERVAL, 3, TimeUnit.SECONDS);
config.setBoolean(OzoneConfigKeys.OZONE_ACL_ENABLED, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ void init() {
conf.setInt(OZONE_SCM_GRPC_PORT_KEY, getFreePort());
conf.set(OZONE_OM_ADDRESS_KEY,
InetAddress.getLocalHost().getCanonicalHostName() + ":" + getFreePort());
conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, false);

DefaultMetricsSystem.setMiniClusterMode(true);
ExitUtils.disableSystemExit();
Expand Down Expand Up @@ -353,10 +352,17 @@ void testSecureScmStartupSuccess() throws Exception {
initSCM();
scm = HddsTestUtils.getScmSimple(conf);
//Reads the SCM Info from SCM instance
ScmInfo scmInfo = scm.getClientProtocolServer().getScmInfo();
assertEquals(clusterId, scmInfo.getClusterId());
assertEquals(scmId, scmInfo.getScmId());
assertEquals(2, scm.getScmCertificateClient().getTrustChain().size());
try {
scm.start();
ScmInfo scmInfo = scm.getClientProtocolServer().getScmInfo();
assertEquals(clusterId, scmInfo.getClusterId());
assertEquals(scmId, scmInfo.getScmId());
assertEquals(2, scm.getScmCertificateClient().getTrustChain().size());
} finally {
if (scm != null) {
scm.stop();
}
}
}

@Test
Expand Down Expand Up @@ -444,28 +450,6 @@ void testAdminAccessControlException() throws Exception {
}
}

@Test
void testSecretManagerInitializedNonHASCM() throws Exception {
conf.setBoolean(HDDS_BLOCK_TOKEN_ENABLED, true);
initSCM();
scm = HddsTestUtils.getScmSimple(conf);
//Reads the SCM Info from SCM instance
try {
scm.start();

SecretKeyManager secretKeyManager = scm.getSecretKeyManager();
boolean inSafeMode = scm.getScmSafeModeManager().getInSafeMode();
assertFalse(SCMHAUtils.isSCMHAEnabled(conf));
assertTrue(inSafeMode);
assertNotNull(secretKeyManager);
assertTrue(secretKeyManager.isInitialized());
} finally {
if (scm != null) {
scm.stop();
}
}
}

private void initSCM() throws IOException {
Path scmPath = new File(tempDir, "scm-meta").toPath();
Files.createDirectories(scmPath);
Expand All @@ -474,6 +458,7 @@ private void initSCM() throws IOException {
SCMStorageConfig scmStore = new SCMStorageConfig(conf);
scmStore.setClusterId(clusterId);
scmStore.setScmId(scmId);
scmStore.setSCMHAFlag(true);
HASecurityUtils.initializeSecurity(scmStore, conf,
InetAddress.getLocalHost().getHostName(), true);
scmStore.setPrimaryScmNodeId(scmId);
Expand Down

0 comments on commit caaa0a7

Please sign in to comment.