mirror of https://github.com/apache/cloudstack.git
Add DeleteTemplate unit test.
This commit is contained in:
parent
26424ff2a8
commit
41272c976e
|
|
@ -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<TemplateApiResult> future = new AsyncCallFuture<TemplateApiResult>();
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@
|
|||
<parameter name="primary-storage-want-to-add" value="nfs://192.168.56.2/opt/storage/primarynfs"/>
|
||||
<parameter name="devcloud-local-storage-uuid" value="cd10cac1-4772-92e5-5da6-c2bc16b1ce1b"/>
|
||||
<parameter name="devcloud-host-uuid" value="759ee4c9-a15a-297b-67c6-ac267d8aa429"/>
|
||||
<!-- <parameter name="devcloud-secondary-storage" value="nfs://192.168.56.10/opt/storage/secondary"/> -->
|
||||
<parameter name="devcloud-secondary-storage" value="nfs://nfs2.lab.vmops.com:/export/home/edison/secondary" />
|
||||
<parameter name="devcloud-secondary-storage" value="nfs://192.168.56.10/opt/storage/secondary"/>
|
||||
<parameter name="primary-storage-uuid-want-to-add" value="759ee4c9-a15a-297b-67c6-ac267d8abe29" />
|
||||
|
||||
<parameter name="s3-accesskey" value="OYAZXCAFUC1DAFOXNJWI"/>
|
||||
<parameter name="s3-secretkey" value="YHpRtzNDwl12DtrQmwRvdpnf2xK2AeVM30rXxQ=="/>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -193,13 +193,20 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
|||
}
|
||||
}
|
||||
|
||||
protected Void createTemplateAsyncCallBack(AsyncCallbackDispatcher<HypervisorTemplateAdapter,
|
||||
TemplateApiResult> callback, CreateTemplateContext<TemplateApiResult> 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<HypervisorTemplateAdapter, TemplateApiResult> callback,
|
||||
CreateTemplateContext<TemplateApiResult> 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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue