You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2022/12/30 10:33:43 UTC
[cloudstack] branch main updated: engine/orchestration: enable unit tests and fix errors (#7034)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push:
new 0bedb58fbe1 engine/orchestration: enable unit tests and fix errors (#7034)
0bedb58fbe1 is described below
commit 0bedb58fbe162f57a48c9f087b12c8eabbebf1d8
Author: Wei Zhou <we...@apache.org>
AuthorDate: Fri Dec 30 11:33:36 2022 +0100
engine/orchestration: enable unit tests and fix errors (#7034)
The unit tests in engine/orchestration module are skipped for now.
This PR enables the unit tests and fixes the errors with the unit tests.
---
engine/orchestration/pom.xml | 3 -
.../cloud/vm/VirtualMachineManagerImplTest.java | 96 +++++++++++++---------
.../engine/provisioning/test/ProvisioningTest.java | 63 +++++++-------
.../src/test/resources/provisioningContext.xml | 47 -----------
4 files changed, 93 insertions(+), 116 deletions(-)
diff --git a/engine/orchestration/pom.xml b/engine/orchestration/pom.xml
index 53c081492df..52e6b62cd04 100755
--- a/engine/orchestration/pom.xml
+++ b/engine/orchestration/pom.xml
@@ -73,9 +73,6 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
<executions>
<execution>
<phase>integration-test</phase>
diff --git a/engine/orchestration/src/test/java/com/cloud/vm/VirtualMachineManagerImplTest.java b/engine/orchestration/src/test/java/com/cloud/vm/VirtualMachineManagerImplTest.java
index 87b5b5c0c6f..57f96e4f9de 100644
--- a/engine/orchestration/src/test/java/com/cloud/vm/VirtualMachineManagerImplTest.java
+++ b/engine/orchestration/src/test/java/com/cloud/vm/VirtualMachineManagerImplTest.java
@@ -26,16 +26,13 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import com.cloud.agent.api.routing.NetworkElementCommand;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.storage.StorageManager;
-import com.cloud.host.Host;
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
@@ -55,16 +52,22 @@ import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.StopAnswer;
import com.cloud.agent.api.StopCommand;
+import com.cloud.agent.api.routing.NetworkElementCommand;
+import com.cloud.api.query.dao.UserVmJoinDao;
import com.cloud.deploy.DataCenterDeployment;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.deploy.DeploymentPlanner;
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.host.Host;
import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.ScopeType;
+import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolHostVO;
import com.cloud.storage.Volume;
@@ -74,6 +77,7 @@ import com.cloud.storage.dao.StoragePoolHostDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.VirtualMachine.State;
+import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.VMInstanceDao;
@RunWith(MockitoJUnitRunner.class)
@@ -103,6 +107,8 @@ public class VirtualMachineManagerImplTest {
private DiskOfferingVO diskOfferingMock;
private long hostMockId = 1L;
+ private long clusterMockId = 2L;
+ private long zoneMockId = 3L;
@Mock
private HostVO hostMock;
@Mock
@@ -128,22 +134,34 @@ public class VirtualMachineManagerImplTest {
@Mock
private DiskOfferingDao diskOfferingDaoMock;
+ @Mock
+ private HostDao hostDaoMock;
+ @Mock
+ private UserVmJoinDao userVmJoinDaoMock;
+ @Mock
+ private UserVmDao userVmDaoMock;
+ @Mock
+ private UserVmVO userVmMock;
+
@Before
public void setup() {
virtualMachineManagerImpl.setHostAllocators(new ArrayList<>());
when(vmInstanceMock.getId()).thenReturn(vmInstanceVoMockId);
when(vmInstanceMock.getServiceOfferingId()).thenReturn(2L);
- when(vmInstanceMock.getInstanceName()).thenReturn("myVm");
- when(vmInstanceMock.getHostId()).thenReturn(2L);
- when(vmInstanceMock.getType()).thenReturn(VirtualMachine.Type.User);
when(hostMock.getId()).thenReturn(hostMockId);
when(dataCenterDeploymentMock.getHostId()).thenReturn(hostMockId);
+ when(dataCenterDeploymentMock.getClusterId()).thenReturn(clusterMockId);
+
+ when(hostMock.getDataCenterId()).thenReturn(zoneMockId);
+ when(hostDaoMock.findById(any())).thenReturn(hostMock);
+
+ when(userVmJoinDaoMock.searchByIds(any())).thenReturn(new ArrayList<>());
+ when(userVmDaoMock.findById(any())).thenReturn(userVmMock);
Mockito.doReturn(vmInstanceVoMockId).when(virtualMachineProfileMock).getId();
Mockito.doReturn(storagePoolVoMockId).when(storagePoolVoMock).getId();
- Mockito.doReturn(storagePoolVoMockClusterId).when(storagePoolVoMock).getClusterId();
Mockito.doReturn(volumeMockId).when(volumeVoMock).getId();
Mockito.doReturn(storagePoolVoMockId).when(volumeVoMock).getPoolId();
@@ -191,7 +209,6 @@ public class VirtualMachineManagerImplTest {
when(testConfig.valueIn(dataCenterId)).thenReturn(false);
when(vmHost.getDataCenterId()).thenReturn(dataCenterId);
- when(vmHost.getPrivateIpAddress()).thenReturn(hostIp);
virtualMachineManagerImpl.addHostIpToCertDetailsIfConfigAllows(vmHost, ipAddresses, testConfig);
assertFalse(ipAddresses.containsKey(NetworkElementCommand.HYPERVISOR_HOST_PRIVATE_IP));
@@ -201,9 +218,6 @@ public class VirtualMachineManagerImplTest {
@Test(expected = CloudRuntimeException.class)
public void testScaleVM3() throws Exception {
- when(vmInstanceMock.getHostId()).thenReturn(null);
- when(vmInstanceDaoMock.findById(anyLong())).thenReturn(vmInstanceMock);
- when(vmInstanceDaoMock.findByUuid(any(String.class))).thenReturn(vmInstanceMock);
DeploymentPlanner.ExcludeList excludeHostList = new DeploymentPlanner.ExcludeList();
virtualMachineManagerImpl.findHostAndMigrate(vmInstanceMock.getUuid(), 2l, null, excludeHostList);
}
@@ -258,19 +272,26 @@ public class VirtualMachineManagerImplTest {
assertTrue(virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.KVM) == false);
assertTrue(virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.Ovm3) == VirtualMachineManager.ExecuteInSequence.value());
}
+
+ private void overrideDefaultConfigValue(final ConfigKey configKey, final String value) throws IllegalAccessException, NoSuchFieldException {
+ final Field f = ConfigKey.class.getDeclaredField("_defaultValue");
+ f.setAccessible(true);
+ f.set(configKey, value);
+ }
+
@Test
- public void testExeceuteInSequenceVmware() {
- when(StorageManager.getFullCloneConfiguration(anyLong())).thenReturn(Boolean.FALSE);
- when(StorageManager.getAllowParallelExecutionConfiguration()).thenReturn(Boolean.FALSE);
+ public void testExeceuteInSequenceVmware() throws IllegalAccessException, NoSuchFieldException {
+ overrideDefaultConfigValue(StorageManager.VmwareCreateCloneFull, "false");
+ overrideDefaultConfigValue(StorageManager.VmwareAllowParallelExecution, "false");
assertFalse("no full clones so no need to execute in sequence", virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware));
- when(StorageManager.getFullCloneConfiguration(anyLong())).thenReturn(Boolean.TRUE);
- when(StorageManager.getAllowParallelExecutionConfiguration()).thenReturn(Boolean.FALSE);
+ overrideDefaultConfigValue(StorageManager.VmwareCreateCloneFull, "true");
+ overrideDefaultConfigValue(StorageManager.VmwareAllowParallelExecution, "false");
assertTrue("full clones and no explicit parallel execution allowed, should execute in sequence", virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware));
- when(StorageManager.getFullCloneConfiguration(anyLong())).thenReturn(Boolean.TRUE);
- when(StorageManager.getAllowParallelExecutionConfiguration()).thenReturn(Boolean.TRUE);
+ overrideDefaultConfigValue(StorageManager.VmwareCreateCloneFull, "true");
+ overrideDefaultConfigValue(StorageManager.VmwareAllowParallelExecution, "true");
assertFalse("execute in sequence should not be needed as parallel is allowed", virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware));
- when(StorageManager.getFullCloneConfiguration(anyLong())).thenReturn(Boolean.FALSE);
- when(StorageManager.getAllowParallelExecutionConfiguration()).thenReturn(Boolean.TRUE);
+ overrideDefaultConfigValue(StorageManager.VmwareCreateCloneFull, "false");
+ overrideDefaultConfigValue(StorageManager.VmwareAllowParallelExecution, "true");
assertFalse("double reasons to allow parallel execution", virtualMachineManagerImpl.getExecuteInSequence(HypervisorType.VMware));
}
@@ -279,18 +300,20 @@ public class VirtualMachineManagerImplTest {
when(vmInstanceMock.getState()).thenReturn(State.Stopped);
when(serviceOfferingMock.isDynamic()).thenReturn(true);
when(vmInstanceMock.getServiceOfferingId()).thenReturn(1l);
- when(serviceOfferingMock.getId()).thenReturn(2l);
ServiceOfferingVO mockCurrentServiceOffering = mock(ServiceOfferingVO.class);
DiskOfferingVO mockCurrentDiskOffering = mock(DiskOfferingVO.class);
when(serviceOfferingDaoMock.findByIdIncludingRemoved(anyLong(), anyLong())).thenReturn(mockCurrentServiceOffering);
- when(mockCurrentDiskOffering.isUseLocalStorage()).thenReturn(true);
- when(diskOfferingMock.isUseLocalStorage()).thenReturn(true);
+ when(diskOfferingDaoMock.findByIdIncludingRemoved(anyLong())).thenReturn(mockCurrentDiskOffering);
+ when(diskOfferingDaoMock.findById(anyLong())).thenReturn(diskOfferingMock);
+ when(diskOfferingMock.isUseLocalStorage()).thenReturn(false);
when(mockCurrentServiceOffering.isSystemUse()).thenReturn(true);
when(serviceOfferingMock.isSystemUse()).thenReturn(true);
- when(mockCurrentDiskOffering.getTags()).thenReturn("x,y");
- when(diskOfferingMock.getTags()).thenReturn("z,x,y");
+ String[] oldDOStorageTags = {"x","y"};
+ String[] newDOStorageTags = {"z","x","y"};
+ when(mockCurrentDiskOffering.getTagsArray()).thenReturn(oldDOStorageTags);
+ when(diskOfferingMock.getTagsArray()).thenReturn(newDOStorageTags);
virtualMachineManagerImpl.checkIfCanUpgrade(vmInstanceMock, serviceOfferingMock);
}
@@ -317,8 +340,6 @@ public class VirtualMachineManagerImplTest {
@Test
public void isStorageCrossClusterMigrationTestStorageTypeEqualsZone() {
- Mockito.doReturn(1L).when(hostMock).getClusterId();
- Mockito.doReturn(2L).when(storagePoolVoMock).getClusterId();
Mockito.doReturn(ScopeType.ZONE).when(storagePoolVoMock).getScope();
boolean returnedValue = virtualMachineManagerImpl.isStorageCrossClusterMigration(1L, storagePoolVoMock);
@@ -470,7 +491,7 @@ public class VirtualMachineManagerImplTest {
Mockito.doReturn(poolListMock).when(storagePoolAllocatorMock).allocateToPool(Mockito.any(DiskProfile.class), Mockito.any(VirtualMachineProfile.class), Mockito.any(DeploymentPlan.class),
Mockito.any(ExcludeList.class), Mockito.eq(StoragePoolAllocator.RETURN_UPTO_ALL));
- Mockito.doReturn(true).when(virtualMachineManagerImpl).isStorageCrossClusterMigration(hostMockId, storagePoolVoMock);
+ Mockito.doReturn(true).when(virtualMachineManagerImpl).isStorageCrossClusterMigration(clusterMockId, storagePoolVoMock);
List<StoragePool> poolList = virtualMachineManagerImpl.getCandidateStoragePoolsToMigrateLocalVolume(virtualMachineProfileMock, dataCenterDeploymentMock, volumeVoMock);
assertEquals(1, poolList.size());
@@ -489,7 +510,7 @@ public class VirtualMachineManagerImplTest {
Mockito.doReturn(poolListMock).when(storagePoolAllocatorMock).allocateToPool(Mockito.any(DiskProfile.class), Mockito.any(VirtualMachineProfile.class), Mockito.any(DeploymentPlan.class),
Mockito.any(ExcludeList.class), Mockito.eq(StoragePoolAllocator.RETURN_UPTO_ALL));
- Mockito.doReturn(false).when(virtualMachineManagerImpl).isStorageCrossClusterMigration(hostMockId, storagePoolVoMock);
+ Mockito.doReturn(false).when(virtualMachineManagerImpl).isStorageCrossClusterMigration(clusterMockId, storagePoolVoMock);
List<StoragePool> poolList = virtualMachineManagerImpl.getCandidateStoragePoolsToMigrateLocalVolume(virtualMachineProfileMock, dataCenterDeploymentMock, volumeVoMock);
Assert.assertTrue(poolList.isEmpty());
@@ -523,7 +544,7 @@ public class VirtualMachineManagerImplTest {
Mockito.doReturn(new ArrayList<>()).when(storagePoolAllocatorMock3).allocateToPool(Mockito.any(DiskProfile.class), Mockito.any(VirtualMachineProfile.class), Mockito.any(DeploymentPlan.class),
Mockito.any(ExcludeList.class), Mockito.eq(StoragePoolAllocator.RETURN_UPTO_ALL));
- Mockito.doReturn(false).when(virtualMachineManagerImpl).isStorageCrossClusterMigration(hostMockId, storagePoolVoMock);
+ Mockito.doReturn(false).when(virtualMachineManagerImpl).isStorageCrossClusterMigration(clusterMockId, storagePoolVoMock);
List<StoragePool> poolList = virtualMachineManagerImpl.getCandidateStoragePoolsToMigrateLocalVolume(virtualMachineProfileMock, dataCenterDeploymentMock, volumeVoMock);
Assert.assertTrue(poolList.isEmpty());
@@ -604,14 +625,14 @@ public class VirtualMachineManagerImplTest {
Mockito.doReturn(ScopeType.CLUSTER).when(storagePoolVoMock).getScope();
Mockito.doNothing().when(virtualMachineManagerImpl).executeManagedStorageChecksWhenTargetStoragePoolNotProvided(hostMock, storagePoolVoMock, volumeVoMock);
Mockito.doNothing().when(virtualMachineManagerImpl).createVolumeToStoragePoolMappingIfPossible(virtualMachineProfileMock, dataCenterDeploymentMock, volumeToPoolObjectMap, volumeVoMock, storagePoolVoMock);
- Mockito.doReturn(true).when(virtualMachineManagerImpl).isStorageCrossClusterMigration(hostMockId, storagePoolVoMock);
+ Mockito.doReturn(true).when(virtualMachineManagerImpl).isStorageCrossClusterMigration(clusterMockId, storagePoolVoMock);
virtualMachineManagerImpl.createStoragePoolMappingsForVolumes(virtualMachineProfileMock, dataCenterDeploymentMock, volumeToPoolObjectMap, allVolumes);
Assert.assertTrue(volumeToPoolObjectMap.isEmpty());
Mockito.verify(virtualMachineManagerImpl).executeManagedStorageChecksWhenTargetStoragePoolNotProvided(hostMock, storagePoolVoMock, volumeVoMock);
Mockito.verify(virtualMachineManagerImpl).createVolumeToStoragePoolMappingIfPossible(virtualMachineProfileMock, dataCenterDeploymentMock, volumeToPoolObjectMap, volumeVoMock, storagePoolVoMock);
- Mockito.verify(virtualMachineManagerImpl).isStorageCrossClusterMigration(hostMockId, storagePoolVoMock);
+ Mockito.verify(virtualMachineManagerImpl).isStorageCrossClusterMigration(clusterMockId, storagePoolVoMock);
}
@Test
@@ -623,7 +644,6 @@ public class VirtualMachineManagerImplTest {
Mockito.doReturn(ScopeType.CLUSTER).when(storagePoolVoMock).getScope();
Mockito.doNothing().when(virtualMachineManagerImpl).executeManagedStorageChecksWhenTargetStoragePoolNotProvided(Mockito.any(), Mockito.any(), Mockito.any());
- Mockito.doNothing().when(virtualMachineManagerImpl).createVolumeToStoragePoolMappingIfPossible(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
Mockito.doReturn(false).when(virtualMachineManagerImpl).isStorageCrossClusterMigration(Mockito.anyLong(), Mockito.any());
virtualMachineManagerImpl.createStoragePoolMappingsForVolumes(virtualMachineProfileMock, dataCenterDeploymentMock, volumeToPoolObjectMap, allVolumes);
@@ -632,7 +652,7 @@ public class VirtualMachineManagerImplTest {
assertEquals(storagePoolVoMock, volumeToPoolObjectMap.get(volumeVoMock));
Mockito.verify(virtualMachineManagerImpl).executeManagedStorageChecksWhenTargetStoragePoolNotProvided(hostMock, storagePoolVoMock, volumeVoMock);
- Mockito.verify(virtualMachineManagerImpl).isStorageCrossClusterMigration(hostMockId, storagePoolVoMock);
+ Mockito.verify(virtualMachineManagerImpl).isStorageCrossClusterMigration(clusterMockId, storagePoolVoMock);
Mockito.verify(virtualMachineManagerImpl, Mockito.times(0)).createVolumeToStoragePoolMappingIfPossible(virtualMachineProfileMock, dataCenterDeploymentMock, volumeToPoolObjectMap, volumeVoMock,
storagePoolVoMock);
}
@@ -646,7 +666,8 @@ public class VirtualMachineManagerImplTest {
Mockito.anyMapOf(Long.class, Long.class));
Mockito.doReturn(volumesNotMapped).when(virtualMachineManagerImpl).findVolumesThatWereNotMappedByTheUser(virtualMachineProfileMock, volumeToPoolObjectMap);
- Mockito.doNothing().when(virtualMachineManagerImpl).createStoragePoolMappingsForVolumes(virtualMachineProfileMock, dataCenterDeploymentMock, volumeToPoolObjectMap, volumesNotMapped);
+ Mockito.doNothing().when(virtualMachineManagerImpl).createStoragePoolMappingsForVolumes(Mockito.eq(virtualMachineProfileMock),
+ Mockito.any(DataCenterDeployment.class), Mockito.eq(volumeToPoolObjectMap), Mockito.eq(volumesNotMapped));
Map<Volume, StoragePool> mappingVolumeAndStoragePool = virtualMachineManagerImpl.createMappingVolumeAndStoragePool(virtualMachineProfileMock, hostMock, new HashMap<>());
@@ -655,7 +676,8 @@ public class VirtualMachineManagerImplTest {
InOrder inOrder = Mockito.inOrder(virtualMachineManagerImpl);
inOrder.verify(virtualMachineManagerImpl).buildMapUsingUserInformation(Mockito.eq(virtualMachineProfileMock), Mockito.eq(hostMock), Mockito.anyMapOf(Long.class, Long.class));
inOrder.verify(virtualMachineManagerImpl).findVolumesThatWereNotMappedByTheUser(virtualMachineProfileMock, volumeToPoolObjectMap);
- inOrder.verify(virtualMachineManagerImpl).createStoragePoolMappingsForVolumes(virtualMachineProfileMock, dataCenterDeploymentMock, volumeToPoolObjectMap, volumesNotMapped);
+ inOrder.verify(virtualMachineManagerImpl).createStoragePoolMappingsForVolumes(Mockito.eq(virtualMachineProfileMock),
+ Mockito.any(DataCenterDeployment.class), Mockito.eq(volumeToPoolObjectMap), Mockito.eq(volumesNotMapped));
}
@Test
diff --git a/engine/orchestration/src/test/java/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java b/engine/orchestration/src/test/java/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java
index c2a9dc7989c..c9e6424a345 100644
--- a/engine/orchestration/src/test/java/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java
+++ b/engine/orchestration/src/test/java/org/apache/cloudstack/engine/provisioning/test/ProvisioningTest.java
@@ -22,17 +22,19 @@ package org.apache.cloudstack.engine.provisioning.test;
import java.util.HashMap;
import java.util.UUID;
-import javax.inject.Inject;
-
import junit.framework.TestCase;
+import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceManager;
+import org.apache.cloudstack.engine.service.api.ProvisioningServiceImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
import org.mockito.Matchers;
+import org.mockito.Mock;
import org.mockito.Mockito;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.mockito.Spy;
+import org.mockito.runners.MockitoJUnitRunner;
import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity;
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
@@ -51,46 +53,49 @@ import org.apache.cloudstack.engine.service.api.ProvisioningService;
import com.cloud.dc.DataCenter.NetworkType;
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = "classpath:/resource/provisioningContext.xml")
+import static org.mockito.ArgumentMatchers.any;
+
+@RunWith(MockitoJUnitRunner.class)
public class ProvisioningTest extends TestCase {
- @Inject
- ProvisioningService service;
+ @Spy
+ @InjectMocks
+ ProvisioningService service = new ProvisioningServiceImpl();
+
+ @Mock
+ DataCenterResourceManager dataCenterResourceManager;
- @Inject
+ @Mock
EngineDataCenterDao dcDao;
- @Inject
+ @Mock
EngineHostPodDao _podDao;
- @Inject
+ @Mock
EngineClusterDao _clusterDao;
- @Inject
+ @Mock
EngineHostDao _hostDao;
- @Override
- @Before
- public void setUp() {
- EngineDataCenterVO dc =
- new EngineDataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, NetworkType.Basic, null, null,
- true, true, null, null);
- Mockito.when(dcDao.findByUuid(Matchers.anyString())).thenReturn(dc);
- Mockito.when(dcDao.persist((EngineDataCenterVO)Matchers.anyObject())).thenReturn(dc);
+ @Mock
+ EngineDataCenterVO dataCenterVO;
- EngineHostPodVO pod = new EngineHostPodVO("lab", 123, "10.0.0.1", "10.0.0.1", 24, "test");
- Mockito.when(_podDao.findByUuid(Matchers.anyString())).thenReturn(pod);
- Mockito.when(_podDao.persist((EngineHostPodVO)Matchers.anyObject())).thenReturn(pod);
+ @Mock
+ EngineHostPodVO podVO;
- EngineClusterVO cluster = new EngineClusterVO();
- Mockito.when(_clusterDao.findByUuid(Matchers.anyString())).thenReturn(cluster);
- Mockito.when(_clusterDao.persist((EngineClusterVO)Matchers.anyObject())).thenReturn(cluster);
+ @Mock
+ EngineClusterVO clusterVO;
- EngineHostVO host = new EngineHostVO("68765876598");
- Mockito.when(_hostDao.findByUuid(Matchers.anyString())).thenReturn(host);
- Mockito.when(_hostDao.persist((EngineHostVO)Matchers.anyObject())).thenReturn(host);
+ @Mock
+ EngineHostVO hostVO;
+ @Override
+ @Before
+ public void setUp() {
+ Mockito.when(dataCenterResourceManager.loadDataCenter(any())).thenReturn(dataCenterVO);
+ Mockito.when(dataCenterResourceManager.loadPod(any())).thenReturn(podVO);
+ Mockito.when(dataCenterResourceManager.loadCluster(any())).thenReturn(clusterVO);
+ Mockito.when(dataCenterResourceManager.loadHost(any())).thenReturn(hostVO);
}
private void registerAndEnableZone() {
diff --git a/engine/orchestration/src/test/resources/provisioningContext.xml b/engine/orchestration/src/test/resources/provisioningContext.xml
deleted file mode 100644
index 4fff3bff7ad..00000000000
--- a/engine/orchestration/src/test/resources/provisioningContext.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd">
- <context:annotation-config />
- <context:component-scan base-package="org.apache.cloudstack.engine" />
-
- <tx:annotation-driven transaction-manager="transactionManager" />
- <!-- bean id="aopTestBean" class="org.apache.cloudstack.storage.test.AopTestAdvice"/-->
- <!-- aop:config proxy-target-class="true" >
- <aop:aspect id="AopTestAdvice" ref="aopTestBean">
- <aop:pointcut id="aoptest"
- expression="@annotation(com.cloud.utils.db.DB)" />
- <aop:around pointcut-ref="aoptest" method="AopTestMethod"/>
- </aop:aspect>
- </aop:config>
- -->
-
- <bean class="org.apache.cloudstack.engine.provisioning.test.ChildTestConfiguration" />
-
-</beans>
\ No newline at end of file