This is an automated email from the ASF dual-hosted git repository.
chihsuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 64d4a791502 HDDS-17181. Speed up TestSCMBlockProtocolServer (#11640)
64d4a791502 is described below
commit 64d4a7915028930d28e6fc2e8cc04d2e4bfbbe20
Author: Shuo Huang <[email protected]>
AuthorDate: Wed Oct 21 21:17:44 2026 +0800
HDDS-17181. Speed up TestSCMBlockProtocolServer (#11640)
---
.../scm/server/TestSCMBlockProtocolServer.java | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestSCMBlockProtocolServer.java
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestSCMBlockProtocolServer.java
index be547f1ff76..32ab3abaab2 100644
---
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestSCMBlockProtocolServer.java
+++
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestSCMBlockProtocolServer.java
@@ -95,15 +95,17 @@
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.ozone.test.GenericTestUtils.LogCapturer;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
+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.io.TempDir;
import org.mockito.MockedStatic;
/**
* Test class for @{@link SCMBlockProtocolServer}.
*/
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class TestSCMBlockProtocolServer {
private OzoneConfiguration config;
private SCMBlockProtocolServer server;
@@ -186,7 +188,7 @@ public void close() throws IOException {
}
}
- @BeforeEach
+ @BeforeAll
void setUp(@TempDir File dir) throws Exception {
config = SCMTestUtils.getConf(dir);
config.set(SCMBlockProtocolServer.OM_KERBEROS_PRINCIPAL_KEY,
"om/[email protected]");
@@ -219,7 +221,7 @@ void setUp(@TempDir File dir) throws Exception {
service = new ScmBlockLocationProtocolServerSideTranslatorPB(server, scm,
mock(ProtocolMessageMetrics.class));
}
- @AfterEach
+ @AfterAll
public void tearDown() throws Exception {
if (scm != null) {
scm.stop();
@@ -589,11 +591,15 @@ public void testQueryUpgradeStatusHddsInProgress() throws
Exception {
public void testQueryUpgradeStatusInSafemode() {
// Put SCM into safe mode via the context the server consults.
scm.getScmContext().updateSafeModeStatus(SafeModeStatus.INITIAL);
- assertTrue(scm.getScmContext().isInSafeMode());
+ try {
+ assertTrue(scm.getScmContext().isInSafeMode());
- // Querying upgrade status is blocked while SCM is in safe mode.
- SCMException ex = assertThrows(SCMException.class, () ->
server.queryUpgradeStatus());
- assertEquals(SCMException.ResultCodes.SAFE_MODE_EXCEPTION, ex.getResult());
+ // Querying upgrade status is blocked while SCM is in safe mode.
+ SCMException ex = assertThrows(SCMException.class, () ->
server.queryUpgradeStatus());
+ assertEquals(SCMException.ResultCodes.SAFE_MODE_EXCEPTION,
ex.getResult());
+ } finally {
+
scm.getScmContext().updateSafeModeStatus(SafeModeStatus.OUT_OF_SAFE_MODE);
+ }
}
private SCMBlockProtocolServer buildTestServer(
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]