Skip to content
Draft
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 @@ -233,6 +233,31 @@ public OzoneConfiguration getTestOzoneConfiguration(
return configuration;
}

/**
* Closes all resources created by this injector.
* This should be called in test tearDown methods to ensure proper cleanup.
*
* @throws Exception if any resource fails to close
*/
public void close() throws Exception {
// Close ReconDBProvider if it was created
if (withContainerDB && injector != null) {
try {
ReconDBProvider reconDBProvider =
injector.getInstance(ReconDBProvider.class);
if (reconDBProvider != null) {
reconDBProvider.close();
}
} catch (Exception e) {
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case of exception here we should fail the test.

}

// Close OzoneStorageContainerManager if it was created
if (reconScm != null) {
reconScm.stop();
}
}

/**
* Builder for Recon Test Injector.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public class TestOmDBInsightEndPoint extends AbstractReconSqlDBTest {
private ReconOMMetadataManager reconOMMetadataManager;
private ReconNamespaceSummaryManager reconNamespaceSummaryManager;
private OMDBInsightEndpoint omdbInsightEndpoint;
private ReconTestInjector reconTestInjector;
private Pipeline pipeline;
private Random random = new Random();
private OzoneConfiguration ozoneConfiguration;
Expand Down Expand Up @@ -297,7 +298,7 @@ public void setUp() throws Exception {
reconOMMetadataManager = getTestReconOmMetadataManager(omMetadataManager,
Files.createDirectory(temporaryFolder.resolve(
"JunitOmMetadataTest")).toFile());
ReconTestInjector reconTestInjector =
reconTestInjector =
new ReconTestInjector.Builder(temporaryFolder.toFile())
.withReconSqlDb()
.withReconOm(reconOMMetadataManager)
Expand Down Expand Up @@ -350,6 +351,9 @@ public void tearDown() throws Exception {
if (reconOMMetadataManager != null) {
reconOMMetadataManager.stop();
}
if (reconTestInjector != null) {
reconTestInjector.close();
}
}

@SuppressWarnings("methodlength")
Expand Down