Return-Path: X-Original-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A6420E20B for ; Mon, 18 Feb 2013 17:21:36 +0000 (UTC) Received: (qmail 95818 invoked by uid 500); 18 Feb 2013 17:21:27 -0000 Delivered-To: apmail-incubator-cloudstack-commits-archive@incubator.apache.org Received: (qmail 95703 invoked by uid 500); 18 Feb 2013 17:21:27 -0000 Mailing-List: contact cloudstack-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cloudstack-dev@incubator.apache.org Delivered-To: mailing list cloudstack-commits@incubator.apache.org Received: (qmail 95020 invoked by uid 99); 18 Feb 2013 17:21:26 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Feb 2013 17:21:26 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 56D3582C07F; Mon, 18 Feb 2013 17:21:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: widodh@apache.org To: cloudstack-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [8/38] git commit: refs/heads/qemu-img - CLOUDSTACK-1295 : Added usage unit tests Fixed Component annontation for usage parsers Fixed mvn target to run usage removed UsageServerComponentConfig which is not required Added region_id to account table in clo Message-Id: <20130218172126.56D3582C07F@tyr.zones.apache.org> Date: Mon, 18 Feb 2013 17:21:26 +0000 (UTC) CLOUDSTACK-1295 : Added usage unit tests Fixed Component annontation for usage parsers Fixed mvn target to run usage removed UsageServerComponentConfig which is not required Added region_id to account table in cloud_usage db Conflicts: setup/db/db/schema-40to410.sql Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/7d61ee6e Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/7d61ee6e Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/7d61ee6e Branch: refs/heads/qemu-img Commit: 7d61ee6e99ffa355516da11fc08d30193e109e39 Parents: 3c764c0 Author: Kishan Kavala Authored: Fri Feb 15 18:27:24 2013 +0530 Committer: Kishan Kavala Committed: Fri Feb 15 18:41:28 2013 +0530 ---------------------------------------------------------------------- .../cloudstack/api/command/test/UsageCmdTest.java | 69 ++++++ setup/db/create-schema-premium.sql | 1 + setup/db/db/schema-40to410.sql | 2 + usage/pom.xml | 5 + usage/resources/usageApplicationContext.xml | 5 +- usage/src/com/cloud/usage/UsageManagerImpl.java | 2 + .../cloud/usage/UsageServerComponentConfig.java | 180 --------------- .../usage/parser/NetworkOfferingUsageParser.java | 3 +- .../com/cloud/usage/parser/NetworkUsageParser.java | 2 + .../usage/parser/PortForwardingUsageParser.java | 5 +- .../usage/parser/SecurityGroupUsageParser.java | 3 +- .../com/cloud/usage/parser/StorageUsageParser.java | 3 +- .../cloud/usage/parser/VMInstanceUsageParser.java | 9 +- .../com/cloud/usage/parser/VPNUserUsageParser.java | 3 +- .../com/cloud/usage/parser/VolumeUsageParser.java | 3 +- usage/test/com/cloud/usage/UsageManagerTest.java | 97 ++++++++ .../cloud/usage/UsageManagerTestConfiguration.java | 94 ++++++++ usage/test/resources/UsageManagerTestContext.xml | 42 ++++ 18 files changed, 335 insertions(+), 193 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d61ee6e/api/test/org/apache/cloudstack/api/command/test/UsageCmdTest.java ---------------------------------------------------------------------- diff --git a/api/test/org/apache/cloudstack/api/command/test/UsageCmdTest.java b/api/test/org/apache/cloudstack/api/command/test/UsageCmdTest.java new file mode 100644 index 0000000..1f218f4 --- /dev/null +++ b/api/test/org/apache/cloudstack/api/command/test/UsageCmdTest.java @@ -0,0 +1,69 @@ +// 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. +package org.apache.cloudstack.api.command.test; + +import junit.framework.TestCase; +import org.apache.cloudstack.api.command.admin.usage.GetUsageRecordsCmd; +import org.apache.cloudstack.usage.Usage; +import org.apache.cloudstack.usage.UsageService; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mockito; + +import java.util.ArrayList; +import java.util.List; + +public class UsageCmdTest extends TestCase { + + private GetUsageRecordsCmd getUsageRecordsCmd; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void setUp() { + + getUsageRecordsCmd = new GetUsageRecordsCmd() { + + }; + } + + @Test + public void testExecuteSuccess() { + UsageService usageService = Mockito.mock(UsageService.class); + getUsageRecordsCmd._usageService = usageService; + getUsageRecordsCmd.execute(); + } + + @Test + public void testExecuteEmptyResult() { + + UsageService usageService = Mockito.mock(UsageService.class); + + List usageRecords = new ArrayList(); + + Mockito.when(usageService.getUsageRecords(getUsageRecordsCmd)).thenReturn( + usageRecords); + + getUsageRecordsCmd._usageService = usageService; + getUsageRecordsCmd.execute(); + + } + +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d61ee6e/setup/db/create-schema-premium.sql ---------------------------------------------------------------------- diff --git a/setup/db/create-schema-premium.sql b/setup/db/create-schema-premium.sql index 2f86c0b..e30812b 100644 --- a/setup/db/create-schema-premium.sql +++ b/setup/db/create-schema-premium.sql @@ -137,6 +137,7 @@ CREATE TABLE `cloud_usage`.`account` ( `cleanup_needed` tinyint(1) NOT NULL default '0', `network_domain` varchar(100) COMMENT 'Network domain name of the Vms of the account', `default_zone_id` bigint unsigned, + `region_id` int unsigned NOT NULL, CONSTRAINT `uc_account__uuid` UNIQUE (`uuid`), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d61ee6e/setup/db/db/schema-40to410.sql ---------------------------------------------------------------------- diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql index 7f00441..3ea8bbd 100644 --- a/setup/db/db/schema-40to410.sql +++ b/setup/db/db/schema-40to410.sql @@ -1323,3 +1323,5 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Account Defaults', 'DEFAULT' INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Project Defaults', 'DEFAULT', 'management-server', 'max.project.cpus', '40', 'The default maximum number of cpu cores that can be used for a project'); INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Project Defaults', 'DEFAULT', 'management-server', 'max.project.memory', '40960', 'The default maximum memory (in MB) that can be used for a project'); + +ALTER TABLE `cloud_usage`.`account` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT '1'; http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d61ee6e/usage/pom.xml ---------------------------------------------------------------------- diff --git a/usage/pom.xml b/usage/pom.xml index bf2001b..4b408c4 100644 --- a/usage/pom.xml +++ b/usage/pom.xml @@ -42,6 +42,11 @@ install src test + + + test/resources + + resources http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7d61ee6e/usage/resources/usageApplicationContext.xml ---------------------------------------------------------------------- diff --git a/usage/resources/usageApplicationContext.xml b/usage/resources/usageApplicationContext.xml index 32da93e..0340038 100644 --- a/usage/resources/usageApplicationContext.xml +++ b/usage/resources/usageApplicationContext.xml @@ -31,7 +31,9 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - + + + + + + + + + + + + + + + + + + + + + + + +