Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2196DCAF6 for ; Thu, 11 Jul 2013 10:54:40 +0000 (UTC) Received: (qmail 49655 invoked by uid 500); 11 Jul 2013 10:54:39 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 49626 invoked by uid 500); 11 Jul 2013 10:54:39 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 49619 invoked by uid 99); 11 Jul 2013 10:54:39 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Jul 2013 10:54:39 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B5E8388F3CC; Thu, 11 Jul 2013 10:54:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: devdeep@apache.org To: commits@cloudstack.apache.org Message-Id: <49d63ae582114a10aae023d48b7ac706@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/4.2 to 293e545 Date: Thu, 11 Jul 2013 10:54:38 +0000 (UTC) Updated Branches: refs/heads/4.2 b1f705656 -> 293e5458d CLOUDSTACK-3467: Fixing the unit tests for implicit dedication planner. When fix for bug 2662 was made the unit tests were not updated correctly. The unit tests should have been changed to return the correct mock object (VMInstanceVO) when vmInstanceDao is queried for the vms running on host. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/293e5458 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/293e5458 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/293e5458 Branch: refs/heads/4.2 Commit: 293e5458d344fc68b2122a620cf717c0d9066ddf Parents: b1f7056 Author: Devdeep Singh Authored: Thu Jul 11 16:01:13 2013 +0530 Committer: Devdeep Singh Committed: Thu Jul 11 16:17:07 2013 +0530 ---------------------------------------------------------------------- .../implicitplanner/ImplicitPlannerTest.java | 46 +++++++++----------- 1 file changed, 20 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/293e5458/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java ---------------------------------------------------------------------- diff --git a/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java b/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java index efbb5c2..e519668 100644 --- a/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java +++ b/plugins/deployment-planners/implicit-dedication/test/org/apache/cloudstack/implicitplanner/ImplicitPlannerTest.java @@ -202,11 +202,10 @@ public class ImplicitPlannerTest { // Validations. // Check cluster 2 and 3 are not in the cluster list. // Host 6 and 7 should also be in avoid list. - //System.out.println("checkStrictModeWithCurrentAccountVmsPresent:: Cluster list should not be empty but ::" + clusterList.toString()); assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty())); boolean foundNeededCluster = false; for (Long cluster : clusterList) { - if (cluster == 4) { + if (cluster != 1) { fail("Found a cluster that shouldn't have been present, cluster id : " + cluster); }else { foundNeededCluster = true; @@ -219,8 +218,7 @@ public class ImplicitPlannerTest { Set hostsThatShouldBeInAvoidList = new HashSet(); hostsThatShouldBeInAvoidList.add(6L); hostsThatShouldBeInAvoidList.add(7L); - //System.out.println("checkStrictModeWithCurrentAccountVmsPresent:: Host in avoidlist :: " + hostsThatShouldBeInAvoidList.toString()); - assertFalse("Hosts 6 and 7 that should have been present were not found in avoid list" , + assertTrue("Hosts 6 and 7 that should have been present were not found in avoid list" , hostsInAvoidList.containsAll(hostsThatShouldBeInAvoidList)); } @@ -244,14 +242,11 @@ public class ImplicitPlannerTest { // Host 5 and 7 should also be in avoid list. assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty())); boolean foundNeededCluster = false; - //System.out.println("Cluster list 2 should not be present ::" + clusterList.toString()); for (Long cluster : clusterList) { if (cluster != 2) { fail("Found a cluster that shouldn't have been present, cluster id : " + cluster); - }else { + } else { foundNeededCluster = true; - //System.out.println("Cluster list 2 should not be present breaking now" + cluster); - break; } } assertTrue("Didn't find cluster 2 in the list. It should have been present", foundNeededCluster); @@ -261,7 +256,7 @@ public class ImplicitPlannerTest { Set hostsThatShouldBeInAvoidList = new HashSet(); hostsThatShouldBeInAvoidList.add(5L); hostsThatShouldBeInAvoidList.add(7L); - assertFalse("Hosts 5 and 7 that should have been present were not found in avoid list" , + assertTrue("Hosts 5 and 7 that should have been present were not found in avoid list" , hostsInAvoidList.containsAll(hostsThatShouldBeInAvoidList)); } @@ -283,8 +278,7 @@ public class ImplicitPlannerTest { // Validations. // Check cluster list is empty. - //System.out.println("Cluster list should not be empty but ::" + clusterList.toString()); - assertFalse("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty())); + assertTrue("Cluster list should not be null/empty", (clusterList == null || clusterList.isEmpty())); } @Test @@ -360,7 +354,7 @@ public class ImplicitPlannerTest { when(vmProfile.getOwner()).thenReturn(account); when(vmProfile.getVirtualMachine()).thenReturn(vm); when(vmProfile.getId()).thenReturn(12L); - when( vmDao.findById(12L)).thenReturn(userVm); + when(vmDao.findById(12L)).thenReturn(userVm); when(userVm.getAccountId()).thenReturn(accountId); when(vm.getDataCenterId()).thenReturn(dataCenterId); @@ -440,20 +434,20 @@ public class ImplicitPlannerTest { UserVmVO vm3 = mock(UserVmVO.class); when(vm3.getAccountId()).thenReturn(201L); when(vm3.getServiceOfferingId()).thenReturn(offeringIdForVmsOfOtherAccount); - List userVmsForHost1 = new ArrayList(); - List userVmsForHost2 = new ArrayList(); - List userVmsForHost3 = new ArrayList(); - List stoppedVmsForHost = new ArrayList(); + List vmsForHost1 = new ArrayList(); + List vmsForHost2 = new ArrayList(); + List vmsForHost3 = new ArrayList(); + List stoppedVmsForHost = new ArrayList(); // Host 2 is empty. - userVmsForHost1.add(vm1); - userVmsForHost1.add(vm2); - userVmsForHost3.add(vm3); - when(vmDao.listUpByHostId(5L)).thenReturn(userVmsForHost1); - when(vmDao.listUpByHostId(6L)).thenReturn(userVmsForHost2); - when(vmDao.listUpByHostId(7L)).thenReturn(userVmsForHost3); - when(vmDao.listByLastHostId(5L)).thenReturn(stoppedVmsForHost); - when(vmDao.listByLastHostId(6L)).thenReturn(stoppedVmsForHost); - when(vmDao.listByLastHostId(7L)).thenReturn(stoppedVmsForHost); + vmsForHost1.add(vm1); + vmsForHost1.add(vm2); + vmsForHost3.add(vm3); + when(vmInstanceDao.listUpByHostId(5L)).thenReturn(vmsForHost1); + when(vmInstanceDao.listUpByHostId(6L)).thenReturn(vmsForHost2); + when(vmInstanceDao.listUpByHostId(7L)).thenReturn(vmsForHost3); + when(vmInstanceDao.listByLastHostId(5L)).thenReturn(stoppedVmsForHost); + when(vmInstanceDao.listByLastHostId(6L)).thenReturn(stoppedVmsForHost); + when(vmInstanceDao.listByLastHostId(7L)).thenReturn(stoppedVmsForHost); // Mock the offering with which the vm was created. ServiceOfferingVO offeringForVmOfThisAccount = mock(ServiceOfferingVO.class); @@ -589,4 +583,4 @@ public class ImplicitPlannerTest { } } } -} +} \ No newline at end of file