Allon Mureinik has uploaded a new change for review. Change subject: core: Use FixturesTool in VmDAOTest ......................................................................
core: Use FixturesTool in VmDAOTest Removed local constants and hardcoded values and used FixturesTools constants instead where those existed. Where they didn't, they were added. The fixtures.xml file was also slightly fixed to avoid naming confusion with non-unique names. Change-Id: Ia3afb7afa9f508ea61ea3bc6502c80d0812d18fa Signed-off-by: Allon Mureinik <[email protected]> --- M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/FixturesTool.java M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDAOTest.java M backend/manager/modules/dal/src/test/resources/fixtures.xml 3 files changed, 32 insertions(+), 26 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/37/24037/1 diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/FixturesTool.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/FixturesTool.java index 287b8eb..e69950e 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/FixturesTool.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/FixturesTool.java @@ -33,6 +33,11 @@ protected static final Guid STORAGE_POOL_RHEL6_LOCALFS = new Guid("386bffd1-e7ed-4b08-bce9-d7df10f8c9a2"); /** + * Predefined storage pool serving Fedora VMs. + */ + protected static final Guid STORAGE_POOL_FEDORA = new Guid("103cfd1d-18b1-4790-8a0c-1e52621b0076"); + + /** * Predefined NFS master storage domain. */ protected static final Guid STORAGE_DOAMIN_NFS_MASTER = new Guid("c2211b56-8869-41cd-84e1-78d7cb96f31d"); @@ -154,6 +159,16 @@ /** * Predefined VM for testing with the following properties : * <ul> + * <li>VM name: rhel5-pool-52</li> + * <li>Vds group: rhel6.iscsi (b399944a-81ab-4ec5-8266-e19ba7c3c9d1)</li> + * <li>Based on template: 1 (1b85420c-b84c-4f29-997e-0eb674b40b79)</li> + * </ul> + */ + protected static final Guid VM_RHEL5_POOL_52 = new Guid("77296e00-0cad-4e5a-9299-008a7b6f5002"); + + /** + * Predefined VM for testing with the following properties : + * <ul> * <li>VM name: rhel5-pool-57</li> * <li>Vds group: rhel6.iscsi (b399944a-81ab-4ec5-8266-e19ba7c3c9d1)</li> * <li>Based on template: 1 (1b85420c-b84c-4f29-997e-0eb674b40b79)</li> diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDAOTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDAOTest.java index 78a97b3..5dfcf91 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDAOTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDAOTest.java @@ -22,13 +22,6 @@ import org.ovirt.engine.core.compat.Guid; public class VmDAOTest extends BaseDAOTestCase { - private static final Guid VDS_STATIC_ID = new Guid("afce7a39-8e8c-4819-ba9c-796d316592e6"); - private static final Guid VDS_GROUP_ID = new Guid("b399944a-81ab-4ec5-8266-e19ba7c3c9d1"); - private static final Guid USER_ID = new Guid("9bf7c640-b620-456f-a550-0348f366544b"); - private static final Guid STORAGE_DOMAIN_ID = new Guid("72e3a666-89e1-4005-a7ca-f7548004a9ab"); - private static final Guid POOL_ID = new Guid("103cfd1d-18b1-4790-8a0c-1e52621b0076"); - private static final Guid VM_TO_UPDATE_ID = new Guid("77296e00-0cad-4e5a-9299-008a7b6f5002"); - private static final int VM_COUNT = 7; private VmDAO dao; private VM existingVm; @@ -42,21 +35,19 @@ super.setUp(); dao = dbFacade.getVmDao(); - existingVm = dao.get(new Guid("77296e00-0cad-4e5a-9299-008a7b6f4355")); + existingVm = dao.get(FixturesTool.VM_RHEL5_POOL_57); existingVm.setStatus(VMStatus.Up); - vmtemplate = dbFacade.getVmTemplateDao().get( - new Guid("1b85420c-b84c-4f29-997e-0eb674b40b79")); - existingTemplate = dbFacade.getVmTemplateDao().get( - new Guid("1b85420c-b84c-4f29-997e-0eb674b40b79")); + vmtemplate = dbFacade.getVmTemplateDao().get(FixturesTool.VM_TEMPLATE_RHEL5); + existingTemplate = dbFacade.getVmTemplateDao().get(FixturesTool.VM_TEMPLATE_RHEL5); newVm = new VM(); newVm.setId(Guid.newGuid()); - newVm.setVdsGroupId(VDS_GROUP_ID); + newVm.setVdsGroupId(FixturesTool.VDS_GROUP_RHEL6_ISCSI); newVm.setVmtGuid(vmtemplate.getId()); newVmStatic = new VmStatic(); newVmStatic.setName("New Virtual Machine"); - newVmStatic.setVdsGroupId(VDS_GROUP_ID); + newVmStatic.setVdsGroupId(FixturesTool.VDS_GROUP_RHEL6_ISCSI); newVmStatic.setVmtGuid(vmtemplate.getId()); } @@ -273,7 +264,7 @@ */ @Test public void testGetAllForStorageDomain() { - List<VM> result = dao.getAllForStorageDomain(STORAGE_DOMAIN_ID); + List<VM> result = dao.getAllForStorageDomain(FixturesTool.STORAGE_DOAMIN_SCALE_SD5); assertNotNull(result); assertFalse(result.isEmpty()); @@ -284,7 +275,7 @@ */ @Test public void testGetAllForUser() { - List<VM> result = dao.getAllForUser(USER_ID); + List<VM> result = dao.getAllForUser(FixturesTool.USER_EXISTING_ID); assertNotNull(result); assertFalse(result.isEmpty()); @@ -295,7 +286,7 @@ */ @Test public void testGetAllForUsersWithGroupsAndUserRoles() { - List<VM> result = dao.getAllForUserWithGroupsAndUserRoles(USER_ID); + List<VM> result = dao.getAllForUserWithGroupsAndUserRoles(FixturesTool.USER_EXISTING_ID); assertNotNull(result); assertFalse(result.isEmpty()); @@ -306,7 +297,7 @@ */ @Test public void testGetAllRunningForVds() { - Map<Guid, VM> result = dao.getAllRunningByVds(VDS_STATIC_ID); + Map<Guid, VM> result = dao.getAllRunningByVds(FixturesTool.VDS_RHEL6_NFS_SPM); assertNotNull(result); assertFalse(result.isEmpty()); @@ -317,7 +308,7 @@ */ @Test public void getAllRunningOnOrMigratingToVds() { - List<VM> result = dao.getAllRunningOnOrMigratingToVds(VDS_STATIC_ID); + List<VM> result = dao.getAllRunningOnOrMigratingToVds(FixturesTool.VDS_RHEL6_NFS_SPM); assertNotNull(result); assertFalse(result.isEmpty()); @@ -328,7 +319,7 @@ */ @Test public void testGetAllActiveForStorageDomain() { - List<VM> result = dao.getAllActiveForStorageDomain(STORAGE_DOMAIN_ID); + List<VM> result = dao.getAllActiveForStorageDomain(FixturesTool.STORAGE_DOAMIN_SCALE_SD5); assertNotNull(result); assertFalse(result.isEmpty()); @@ -339,7 +330,7 @@ */ @Test public void testGetAllForVdsGroup() { - List<VM> result = dao.getAllForVdsGroup(VDS_GROUP_ID); + List<VM> result = dao.getAllForVdsGroup(FixturesTool.VDS_GROUP_RHEL6_ISCSI); assertNotNull(result); assertFalse(result.isEmpty()); @@ -431,7 +422,7 @@ @Test public void testGetAllForVmPool() { - List<VM> result = dao.getAllForVmPool(POOL_ID); + List<VM> result = dao.getAllForVmPool(FixturesTool.STORAGE_POOL_FEDORA); assertNotNull(result); assertEquals("wrong number of VMs attached to pool", 2, result.size()); @@ -464,7 +455,7 @@ @Test public void testUpdateOriginalTemplateName() { dao.updateOriginalTemplateName( - new Guid("1b85420c-b84c-4f29-997e-0eb674b40b82"), + FixturesTool.VM_TEMPLATE_RHEL6_2, "renamed" ); @@ -496,7 +487,7 @@ */ @Test public void testAllRunningByCluster() { - List<VM> result = dao.getAllRunningByCluster(VDS_GROUP_ID); + List<VM> result = dao.getAllRunningByCluster(FixturesTool.VDS_GROUP_RHEL6_ISCSI); assertNotNull(result); assertFalse(result.isEmpty()); @@ -506,6 +497,6 @@ public void testGetVmIdsForVersionUpdate() { List<Guid> vmIdsToUpdate = dao.getVmIdsForVersionUpdate(FixturesTool.VM_TEMPLATE_RHEL5); - assertTrue(vmIdsToUpdate.contains(VM_TO_UPDATE_ID)); + assertTrue(vmIdsToUpdate.contains(FixturesTool.VM_RHEL5_POOL_52)); } } diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index b3c5ff3..78dd5cb 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -2329,7 +2329,7 @@ <row> <value>77296e00-0cad-4e5a-9299-008a7b6f5002</value> <value>VM</value> - <value>rhel5-pool-50</value> + <value>rhel5-pool-52</value> <value>1024</value> <value>1b85420c-b84c-4f29-997e-0eb674b40b83</value> <value>0</value> -- To view, visit http://gerrit.ovirt.org/24037 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia3afb7afa9f508ea61ea3bc6502c80d0812d18fa Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
