Skip to content

Commit

Permalink
server: fix duplicated records for templates if there are multiple zones
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhouapache committed Apr 17, 2024
1 parent 8511014 commit 070fcf0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ protected void createTemplateWithinZones(TemplateProfile profile, VMTemplateVO t
zonesIds = _dcDao.listAllZones().stream().map(DataCenterVO::getId).collect(Collectors.toList());
}

List<DataStore> imageStores = getImageStoresThrowsExceptionIfNotFound(zonesIds, profile);

for (long zoneId : zonesIds) {
DataStore imageStore = verifyHeuristicRulesForZone(template, zoneId);

if (imageStore == null) {
List<DataStore> imageStores = getImageStoresThrowsExceptionIfNotFound(List.of(zoneId), profile);
standardImageStoreAllocation(imageStores, template);
} else {
validateSecondaryStorageAndCreateTemplate(List.of(imageStore), template, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ public void createTemplateWithinZonesTestZoneIdsNullShouldCallListAllZones() {
VMTemplateVO vmTemplateVOMock = Mockito.mock(VMTemplateVO.class);

Mockito.when(templateProfileMock.getZoneIdList()).thenReturn(null);
Mockito.doReturn(null).when(_adapter).getImageStoresThrowsExceptionIfNotFound(Mockito.any(List.class), Mockito.any(TemplateProfile.class));

_adapter.createTemplateWithinZones(templateProfileMock, vmTemplateVOMock);

Expand Down Expand Up @@ -370,7 +369,6 @@ public void createTemplateWithinZonesTestZoneWithHeuristicRuleShouldCallValidate
List<Long> zoneIds = List.of(1L);

Mockito.when(templateProfileMock.getZoneIdList()).thenReturn(zoneIds);
Mockito.doReturn(null).when(_adapter).getImageStoresThrowsExceptionIfNotFound(Mockito.any(List.class), Mockito.any(TemplateProfile.class));
Mockito.doReturn(dataStoreMock).when(_adapter).verifyHeuristicRulesForZone(Mockito.any(VMTemplateVO.class), Mockito.anyLong());
Mockito.doNothing().when(_adapter).validateSecondaryStorageAndCreateTemplate(Mockito.any(List.class), Mockito.any(VMTemplateVO.class), Mockito.isNull());

Expand Down

0 comments on commit 070fcf0

Please sign in to comment.