This is an automated email from the ASF dual-hosted git repository.
Gargi-jais11 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 fd2f6092c6d HDDS-16941. Add unit tests for OzoneManagerStarter
bootstrap CLI (#11520).
fd2f6092c6d is described below
commit fd2f6092c6d753e5e3a2600974f4efa8ad729fe4
Author: Aayush Gupta <[email protected]>
AuthorDate: Wed Oct 14 16:32:46 2026 +0530
HDDS-16941. Add unit tests for OzoneManagerStarter bootstrap CLI (#11520).
---
.../hadoop/ozone/om/TestOzoneManagerStarter.java | 35 +++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerStarter.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerStarter.java
index 381e0de11b1..a294546ce47 100644
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerStarter.java
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerStarter.java
@@ -117,6 +117,32 @@ public void testUsagePrintedOnInvalidInput()
assertTrue(m.find());
}
+ @Test
+ public void testPassingBootstrapSwitchCallsBootstrap() {
+ assertEquals(OK, executeCommand("--bootstrap"));
+ assertTrue(mock.bootstrapCalled);
+ assertFalse(mock.bootstrapForce);
+ }
+
+ @Test
+ public void testBootstrapForceOptionPassedToReceiver() {
+ assertEquals(OK, executeCommand("--bootstrap", "--force"));
+ assertTrue(mock.bootstrapCalled);
+ assertTrue(mock.bootstrapForce);
+ }
+
+ @Test
+ public void testBootstrapSwitchWithInvalidParamDoesNotRun() {
+ assertEquals(USAGE, executeCommand("--bootstrap", "--invalid"));
+ assertFalse(mock.bootstrapCalled);
+ }
+
+ @Test
+ public void testUnSuccessfulBootstrapThrowsException() {
+ mock.throwOnBootstrap = true;
+ assertEquals(EXECUTION_ERROR_EXIT_CODE, executeCommand("--bootstrap"));
+ }
+
private int executeCommand(String... args) {
return new OzoneManagerStarter(mock).execute(args);
}
@@ -128,6 +154,9 @@ static class MockOMStarter implements OMStarterInterface {
private boolean initStatus = true;
private boolean throwOnStart = false;
private boolean throwOnInit = false;
+ private boolean bootstrapCalled = false;
+ private boolean bootstrapForce = false;
+ private boolean throwOnBootstrap = false;
@Override
public void start(OzoneConfiguration conf) throws IOException,
@@ -151,7 +180,11 @@ public boolean init(OzoneConfiguration conf) throws
IOException,
@Override
public void bootstrap(OzoneConfiguration conf, boolean force)
throws IOException, AuthenticationException {
- //TODO: Add test for bootstrap
+ bootstrapCalled = true;
+ bootstrapForce = force;
+ if (throwOnBootstrap) {
+ throw new IOException("Simulated Exception");
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]