* Test cancelDownload function.
This commit is contained in:
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 zahostModel->cancelDownload();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 取消下载 Ubuntu20.04 镜像成功属性status @canceled
|
||||
- 取消下载 win10 镜像成功属性status @canceled
|
||||
- 取消下载 test 镜像失败 @取消下载镜像任务失败
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/zahost.class.php';
|
||||
su('admin');
|
||||
|
||||
$host = zdTable('host');
|
||||
$host->id->range('1');
|
||||
$host->type->range('zahost');
|
||||
$host->name->range('宿主机1');
|
||||
$host->extranet->range('10.0.1.222');
|
||||
$host->zap->range('55001');
|
||||
$host->gen(1);
|
||||
|
||||
$image = zdTable('image');
|
||||
$image->config('image');
|
||||
$image->name->range('Ubuntu20.04,win10,test');
|
||||
$image->gen(3);
|
||||
|
||||
$imageID = array(1, 2, 3);
|
||||
|
||||
$zahost = new zahostTest();
|
||||
r($zahost->cancelDownloadTest($imageID[0])) && p('status') && e('canceled'); //取消下载 Ubuntu20.04 镜像成功
|
||||
r($zahost->cancelDownloadTest($imageID[1])) && p('status') && e('canceled'); //取消下载 win10 镜像成功
|
||||
r($zahost->cancelDownloadTest($imageID[2])) && p('0') && e('取消下载镜像任务失败'); //取消下载 test 镜像失败
|
||||
@@ -152,10 +152,29 @@ class zahostTest
|
||||
$this->objectModel->downloadImage($image);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
$newImage = $this->objectModel->getImageByID($imageID);
|
||||
return $this->objectModel->getImageByID($imageID);
|
||||
return $newImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试取消下载镜像。
|
||||
* Test cancel download image.
|
||||
*
|
||||
* @param int $imageID
|
||||
* @access public
|
||||
* @return array|object
|
||||
*/
|
||||
public function cancelDownloadTest(int $imageID): array|object
|
||||
{
|
||||
$image = $this->objectModel->getImageByID($imageID);
|
||||
$image->address = "https://pkg.qucheng.com/zenagent/image/{$image->name}.qcow2";
|
||||
|
||||
$this->objectModel->cancelDownload($image);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $this->objectModel->getImageByID($imageID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试获取按主机分组的执行节点列表。
|
||||
* Test get node group by host.
|
||||
|
||||
Reference in New Issue
Block a user