* Adjust code for testtask batchRun.
This commit is contained in:
@@ -232,6 +232,7 @@ class testcase extends control
|
||||
$this->view->modulePairs = $showModule ? $this->tree->getModulePairs($productID, 'case', $showModule) : array();
|
||||
$this->view->showBranch = $showBranch;
|
||||
$this->view->libraries = $this->loadModel('caselib')->getLibraries();
|
||||
$this->view->automation = $this->loadModel('zanode')->getAutomationByProduct($productID);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -285,17 +285,38 @@ js::set('cancelURL', $this->createLink('testtask', 'batchRun', "productID=$
|
||||
<script>
|
||||
$('#module' + moduleID).closest('li').addClass('active');
|
||||
$('#' + caseBrowseType + 'Tab').addClass('btn-active-text').find('.text').after(" <span class='label label-light label-badge'><?php echo $pager->recTotal;?></span>");
|
||||
function runAutocase()
|
||||
{
|
||||
var caseIDList = [];
|
||||
$.each($('input[name^=caseIDList]:checked'),function(){
|
||||
caseIDList.push($(this).val());
|
||||
});
|
||||
|
||||
var url = createLink('zanode', 'ajaxRunZTFScript', 'scriptID=<?php echo $automation->id;?>')
|
||||
|
||||
var postData = {'caseIDList' : caseIDList.join(',')};
|
||||
$.post(url, postData, function(result)
|
||||
{
|
||||
if(result.result == 'fail')
|
||||
{
|
||||
alert(result.message);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
function confirmAction(obj)
|
||||
{
|
||||
if(confirm(runCaseConfirm))
|
||||
{
|
||||
setFormAction(confirmURL, '', '#caseList');
|
||||
var result = runAutocase();
|
||||
if(result) setFormAction(confirmURL, '', '#caseList');
|
||||
}
|
||||
else
|
||||
{
|
||||
setFormAction(cancelURL, '', '#caseList');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
<?php if($useDatatable):?>
|
||||
|
||||
@@ -205,6 +205,7 @@ class testsuite extends control
|
||||
$this->view->modules = $this->loadModel('tree')->getOptionMenu($suite->product, 'case', 0, 'all');
|
||||
$this->view->branches = $this->loadModel('branch')->getPairs($suite->product);
|
||||
$this->view->canBeChanged = common::canBeChanged('testsuite', $suite);
|
||||
$this->view->automation = $this->loadModel('zanode')->getAutomationByProduct($productID);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -165,17 +165,38 @@
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<script>
|
||||
function confirmAction()
|
||||
function runAutocase()
|
||||
{
|
||||
var caseIDList = [];
|
||||
$.each($('input[name^=caseIDList]:checked'),function(){
|
||||
caseIDList.push($(this).val());
|
||||
});
|
||||
|
||||
var url = createLink('zanode', 'ajaxRunZTFScript', 'scriptID=<?php echo $automation->id;?>')
|
||||
|
||||
var postData = {'caseIDList' : caseIDList.join(',')};
|
||||
$.post(url, postData, function(result)
|
||||
{
|
||||
if(result.result == 'fail')
|
||||
{
|
||||
alert(result.message);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
function confirmAction(obj)
|
||||
{
|
||||
if(confirm(runCaseConfirm))
|
||||
{
|
||||
setFormAction(confirmURL, '', '#caseList');
|
||||
var result = runAutocase();
|
||||
if(result) setFormAction(confirmURL, '', '#caseList');
|
||||
}
|
||||
else
|
||||
{
|
||||
setFormAction(cancelURL, '', '#caseList');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -579,6 +579,7 @@ class testtask extends control
|
||||
$this->view->suites = $this->loadModel('testsuite')->getSuitePairs($productID);
|
||||
$this->view->suiteName = isset($suiteName) ? $suiteName : $this->lang->testtask->browseBySuite;
|
||||
$this->view->canBeChanged = $canBeChanged;
|
||||
$this->view->automation = $this->loadModel('zanode')->getAutomationByProduct($productID);
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -1233,7 +1234,7 @@ class testtask extends control
|
||||
$confirmURL = inlink('runCase', "runID=$runID&caseID=$caseID&version=$version&confirm=yes");
|
||||
$cancelURL = inlink('runCase', "runID=$runID&caseID=$caseID&version=$version&confirm=no");
|
||||
|
||||
if($automation and $confirm == '') return print(js::confirm($this->lang->zanode->runCaseConfirm, $confirmURL, $cancelURL));
|
||||
if($automation and $confirm == '' and $run->case->auto == 'auto') return print(js::confirm($this->lang->zanode->runCaseConfirm, $confirmURL, $cancelURL));
|
||||
if($confirm == 'yes')
|
||||
{
|
||||
$resultID = $this->testtask->initResult($runID, $caseID, $run->case->version, $automation->node);
|
||||
@@ -1326,11 +1327,6 @@ class testtask extends control
|
||||
|
||||
if($this->post->results)
|
||||
{
|
||||
if($confirm == 'yes')
|
||||
{
|
||||
$this->post->set('node', $automation->node);
|
||||
$this->post->set('automation', $automation->id);
|
||||
}
|
||||
$this->testtask->batchRun($from, $taskID);
|
||||
$this->loadModel('action');
|
||||
foreach(array_keys($this->post->results) as $caseID) $this->action->create('case', $caseID, 'run', '', $taskID);
|
||||
|
||||
@@ -1351,15 +1351,8 @@ class testtaskModel extends model
|
||||
$result->stepResults = serialize($stepResults);
|
||||
$result->lastRunner = $this->app->user->account;
|
||||
$result->date = $now;
|
||||
if(isset($postData->node)) $result->node = $postData->node;
|
||||
|
||||
$this->dao->insert(TABLE_TESTRESULT)->data($result)->autoCheck()->exec();
|
||||
if(!dao::isError() and isset($postData->node))
|
||||
{
|
||||
$resultID = $this->dao->lastInsertID();
|
||||
$this->loadModel('zanode')->runZTFScript($postData->automation, $caseID, $resultID);
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_CASE)->set('lastRunner')->eq($this->app->user->account)->set('lastRunDate')->eq($now)->set('lastRunResult')->eq($caseResult)->where('id')->eq($caseID)->exec();
|
||||
|
||||
if($runID)
|
||||
@@ -1479,7 +1472,7 @@ class testtaskModel extends model
|
||||
}
|
||||
|
||||
/* Get files of step result. */
|
||||
foreach($result->stepResults as $stepID => $stepResult) $result->stepResults[$stepID]['files'] = isset($stepFiles[$resultID][$stepID]) ? $stepFiles[$resultID][$stepID] : array();
|
||||
if(!empty($result->stepResults)) foreach($result->stepResults as $stepID => $stepResult) $result->stepResults[$stepID]['files'] = isset($stepFiles[$resultID][$stepID]) ? $stepFiles[$resultID][$stepID] : array();
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
@@ -166,19 +166,39 @@ if($shortcut.size() > 0)
|
||||
$(function(){$('#casesForm').table();})
|
||||
<?php endif;?>
|
||||
$("thead").find('.c-assignedTo').attr('class', '');
|
||||
function confirmAction()
|
||||
function runAutocase()
|
||||
{
|
||||
var caseIDList = [];
|
||||
$.each($('input[name^=caseIDList]:checked'),function(){
|
||||
caseIDList.push($(this).val());
|
||||
});
|
||||
|
||||
var url = createLink('zanode', 'ajaxRunZTFScript', 'scriptID=<?php echo $automation->id;?>');
|
||||
|
||||
var postData = {'caseIDList' : caseIDList.join(',')};
|
||||
$.post(url, postData, function(result)
|
||||
{
|
||||
if(result.result == 'fail')
|
||||
{
|
||||
alert(result.message);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, 'json');
|
||||
}
|
||||
|
||||
function confirmAction(obj)
|
||||
{
|
||||
if(confirm(runCaseConfirm))
|
||||
{
|
||||
setFormAction(confirmURL, '', '#caseList');
|
||||
var result = runAutocase();
|
||||
if(result) setFormAction(confirmURL, '', '#caseList');
|
||||
}
|
||||
else
|
||||
{
|
||||
setFormAction(cancelURL, '', '#caseList');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(!empty($result->stepResults)):?>
|
||||
<?php foreach($result->stepResults as $stepID => $stepResult):?>
|
||||
<div class="modal fade" id="stepResult<?php echo $result->id . '-' .$stepID;?>">
|
||||
<div class="modal-dialog">
|
||||
@@ -177,6 +178,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach;?>
|
||||
<?php endif;?>
|
||||
<?php endforeach;?>
|
||||
<div id='resultTip' class='hide'><?php if($count > 0) echo $failCount > 0 ? "<span>" . sprintf($lang->testtask->showFail, $failCount) . "</span>":"<span class='text-success'>{$lang->testtask->passAll}</span>";?></div>
|
||||
<style>
|
||||
|
||||
@@ -386,4 +386,30 @@ class zanode extends control
|
||||
|
||||
return $this->send(array('result' => 'success', 'message' => '', 'data' => $result));
|
||||
}
|
||||
|
||||
/**
|
||||
* ajaxRunZTFScript
|
||||
*
|
||||
* @param int $scriptID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxRunZTFScript($scriptID = 0)
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
$caseIDList = $_POST['caseIDList'];
|
||||
$script = $this->zanode->getAutomationByID($scriptID);
|
||||
$cases = $this->loadModel('testcase')->getByList($caseIDList);
|
||||
|
||||
foreach($cases as $id => $case)
|
||||
{
|
||||
$resultID = $this->loadModel('testtask')->initResult(0, $id, $case->version, $script->node);
|
||||
if(!dao::isError()) $this->zanode->runZTFScript($script->id, $id, $resultID);
|
||||
}
|
||||
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
return $this->send(array('result' => 'success', 'message' => 'success'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -738,7 +738,8 @@ class zanodemodel extends model
|
||||
$result = json_decode(commonModel::http("http://{$node->ip}:{$node->ztf}/api/v1/jobs/add", json_encode($params), array(), array("Authorization:$node->tokenSN")));
|
||||
if(empty($result->data) || $result->code != 0)
|
||||
{
|
||||
return dao::$errors[] = $this->lang->zanode->runTimeout;
|
||||
$this->dao->delete()->from(TABLE_TESTRESULT)->where('id')->eq($task)->exec();
|
||||
return dao::$errors = $this->lang->zanode->runTimeout;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user