From 227e67533947f03d3113df84b729d5e0e19a7102 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Fri, 16 Dec 2022 17:32:49 +0800 Subject: [PATCH 1/5] * Fix bug #30989. --- module/zanode/view/create.html.php | 4 ++-- module/zanode/view/edit.html.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/module/zanode/view/create.html.php b/module/zanode/view/create.html.php index 2ff7038dbc..2823b062bd 100644 --- a/module/zanode/view/create.html.php +++ b/module/zanode/view/create.html.php @@ -23,11 +23,11 @@ zanode->hostName;?> + zanode->name;?> zanode->nameValid}\"");?> - zanode->image;?> @@ -67,7 +67,7 @@ - + goback, '', "class='btn btn-wide btn-back'");?> diff --git a/module/zanode/view/edit.html.php b/module/zanode/view/edit.html.php index 6af26b9953..400b41a099 100644 --- a/module/zanode/view/edit.html.php +++ b/module/zanode/view/edit.html.php @@ -67,7 +67,7 @@ - + goback, '', "class='btn btn-wide btn-back'");?> From 0d454a364927716237d21fe70b7a131d24013610 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Fri, 16 Dec 2022 17:46:22 +0800 Subject: [PATCH 2/5] * Fix bug #30979. --- module/zahost/lang/de.php | 1 + module/zahost/lang/en.php | 1 + module/zahost/lang/fr.php | 1 + module/zahost/lang/zh-cn.php | 1 + module/zahost/view/browse.html.php | 6 ++++-- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index fb872e4165..36a2a6f17f 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -41,6 +41,7 @@ $lang->zahost->initNotice = 'Save successfully, initialize the ZAhost o $lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode'; $lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode'; $lang->zahost->undeletedNotice = "The host has nodes that cannot be deleted."; +$lang->zahost->uninitNotice = 'Please init the host first'; $lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.'; $lang->zahost->init = new stdclass; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index fb872e4165..36a2a6f17f 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -41,6 +41,7 @@ $lang->zahost->initNotice = 'Save successfully, initialize the ZAhost o $lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode'; $lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode'; $lang->zahost->undeletedNotice = "The host has nodes that cannot be deleted."; +$lang->zahost->uninitNotice = 'Please init the host first'; $lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.'; $lang->zahost->init = new stdclass; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index fdcf224784..c9cf30147f 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -41,6 +41,7 @@ $lang->zahost->initNotice = 'Save successfully, initialize the ZAhost o $lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode'; $lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode'; $lang->zahost->undeletedNotice = "The host has nodes that cannot be deleted."; +$lang->zahost->uninitNotice = 'Please init the host first'; $lang->zahost->netError = 'Unable to connect to the host, please check the network and try again.'; $lang->zahost->init = new stdclass; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index f868f6e8de..ef47755ef8 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -41,6 +41,7 @@ $lang->zahost->initNotice = '保存成功,请您初始化宿主机或 $lang->zahost->createZanodeNotice = '初始化成功,您现在可以创建执行节点了。'; $lang->zahost->downloadImageNotice = '初始化成功,请下载镜像用于创建执行节点。'; $lang->zahost->undeletedNotice = "宿主机下存在执行节点无法删除。"; +$lang->zahost->uninitNotice = '请先初始化宿主机'; $lang->zahost->netError = '无法连接到宿主机,请检查网络后重试。'; $lang->zahost->init = new stdclass; diff --git a/module/zahost/view/browse.html.php b/module/zahost/view/browse.html.php index b5a7113c77..c93829ca79 100644 --- a/module/zahost/view/browse.html.php +++ b/module/zahost/view/browse.html.php @@ -70,10 +70,12 @@ heartbeat) ? '' : $host->heartbeat;?> hostID]) ? 'disabled' : '';?> - hostID]) ? $lang->zahost->delete : $lang->zahost->undeletedNotice;?> + hostID]) ? $lang->zahost->undeletedNotice : $lang->zahost->delete;?> hostID}", $host, 'list');?> createLink('zahost', 'delete', "hostID={$host->id}"), '', 'hiddenwin', "title='$title' class='btn $disabled'");;?> - hostID}", $host, 'list', 'snap-house', '', 'iframe', true, "data-width='60%'", $lang->zahost->image->list);?> + status == 'wait') ? 'disabled' : '';?> + status == 'wait') ? $lang->zahost->uninitNotice: $lang->zahost->image->list;?> + hostID}", $host, 'list', 'snap-house', '', "iframe $disabled", true, "data-width='60%'", $title);?> hostID}", $host, 'list', 'refresh', '', ' init', false, "data-placement='bottom'", $lang->zahost->init->title);?> From 00a86549b0b27a068e030083191bd1f13b91c34b Mon Sep 17 00:00:00 2001 From: zhaoke Date: Fri, 16 Dec 2022 11:08:45 +0000 Subject: [PATCH 3/5] Fix bug 30974. --- module/testtask/lang/de.php | 1 + module/testtask/lang/en.php | 1 + module/testtask/lang/fr.php | 1 + module/testtask/lang/vi.php | 1 + module/testtask/lang/zh-cn.php | 1 + module/testtask/model.php | 59 +++++++++++++++++++++++++++++++--- 6 files changed, 60 insertions(+), 4 deletions(-) diff --git a/module/testtask/lang/de.php b/module/testtask/lang/de.php index 57a64c7fb0..e30852370f 100644 --- a/module/testtask/lang/de.php +++ b/module/testtask/lang/de.php @@ -108,6 +108,7 @@ $lang->testtask->caseCount = 'Case Count'; $lang->testtask->passCount = 'Pass'; $lang->testtask->failCount = 'Fail'; $lang->testtask->summary = '%s cases, %s failures, %s time.'; +$lang->testtask->stepSummary = 'Total %s steps, %s passes, %s failures.'; $lang->testtask->pageSummary = 'Total testtasks: %s.'; $lang->testtask->mySummary = 'Total testtasks: %s, Wait: %s, Testing: %s, Blocked: %s.'; $lang->testtask->allSummary = 'Total testtasks: %s, Wait: %s, Testing: %s, Blocked: %s, Done: %s.'; diff --git a/module/testtask/lang/en.php b/module/testtask/lang/en.php index 8e8ad465f7..b16f51140c 100644 --- a/module/testtask/lang/en.php +++ b/module/testtask/lang/en.php @@ -108,6 +108,7 @@ $lang->testtask->caseCount = 'Case Count'; $lang->testtask->passCount = 'Pass'; $lang->testtask->failCount = 'Fail'; $lang->testtask->summary = '%s cases, %s failures, %s time.'; +$lang->testtask->stepSummary = 'Total %s steps, %s passes, %s failures.'; $lang->testtask->pageSummary = 'Total testtasks: %s.'; $lang->testtask->mySummary = 'Total testtasks: %s, Wait: %s, Testing: %s, Blocked: %s.'; $lang->testtask->allSummary = 'Total testtasks: %s, Wait: %s, Testing: %s, Blocked: %s, Done: %s.'; diff --git a/module/testtask/lang/fr.php b/module/testtask/lang/fr.php index 461b984441..8c0081f4d9 100644 --- a/module/testtask/lang/fr.php +++ b/module/testtask/lang/fr.php @@ -108,6 +108,7 @@ $lang->testtask->caseCount = 'Compteur CasTest'; $lang->testtask->passCount = 'Pass'; $lang->testtask->failCount = 'Fail'; $lang->testtask->summary = '%s CasTest, %s échecs, %s heures.'; +$lang->testtask->stepSummary = 'Total %s steps, %s passes, %s failures.'; $lang->testtask->pageSummary = 'Total testtasks: %s.'; $lang->testtask->mySummary = 'Total testtasks: %s, Wait: %s, Testing: %s, Blocked: %s.'; $lang->testtask->allSummary = 'Total testtasks: %s, Wait: %s, Testing: %s, Blocked: %s, Done: %s.'; diff --git a/module/testtask/lang/vi.php b/module/testtask/lang/vi.php index e41c0ff730..9a15146c45 100644 --- a/module/testtask/lang/vi.php +++ b/module/testtask/lang/vi.php @@ -97,6 +97,7 @@ $lang->testtask->caseCount = 'Case Count'; $lang->testtask->passCount = 'Pass'; $lang->testtask->failCount = 'Fail'; $lang->testtask->summary = '%s cases, %s failures, %s time.'; +$lang->testtask->stepSummary = 'Total %s steps, %s passes, %s failures.'; $lang->testtask->beginAndEnd = 'Thời gian'; $lang->testtask->to = 'Tới'; diff --git a/module/testtask/lang/zh-cn.php b/module/testtask/lang/zh-cn.php index bbfe4ee8fc..4074414ce8 100644 --- a/module/testtask/lang/zh-cn.php +++ b/module/testtask/lang/zh-cn.php @@ -108,6 +108,7 @@ $lang->testtask->caseCount = '用例数'; $lang->testtask->passCount = '成功'; $lang->testtask->failCount = '失败'; $lang->testtask->summary = '有%s个用例,失败%s个,耗时%s。'; +$lang->testtask->stepSummary = '共有%s个步骤,%s个通过,%s个失败。'; $lang->testtask->pageSummary = '本页共 %s 个测试单。'; $lang->testtask->mySummary = '本页共 %s 个测试单,待测试测试单 %s,测试中测试单 %s,被阻塞测试单 %s。'; $lang->testtask->allSummary = '本页共 %s 个测试单,待测试测试单 %s,测试中测试单 %s,被阻塞测试单 %s,已测测试单 %s。'; diff --git a/module/testtask/model.php b/module/testtask/model.php index 07e71b7d35..a2fccb6c1e 100755 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -1448,12 +1448,10 @@ class testtaskModel extends model if(!empty($result->ZTFResult)) { - $result->ZTFResult = json_decode($result->ZTFResult); - $result->ZTFResult = empty($result->ZTFResult->log) ? '' : $result->ZTFResult->log; - $result->ZTFResult = "
  • " . str_replace(array("\r", "\n", "\r\n"), "
  • ", $result->ZTFResult) . "
  • "; + $result->ZTFResult = $this->formatZtfLog($result->ZTFResult, $result->stepResults); } - $result->files = zget($resultFiles, $resultID, array()); //Get files of case result. + $result->files = zget($resultFiles, $resultID, array()); //Get files of case result. if(isset($relatedSteps[$result->version])) { $relatedStep = $relatedSteps[$result->version]; @@ -1477,6 +1475,59 @@ class testtaskModel extends model return $results; } + /** + * Format ztf log. + * + * @param string $log + * @access public + * @return string + */ + public function formatZtfLog($result, $stepResults) + { + $logObj = json_decode($result); + $logs = empty($logObj->log) ? '' : $logObj->log; + if(empty($logs)) return ''; + + $logs = str_replace(array("\r", "\n", "\r\n"), "\n", $logs); + $logList = explode("\n", $logs); + $logHtml = ""; + + foreach($logList as $log) + { + $log = preg_replace("/^[\d\-:.\x20]+/", '', $log); + $log = trim($log); + if(empty($log)) continue; + $log = preg_replace(array("/:\x20失败/", "/:\x20fail/", "/:\x20成功/", "/:\x20pass/"), array(': 失败',': fail',': 成功',': pass'), $log); + + $logHtml .= "
  • " . $log . "
  • "; + } + + if(!empty($stepResults)) + { + $total = count($stepResults); + $failCount = $passCount = 0; + + foreach($stepResults as $step) + { + if($step['result'] == 'pass') + { + $passCount++; + } + elseif($step['result'] == 'fail') + { + $failCount++; + } + } + + $caseResult = $passCount ? 'pass':'fail'; + $logHtml .= "
  • " + . sprintf($this->lang->testtask->stepSummary, $total, $passCount, $failCount) + . "
  • "; + } + + return $logHtml; + } + /** * Judge an action is clickable or not. * From 769c65781ba39cba02a24cb339d52c42a73b2d32 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Fri, 16 Dec 2022 19:16:56 +0800 Subject: [PATCH 4/5] * Fix bug #30971. --- module/common/view/successmodal.html.php | 5 ++-- module/testcase/control.php | 4 ++- module/testcase/view/automation.html.php | 36 +++++++++++++++++++++++- module/zanode/control.php | 20 +++++++++++-- 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/module/common/view/successmodal.html.php b/module/common/view/successmodal.html.php index 418d2e92df..4933fc4dfa 100644 --- a/module/common/view/successmodal.html.php +++ b/module/common/view/successmodal.html.php @@ -16,8 +16,9 @@ diff --git a/module/testcase/control.php b/module/testcase/control.php index 53809895dc..230db9a162 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -2375,7 +2375,7 @@ class testcase extends control * @access public * @return void */ - public function automation($productID) + public function automation($productID = 0) { $this->loadModel('zanode'); $nodeList = $this->zanode->getPairs(); @@ -2397,6 +2397,8 @@ class testcase extends control $this->view->automation = $automation; $this->view->nodeList = $nodeList; $this->view->productID = $productID; + $this->view->products = $this->product->getPairs('', 0, '', 'all'); + $this->display(); } diff --git a/module/testcase/view/automation.html.php b/module/testcase/view/automation.html.php index a580d284b2..0f625b2781 100644 --- a/module/testcase/view/automation.html.php +++ b/module/testcase/view/automation.html.php @@ -20,6 +20,12 @@
    + + + + + + @@ -34,7 +40,7 @@ @@ -43,4 +49,32 @@ + diff --git a/module/zanode/control.php b/module/zanode/control.php index dbba606977..0777a637b0 100644 --- a/module/zanode/control.php +++ b/module/zanode/control.php @@ -142,8 +142,8 @@ class zanode extends control $this->view->node = $this->zanode->getNodeById($nodeID); $this->view->notice = $this->lang->zanode->init->initSuccessNoticeTitle; $this->view->buttonName = $this->lang->zanode->init->button; - $productID = $this->session->product ? $this->session->product : 0; - $this->view->modalLink = $this->createLink('testcase', 'browse', "productID={$productID}"); + $this->view->modalLink = $this->createLink('testcase', 'automation', 0, '', true); + $this->view->modalClass = 'iframe'; $this->view->closeLink = $this->createLink('zanode', 'browse'); $this->display(); @@ -381,7 +381,21 @@ class zanode extends control } /** - * ajaxRunZTFScript + * Ajax: get ZTF script. + * + * @access public + * @return void + */ + public function ajaxGetZTFScript($type = 'product', $objectID = 0) + { + $script = array(); + if($type == '') $script = $this->zanode->getAutomationByID($objectID); + if($type == 'product') $script = $this->zanode->getAutomationByProduct($objectID); + return $this->send(array('result' => 'success', 'data' => $script)); + } + + /** + * Ajax: run ZTF script. * * @param int $scriptID * @access public From 26d746598eab75c61be8e43c32eba27b0739c67c Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Fri, 16 Dec 2022 20:20:06 +0800 Subject: [PATCH 5/5] * Fix bug for zanode. --- module/testtask/control.php | 1 + module/zanode/model.php | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/module/testtask/control.php b/module/testtask/control.php index 3d3eb21b60..d12e5cae63 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -1239,6 +1239,7 @@ class testtask extends control { $resultID = $this->testtask->initResult($runID, $caseID, $run->case->version, $automation->node); if(!dao::isError()) $this->zanode->runZTFScript($automation->id, $caseID, $resultID); + if(dao::isError()) return print(js::error(dao::getError()) . js::locate($this->createLink('zanode', 'browse'), 'parent')); } if(!empty($_POST)) diff --git a/module/zanode/model.php b/module/zanode/model.php index 72ef622a27..62dc0eca34 100644 --- a/module/zanode/model.php +++ b/module/zanode/model.php @@ -725,6 +725,13 @@ class zanodemodel extends model { $automation = $this->getAutomationByID($scriptID); $node = $this->getNodeByID($automation->node); + + if(empty($node) or $node->status != 'running' or !$node->ip or !$node->ztf or !$node->tokenSN) + { + $this->dao->delete()->from(TABLE_TESTRESULT)->where('id')->eq($task)->exec(); + return dao::$errors = $this->lang->zanode->runTimeout; + } + $params = array( 'cmd' => $automation->shell, 'ids' => strval($caseID), @@ -733,7 +740,7 @@ 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($result->code != 0) + if(empty($result) or $result->code != 0) { $this->dao->delete()->from(TABLE_TESTRESULT)->where('id')->eq($task)->exec(); return dao::$errors = $this->lang->zanode->runTimeout;
    testcase->product;?>
    zanode->common;?> node) ? $automation->node : '', "class='form-control picker-select'");?>
    - + id);?>