* Merge branch 'zenops_46_zhaoke_77683' into zenops_46_tanghucheng.

This commit is contained in:
tanghucheng
2022-12-07 14:10:33 +08:00
parent 30d183fab5
commit 8a43a646ff
11 changed files with 167 additions and 7 deletions
+2 -2
View File
@@ -102,8 +102,8 @@ CREATE TABLE `zt_image` (
CREATE TABLE `zt_automation` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`node` int(11) unsigned NOT NULL DEFAULT 0,
`product` int(11) unsigned NOT NULL DEFAULT 0,
`path` varchar(255) NOT NULL DEFAULT '',
`product` int(11) unsigned NOT NULL DEFAULT 0,
`scriptPath` varchar(255) NOT NULL DEFAULT '',
`shell` mediumtext NOT NULL,
`createdBy` varchar(30) NOT NULL,
`createdDate` datetime NOT NULL,
+1 -1
View File
@@ -7321,7 +7321,7 @@ CREATE TABLE `zt_automation` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`node` int(11) unsigned NOT NULL DEFAULT 0,
`product` int(11) unsigned NOT NULL DEFAULT 0,
`path` varchar(255) NOT NULL DEFAULT '',
`scriptPath` varchar(255) NOT NULL DEFAULT '',
`shell` mediumtext NOT NULL,
`createdBy` varchar(30) NOT NULL,
`createdDate` datetime NOT NULL,
+2
View File
@@ -1074,6 +1074,7 @@ $lang->resource->testcase->confirmLibcaseChange = 'confirmLibcaseChange';
$lang->resource->testcase->ignoreLibcaseChange = 'ignoreLibcaseChange';
$lang->resource->testcase->batchConfirmStoryChange = 'batchConfirmStoryChange';
$lang->resource->testcase->importToLib = 'importToLib';
$lang->resource->testcase->automation = 'automation';
$lang->testcase->methodOrder[0] = 'index';
$lang->testcase->methodOrder[5] = 'browse';
@@ -1104,6 +1105,7 @@ $lang->testcase->methodOrder[125] = 'confirmLibcaseChange';
$lang->testcase->methodOrder[130] = 'ignoreLibcaseChange';
$lang->testcase->methodOrder[135] = 'batchConfirmStoryChange';
$lang->testcase->methodOrder[140] = 'importToLib';
$lang->testcase->methodOrder[145] = 'automation';
/* Test task. */
$lang->resource->testtask = new stdclass();
+33
View File
@@ -89,6 +89,7 @@ class testcase extends control
public function browse($productID = 0, $branch = '', $browseType = 'all', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1, $projectID = 0)
{
$this->loadModel('datatable');
$this->app->loadLang('zanode');
/* Set browse type. */
$browseType = strtolower($browseType);
@@ -2349,6 +2350,38 @@ class testcase extends control
$this->display();
}
/**
* Automation test setting.
*
* @param int $productID
* @access public
* @return void
*/
public function automation($productID)
{
$this->loadModel('zanode');
$nodeList = $this->zanode->getPairs();
$automation = $this->dao->select('*')->from(TABLE_AUTOMATION)->where('product')->eq($productID)->fetch();
if($_POST)
{
$this->zanode->setAutomationSetting();
if(dao::isError()) return print(js::error(dao::getError()));
$nodeID = $_POST['node'];
$node = $this->zanode->getNodeByID($_POST['node']);
return print(js::closeModal('parent.parent', 'this', "function(){parent.parent.location.reload();}"));
}
$this->view->title = $this->lang->zanode->automation;
$this->view->automation = $automation;
$this->view->nodeList = $nodeList;
$this->view->productID = $productID;
$this->display();
}
/**
* Export case getModuleByStory
*
+46
View File
@@ -0,0 +1,46 @@
<?php
/**
* The close file of task module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author chunsheng wang <chunsheng@cnezsoft.com>
* @package task
* @version $Id: cancel.html.php 935 2010-07-06 07:49:24Z jajacn@126.com $
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<div class='main-header'>
<h2>
<span title='<?php echo $lang->zanode->automation;?>'><?php echo $lang->zanode->automation;?></span>
</h2>
</div>
<form method='post' target='hiddenwin'>
<table class='table table-form'>
<tr>
<th class='w-80px'><?php echo $lang->zanode->common;?></th>
<td class='required'><?php echo html::select('node', $nodeList, !empty($automation->node) ? $automation->node : '', "class='form-control picker-select'");?></td>
</tr>
<tr>
<th><?php echo $lang->zanode->scriptPath;?></th>
<td class='required'><?php echo html::input('scriptPath', !empty($automation->scriptPath) ? $automation->scriptPath : '', "class='form-control'");?></td>
</tr>
<tr>
<th><?php echo $lang->zanode->shell;?></th>
<td><?php echo html::textarea('shell', !empty($automation->shell) ? $automation->shell : '', "rows='6' class='form-control'");?></td>
</tr>
<tr>
<td colspan='2' class='text-center'>
<?php echo html::hidden('product', $productID);?>
<?php if($automation) echo html::hidden('id', $automation->id);?>
<?php echo html::submitButton();?>
</td>
</tr>
</table>
</form>
</div>
</div>
<?php include '../../common/view/footer.html.php';?>
+4 -1
View File
@@ -116,6 +116,9 @@
<?php if(!isonlybody()):?>
<div class='btn-toolbar pull-right'>
<?php if(!empty($productID)): ?>
<div class='btn-group'>
<?php common::printLink('testcase', 'automation', "productID=$productID", "<i class='icon-testcase muted'> </i>" . $lang->zanode->automation, '', "class='btn btn-link iframe'", true, true)?>
</div>
<div class='btn-group'>
<button type='button' class='btn btn-link dropdown-toggle' data-toggle='dropdown'>
<i class='icon icon-export muted'></i> <?php echo $lang->export ?>
@@ -226,7 +229,7 @@ $(function()
}
}
if((hasNeedconfirmTab || hasGroupTab || hasZerocaseTab) && (hasbysuiteTab || hasBrowseunitsTab))
if((hasNeedconfirmTab || hasGroupTab || hasZerocaseTab) && (hasbysuiteTab || hasBrowseunitsTab))
{
if(hasZerocaseTab)
{
+9 -2
View File
@@ -42,12 +42,19 @@ $lang->zanode->confirmSuspend = "Are you sure to suspend the execution node?"
$lang->zanode->confirmResume = "Are you sure to resume the execution node?";
$lang->zanode->actionSuccess = 'Success';
$lang->zanode->deleted = "Deleted";
$lang->zanode->scriptPath = "Script path";
$lang->zanode->shell = "Shell";
$lang->zanode->automation = "Automation";
$lang->automation = new stdClass();
$lang->automation->path = $lang->zanode->scriptPath;
$lang->automation->node = $lang->zanode->common;
$lang->zanode->notFoundAgent = 'No Agent service is found';
$lang->zanode->createVmFail = 'Failed to create a execution node';
$lang->zanode->noVncPort = 'Failed to get vnc port';
$lang->zanode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol";
$lang->zanode->empty = 'No zanode is found';
$lang->zanode->nameValid = "Name must be letters, numbers,'-','_','.', And cannot begin with a symbol";
$lang->zanode->empty = 'Execution node not found.';
$lang->zanode->empty = 'No Execution Node';
$lang->zanode->createImaging = 'Creating';
+7
View File
@@ -42,6 +42,13 @@ $lang->zanode->confirmSuspend = "Are you sure to suspend the execution node?"
$lang->zanode->confirmResume = "Are you sure to resume the execution node?";
$lang->zanode->actionSuccess = 'Success';
$lang->zanode->deleted = "Deleted";
$lang->zanode->scriptPath = "Script path";
$lang->zanode->shell = "Shell";
$lang->zanode->automation = "Automation";
$lang->automation = new stdClass();
$lang->automation->path = $lang->zanode->scriptPath;
$lang->automation->node = $lang->zanode->common;
$lang->zanode->notFoundAgent = 'No Agent service is found';
$lang->zanode->createVmFail = 'Failed to create a execution node';
+7
View File
@@ -42,6 +42,13 @@ $lang->zanode->confirmSuspend = "Are you sure to suspend the execution node?"
$lang->zanode->confirmResume = "Are you sure to resume the execution node?";
$lang->zanode->actionSuccess = 'Success';
$lang->zanode->deleted = "Deleted";
$lang->zanode->scriptPath = "Script path";
$lang->zanode->shell = "Shell";
$lang->zanode->automation = "Automation";
$lang->automation = new stdClass();
$lang->automation->path = $lang->zanode->scriptPath;
$lang->automation->node = $lang->zanode->common;
$lang->zanode->notFoundAgent = 'No Agent service is found';
$lang->zanode->createVmFail = 'Failed to create a execution node';
+7
View File
@@ -42,6 +42,13 @@ $lang->zanode->confirmSuspend = "您确定暂停执行节点吗?";
$lang->zanode->confirmResume = "您确定恢复执行节点吗?";
$lang->zanode->actionSuccess = '操作成功';
$lang->zanode->deleted = "已删除";
$lang->zanode->scriptPath = "脚本目录";
$lang->zanode->shell = "shell命令";
$lang->zanode->automation = "自动化测试";
$lang->automation = new stdClass();
$lang->automation->path = $lang->zanode->scriptPath;
$lang->automation->node = $lang->zanode->common;
$lang->zanode->notFoundAgent = '没有发现Agent服务';
$lang->zanode->createVmFail = '创建执行节点失败';
+49 -1
View File
@@ -352,6 +352,22 @@ class zanodemodel extends model
->fetchAll('id');
}
/**
* Get node pairs.
*
* @param string $orderBy
* @access public
* @return void
*/
public function getPairs($orderBy = 'id_desc')
{
return $this->dao->select('*')->from(TABLE_ZAHOST)
->where('deleted')->eq(0)
->andWhere("type")->eq('node')
->orderBy($orderBy)
->fetchPairs('id', 'name');
}
/**
* Get node list by hostID.
*
@@ -518,7 +534,7 @@ class zanodemodel extends model
$agnetUrl = 'http://' . $node->ip . ':' . $node->hzap . static::KVM_TOKEN_PATH;
$result = json_decode(commonModel::http("$agnetUrl?port={$node->vnc}", array(), array(CURLOPT_CUSTOMREQUEST => 'GET'), array("Authorization:$node->hTokenSN"), 'json'));
if(empty($result) or $result->code != 'success') return false;
$returnData = new stdClass();
@@ -565,6 +581,13 @@ class zanodemodel extends model
return $result;
}
/**
* Build operateMenu for browse view.
*
* @param int $node
* @access public
* @return void
*/
public function buildOperateMenu($node)
{
if($node->deleted) return '';
@@ -626,4 +649,29 @@ class zanodemodel extends model
"ZTF" => $result->data->ztfStatus,
);
}
/**
* Set automation setting.
*
* @access public
* @return void
*/
public function setAutomationSetting()
{
$now = helper::now();
$data = fixer::input('post')
->setDefault('createdBy', $this->app->user->account)
->setDefault('createdDate', $now)
->remove('uid')
->get();
$this->dao->replace(TABLE_AUTOMATION)
->data($data)
->batchcheck('node,scriptPath', 'notempty')
->autoCheck()
->exec();
if(dao::isError()) return false;
return $this->dao->lastInsertID();
}
}