Skip to content

Commit 43bb7db

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
feature/CSTACKEX-213: update UT for attachZone
1 parent e712667 commit 43bb7db

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycleTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ public void testAttachZone_positive() throws Exception {
612612
when(_resourceMgr.getEligibleUpAndEnabledHostsInZoneForStorageConnection(any(), eq(1L), eq(Hypervisor.HypervisorType.KVM)))
613613
.thenReturn(mockHosts);
614614
when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
615-
when(_dataStoreHelper.attachZone(any(DataStore.class))).thenReturn(dataStore);
615+
when(_dataStoreHelper.attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM))).thenReturn(dataStore);
616616

617617
try (MockedStatic<OntapStorageUtils> utilityMock = Mockito.mockStatic(OntapStorageUtils.class)) {
618618
utilityMock.when(() -> OntapStorageUtils.getStrategyByStoragePoolDetails(any()))
@@ -633,7 +633,7 @@ public void testAttachZone_positive() throws Exception {
633633
verify(storagePoolDetailsDao, times(1)).listDetailsKeyPairs(1L);
634634
verify(storageStrategy, times(1)).createAccessGroup(any(AccessGroup.class));
635635
verify(_storageMgr, times(2)).connectHostToSharedPool(any(HostVO.class), eq(1L));
636-
verify(_dataStoreHelper, times(1)).attachZone(any(DataStore.class));
636+
verify(_dataStoreHelper, times(1)).attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM));
637637
}
638638
}
639639

@@ -647,7 +647,7 @@ public void testAttachZone_withSingleHost() throws Exception {
647647
when(_resourceMgr.getEligibleUpAndEnabledHostsInZoneForStorageConnection(any(), eq(1L), eq(Hypervisor.HypervisorType.KVM)))
648648
.thenReturn(singleHost);
649649
when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
650-
when(_dataStoreHelper.attachZone(any(DataStore.class))).thenReturn(dataStore);
650+
when(_dataStoreHelper.attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM))).thenReturn(dataStore);
651651

652652
try (MockedStatic<OntapStorageUtils> utilityMock = Mockito.mockStatic(OntapStorageUtils.class)) {
653653
utilityMock.when(() -> OntapStorageUtils.getStrategyByStoragePoolDetails(any()))
@@ -662,7 +662,7 @@ public void testAttachZone_withSingleHost() throws Exception {
662662
// Verify
663663
assertTrue(result, "attachZone should return true with single host");
664664
verify(_storageMgr, times(1)).connectHostToSharedPool(any(HostVO.class), eq(1L));
665-
verify(_dataStoreHelper, times(1)).attachZone(any(DataStore.class));
665+
verify(_dataStoreHelper, times(1)).attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM));
666666
}
667667
}
668668

@@ -679,7 +679,7 @@ public void testAttachZone_withMultipleHosts() throws Exception {
679679
when(_resourceMgr.getEligibleUpAndEnabledHostsInZoneForStorageConnection(any(), eq(1L), eq(Hypervisor.HypervisorType.KVM)))
680680
.thenReturn(mockHosts);
681681
when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
682-
when(_dataStoreHelper.attachZone(any(DataStore.class))).thenReturn(dataStore);
682+
when(_dataStoreHelper.attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM))).thenReturn(dataStore);
683683

684684
try (MockedStatic<OntapStorageUtils> utilityMock = Mockito.mockStatic(OntapStorageUtils.class)) {
685685
utilityMock.when(() -> OntapStorageUtils.getStrategyByStoragePoolDetails(any()))
@@ -694,7 +694,7 @@ public void testAttachZone_withMultipleHosts() throws Exception {
694694
// Verify
695695
assertTrue(result, "attachZone should return true with multiple hosts");
696696
verify(_storageMgr, times(3)).connectHostToSharedPool(any(HostVO.class), eq(1L));
697-
verify(_dataStoreHelper, times(1)).attachZone(any(DataStore.class));
697+
verify(_dataStoreHelper, times(1)).attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM));
698698
}
699699
}
700700

@@ -724,7 +724,7 @@ public void testAttachZone_hostConnectionFailure() throws Exception {
724724
verify(storageStrategy, times(1)).createAccessGroup(any(AccessGroup.class));
725725
verify(_storageMgr, times(1)).connectHostToSharedPool(any(HostVO.class), eq(1L));
726726
// _dataStoreHelper.attachZone should NOT be called due to early return
727-
verify(_dataStoreHelper, times(0)).attachZone(any(DataStore.class));
727+
verify(_dataStoreHelper, times(0)).attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM));
728728
}
729729
}
730730

@@ -737,7 +737,7 @@ public void testAttachZone_emptyHostList() throws Exception {
737737
when(_resourceMgr.getEligibleUpAndEnabledHostsInZoneForStorageConnection(any(), eq(1L), eq(Hypervisor.HypervisorType.KVM)))
738738
.thenReturn(emptyHosts);
739739
when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
740-
when(_dataStoreHelper.attachZone(any(DataStore.class))).thenReturn(dataStore);
740+
when(_dataStoreHelper.attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM))).thenReturn(dataStore);
741741

742742
try (MockedStatic<OntapStorageUtils> utilityMock = Mockito.mockStatic(OntapStorageUtils.class)) {
743743
utilityMock.when(() -> OntapStorageUtils.getStrategyByStoragePoolDetails(any()))
@@ -751,7 +751,7 @@ public void testAttachZone_emptyHostList() throws Exception {
751751
// Verify
752752
assertTrue(result, "attachZone should return true even with no hosts");
753753
verify(_storageMgr, times(0)).connectHostToSharedPool(any(HostVO.class), anyLong());
754-
verify(_dataStoreHelper, times(1)).attachZone(any(DataStore.class));
754+
verify(_dataStoreHelper, times(1)).attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM));
755755
}
756756
}
757757

@@ -780,7 +780,7 @@ public void testAttachZone_secondHostConnectionFails() throws Exception {
780780
// Verify
781781
assertFalse(result, "attachZone should return false when any host connection fails");
782782
verify(_storageMgr, times(2)).connectHostToSharedPool(any(HostVO.class), eq(1L));
783-
verify(_dataStoreHelper, times(0)).attachZone(any(DataStore.class));
783+
verify(_dataStoreHelper, times(0)).attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM));
784784
}
785785
}
786786

@@ -791,7 +791,7 @@ public void testAttachZone_createAccessGroupCalled() throws Exception {
791791
when(_resourceMgr.getEligibleUpAndEnabledHostsInZoneForStorageConnection(any(), eq(1L), eq(Hypervisor.HypervisorType.KVM)))
792792
.thenReturn(mockHosts);
793793
when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
794-
when(_dataStoreHelper.attachZone(any(DataStore.class))).thenReturn(dataStore);
794+
when(_dataStoreHelper.attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM))).thenReturn(dataStore);
795795

796796
try (MockedStatic<OntapStorageUtils> utilityMock = Mockito.mockStatic(OntapStorageUtils.class)) {
797797
utilityMock.when(() -> OntapStorageUtils.getStrategyByStoragePoolDetails(any()))
@@ -838,7 +838,7 @@ public void testAttachZone_kvmHypervisorSetsAndUpdatesPool() throws Exception {
838838
when(_resourceMgr.getEligibleUpAndEnabledHostsInZoneForStorageConnection(any(), eq(1L), eq(Hypervisor.HypervisorType.KVM)))
839839
.thenReturn(mockHosts);
840840
when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
841-
when(_dataStoreHelper.attachZone(any(DataStore.class))).thenReturn(dataStore);
841+
when(_dataStoreHelper.attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM))).thenReturn(dataStore);
842842

843843
try (MockedStatic<OntapStorageUtils> utilityMock = Mockito.mockStatic(OntapStorageUtils.class)) {
844844
utilityMock.when(() -> OntapStorageUtils.getStrategyByStoragePoolDetails(any()))
@@ -850,7 +850,7 @@ public void testAttachZone_kvmHypervisorSetsAndUpdatesPool() throws Exception {
850850
dataStore, zoneScope, Hypervisor.HypervisorType.KVM);
851851

852852
assertTrue(result, "attachZone should succeed for KVM hypervisor");
853-
verify(storagePoolDao, times(1)).update(eq(1L), any(StoragePoolVO.class));
853+
verify(_dataStoreHelper, times(1)).attachZone(any(DataStore.class), eq(Hypervisor.HypervisorType.KVM));
854854
}
855855
}
856856

0 commit comments

Comments
 (0)