ArafatKhan2198 commented on code in PR #6742:
URL: https://github.com/apache/ozone/pull/6742#discussion_r1618712340
##########
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/scm/TestReconPipelineManager.java:
##########
@@ -208,6 +208,40 @@ public void testAddPipeline() throws IOException,
TimeoutException {
assertTrue(reconPipelineManager.containsPipeline(pipeline.getId()));
}
+ @Test
+ public void testDuplicatePipelineHandling() throws IOException {
+ Pipeline pipeline = getRandomPipeline();
+ NetworkTopology clusterMap = new NetworkTopologyImpl(conf);
+ EventQueue eventQueue = new EventQueue();
+ this.versionManager = mock(HDDSLayoutVersionManager.class);
+ when(versionManager.getMetadataLayoutVersion()).thenReturn(
+ maxLayoutVersion());
+ when(versionManager.getSoftwareLayoutVersion()).thenReturn(
+ maxLayoutVersion());
+ NodeManager nodeManager =
+ new SCMNodeManager(conf, scmStorageConfig, eventQueue, clusterMap,
+ SCMContext.emptyContext(), versionManager);
+
+ ReconPipelineManager reconPipelineManager =
+ ReconPipelineManager.newReconPipelineManager(conf, nodeManager,
+ ReconSCMDBDefinition.PIPELINES.getTable(store), eventQueue,
+ scmhaManager, scmContext);
+
+ try {
+ reconPipelineManager.addPipeline(pipeline);
+ reconPipelineManager.addPipeline(
+ pipeline); // Adding the same pipeline again to check for duplicates
+ } catch (Exception e) {
+ // Fail the test if an exception is thrown
+ assertTrue(false,
+ "Exception was thrown when adding a duplicate pipeline: " +
+ e.getMessage());
+ }
+
+ // If no exception was thrown, the test is successful
+ assertTrue(true);
Review Comment:
Yes you are right, this will work as well!
Thanks for the optimisation @dombizita
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]