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 682ED10BE0 for ; Tue, 7 May 2013 06:02:48 +0000 (UTC) Received: (qmail 58317 invoked by uid 500); 7 May 2013 06:02:48 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 58300 invoked by uid 500); 7 May 2013 06:02:48 -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 58287 invoked by uid 99); 7 May 2013 06:02:47 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 May 2013 06:02:47 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 6FB098883AE; Tue, 7 May 2013 06:02:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mchen@apache.org To: commits@cloudstack.apache.org Message-Id: <1d19e855646e43939032ab5b919504cc@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/object_store to 41272c9 Date: Tue, 7 May 2013 06:02:47 +0000 (UTC) Updated Branches: refs/heads/object_store 26424ff2a -> 41272c976 Add DeleteTemplate unit test. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/41272c97 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/41272c97 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/41272c97 Branch: refs/heads/object_store Commit: 41272c976e5ffddacddf2fdff9d00a065da0c8a3 Parents: 26424ff Author: Min Chen Authored: Mon May 6 23:02:28 2013 -0700 Committer: Min Chen Committed: Mon May 6 23:02:28 2013 -0700 ---------------------------------------------------------------------- .../cloudstack/storage/test/TemplateTest.java | 21 ++++++++++++++- .../integration-test/test/resource/testng.xml | 4 +- .../cloud/storage/download/DownloadListener.java | 2 +- .../cloud/template/HypervisorTemplateAdapter.java | 21 ++++++++++----- 4 files changed, 37 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/41272c97/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TemplateTest.java ---------------------------------------------------------------------- diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TemplateTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TemplateTest.java index 7749c07..a38b91c 100644 --- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TemplateTest.java +++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/TemplateTest.java @@ -61,7 +61,7 @@ public class TemplateTest extends CloudStackTestNGBase { @Inject DownloadMonitorImpl downloadMonitor; - + long dcId; long templateId; @@ -134,4 +134,23 @@ public class TemplateTest extends CloudStackTestNGBase { } } + // @Test + public void deleteTemplate() { + TemplateInfo template = templateFactory.getTemplate(templateId); + DataStore store = dataStoreMgr.getImageStore(dcId); + AsyncCallFuture future = new AsyncCallFuture(); + templateSvr.deleteTemplateAsync(template); + try { + TemplateApiResult result = future.get(); + assertTrue(result.isSuccess(), "failed to delete template: " + result.getResult()); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + assertTrue(false, e.getMessage()); + } catch (ExecutionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + assertTrue(false, e.getMessage()); + } + } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/41272c97/engine/storage/integration-test/test/resource/testng.xml ---------------------------------------------------------------------- diff --git a/engine/storage/integration-test/test/resource/testng.xml b/engine/storage/integration-test/test/resource/testng.xml index dbadae1..4b07448 100644 --- a/engine/storage/integration-test/test/resource/testng.xml +++ b/engine/storage/integration-test/test/resource/testng.xml @@ -27,8 +27,8 @@ - - + + http://git-wip-us.apache.org/repos/asf/cloudstack/blob/41272c97/server/src/com/cloud/storage/download/DownloadListener.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/download/DownloadListener.java b/server/src/com/cloud/storage/download/DownloadListener.java index 84c51b1..001b45d 100755 --- a/server/src/com/cloud/storage/download/DownloadListener.java +++ b/server/src/com/cloud/storage/download/DownloadListener.java @@ -99,7 +99,7 @@ public class DownloadListener implements Listener { public static final Logger s_logger = Logger.getLogger(DownloadListener.class.getName()); public static final int SMALL_DELAY = 100; - public static final long STATUS_POLL_INTERVAL = 300000L; //10000L; + public static final long STATUS_POLL_INTERVAL = 10000L; public static final String DOWNLOADED=Status.DOWNLOADED.toString(); public static final String NOT_DOWNLOADED=Status.NOT_DOWNLOADED.toString(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/41272c97/server/src/com/cloud/template/HypervisorTemplateAdapter.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/template/HypervisorTemplateAdapter.java b/server/src/com/cloud/template/HypervisorTemplateAdapter.java index 973b558..35bc5e5 100755 --- a/server/src/com/cloud/template/HypervisorTemplateAdapter.java +++ b/server/src/com/cloud/template/HypervisorTemplateAdapter.java @@ -193,13 +193,20 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { } } - protected Void createTemplateAsyncCallBack(AsyncCallbackDispatcher callback, CreateTemplateContext context) { - TemplateInfo template = context.template; - VMTemplateVO tmplt = this._tmpltDao.findById(template.getId()); - long accountId = tmplt.getAccountId(); - if (template.getSize() != null) { - _resourceLimitMgr.incrementResourceCount(accountId, ResourceType.secondary_storage, template.getSize()); + protected Void createTemplateAsyncCallBack(AsyncCallbackDispatcher callback, + CreateTemplateContext context) { + TemplateApiResult result = callback.getResult(); + TemplateInfo template = context.template; + if (result.isFailed()) { + // failed in creating template, we need to remove those already + // populated template entry + _tmpltDao.remove(template.getId()); + } else { + VMTemplateVO tmplt = this._tmpltDao.findById(template.getId()); + long accountId = tmplt.getAccountId(); + if (template.getSize() != null) { + _resourceLimitMgr.incrementResourceCount(accountId, ResourceType.secondary_storage, template.getSize()); + } } return null;