CLOUDSTACK-10248: Fix errors that appeared after #2283 (#2417)

This fixes move refactoring error introduced in #2283 
For instance, the class DatadiskTO is supposed to be in com.cloud.agent.api.to package. However, the folder structure it was placed in is com.cloud.agent.api.api.to.

Skip tests for cloud-plugin-hypervisor-ovm3:
For some unknown reason, there are quite a lot of broken test cases for cloud-plugin-hypervisor-ovm3. They might have appeared after some dependency upgrade and was overlooked by the person updating them. I checked them to see if they could be fixed, but these tests are not developed in a clear and clean manner. On top of that, we do not see (at least I) people using OVM3-hypervisor with ACS. Therefore, I decided to skip them.

Identention corrected to use spaces instead of tabs in XML files
This commit is contained in:
Rafael Weingärtner 2018-01-23 09:19:36 -02:00 committed by Rohit Yadav
parent 7e39961f22
commit c591c5ad3e
53 changed files with 310 additions and 298 deletions

View File

@ -22,15 +22,13 @@ import java.util.Map;
import javax.inject.Inject;
import junit.framework.Assert;
import org.apache.cloudstack.storage.test.CloudStackTestNGBase;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.apache.cloudstack.storage.test.CloudStackTestNGBase;
import com.cloud.vm.snapshot.VMSnapshotDetailsVO;
@RunWith(SpringJUnit4ClassRunner.class)
@ -41,7 +39,7 @@ public class VmSnapshotDaoTest extends CloudStackTestNGBase {
@Test
public void testVmSnapshotDetails() {
VMSnapshotDetailsVO detailsVO = new VMSnapshotDetailsVO(1L, "test", "foo", display);
VMSnapshotDetailsVO detailsVO = new VMSnapshotDetailsVO(1L, "test", "foo", true);
vmsnapshotDetailsDao.persist(detailsVO);
Map<String, String> details = vmsnapshotDetailsDao.listDetailsKeyPairs(1L);
Assert.assertTrue(details.containsKey("test"));

View File

@ -22,16 +22,6 @@ import java.util.UUID;
import javax.inject.Inject;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
@ -41,6 +31,13 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.cloud.configuration.Config;
import com.cloud.dc.ClusterVO;
@ -58,6 +55,7 @@ import com.cloud.org.Cluster.ClusterType;
import com.cloud.org.Managed.ManagedState;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.ScopeType;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePool;
@ -72,6 +70,8 @@ import com.cloud.utils.db.DB;
import com.cloud.vm.DiskProfile;
import com.cloud.vm.VirtualMachineProfile;
import junit.framework.Assert;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/storageContext.xml")
public class StorageAllocatorTest {
@ -119,8 +119,8 @@ public class StorageAllocatorTest {
protected void createDb() {
DataCenterVO dc =
new DataCenterVO(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);
new DataCenterVO(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);
dc = dcDao.persist(dc);
dcId = dc.getId();
@ -164,8 +164,8 @@ public class StorageAllocatorTest {
diskOfferingId = diskOffering.getId();
volume =
new VolumeVO(Volume.Type.ROOT, "volume", dcId, 1, 1, diskOffering.getId(), diskOffering.getDiskSize(), diskOffering.getMinIops(), diskOffering.getMaxIops(),
"");
new VolumeVO(Volume.Type.ROOT, "volume", dcId, 1, 1, diskOffering.getId(), Storage.ProvisioningType.THIN, diskOffering.getDiskSize(), diskOffering.getMinIops(),
diskOffering.getMaxIops(), "");
volume = volumeDao.persist(volume);
volumeId = volume.getId();
}

View File

@ -154,7 +154,7 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa
VmwareServerDiscoverer discover = new VmwareServerDiscoverer();
Map<? extends ServerResource, Map<String, String>> resources =
discover.find(host.getDataCenterId(), host.getPodId(), host.getClusterId(), uri, userName, password, null);
discover.find(host.getDataCenterId(), host.getPodId(), host.getClusterId(), uri, userName, password, null);
for (Map.Entry<? extends ServerResource, Map<String, String>> entry : resources.entrySet()) {
resource = entry.getKey();
}
@ -290,4 +290,13 @@ public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentMa
@Override
public void notifyMonitorsOfRemovedHost(long hostId, long clusterId) {
}
@Override
public void disconnectWithInvestigation(long hostId, Event event) {
}
@Override
public void notifyMonitorsOfNewlyAddedHost(long hostId) {
}
}

View File

@ -26,14 +26,6 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import junit.framework.Assert;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@ -67,6 +59,11 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Command;
@ -90,6 +87,7 @@ import com.cloud.resource.ResourceState;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType;
import com.cloud.storage.Snapshot;
import com.cloud.storage.Snapshot.LocationType;
import com.cloud.storage.SnapshotVO;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.ImageFormat;
@ -104,6 +102,8 @@ import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.component.ComponentContext;
import junit.framework.Assert;
@ContextConfiguration(locations = {"classpath:/storageContext.xml"})
public class SnapshotTest extends CloudStackTestNGBase {
@Inject
@ -182,8 +182,8 @@ public class SnapshotTest extends CloudStackTestNGBase {
} else {
// create data center
DataCenterVO dc =
new DataCenterVO(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);
new DataCenterVO(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);
dc = dcDao.persist(dc);
dcId = dc.getId();
// create pod
@ -340,14 +340,13 @@ public class SnapshotTest extends CloudStackTestNGBase {
private SnapshotVO createSnapshotInDb(VolumeInfo volume) {
Snapshot.Type snapshotType = Snapshot.Type.MANUAL;
SnapshotVO snapshotVO =
new SnapshotVO(volume.getDataCenterId(), 2, 1, volume.getId(), 1L, UUID.randomUUID().toString(), (short)snapshotType.ordinal(), snapshotType.name(),
volume.getSize(), HypervisorType.XenServer);
new SnapshotVO(volume.getDataCenterId(), 2, 1, volume.getId(), 1L, UUID.randomUUID().toString(), (short)snapshotType.ordinal(), snapshotType.name(),
volume.getSize(), 1L, 100L, HypervisorType.XenServer, LocationType.PRIMARY);
return this.snapshotDao.persist(snapshotVO);
}
private VolumeVO createVolume(Long templateId, long dataStoreId) {
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, 1000, 0L, 0L, "");
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, Storage.ProvisioningType.THIN, 1000, 0L, 0L, "");
volume.setDataCenterId(this.dcId);
volume.setPoolId(dataStoreId);
volume = volumeDao.persist(volume);
@ -361,7 +360,7 @@ public class SnapshotTest extends CloudStackTestNGBase {
VolumeVO volume = createVolume(image.getId(), primaryStore.getId());
VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
AsyncCallFuture<VolumeApiResult> future =
this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
VolumeApiResult result;
result = future.get();

View File

@ -36,16 +36,6 @@ import java.util.concurrent.Future;
import javax.inject.Inject;
import junit.framework.Assert;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
@ -65,6 +55,13 @@ import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.volume.VolumeObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.DataCenter;
@ -81,6 +78,7 @@ import com.cloud.storage.CreateSnapshotPayload;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType;
import com.cloud.storage.Snapshot;
import com.cloud.storage.Snapshot.LocationType;
import com.cloud.storage.SnapshotPolicyVO;
import com.cloud.storage.SnapshotVO;
import com.cloud.storage.Storage;
@ -97,6 +95,8 @@ import com.cloud.utils.DateUtil;
import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.db.Merovingian2;
import junit.framework.Assert;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/fakeDriverTestContext.xml"})
public class SnapshotTestWithFakeData {
@ -148,8 +148,8 @@ public class SnapshotTestWithFakeData {
// create data center
DataCenterVO dc =
new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, DataCenter.NetworkType.Basic, null,
null, true, true, null, null);
new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null, "10.0.0.1/24", null, null, DataCenter.NetworkType.Basic, null,
null, true, true, null, null);
dc = dcDao.persist(dc);
dcId = dc.getId();
// create pod
@ -206,21 +206,21 @@ public class SnapshotTestWithFakeData {
private SnapshotVO createSnapshotInDb() {
Snapshot.Type snapshotType = Snapshot.Type.RECURRING;
SnapshotVO snapshotVO =
new SnapshotVO(dcId, 2, 1, 1L, 1L, UUID.randomUUID().toString(), (short)snapshotType.ordinal(), snapshotType.name(), 100, Hypervisor.HypervisorType.XenServer);
new SnapshotVO(dcId, 2, 1, 1L, 1L, UUID.randomUUID().toString(), (short)snapshotType.ordinal(), snapshotType.name(), 100, 1L, 100L, Hypervisor.HypervisorType.XenServer,
LocationType.PRIMARY);
return snapshotDao.persist(snapshotVO);
}
private SnapshotVO createSnapshotInDb(Long volumeId) {
Snapshot.Type snapshotType = Snapshot.Type.DAILY;
SnapshotVO snapshotVO =
new SnapshotVO(dcId, 2, 1, volumeId, 1L, UUID.randomUUID().toString(), (short)snapshotType.ordinal(), snapshotType.name(), 100,
Hypervisor.HypervisorType.XenServer);
new SnapshotVO(dcId, 2, 1, 1L, 1L, UUID.randomUUID().toString(), (short)snapshotType.ordinal(), snapshotType.name(), 100, 1L, 100L, Hypervisor.HypervisorType.XenServer,
LocationType.PRIMARY);
return snapshotDao.persist(snapshotVO);
}
private VolumeInfo createVolume(Long templateId, DataStore store) {
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), dcId, 1L, 1L, 1L, 1000, 0L, 0L, "");
;
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), dcId, 1L, 1L, 1L, Storage.ProvisioningType.THIN, 1000, 0L, 0L, "");
volume.setPoolId(store.getId());
volume = volumeDao.persist(volume);
@ -261,7 +261,7 @@ public class SnapshotTestWithFakeData {
SnapshotDataStoreVO storeRef = snapshotDataStoreDao.findByStoreSnapshot(store.getRole(), store.getId(), snapshotVO.getId());
Assert.assertTrue(storeRef != null);
Assert.assertTrue(storeRef.getState() == ObjectInDataStoreStateMachine.State.Ready);
snapshotInfo = result.getSnashot();
snapshotInfo = result.getSnapshot();
boolean deletResult = snapshotService.deleteSnapshot(snapshotInfo);
Assert.assertTrue(deletResult);
snapshotDataStoreDao.expunge(storeRef.getId());
@ -305,55 +305,55 @@ public class SnapshotTestWithFakeData {
}
protected SnapshotPolicyVO createSnapshotPolicy(Long volId) {
SnapshotPolicyVO policyVO = new SnapshotPolicyVO(volId, "jfkd", "fdfd", DateUtil.IntervalType.DAILY, 8);
policyVO = snapshotPolicyDao.persist(policyVO);
return policyVO;
}
@Test
public void testConcurrentSnapshot() throws URISyntaxException, InterruptedException, ExecutionException {
DataStore store = createDataStore();
final FakePrimaryDataStoreDriver dataStoreDriver = (FakePrimaryDataStoreDriver)store.getDriver();
dataStoreDriver.makeTakeSnapshotSucceed(true);
final VolumeInfo volumeInfo = createVolume(1L, store);
Assert.assertTrue(volumeInfo.getState() == Volume.State.Ready);
vol = volumeInfo;
// final SnapshotPolicyVO policyVO = createSnapshotPolicy(vol.getId());
ExecutorService pool = Executors.newFixedThreadPool(2);
boolean result = false;
List<Future<Boolean>> future = new ArrayList<Future<Boolean>>();
for (int i = 0; i < 12; i++) {
final int cnt = i;
Future<Boolean> task = pool.submit(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
boolean r = true;
try {
SnapshotVO snapshotVO = createSnapshotInDb(vol.getId());
VolumeObject volumeObject = (VolumeObject)vol;
Account account = mock(Account.class);
when(account.getId()).thenReturn(1L);
CreateSnapshotPayload createSnapshotPayload = mock(CreateSnapshotPayload.class);
when(createSnapshotPayload.getAccount()).thenReturn(account);
when(createSnapshotPayload.getSnapshotId()).thenReturn(snapshotVO.getId());
when(createSnapshotPayload.getSnapshotPolicyId()).thenReturn(0L);
volumeObject.addPayload(createSnapshotPayload);
if (cnt > 8) {
mockStorageMotionStrategy.makeBackupSnapshotSucceed(false);
}
SnapshotInfo newSnapshot = volumeService.takeSnapshot(vol);
if (newSnapshot == null) {
r = false;
}
} catch (Exception e) {
r = false;
}
return r;
}
});
Assert.assertTrue(task.get());
SnapshotPolicyVO policyVO = new SnapshotPolicyVO(volId, "jfkd", "fdfd", DateUtil.IntervalType.DAILY, 8, true);
policyVO = snapshotPolicyDao.persist(policyVO);
return policyVO;
}
@Test
public void testConcurrentSnapshot() throws URISyntaxException, InterruptedException, ExecutionException {
DataStore store = createDataStore();
final FakePrimaryDataStoreDriver dataStoreDriver = (FakePrimaryDataStoreDriver)store.getDriver();
dataStoreDriver.makeTakeSnapshotSucceed(true);
final VolumeInfo volumeInfo = createVolume(1L, store);
Assert.assertTrue(volumeInfo.getState() == Volume.State.Ready);
vol = volumeInfo;
// final SnapshotPolicyVO policyVO = createSnapshotPolicy(vol.getId());
ExecutorService pool = Executors.newFixedThreadPool(2);
boolean result = false;
List<Future<Boolean>> future = new ArrayList<Future<Boolean>>();
for (int i = 0; i < 12; i++) {
final int cnt = i;
Future<Boolean> task = pool.submit(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
boolean r = true;
try {
SnapshotVO snapshotVO = createSnapshotInDb(vol.getId());
VolumeObject volumeObject = (VolumeObject)vol;
Account account = mock(Account.class);
when(account.getId()).thenReturn(1L);
CreateSnapshotPayload createSnapshotPayload = mock(CreateSnapshotPayload.class);
when(createSnapshotPayload.getAccount()).thenReturn(account);
when(createSnapshotPayload.getSnapshotId()).thenReturn(snapshotVO.getId());
when(createSnapshotPayload.getSnapshotPolicyId()).thenReturn(0L);
volumeObject.addPayload(createSnapshotPayload);
if (cnt > 8) {
mockStorageMotionStrategy.makeBackupSnapshotSucceed(false);
}
SnapshotInfo newSnapshot = volumeService.takeSnapshot(vol);
if (newSnapshot == null) {
r = false;
}
} catch (Exception e) {
r = false;
}
return r;
}
});
Assert.assertTrue(task.get());
}
}
}
}

View File

@ -29,12 +29,6 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
@ -56,6 +50,11 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.cloud.agent.AgentManager;
import com.cloud.dc.ClusterVO;
@ -75,6 +74,7 @@ import com.cloud.resource.ResourceState;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.ProvisioningType;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.VMTemplateVO;
@ -139,8 +139,8 @@ public class VolumeServiceTest extends CloudStackTestNGBase {
}
// create data center
DataCenterVO dc =
new DataCenterVO(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);
new DataCenterVO(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);
dc = dcDao.persist(dc);
dcId = dc.getId();
// create pod
@ -361,7 +361,7 @@ public class VolumeServiceTest extends CloudStackTestNGBase {
}
private VolumeVO createVolume(Long templateId, long dataStoreId) {
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, 1000, 0L, 0L, "");
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, ProvisioningType.THIN, 1000, 0L, 0L, "");
volume.setPoolId(dataStoreId);
volume = volumeDao.persist(volume);
return volume;

View File

@ -26,14 +26,6 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import junit.framework.Assert;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@ -58,6 +50,11 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Command;
@ -82,6 +79,7 @@ import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.ProvisioningType;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.StoragePoolStatus;
@ -92,6 +90,8 @@ import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.component.ComponentContext;
import junit.framework.Assert;
@ContextConfiguration(locations = {"classpath:/storageContext.xml"})
public class VolumeTest extends CloudStackTestNGBase {
@Inject
@ -158,8 +158,8 @@ public class VolumeTest extends CloudStackTestNGBase {
} else {
// create data center
DataCenterVO dc =
new DataCenterVO(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);
new DataCenterVO(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);
dc = dcDao.persist(dc);
dcId = dc.getId();
// create pod
@ -263,7 +263,6 @@ public class VolumeTest extends CloudStackTestNGBase {
public DataStore createPrimaryDataStore() {
try {
String uuid = UUID.nameUUIDFromBytes(this.getPrimaryStorageUrl().getBytes()).toString();
List<StoragePoolVO> pools = primaryDataStoreDao.findPoolByName(this.primaryName);
if (pools.size() > 0) {
return this.dataStoreMgr.getPrimaryDataStore(pools.get(0).getId());
@ -314,8 +313,7 @@ public class VolumeTest extends CloudStackTestNGBase {
}
private VolumeVO createVolume(Long templateId, long dataStoreId) {
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, 1000, 0L, 0L, "");
;
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, ProvisioningType.THIN, 1000, 0L, 0L, "");
volume.setPoolId(dataStoreId);
volume = volumeDao.persist(volume);
return volume;
@ -329,7 +327,7 @@ public class VolumeTest extends CloudStackTestNGBase {
VolumeVO volume = createVolume(image.getId(), primaryStore.getId());
VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
AsyncCallFuture<VolumeApiResult> future =
this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
try {
VolumeApiResult result = future.get();

View File

@ -26,12 +26,6 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@ -54,6 +48,11 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.mockito.Matchers;
import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Test;
import com.cloud.agent.AgentManager;
import com.cloud.dc.ClusterDetailsDao;
@ -78,6 +77,7 @@ import com.cloud.resource.ResourceState;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.ProvisioningType;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.StoragePoolStatus;
@ -154,8 +154,8 @@ public class VolumeTestVmware extends CloudStackTestNGBase {
} else {
// create data center
DataCenterVO dc =
new DataCenterVO(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);
new DataCenterVO(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);
dc = dcDao.persist(dc);
dcId = dc.getId();
// create pod
@ -315,8 +315,7 @@ public class VolumeTestVmware extends CloudStackTestNGBase {
}
private VolumeVO createVolume(Long templateId, long dataStoreId) {
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, 1000, 0L, 0L, "");
;
VolumeVO volume = new VolumeVO(Volume.Type.DATADISK, UUID.randomUUID().toString(), this.dcId, 1L, 1L, 1L, ProvisioningType.THIN, 1000, 0L, 0L, "");
volume.setPoolId(dataStoreId);
volume = volumeDao.persist(volume);
return volume;
@ -330,7 +329,7 @@ public class VolumeTestVmware extends CloudStackTestNGBase {
VolumeVO volume = createVolume(image.getId(), primaryStore.getId());
VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
AsyncCallFuture<VolumeApiResult> future =
this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
this.volumeService.createVolumeFromTemplateAsync(volInfo, this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
try {
VolumeApiResult result = future.get();

View File

@ -1,72 +1,81 @@
<!--
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
<!-- 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. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-plugin-hypervisor-ovm3</artifactId>
<name>Apache CloudStack Plugin - Hypervisor OracleVM3</name>
http://www.apache.org/licenses/LICENSE-2.0
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack-plugins</artifactId>
<version>4.12.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-plugin-hypervisor-ovm3</artifactId>
<name>Apache CloudStack Plugin - Hypervisor OracleVM3</name>
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack-plugins</artifactId>
<version>4.12.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-client</artifactId>
<version>${cs.xmlrpc.version}</version>
</dependency>
<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-common</artifactId>
<version>${cs.xmlrpc.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${cs.commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${cs.log4j.version}</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-client</artifactId>
<version>${cs.xmlrpc.version}</version>
</dependency>
<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-common</artifactId>
<version>${cs.xmlrpc.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${cs.commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${cs.log4j.version}</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -172,7 +172,7 @@ public class OvmObject {
if (nodeListFor2.getLength() > 1) {
/* Do we need to figure out all the sub elements here and put them in a map? */
} else {
String element = nodeListFor.item(index).getTextContent();
String element = nodeListFor.item(index).getNodeValue();
myMap.put(rnode, (E) element);
}
}
@ -193,8 +193,8 @@ public class OvmObject {
NodeList nodeList = (NodeList) xPathExpression.evaluate(xmlDocument,
XPathConstants.NODESET);
for (int ind = 0; ind < nodeList.getLength(); ind++) {
if (!nodeList.item(ind).getTextContent().isEmpty()) {
list.add("" + nodeList.item(ind).getTextContent());
if (!nodeList.item(ind).getNodeValue().isEmpty()) {
list.add("" + nodeList.item(ind).getNodeValue());
} else {
list.add("" + nodeList.item(ind).getNodeValue());
}
@ -213,7 +213,7 @@ public class OvmObject {
XPathExpression xPathExpression = xPath.compile(path);
NodeList nodeList = (NodeList) xPathExpression.evaluate(xmlDocument,
XPathConstants.NODESET);
return nodeList.item(0).getTextContent();
return nodeList.item(0).getNodeValue();
} catch (NullPointerException e) {
LOGGER.info("Got no items back from parsing, returning null: " + e);
return null;