From 14f45f9ba74fde777dd4de7620f7d5937b194fb4 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Wed, 25 May 2022 13:27:28 -0400 Subject: [PATCH] Removing jenkins files --- .../xcat/tools/jenkins/testreport/email.sh | 398 ---- .../tools/jenkins/testreport/send-report.sh | 43 - .../jenkins/testreport/xCATjkLogAnalyzer.sql | 958 -------- .../jenkins/testreport/xcatjk-log2sql.sh | 462 ---- .../testreport/xcatjk-scanlogs-last3days.sh | 33 - .../xcatjk-scanlogs-redo-everything.sh | 43 - .../jenkins/testreport/xcatjk-scanlogs.sh | 249 --- .../share/xcat/tools/jenkins/xcatjktest | 1966 ----------------- 8 files changed, 4152 deletions(-) delete mode 100644 xCAT-server/share/xcat/tools/jenkins/testreport/email.sh delete mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh delete mode 100644 xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql delete mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh delete mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-scanlogs-last3days.sh delete mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-scanlogs-redo-everything.sh delete mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-scanlogs.sh delete mode 100755 xCAT-server/share/xcat/tools/jenkins/xcatjktest diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh deleted file mode 100644 index 5a999f85a..000000000 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh +++ /dev/null @@ -1,398 +0,0 @@ -#!/bin/bash - -# -# Author: GONG Jie -# Create: 2016-05-27 -# Update: 2016-06-07 -# Version: 0.99 -# -# EXAMPLE -# #!/bin/bash -# -# source /path/to/email.sh -# -# Email report -# -# $report_setTo bob@example.org -# $report_setTo charlie@example.org -# $report_setTo Dave dave@example.org -# $report_setCc trent@example.org -# $report_setBcc eve@example.org -# $report_setFrom Alice alice@example.org -# $report_setSubject "A Sample Email Report" -# -# $report_setText <<-EOF -# Blah blah blah... -# EOF -# -# $report_addAttachmentFile /path/to/doc/document-a4.pdf -# $report_addAttachmentFile /path/to/doc/onepage-a4.pdf -# -# $report_send -# -# SEE ALSO -# RFC 2045, RFC 2046, RFC 2047, RFC 2822, RFC 5322, RFC 5321 -# - -function Email() -{ - local base="${FUNCNAME}" - local this="$1" - - ! type base64 >/dev/null 2>&1 && - echo "${c}: command not found" >&2 && - return 1 - - declare -g base64_encode=base64 - - [[ "$(base64 --help)" =~ GNU ]] && - declare -g base64_encode="base64 -w 0" - - declare -g ${this}_mailTo="" - declare -g ${this}_mailCc="" - declare -g ${this}_mailBcc="" - declare -g ${this}_mailFrom="" - declare -g ${this}_mailReplyTo="" - declare -g ${this}_mailSubject="" - declare -g -a ${this}_mailAttachmentContentTypes - declare -g -a ${this}_mailAttachmentMessages - declare -g -a ${this}_mailAttachmentNames - - eval "${this}_mailAttachmentContentTypes=()" - eval "${this}_mailAttachmentMessages=()" - eval "${this}_mailAttachmentNames=()" - - local method - - for method in $(compgen -A function "${base}_") - do - declare -g ${method/#$base\_/$this\_}="${method} ${this}" - done -} - -function Email_setTo() -{ - local base="${FUNCNAME%%_*}" - local this="$1" - local inName="" - [ -n "$3" ] && inName="$2" && shift - local inAddress="$2" - - local mailTo="${this}_mailTo" - - # The format of Email address, - # see RFC 5322, sections 3.2.3 and 3.4.1, and RFC 5321 - - [[ "${inAddress}" =~ ^[0-9A-Za-z._%+-]+@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$ ]] || - return 1 - [ -n "${!mailTo}" ] && declare -g ${mailTo}+=","$'\n'" " - [ -n "${inName}" ] && - declare -g ${mailTo}+="=?UTF-8?B?$(echo -n "${inName}" | - ${base64_encode})?="$'\n'" <${inAddress}>" || - declare -g ${mailTo}+="${inAddress}" - - return 0 -} - -function Email_setCc() -{ - local base="${FUNCNAME%%_*}" - local this="$1" - local inName="" - [ -n "$3" ] && inName="$2" && shift - local inAddress="$2" - - local mailCc="${this}_mailCc" - - [[ "${inAddress}" =~ ^[0-9A-Za-z._%+-]+@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$ ]] || - return 1 - [ -n "${!mailCc}" ] && declare -g ${mailCc}+=","$'\n'" " - [ -n "${inName}" ] && - declare -g ${mailCc}+="=?UTF-8?B?$(echo -n "${inName}" | - ${base64_encode})?="$'\n'" <${inAddress}>" || - declare -g ${mailCc}+="${inAddress}" - - return 0 -} - -function Email_setBcc() -{ - local base="${FUNCNAME%%_*}" - local this="$1" - local inName="" - [ -n "$3" ] && inName="$2" && shift - local inAddress="$2" - - local mailBcc="${this}_mailBcc" - - [[ "${inAddress}" =~ ^[0-9A-Za-z._%+-]+@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$ ]] || - return 1 - [ -n "${!mailBcc}" ] && declare -g ${mailBcc}+=","$'\n'" " - [ -n "${inName}" ] && - declare -g ${mailBcc}+="=?UTF-8?B?$(echo -n "${inName}" | - ${base64_encode})?="$'\n'" <${inAddress}>" || - declare -g ${mailBcc}+="${inAddress}" - - return 0 -} - -function Email_setFrom() -{ - local base="${FUNCNAME%%_*}" - local this="$1" - local inName="" - [ -n "$3" ] && inName="$2" && shift - local inAddress="$2" - - local mailFrom="${this}_mailFrom" - - [[ "${inAddress}" =~ ^[0-9A-Za-z._%+-]+@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$ ]] || - return 1 - [ -n "${inName}" ] && - declare -g ${mailFrom}="=?UTF-8?B?$(echo -n "${inName}" | - ${base64_encode})?="$'\n'" <${inAddress}>" || - declare -g ${mailFrom}="${inAddress}" - - return 0 -} - -function Email_setReplyTo() -{ - local base="${FUNCNAME%%_*}" - local this="$1" - local inName="" - [ -n "$3" ] && inName="$2" && shift - local inAddress="$2" - - local mailReplyTo="${this}_mailReplyTo" - - [[ "${inAddress}" =~ ^[0-9A-Za-z._%+-]+@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$ ]] || - return 1 - [ -n "${inName}" ] && - declare -g ${mailReplyTo}="=?UTF-8?B?$(echo -n "${inName}" | - ${base64_encode})?="$'\n'" <${inAddress}>" || - declare -g ${mailReplyTo}="${inAddress}" - - return 0 -} - -function Email_setSubject() -{ - local base="${FUNCNAME%%_*}" - local this="$1" - local inSubject="$2" - - local mailSubject="${this}_mailSubject" - - local oLANG="${LANG}" - LANG=C - - [[ "${#inSubject}" -le 66 && "${inSubject}" =~ ^[0-9A-Za-z\ ._/=+-]+$ ]] && - declare -g ${mailSubject}="${inSubject}" && - return 0 - - # See RFC 5355 - - declare -g ${mailSubject}="=?UTF-8?B?" - - local c="" - local w="" - local -i limit=39 - - while : - do - read -r -n 1 - [[ -z "${REPLY}" || "${REPLY}" =~ [\x00-\x7f\xc0-\xff] ]] && - (( ${#w} + ${#c} > limit )) && - declare -g ${mailSubject}+="$(echo -n "${w}" | - ${base64_encode})?="$'\n'" =?UTF-8?B?" && - w="" && limit=45 - w+="${c}" && c="" - [ -n "${REPLY}" ] && c+="${REPLY}" || break - done < <(echo -n "${inSubject}") - declare -g ${mailSubject}+="$(echo -n "${w}" | ${base64_encode})?=" - - LANG="${oLANG}" - - return 0 -} - -function Email_setText() -{ - local base="${FUNCNAME%%_*}" - local this="$1" - - Email_addAttachment "${this}" "" "text/plain; charset=UTF-8" -} - -function Email_setHTML() -{ - local base="${FUNCNAME%%_*}" - local this="$1" - - Email_addAttachment "${this}" "" "text/html; charset=UTF-8" -} - -function Email_addAttachment() -{ - local base="${FUNCNAME%%_*}" - local this="$1" - local inName="$2" - local inContentType="$3" - local inMessage="" - - # 76 is a magic number, see RFC 2045 - - while read -r -n 76 - do - inMessage+="${REPLY}" - inMessage+=$'\n' - done < <(${base64_encode} && echo) - - local mailAttachmentContentTypes="${this}_mailAttachmentContentTypes" - local mailAttachmentMessages="${this}_mailAttachmentMessages" - local mailAttachmentNames="${this}_mailAttachmentNames" - - eval "${mailAttachmentContentTypes}+=(\"${inContentType}\")" - eval "${mailAttachmentMessages}+=(\"${inMessage}\")" - eval "${mailAttachmentNames}+=(\"${inName}\")" -} - -function Email_addAttachmentFile() -{ - local base="${FUNCNAME%%_*}" - local this="$1" - local inFileName="$2" - - [ -f "${inFileName}" ] || return 1 - [ -r "${inFileName}" ] || return 1 - - local inContentType="" - - # These are magic strings, see RFC 2046 - - case "${inFileName##*.}" in - "7z") inContentType="application/x-7z-compressed" ;; - "bz"|"bz2") - inContentType="application/x-bzip2" ;; - "bpg") inContentType="image/bpg" ;; - "cpio") inContentType="application/x-cpio" ;; - "gif") inContentType="image/gif" ;; - "gz") inContentType="application/x-gzip" ;; - "htm"|"html") - inContentType="text/html" ;; - "jpe"|"jpeg"|"jpg") - inContentType="image/jpeg" ;; - "png") inContentType="image/png" ;; - "rar") inContentType="application/x-rar-compressed" ;; - "tar") inContentType="application/x-tar" ;; - "txt") inContentType="text/plain" ;; - "xz") inContentType="application/x-xz" ;; - "zip") inContentType="application/x-zip-compressed" ;; - *) inContentType="application/octet-stream" ;; - esac - - Email_addAttachment "${this}" "${inFileName##*/}" "${inContentType}" <"${inFileName}" -} - -function Email_send() -{ - local base="${FUNCNAME%%_*}" - local this="$1" - - local mailTo="${this}_mailTo" - local mailCc="${this}_mailCc" - local mailBcc="${this}_mailBcc" - local mailFrom="${this}_mailFrom" - local mailReplyTo="${this}_mailReplyTo" - local mailSubject="${this}_mailSubject" - - # Sendmail is here, see Linux Standard Base Core Specification - # - Generic 5.0 Edition, section 17.2 - - local SENDMAIL="/usr/sbin/sendmail" - - ! type "${SENDMAIL}" >/dev/null 2>&1 && - echo "${SENDMAIL}: command not found" >&2 && - return 1 - - # Email headers, see RFC 2076 - - "${SENDMAIL}" -t -i <<-EOF - To: ${!mailTo} - Cc: ${!mailCc} - Bcc: ${!mailBcc} - From: ${!mailFrom} - Reply-To: ${!mailReplyTo} - Subject: ${!mailSubject} - X-Mailer: Flying Nimbus 0.0.1 - MIME-Version: 1.0 - $(Email_buildMultipart "${this}") - EOF -} - -function Email_buildMultipart() -{ - local base="${FUNCNAME%%_*}" - local this="$1" - - local mailAttachmentContentTypes="${this}_mailAttachmentContentTypes" - local mailAttachmentMessages="${this}_mailAttachmentMessages" - local mailAttachmentNames="${this}_mailAttachmentNames" - - local boundary="-=0xdeadbeef${RANDOM}${RANDOM}=-" - - # See RFC 2046, section 5.1.3 - - echo "Content-Type: multipart/mixed; boundary=0__${boundary}" - echo - echo "This is a message with multiple parts in MIME format." - echo "--0__${boundary}" - - local -i i - - # See RFC 2046, section 5.1.4 - - echo "Content-Type: multipart/alternative; boundary=1__${boundary}" - echo - echo -n "--1__${boundary}" - for (( i = 0; i < $(eval "echo \"\${#${mailAttachmentNames}[@]}\""); ++i )) - do - local mailAttachmentContentType="${mailAttachmentContentTypes}[${i}]" - local mailAttachmentMessage="${mailAttachmentMessages}[${i}]" - local mailAttachmentName="${mailAttachmentNames}[${i}]" - - [ -n "${!mailAttachmentName}" ] && continue - - echo - echo "Content-Type: ${!mailAttachmentContentType}" - echo "Content-Disposition: inline" - echo "Content-Transfer-Encoding: base64" - echo - echo "${!mailAttachmentMessage}" - echo - echo -n "--1__${boundary}" - done - echo "--" - echo -n "--0__${boundary}" - - for (( i = 0; i < $(eval "echo \"\${#${mailAttachmentNames}[@]}\""); ++i )) - do - local mailAttachmentContentType="${mailAttachmentContentTypes}[${i}]" - local mailAttachmentMessage="${mailAttachmentMessages}[${i}]" - local mailAttachmentName="${mailAttachmentNames}[${i}]" - - [ -z "${!mailAttachmentName}" ] && continue - - echo - echo "Content-Type: ${!mailAttachmentContentType}; name=\"${!mailAttachmentName}\"" - echo "Content-Disposition: attachment; filename=${!mailAttachmentName}" - echo "Content-Transfer-Encoding: base64" - echo - echo "${!mailAttachmentMessage}" - echo - echo -n "--0__${boundary}" - done - echo "--" -} -# End of file diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh deleted file mode 100755 index 0110776d9..000000000 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -SCRIPT="$0" -! type readlink >/dev/null 2>&1 && - echo "Command \"readlink\" not found" >&2 && exit 1 -while [ -L "${SCRIPT}" ] -do - LINK="$(readlink "${SCRIPT}")" - if [ "/" = "${LINK:0:1}" ] - then - SCRIPT="${LINK}" - else - SCRIPT="${SCRIPT%/*}/${LINK}" - fi -done -BASE_DIR="${SCRIPT%/*}" - -! source "${BASE_DIR}/email.sh" >/dev/null 2>&1 && - echo "File \"${BASE_DIR}/email.sh\" not found" >&2 && exit 1 -! type mysql >/dev/null 2>&1 && - echo "Command \"mysql\" not found" >&2 && exit 1 - -# The configuration part - -MYSQL_HOST="localhost" -MYSQL_USER="root" -MYSQL_PASS="password" -MYSQL_DB="xCATjkLogAnalyzer" - -MYSQL_COMMAND=("mysql" -B -N -r -s "-h" "${MYSQL_HOST}" -u "${MYSQL_USER}" -p"${MYSQL_PASS}" "${MYSQL_DB}") - -# The main part - -Email report - -$report_setTo "Alice" alice@example.org - -$report_setFrom "xCAT Jenkins Mail Bot" root@localhost.localdomain - -$report_setSubject "$("${MYSQL_COMMAND[@]}" <<<"SELECT * FROM LatestDailyMailReportSubject;")" -$report_setHTML < <("${MYSQL_COMMAND[@]}" <<<"CALL CreateLatestDailyMailReport;") - -$report_send diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql deleted file mode 100644 index e10e9eda0..000000000 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql +++ /dev/null @@ -1,958 +0,0 @@ --- MySQL dump 10.14 Distrib 5.5.47-MariaDB, for Linux (ppc64) --- --- Host: localhost Database: xCATjkLogAnalyzer --- ------------------------------------------------------ --- Server version 5.5.47-MariaDB - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `ArchDict` --- - -DROP TABLE IF EXISTS `ArchDict`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ArchDict` ( - `ArchId` int(11) NOT NULL AUTO_INCREMENT, - `ArchName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, - PRIMARY KEY (`ArchId`), - UNIQUE KEY `ArchName` (`ArchName`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Temporary table structure for view `FailedTestCasesTopList` --- - -DROP TABLE IF EXISTS `FailedTestCasesTopList`; -/*!50001 DROP VIEW IF EXISTS `FailedTestCasesTopList`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `FailedTestCasesTopList` ( - `Test case` tinyint NOT NULL, - `Arch` tinyint NOT NULL, - `OS` tinyint NOT NULL, - `Last seven days` tinyint NOT NULL, - `Last thirty days` tinyint NOT NULL, - `Last ninety days` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `LatestDailyMailReportSubject` --- - -DROP TABLE IF EXISTS `LatestDailyMailReportSubject`; -/*!50001 DROP VIEW IF EXISTS `LatestDailyMailReportSubject`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `LatestDailyMailReportSubject` ( - `Subject` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `LatestDailyReport` --- - -DROP TABLE IF EXISTS `LatestDailyReport`; -/*!50001 DROP VIEW IF EXISTS `LatestDailyReport`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `LatestDailyReport` ( - `Title` tinyint NOT NULL, - `Arch` tinyint NOT NULL, - `OS` tinyint NOT NULL, - `Duration` tinyint NOT NULL, - `Passed` tinyint NOT NULL, - `Failed` tinyint NOT NULL, - `No run` tinyint NOT NULL, - `Subtotal` tinyint NOT NULL, - `Pass rate` tinyint NOT NULL, - `Failed test cases` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `NinetyDayFailed` --- - -DROP TABLE IF EXISTS `NinetyDayFailed`; -/*!50001 DROP VIEW IF EXISTS `NinetyDayFailed`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `NinetyDayFailed` ( - `TestCaseId` tinyint NOT NULL, - `ArchId` tinyint NOT NULL, - `OSId` tinyint NOT NULL, - `Failed` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `NinetyDayLookBack` --- - -DROP TABLE IF EXISTS `NinetyDayLookBack`; -/*!50001 DROP VIEW IF EXISTS `NinetyDayLookBack`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `NinetyDayLookBack` ( - `Arch` tinyint NOT NULL, - `OS` tinyint NOT NULL, - `Test runs` tinyint NOT NULL, - `Passed` tinyint NOT NULL, - `Failed` tinyint NOT NULL, - `No run` tinyint NOT NULL, - `Subtotal` tinyint NOT NULL, - `Pass rate` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `NinetyDayReport` --- - -DROP TABLE IF EXISTS `NinetyDayReport`; -/*!50001 DROP VIEW IF EXISTS `NinetyDayReport`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `NinetyDayReport` ( - `ArchId` tinyint NOT NULL, - `OSId` tinyint NOT NULL, - `Passed` tinyint NOT NULL, - `Failed` tinyint NOT NULL, - `No run` tinyint NOT NULL, - `Subtotal` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Table structure for table `OSDict` --- - -DROP TABLE IF EXISTS `OSDict`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `OSDict` ( - `OSId` int(11) NOT NULL AUTO_INCREMENT, - `OSName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, - PRIMARY KEY (`OSId`), - UNIQUE KEY `OSName` (`OSName`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `ResultDict` --- - -DROP TABLE IF EXISTS `ResultDict`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `ResultDict` ( - `ResultId` int(11) NOT NULL AUTO_INCREMENT, - `ResultName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, - PRIMARY KEY (`ResultId`), - UNIQUE KEY `ResultName` (`ResultName`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Temporary table structure for view `SevenDayFailed` --- - -DROP TABLE IF EXISTS `SevenDayFailed`; -/*!50001 DROP VIEW IF EXISTS `SevenDayFailed`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `SevenDayFailed` ( - `TestCaseId` tinyint NOT NULL, - `ArchId` tinyint NOT NULL, - `OSId` tinyint NOT NULL, - `Failed` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `SevenDayLookBack` --- - -DROP TABLE IF EXISTS `SevenDayLookBack`; -/*!50001 DROP VIEW IF EXISTS `SevenDayLookBack`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `SevenDayLookBack` ( - `Arch` tinyint NOT NULL, - `OS` tinyint NOT NULL, - `Test runs` tinyint NOT NULL, - `Passed` tinyint NOT NULL, - `Failed` tinyint NOT NULL, - `No run` tinyint NOT NULL, - `Subtotal` tinyint NOT NULL, - `Pass rate` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `SevenDayReport` --- - -DROP TABLE IF EXISTS `SevenDayReport`; -/*!50001 DROP VIEW IF EXISTS `SevenDayReport`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `SevenDayReport` ( - `ArchId` tinyint NOT NULL, - `OSId` tinyint NOT NULL, - `Passed` tinyint NOT NULL, - `Failed` tinyint NOT NULL, - `No run` tinyint NOT NULL, - `Subtotal` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Table structure for table `TestCase` --- - -DROP TABLE IF EXISTS `TestCase`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `TestCase` ( - `TestCaseId` int(11) NOT NULL AUTO_INCREMENT, - `TestCaseName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, - `Memo` text NOT NULL, - PRIMARY KEY (`TestCaseId`), - UNIQUE KEY `TestCaseName` (`TestCaseName`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `TestResult` --- - -DROP TABLE IF EXISTS `TestResult`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `TestResult` ( - `TestRunId` int(11) NOT NULL, - `TestCaseId` int(11) NOT NULL, - `ResultId` int(11) NOT NULL, - `DurationTime` int(11) NOT NULL, - PRIMARY KEY (`TestRunId`,`TestCaseId`), - KEY `Result` (`ResultId`), - KEY `TestCaseId` (`TestCaseId`), - CONSTRAINT `ResutId` FOREIGN KEY (`ResultId`) REFERENCES `ResultDict` (`ResultId`), - CONSTRAINT `TestCaseId` FOREIGN KEY (`TestCaseId`) REFERENCES `TestCase` (`TestCaseId`), - CONSTRAINT `TestRunId` FOREIGN KEY (`TestRunId`) REFERENCES `TestRun` (`TestRunId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `TestRun` --- - -DROP TABLE IF EXISTS `TestRun`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `TestRun` ( - `TestRunId` int(11) NOT NULL AUTO_INCREMENT, - `TestRunName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, - `StartTime` datetime NOT NULL, - `EndTime` datetime NOT NULL, - `ArchId` int(11) NOT NULL, - `OSId` int(11) NOT NULL, - `xCATgitCommit` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, - `Memo` text NOT NULL, - PRIMARY KEY (`TestRunId`), - UNIQUE KEY `TestRunName` (`TestRunName`), - KEY `ArchId` (`ArchId`), - KEY `OSId` (`OSId`), - CONSTRAINT `ArchId` FOREIGN KEY (`ArchId`) REFERENCES `ArchDict` (`ArchId`), - CONSTRAINT `OSId` FOREIGN KEY (`OSId`) REFERENCES `OSDict` (`OSId`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Temporary table structure for view `ThirtyDayFailed` --- - -DROP TABLE IF EXISTS `ThirtyDayFailed`; -/*!50001 DROP VIEW IF EXISTS `ThirtyDayFailed`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `ThirtyDayFailed` ( - `TestCaseId` tinyint NOT NULL, - `ArchId` tinyint NOT NULL, - `OSId` tinyint NOT NULL, - `Failed` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `ThirtyDayLookBack` --- - -DROP TABLE IF EXISTS `ThirtyDayLookBack`; -/*!50001 DROP VIEW IF EXISTS `ThirtyDayLookBack`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `ThirtyDayLookBack` ( - `Arch` tinyint NOT NULL, - `OS` tinyint NOT NULL, - `Test runs` tinyint NOT NULL, - `Passed` tinyint NOT NULL, - `Failed` tinyint NOT NULL, - `No run` tinyint NOT NULL, - `Subtotal` tinyint NOT NULL, - `Pass rate` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Temporary table structure for view `ThirtyDayReport` --- - -DROP TABLE IF EXISTS `ThirtyDayReport`; -/*!50001 DROP VIEW IF EXISTS `ThirtyDayReport`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE TABLE `ThirtyDayReport` ( - `ArchId` tinyint NOT NULL, - `OSId` tinyint NOT NULL, - `Passed` tinyint NOT NULL, - `Failed` tinyint NOT NULL, - `No run` tinyint NOT NULL, - `Subtotal` tinyint NOT NULL -) ENGINE=MyISAM */; -SET character_set_client = @saved_cs_client; - --- --- Dumping routines for database 'xCATjkLogAnalyzer' --- -/*!50003 DROP PROCEDURE IF EXISTS `CreateLatestDailyMailReport` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8 */ ; -/*!50003 SET character_set_results = utf8 */ ; -/*!50003 SET collation_connection = utf8_general_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = '' */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateLatestDailyMailReport`() -BEGIN -SET group_concat_max_len := @@max_allowed_packet; -SELECT CONCAT( -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'xCAT Jenkins Test Report', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'

xCAT Jenkins Test Report

xCAT Logo
', "\n", -'

', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -LatestDailyReportContents.HTML, -LatestDailyReportSummary.HTML, -'
ArchOSDurationPassedFailedNo runSubtotalPass rate
', "\n", -'
', "\n", -'

Failed Test Cases

', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -FailedTestCasesReport.HTML, -'
ArchOSFailed test cases
', "\n", -'

Seven-day Look Back

', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -SevenDayLookBackContents.HTML, -SevenDayLookBackSummary.HTML, -'
ArchOSTest runsPassedFailedNo runSubtotalPass rate
', "\n", -'

Thirty-day Look Back

', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -ThirtyDayLookBackContents.HTML, -ThirtyDayLookBackSummary.HTML, -'
ArchOSTest runsPassedFailedNo runSubtotalPass rate
', "\n", -'

Ninety-day Look Back

', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -NinetyDayLookBackContents.HTML, -NinetyDayLookBackSummary.HTML, -'
ArchOSTest runsPassedFailedNo runSubtotalPass rate
', "\n", -'

Top 50 Failed Test Cases

', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -TopFiftyFailedTestCases.HTML, -'
RankTest caseArchOSLast 7 daysLast 30 daysLast 90 days
', "\n", -'
', "\n", -'', "\n", -'', "\n", -'', "\n", -'', "\n", -'

This email has been sent to you by xCAT Jenkins Mail Bot.
', "\n", -'This email was sent from a notification-only address that cannot accept incoming email. Please do not reply to this message. If you have received this email in error, please delete it.
', "\n", -'All the times shown in this test report are the local times of the testing environment.

', "\n", -'

', -NOW(), ' ', REPLACE(CONCAT('+', TIME_FORMAT(TIMEDIFF(NOW(), UTC_TIMESTAMP), '%H%i')), '+-', '-'), -'

', "\n", -'', "\n", -'' -) AS HTML -FROM ( -SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML -FROM ( -SELECT CONCAT( -'', "\n", -'', -Arch, '', "\n", -'', -OS, '', "\n" -'', -Duration, '', "\n", -'', -Passed, '', "\n", -'', -Failed, '', "\n", -'', -`No run`, '', "\n", -'', -Subtotal, '', "\n", -'', -`Pass rate`, '', "\n", -'', "\n" -) AS HTML -FROM LatestDailyReport, -( SELECT @color := '' ) AS tmp00 -) AS tmp10 -) AS LatestDailyReportContents, ( -SELECT CONCAT( -'', "\n", -'Total', "\n", -'-', "\n", -'', -IFNULL(SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))), 'N/A'), '', "\n" -'', -IFNULL(SUM(Passed), 'N/A'), '', "\n", -'', -IFNULL(SUM(Failed), 'N/A'), '', "\n", -'', -IFNULL(SUM(`No run`), 'N/A'), '', "\n", -'', -IFNULL(SUM(Subtotal), 'N/A'), '', "\n", -'', -IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", -'', "\n" -) AS HTML -FROM LatestDailyReport -) AS LatestDailyReportSummary, ( -SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML -FROM ( -SELECT CONCAT( -'', "\n", -'', -Arch, '', "\n", -'', -OS, '', "\n", -'', -`Failed test cases`, '', "\n", -'' , "\n" -) AS HTML -FROM LatestDailyReport, -( SELECT @color := '' ) AS tmp00 -) AS tmp10 -) AS FailedTestCasesReport, ( -SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML -FROM ( -SELECT CONCAT( -'', "\n", -'', -Arch, '', "\n", -'', -OS, '', "\n", -'', -`Test runs`, '', "\n", -'', -Passed, '', "\n", -'', -Failed, '', "\n", -'', -`No run`, '', "\n", -'', -Subtotal, '', "\n", -'', -`Pass rate`, '', "\n", -'', "\n" -) AS HTML -FROM SevenDayLookBack, -( SELECT @color := '' ) AS tmp00 -) AS tmp10 -) AS SevenDayLookBackContents, ( -SELECT CONCAT( -'', "\n", -'Total', "\n", -'-', "\n", -'', -IFNULL(SUM(`Test runs`), 'N/A'), '', "\n", -'', -IFNULL(SUM(Passed), 'N/A'), '', "\n", -'', -IFNULL(SUM(Failed), 'N/A'), '', "\n", -'', -IFNULL(SUM(`No run`), 'N/A'), '', "\n", -'', -IFNULL(SUM(Subtotal), 'N/A'), '', "\n", -'', -IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", -'', "\n" -) AS HTML -FROM SevenDayLookBack -) AS SevenDayLookBackSummary, ( -SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML -FROM ( -SELECT CONCAT( -'', "\n", -'', -Arch, '', "\n", -'', -OS, '', "\n", -'', -`Test runs`, '', "\n", -'', -Passed, '', "\n", -'', -Failed, '', "\n", -'', -`No run`, '', "\n", -'', -Subtotal, '', "\n", -'', -`Pass rate`, '', "\n", -'', "\n" -) AS HTML -FROM ThirtyDayLookBack, -( SELECT @color := '' ) AS tmp00 -) AS tmp10 -) AS ThirtyDayLookBackContents, ( -SELECT CONCAT( -'', "\n", -'Total', "\n", -'-', "\n", -'', -IFNULL(SUM(`Test runs`), 'N/A'), '', "\n", -'', -IFNULL(SUM(Passed), 'N/A'), '', "\n", -'', -IFNULL(SUM(Failed), 'N/A'), '', "\n", -'', -IFNULL(SUM(`No run`), 'N/A'), '', "\n", -'', -IFNULL(SUM(Subtotal), 'N/A'), '', "\n", -'', -IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", -'', "\n" -) AS HTML -FROM ThirtyDayLookBack -) AS ThirtyDayLookBackSummary, ( -SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML -FROM ( -SELECT CONCAT( -'', "\n", -'', -Arch, '', "\n", -'', -OS, '', "\n", -'', -`Test runs`, '', "\n", -'', -Passed, '', "\n", -'', -Failed, '', "\n", -'', -`No run`, '', "\n", -'', -Subtotal, '', "\n", -'', -`Pass rate`, '', "\n", -'', "\n" -) AS HTML -FROM NinetyDayLookBack, -( SELECT @color := '' ) AS tmp00 -) AS tmp10 -) AS NinetyDayLookBackContents, ( -SELECT CONCAT( -'', "\n", -'Total', "\n", -'-', "\n", -'', -IFNULL(SUM(`Test runs`), 'N/A'), '', "\n", -'', -IFNULL(SUM(Passed), 'N/A'), '', "\n", -'', -IFNULL(SUM(Failed), 'N/A'), '', "\n", -'', -IFNULL(SUM(`No run`), 'N/A'), '', "\n", -'', -IFNULL(SUM(Subtotal), 'N/A'), '', "\n", -'', -IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", -'', "\n" -) AS HTML -FROM NinetyDayLookBack -) AS NinetyDayLookBackSummary, ( -SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML -FROM ( -SELECT CONCAT( -'', "\n", -'', -@rank := @rank + 1, '', "\n", -'', -`Test case`, '', "\n", -'', -Arch, '', "\n", -'', -OS, '', "\n", -'', -`Last seven days`, '', "\n", -'', -`Last thirty days`, '', "\n", -'', -`Last ninety days`, '', "\n", -'', "\n" -) AS HTML FROM ( -SELECT `Test case`, Arch, OS, `Last seven days`, `Last thirty days`, `Last ninety days` -FROM FailedTestCasesTopList LIMIT 50 -) AS TopFifty, -( SELECT @color := '' ) AS tmp00, -( SELECT @rank := 0 ) AS tmp09 -) AS tmp10 -) AS TopFiftyFailedTestCases; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; - --- --- Final view structure for view `FailedTestCasesTopList` --- - -/*!50001 DROP TABLE IF EXISTS `FailedTestCasesTopList`*/; -/*!50001 DROP VIEW IF EXISTS `FailedTestCasesTopList`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `FailedTestCasesTopList` AS select `TestCase`.`TestCaseName` AS `Test case`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,ifnull(`SevenDayFailed`.`Failed`,0) AS `Last seven days`,ifnull(`ThirtyDayFailed`.`Failed`,0) AS `Last thirty days`,`NinetyDayFailed`.`Failed` AS `Last ninety days` from (((((`NinetyDayFailed` left join `SevenDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `SevenDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `SevenDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `SevenDayFailed`.`OSId`)))) left join `ThirtyDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `ThirtyDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `ThirtyDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `ThirtyDayFailed`.`OSId`)))) left join `TestCase` on((`NinetyDayFailed`.`TestCaseId` = `TestCase`.`TestCaseId`))) left join `ArchDict` on((`NinetyDayFailed`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayFailed`.`OSId` = `OSDict`.`OSId`))) order by ifnull(`SevenDayFailed`.`Failed`,0) desc,ifnull(`ThirtyDayFailed`.`Failed`,0) desc,`NinetyDayFailed`.`Failed` desc,`OSDict`.`OSName`,`ArchDict`.`ArchName`,`TestCase`.`TestCaseName` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `LatestDailyMailReportSubject` --- - -/*!50001 DROP TABLE IF EXISTS `LatestDailyMailReportSubject`*/; -/*!50001 DROP VIEW IF EXISTS `LatestDailyMailReportSubject`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `LatestDailyMailReportSubject` AS select concat('[xCAT Jenkins] ','Passed: ',ifnull(sum(`LatestDailyReport`.`Passed`),'N/A'),' Failed: ',ifnull(sum(`LatestDailyReport`.`Failed`),'N/A'),' No run: ',ifnull(sum(`LatestDailyReport`.`No run`),'N/A')) AS `Subject` from `LatestDailyReport` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `LatestDailyReport` --- - -/*!50001 DROP TABLE IF EXISTS `LatestDailyReport`*/; -/*!50001 DROP VIEW IF EXISTS `LatestDailyReport`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `LatestDailyReport` AS select `TestRun`.`TestRunName` AS `Title`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,timediff(`TestRun`.`EndTime`,`TestRun`.`StartTime`) AS `Duration`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) AS `Passed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'No run')))) AS `No run`,(select count(0) from `TestResult` where (`TestResult`.`TestRunId` = `TestRun`.`TestRunId`)) AS `Subtotal`,ifnull(concat(round((((select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) / ((select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) + (select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))))) * 100),2),'%'),'N/A') AS `Pass rate`,(select ifnull(group_concat(`TestCase`.`TestCaseName` separator ' '),'') from (`TestResult` left join `TestCase` on((`TestResult`.`TestCaseId` = `TestCase`.`TestCaseId`))) where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed test cases` from ((`TestRun` left join `ArchDict` on((`TestRun`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`TestRun`.`OSId` = `OSDict`.`OSId`))) where `TestRun`.`TestRunId` in (select max(`TestRun`.`TestRunId`) AS `TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 2 day)) group by `TestRun`.`ArchId`,`TestRun`.`OSId`) order by `OSDict`.`OSName`,`ArchDict`.`ArchName` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `NinetyDayFailed` --- - -/*!50001 DROP TABLE IF EXISTS `NinetyDayFailed`*/; -/*!50001 DROP VIEW IF EXISTS `NinetyDayFailed`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `NinetyDayFailed` AS select `TestResult`.`TestCaseId` AS `TestCaseId`,`TestRun`.`ArchId` AS `ArchId`,`TestRun`.`OSId` AS `OSId`,count(0) AS `Failed` from (`TestResult` left join `TestRun` on((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`))) where (`TestResult`.`TestRunId` in (select `TestRun`.`TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 90 day))) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed'))) group by `TestResult`.`TestCaseId`,`TestRun`.`ArchId`,`TestRun`.`OSId` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `NinetyDayLookBack` --- - -/*!50001 DROP TABLE IF EXISTS `NinetyDayLookBack`*/; -/*!50001 DROP VIEW IF EXISTS `NinetyDayLookBack`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `NinetyDayLookBack` AS select `ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,count(0) AS `Test runs`,sum(`NinetyDayReport`.`Passed`) AS `Passed`,sum(`NinetyDayReport`.`Failed`) AS `Failed`,sum(`NinetyDayReport`.`No run`) AS `No run`,sum(`NinetyDayReport`.`Subtotal`) AS `Subtotal`,ifnull(concat(round(((sum(`NinetyDayReport`.`Passed`) / (sum(`NinetyDayReport`.`Passed`) + sum(`NinetyDayReport`.`Failed`))) * 100),2),'%'),'N/A') AS `Pass rate` from ((`NinetyDayReport` left join `ArchDict` on((`NinetyDayReport`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayReport`.`OSId` = `OSDict`.`OSId`))) group by `NinetyDayReport`.`ArchId`,`NinetyDayReport`.`OSId` order by `OSDict`.`OSName`,`ArchDict`.`ArchName` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `NinetyDayReport` --- - -/*!50001 DROP TABLE IF EXISTS `NinetyDayReport`*/; -/*!50001 DROP VIEW IF EXISTS `NinetyDayReport`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `NinetyDayReport` AS select `TestRun`.`ArchId` AS `ArchId`,`TestRun`.`OSId` AS `OSId`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) AS `Passed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'No run')))) AS `No run`,(select count(0) from `TestResult` where (`TestResult`.`TestRunId` = `TestRun`.`TestRunId`)) AS `Subtotal` from `TestRun` where `TestRun`.`TestRunId` in (select `TestRun`.`TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 90 day))) */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `SevenDayFailed` --- - -/*!50001 DROP TABLE IF EXISTS `SevenDayFailed`*/; -/*!50001 DROP VIEW IF EXISTS `SevenDayFailed`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `SevenDayFailed` AS select `TestResult`.`TestCaseId` AS `TestCaseId`,`TestRun`.`ArchId` AS `ArchId`,`TestRun`.`OSId` AS `OSId`,count(0) AS `Failed` from (`TestResult` left join `TestRun` on((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`))) where (`TestResult`.`TestRunId` in (select `TestRun`.`TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 7 day))) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed'))) group by `TestResult`.`TestCaseId`,`TestRun`.`ArchId`,`TestRun`.`OSId` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `SevenDayLookBack` --- - -/*!50001 DROP TABLE IF EXISTS `SevenDayLookBack`*/; -/*!50001 DROP VIEW IF EXISTS `SevenDayLookBack`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `SevenDayLookBack` AS select `ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,count(0) AS `Test runs`,sum(`SevenDayReport`.`Passed`) AS `Passed`,sum(`SevenDayReport`.`Failed`) AS `Failed`,sum(`SevenDayReport`.`No run`) AS `No run`,sum(`SevenDayReport`.`Subtotal`) AS `Subtotal`,ifnull(concat(round(((sum(`SevenDayReport`.`Passed`) / (sum(`SevenDayReport`.`Passed`) + sum(`SevenDayReport`.`Failed`))) * 100),2),'%'),'N/A') AS `Pass rate` from ((`SevenDayReport` left join `ArchDict` on((`SevenDayReport`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`SevenDayReport`.`OSId` = `OSDict`.`OSId`))) group by `SevenDayReport`.`ArchId`,`SevenDayReport`.`OSId` order by `OSDict`.`OSName`,`ArchDict`.`ArchName` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `SevenDayReport` --- - -/*!50001 DROP TABLE IF EXISTS `SevenDayReport`*/; -/*!50001 DROP VIEW IF EXISTS `SevenDayReport`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `SevenDayReport` AS select `TestRun`.`ArchId` AS `ArchId`,`TestRun`.`OSId` AS `OSId`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) AS `Passed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'No run')))) AS `No run`,(select count(0) from `TestResult` where (`TestResult`.`TestRunId` = `TestRun`.`TestRunId`)) AS `Subtotal` from `TestRun` where `TestRun`.`TestRunId` in (select `TestRun`.`TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 7 day))) */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `ThirtyDayFailed` --- - -/*!50001 DROP TABLE IF EXISTS `ThirtyDayFailed`*/; -/*!50001 DROP VIEW IF EXISTS `ThirtyDayFailed`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ThirtyDayFailed` AS select `TestResult`.`TestCaseId` AS `TestCaseId`,`TestRun`.`ArchId` AS `ArchId`,`TestRun`.`OSId` AS `OSId`,count(0) AS `Failed` from (`TestResult` left join `TestRun` on((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`))) where (`TestResult`.`TestRunId` in (select `TestRun`.`TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 30 day))) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed'))) group by `TestResult`.`TestCaseId`,`TestRun`.`ArchId`,`TestRun`.`OSId` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `ThirtyDayLookBack` --- - -/*!50001 DROP TABLE IF EXISTS `ThirtyDayLookBack`*/; -/*!50001 DROP VIEW IF EXISTS `ThirtyDayLookBack`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ThirtyDayLookBack` AS select `ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,count(0) AS `Test runs`,sum(`ThirtyDayReport`.`Passed`) AS `Passed`,sum(`ThirtyDayReport`.`Failed`) AS `Failed`,sum(`ThirtyDayReport`.`No run`) AS `No run`,sum(`ThirtyDayReport`.`Subtotal`) AS `Subtotal`,ifnull(concat(round(((sum(`ThirtyDayReport`.`Passed`) / (sum(`ThirtyDayReport`.`Passed`) + sum(`ThirtyDayReport`.`Failed`))) * 100),2),'%'),'N/A') AS `Pass rate` from ((`ThirtyDayReport` left join `ArchDict` on((`ThirtyDayReport`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`ThirtyDayReport`.`OSId` = `OSDict`.`OSId`))) group by `ThirtyDayReport`.`ArchId`,`ThirtyDayReport`.`OSId` order by `OSDict`.`OSName`,`ArchDict`.`ArchName` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - --- --- Final view structure for view `ThirtyDayReport` --- - -/*!50001 DROP TABLE IF EXISTS `ThirtyDayReport`*/; -/*!50001 DROP VIEW IF EXISTS `ThirtyDayReport`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8 */; -/*!50001 SET character_set_results = utf8 */; -/*!50001 SET collation_connection = utf8_general_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ThirtyDayReport` AS select `TestRun`.`ArchId` AS `ArchId`,`TestRun`.`OSId` AS `OSId`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) AS `Passed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'No run')))) AS `No run`,(select count(0) from `TestResult` where (`TestResult`.`TestRunId` = `TestRun`.`TestRunId`)) AS `Subtotal` from `TestRun` where `TestRun`.`TestRunId` in (select `TestRun`.`TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 30 day))) */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2016-08-22 4:06:36 diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh deleted file mode 100755 index bc83667e1..000000000 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh +++ /dev/null @@ -1,462 +0,0 @@ -#!/bin/bash - -function usage() -{ - local script="${0##*/}" - - while read -r ; do echo "${REPLY}" ; done <<-EOF - Usage: ${script} [OPTIONS] DIRECTORY - - Options: - --help display this help and exit - - Examples: - - ${script} /xCATjk/log/ubuntu16.04-ppc64el/8 - EOF -} - -PATH="/usr/sbin:/usr/bin:/sbin:/bin" -export PATH - -# -# warn_if_bad Put out warning message(s) if $1 has bad RC. -# -# $1 0 (pass) or non-zero (fail). -# $2+ Remaining arguments printed only if the $1 is non-zero. -# -# Incoming $1 is returned unless it is 0 -# -function warn_if_bad() -{ - local -i rc="$1" - local script="${0##*/}" - - # Ignore if no problems - [ "${rc}" -eq "0" ] && return 0 - - # Broken - shift - echo "${script}: $@" >&2 - return "${rc}" -} - -# -# exit_if_bad Put out error message(s) if $1 has bad RC. -# -# $1 0 (pass) or non-zero (fail). -# $2+ Remaining arguments printed only if the $1 is non-zero. -# -# Exits with 1 unless $1 is 0 -# -function exit_if_bad() -{ - warn_if_bad "$@" || exit 1 - return 0 -} - -# -# check_root_or_exit -# -# Breaks the script if not running as root. -# -# If this returns 1, the invoker MUST abort the script. -# -# Returns 0 if running as root -# Returns 1 if not (and breaks the script) -# -function check_root_or_exit() -{ - [ "${UID}" -eq "0" ] - exit_if_bad "$?" "Must be run by UID=0. Actual UID=${UID}." - return 0 -} - -# -# check_executes Check for executable(s) -# -# Returns 0 if true. -# Returns 1 if not. -# -function check_executes() -{ - local cmd - local all_ok="yes" - for cmd in "$@" - do - if ! type "${cmd}" &>/dev/null - then - echo "Command \"${cmd}\" not found." >&2 - all_ok="no" - fi - done - [ "${all_ok}" = "yes" ] -} - -# -# check_exec_or_exit Check for required executables. -# -# Exits (not returns) if commands listed on command line do not exist. -# -# Returns 0 if true. -# Exits with 1 if not. -# -function check_exec_or_exit() -{ - check_executes "$@" - exit_if_bad "$?" "Above listed required command(s) not found." - return 0 -} - -TMP_DIR="" - -# -# internal_setup Script setup -# -# Returns 0 on success. -# Exits (not returns) with 1 on failure. -# -function internal_setup() -{ - shopt -s extglob - - # Trap exit for internal_cleanup function. - trap "internal_cleanup" EXIT - - check_exec_or_exit awk mktemp printf - - umask 0077 - - TMP_DIR="$(mktemp -d "/tmp/${0##*/}.XXXXXXXX" 2>/dev/null)" - [ -d "${TMP_DIR}" ] - exit_if_bad "$?" "Make temporary directory failed." - - custom_setup -} - -# -# internal_cleanup Script cleanup (reached via trap 0) -# -# Destory any temporarily facility created by internal_setup. -# -function internal_cleanup() -{ - custom_cleanup - - [ -d "${TMP_DIR}" ] && rm -rf "${TMP_DIR}" -} - -# -# custom_setup -# -function custom_setup() -{ - check_exec_or_exit awk sed tr date -} - -# -# custom_cleanup -# -function custom_cleanup() -{ - : -} - -# -# cleanup_n_exec Do the cleanup, then execute the command -# -# $1+ The command to execute -# -function cleanup_n_exec() -{ - internal_cleanup - - exec "$@" -} - -internal_setup - -# -# xcattestlog2sql -# -# $1 The name of the test run -# $2 Log file of xcattest -# -function xcattestlog2sql() -{ - local test_run_name="$1" - local logfile="$2" - - local test_case_name="" - local test_case_result="" - local duration="" - - [ -n "${test_run_name}" ] - warn_if_bad "$?" "test run has no name" || return 1 - - while read -r ; do echo "${REPLY}" ; done <<-EOF - -- - -- Test run has name '${test_run_name}' - -- - - EOF - - [ -f "${logfile}" ] - warn_if_bad "$?" "${logfile}: No such log file" || return 1 - - while read -r ; do echo "${REPLY}" ; done <<-EOF - -- - -- Analysis file '${logfile}' - -- - - EOF - - while read -r test_case_name test_case_result duration - do - while read -r ; do echo "${REPLY}" ; done <<-EOF - INSERT INTO TestCase (TestCaseId, TestCaseName) - SELECT * FROM (SELECT NULL, '${test_case_name}') AS tmp - WHERE NOT EXISTS ( - SELECT TestCaseId FROM TestCase WHERE TestCaseName = '${test_case_name}' - ) LIMIT 1; - - INSERT INTO ResultDict (ResultId, ResultName) - SELECT * FROM (SELECT NULL, '${test_case_result}') AS tmp - WHERE NOT EXISTS ( - SELECT ResultId FROM ResultDict WHERE ResultName = '${test_case_result}' - ) LIMIT 1; - - REPLACE INTO TestResult (TestRunId, TestCaseId, ResultId, DurationTime) - SELECT ( - SELECT TestRunId FROM TestRun WHERE TestRunName = '${test_run_name}' - ) AS TestRunId, ( - SELECT TestCaseId FROM TestCase WHERE TestCaseName = '${test_case_name}' - ) AS TestCaseId, ( - SELECT ResultId FROM ResultDict WHERE ResultName = '${test_case_result}' - ) AS ResultId, '${duration}'; - - EOF - done < <(tr -d '\r' <"${logfile}" | grep "^------END" | - sed -e 's/^.*END::\(.*\)::\([A-Za-z0-9]*\)::.*Duration::\(-*[0-9]*\) sec.*$/\1 \2 \3/') - - return 0 -} - -# -# xcattestbundle2sql -# -# $1 The name of the test run -# $2 Bundle file of xcattest -# -function xcattestbundle2sql() -{ - local test_run_name="$1" - local logfile="$2" - - local test_case_name="" - local test_case_result="No run" - - [ -n "${test_run_name}" ] - warn_if_bad "$?" "test run has no name" || return 1 - - while read -r ; do echo "${REPLY}" ; done <<-EOF - -- - -- Test run has name '${test_run_name}' - -- - - EOF - - [ -f "${logfile}" ] - warn_if_bad "$?" "${logfile}: No such log file" || return 1 - - while read -r ; do echo "${REPLY}" ; done <<-EOF - -- - -- Analysis file '${logfile}' - -- - - INSERT INTO ResultDict (ResultId, ResultName) - SELECT * FROM (SELECT NULL, '${test_case_result}') AS tmp - WHERE NOT EXISTS ( - SELECT ResultId FROM ResultDict WHERE ResultName = '${test_case_result}' - ) LIMIT 1; - - EOF - - while read -r test_case_name - do - # Remove any comment - test_case_name="${test_case_name%%#*}" - # Chomp - test_case_name=$(echo ${test_case_name}) - [ -z "${test_case_name}" ] && continue - - while read -r ; do echo "${REPLY}" ; done <<-EOF - INSERT INTO TestCase (TestCaseId, TestCaseName) - SELECT * FROM (SELECT NULL, '${test_case_name}') AS tmp - WHERE NOT EXISTS ( - SELECT TestCaseId FROM TestCase WHERE TestCaseName = '${test_case_name}' - ) LIMIT 1; - - INSERT IGNORE INTO TestResult (TestRunId, TestCaseId, ResultId, DurationTime) - SELECT ( - SELECT TestRunId FROM TestRun WHERE TestRunName = '${test_run_name}' - ) AS TestRunId, ( - SELECT TestCaseId FROM TestCase WHERE TestCaseName = '${test_case_name}' - ) AS TestCaseId, ( - SELECT ResultId FROM ResultDict WHERE ResultName = '${test_case_result}' - ) AS ResultId, '0'; - - EOF - done < <(tr -d '\r' <"${logfile}") -} - -# -# jenkinsprojectlog2sql -# -# $1 Log file of jenkins project run -# -# When return 0, will set global shell variable TestRunName -# -function jenkinsprojectlog2sql() -{ - local logfile="$1" - local foo="" - - local test_run_name="" - local start_time="" - local end_time="" - local os="" - local arch="" - local xcat_git_commit="" - local memo="" - - [ -f "${logfile}" ] - warn_if_bad "$?" "${logfile}: No such log file" || return 1 - - while read -r ; do echo "${REPLY}" ; done <<-EOF - -- - -- Analysis file '${logfile}' - -- - - EOF - - test_run_name="$(tr -d '\r' <"${logfile}" | - awk '/project.*description/ { print $(NF - 1) }')" - [ -n "${test_run_name}" ] - warn_if_bad "$?" "${test_run_name}: fail to parse test run name" || return 1 - - foo="$(tr -d '\r' <"${logfile}" | head -n 1 | cut -d ' ' -f 1)" - [ "${#foo}" = 14 ] - warn_if_bad "$?" "${foo}: fail to parse test start time" || return 1 - start_time="${foo:0:4}-${foo:4:2}-${foo:6:2} ${foo:8:2}:${foo:10:2}:${foo:12:2}" - - foo="$(tr -d '\r' <"${logfile}" | tail -n 1 | cut -d ' ' -f 1)" - [ "${#foo}" = 14 ] - warn_if_bad "$?" "${foo}: fail to parse test end time" || return 1 - end_time="${foo:0:4}-${foo:4:2}-${foo:6:2} ${foo:8:2}:${foo:10:2}:${foo:12:2}" - - arch="$(tr -d '\r' <"${logfile}" | awk -F - '/project.*description/ { print $2 }')" - [ "${arch}" = "ppc64el" ] && arch="ppc64le" - [ -n "${arch}" ] - warn_if_bad "$?" "${arch}: fail to parse arch" || return 1 - - os="$(tr -d '\r' <"${logfile}" | awk '/os.*=>/ { print $NF }')" - [ -n "${os}" ] - warn_if_bad "$?" "${os}: fail to parse operating system" || return 1 - - memo="$(tr -d '\r' <"${logfile}" | grep -A 7 'project.*description' | cut -d ' ' -f 4-)" - - while read -r ; do echo "${REPLY}" ; done <<-EOF - INSERT INTO ArchDict (ArchId, ArchName) - SELECT * FROM (SELECT NULL, '${arch}') AS tmp - WHERE NOT EXISTS ( - SELECT ArchId FROM ArchDict WHERE ArchName = '${arch}' - ) LIMIT 1; - - INSERT INTO OSDict (OSId, OSName) - SELECT * FROM (SELECT NULL, '${os}') AS tmp - WHERE NOT EXISTS ( - SELECT OSId FROM OSDict WHERE OSName = '${os}' - ) LIMIT 1; - - INSERT IGNORE INTO TestRun - (TestRunId, TestRunName, StartTime, EndTime, ArchId, OSId, xCATgitCommit, Memo) - SELECT NULL, '${test_run_name}', '${start_time}', '${end_time}', ( - SELECT ArchId FROM ArchDict WHERE ArchName = '${arch}' - ) AS ArchId, ( - SELECT OSId FROM OSDict WHERE OSName = '${os}' - ) AS OSId, '${xcat_git_commit}', '${memo}'; - - EOF - - TestRunName="${test_run_name}" - - return 0 -} - -# Main - -declare VERSION="0.00.1" - -declare xCATjkLog_DIR="" -declare TestRunName="" - -declare JenkinsProjectLog="" -declare xCATTestLogs="" - -while [ "$#" -gt "0" ] -do - case "$1" in - "--help") - usage - exit 0 - ;; - *) - [ "$1" == "--" ] && shift - [ -z "${xCATjkLog_DIR}" ] - exit_if_bad "$?" "invalid predicate - $1" - xCATjkLog_DIR="$1" - ;; - esac - shift -done - -[ -z "${xCATjkLog_DIR}" ] && usage >&2 && exit 1 - -[ -d "${xCATjkLog_DIR}" ] -exit_if_bad "$?" "${xCATjkLog_DIR}: No such directory" - -# Check if the mail log is there. If it is not, exit directly -JenkinsMailLog="$(echo "${xCATjkLog_DIR}/mail."*)" -[ -f "${JenkinsMailLog}" ] -exit_if_bad "$?" "${JenkinsMailLog}: no such log file" - -while read -r ; do echo "${REPLY}" ; done </dev/null 2>&1 && - echo "Command \"readlink\" not found" >&2 && exit 1 -while [ -L "${SCRIPT}" ] -do - LINK="$(readlink "${SCRIPT}")" - if [ "/" = "${LINK:0:1}" ] - then - SCRIPT="${LINK}" - else - SCRIPT="${SCRIPT%/*}/${LINK}" - fi -done -BASE_DIR="${SCRIPT%/*}" - -xCATjkScanLogs="${BASE_DIR}/xcatjk-scanlogs.sh" -if [ ! -x "${xCATjkScanLogs}" ] -then - echo "Script ${xCATjkScanLogs} not found" >&2 - exit 1 -fi - -while read -r ; do echo "${REPLY}" ; done </dev/null 2>&1 && - echo "Command \"readlink\" not found" >&2 && exit 1 -while [ -L "${SCRIPT}" ] -do - LINK="$(readlink "${SCRIPT}")" - if [ "/" = "${LINK:0:1}" ] - then - SCRIPT="${LINK}" - else - SCRIPT="${SCRIPT%/*}/${LINK}" - fi -done -BASE_DIR="${SCRIPT%/*}" - -SQLofCreateTables="${BASE_DIR}/xCATjkLogAnalyzer.sql" -if [ ! -f "${SQLofCreateTables}" ] -then - echo "${SQLofCreateTables}: SQL file not found" >&2 - exit 1 -fi - - -xCATjkScanLogs="${BASE_DIR}/xcatjk-scanlogs.sh" -if [ ! -x "${xCATjkScanLogs}" ] -then - echo "Script ${xCATjkScanLogs} not found" >&2 - exit 1 -fi - -while read -r ; do echo "${REPLY}" ; done <&2 - return "${rc}" -} - -# -# exit_if_bad Put out error message(s) if $1 has bad RC. -# -# $1 0 (pass) or non-zero (fail). -# $2+ Remaining arguments printed only if the $1 is non-zero. -# -# Exits with 1 unless $1 is 0 -# -function exit_if_bad() -{ - warn_if_bad "$@" || exit 1 - return 0 -} - -# -# check_root_or_exit -# -# Breaks the script if not running as root. -# -# If this returns 1, the invoker MUST abort the script. -# -# Returns 0 if running as root -# Returns 1 if not (and breaks the script) -# -function check_root_or_exit() -{ - [ "${UID}" -eq "0" ] - exit_if_bad "$?" "Must be run by UID=0. Actual UID=${UID}." - return 0 -} - -# -# check_executes Check for executable(s) -# -# Returns 0 if true. -# Returns 1 if not. -# -function check_executes() -{ - local cmd - local all_ok="yes" - for cmd in "$@" - do - if ! type "${cmd}" &>/dev/null - then - echo "Command \"${cmd}\" not found." >&2 - all_ok="no" - fi - done - [ "${all_ok}" = "yes" ] -} - -# -# check_exec_or_exit Check for required executables. -# -# Exits (not returns) if commands listed on command line do not exist. -# -# Returns 0 if true. -# Exits with 1 if not. -# -function check_exec_or_exit() -{ - check_executes "$@" - exit_if_bad "$?" "Above listed required command(s) not found." - return 0 -} - -TMP_DIR="" - -# -# internal_setup Script setup -# -# Returns 0 on success. -# Exits (not returns) with 1 on failure. -# -function internal_setup() -{ - shopt -s extglob - - # Trap exit for internal_cleanup function. - trap "internal_cleanup" EXIT - - check_exec_or_exit awk mktemp printf - - umask 0077 - - TMP_DIR="$(mktemp -d "/tmp/${0##*/}.XXXXXXXX" 2>/dev/null)" - [ -d "${TMP_DIR}" ] - exit_if_bad "$?" "Make temporary directory failed." - - custom_setup -} - -# -# internal_cleanup Script cleanup (reached via trap 0) -# -# Destory any temporarily facility created by internal_setup. -# -function internal_cleanup() -{ - custom_cleanup - - [ -d "${TMP_DIR}" ] && rm -rf "${TMP_DIR}" -} - -# -# custom_setup -# -function custom_setup() -{ - check_exec_or_exit awk dirname -} - -# -# custom_cleanup -# -function custom_cleanup() -{ - : -} - -# -# cleanup_n_exec Do the cleanup, then execute the command -# -# $1+ The command to execute -# -function cleanup_n_exec() -{ - internal_cleanup - - exec "$@" -} - -internal_setup - -SCRIPT="$0" -! type readlink >/dev/null 2>&1 && - echo "Command \"readlink\" not found" >&2 && exit 1 -while [ -L "${SCRIPT}" ] -do - LINK="$(readlink "${SCRIPT}")" - if [ "/" = "${LINK:0:1}" ] - then - SCRIPT="${LINK}" - else - SCRIPT="${SCRIPT%/*}/${LINK}" - fi -done -BASE_DIR="${SCRIPT%/*}" - -xCATjkLog2SQL="${BASE_DIR}/xcatjk-log2sql.sh" -[ -x "${xCATjkLog2SQL}" ] -exit_if_bad "$?" "Script ${xCATjkLog2SQL} not found" - -declare VERSION="0.0.1" - -declare xCATjkLog_TOPDIR="" -declare -a FIND_ARGS=() - -while [ "$#" -gt "0" ] -do - case "$1" in - "--help") - usage - exit 0 - ;; - "--recent") - FIND_ARGS=(-mtime -3) - ;; - *) - [ "$1" == "--" ] && shift - [ -z "${xCATjkLog_TopDir}" ] - exit_if_bad "$?" "invalid predicate - $1" - xCATjkLog_TopDir="$1" - ;; - esac - shift -done - -[ -z "${xCATjkLog_TopDir}" ] && usage >&2 && exit 1 - -[ -d "${xCATjkLog_TopDir}" ] -exit_if_bad "$?" "${xCATjkLog_TopDir}: No such directory" - -while read -r ; do echo "${REPLY}" ; done <rel2abs(__FILE__)); -my $logfiledir = ""; -my $logfile=""; -my $globalconffile="$homedir/global.conf"; -my $xcatpackagesdir=""; -my $mailfile=""; -my %confkeys; #global conf file -my %config; #cluster conf file -my $arch; -my $mn; -my $err_record=""; -my $installlog="/var/log/xcat/autotest.log"; -my $isodir="$homedir/iso"; -my $plugindir="$homedir/plugin"; -my $orgclusterconffile=""; -my $newclusterconffile=""; -my $all_reg_time_consumption=0; -my $env_dply_time_consumption=0; -my $totalcase=0; -my $alltestpass=0; -my $teststopflag=0; -my $lastcase; -my $defaultmail="userid1\@domain,userid2\@domain"; -my $sub_process_rt=0; -my $proid; -my $timeout = 12; #units is hours -my @attachfiles; - -my $automation_mountpoint="/tmp/automation_mountpoint"; -my $extra_resource_path="server:/path"; -my $login_node_nameserver="0.0.0.0"; -$extra_resource_path = $ENV{'EXTRA_RESOUCE_DIR'} if exists $ENV{'EXTRA_RESOUCE_DIR'}; - -#build information -my $commitnum=undef; -my $buildtime=undef; -my $xcatversion=undef; -my $xcatrelease=undef; -my $buildserver=undef; - -# Use MySQL database for the xCAT hierarchy support -my $xcat_database = "MySQL"; - -# command line arguments -my $cluster_name; -my $os; -my $xcatcore_addr; -my $xcatdep_addr; -my $xcattest_addr; -my $xcattest_pkg; -my $bucket; -my $mail_list; -my $quiet=0; -my $hold=0; -my $needhelp = 0; -my $proname=""; -my $proruntime=""; -my $regstarttime = 0; -my $regendtime = 0; -my $plugin=undef; - - -####################################### -# send messages -####################################### -sub send_msg { - my $num = shift; - my $msg = shift; - my $content; - if ($num == 0) { - $content = "Fatal error:"; - } elsif($num == 1) { - $content = "Warning:"; - } elsif($num == 2) { - $content = "Notice:"; - } - my $timestamp = `date +"%Y-%m-%d %H:%M:%S"`; - chomp($timestamp); - if ( !open (LOGFILE, ">> $logfiledir/$logfile") ) { - return 1; - } - print LOGFILE "$timestamp $$ $content $msg\n"; - close LOGFILE; - - if(!$quiet){ - print "$timestamp $$ $content $msg\n"; - } -} - -####################################### -# runcmd -####################################### -sub runcmd { - my ($cmd) = @_; - my $rc = 0; - $::RUNCMD_RC = 0; - my $outref = []; - - @$outref = `$cmd 2>&1`; - $rc = $? ; - chomp(@$outref); - if ($rc) { - my $tmpoutput1 = join(' ', @$outref); - send_msg(0, "[runcmd] failed to run $cmd: $tmpoutput1"); - $::RUNCMD_RC = $rc; - } - return @$outref; -} - -####################################### -# parse cluser.conf file -####################################### -sub load_cluster_conf { - my $type = undef; #Script_Prev,Script_Post,Table,Object,System,Custom - my $sub_type = undef; # The string after $type_ - my $name = undef; - my $attr = undef; - my $value = undef; - my $c = 0; - - open(FILE, "$orgclusterconffile") or die "can't to open $orgclusterconffile"; - while(my $line = ) { - $line =~ s/^\s+|#.+|\s+$//g; - next if(length($line) == 0); - - #Table name can not contain "_" - if($line =~ /\[\s*(\w+)\_(\w+)\s*\]/) { - $type = $1; - $sub_type = $2; - $name = undef; - $c = 0; - }elsif($line =~ /\[\s*System|Custom\s*\]/){ - $type = "Varible"; - }elsif ($type eq "Table") { - ##TABLE BLOCK## - if($line =~ /(\w+)\s*=\s*([\w\.\-]+)/) { - $attr = $1; - $value = $2; - if($name&&($config{table}{$sub_type}{$name}{__KEY__} ne $attr)){ - $config{table}{$sub_type}{$name}{$attr}=$value; - } else { - $name = $value; - $config{table}{$sub_type}{$name}{__KEY__}=$attr; - } - } - }elsif ($type eq "Object") { - ##OBJECT BLOCK## - if($line =~ /(\w+)\s*=\s*([:,\w\.\-\/]+)/) { - $attr = $1; - $value = $2; - if($attr eq "Name"){ - $name = $value; - } elsif(!defined($name)){ - #print "Please give name for Object\n"; - close FILE; - return 1; - } else { - $config{object}{$sub_type}{$name}{$attr}=$value; - } - } - }elsif ($type eq "Script") { - ##SCRIPT_BLOCK## - if($sub_type eq "Prev") { - $config{script_prev}->[$c] = $line; - $c = $c + 1; - } - elsif ($sub_type eq "Post") { - $config{script_post}->[$c] = $line; - $c = $c + 1; - } - } elsif ($type eq "Varible") { - ##NODE_BLOCK## - if($line =~ /(\w+)\s*=\s*([\w\.\-\+\/:]+)/) { - $config{var}{$1} = $2; - } - } - } - - close FILE; - return 0; -} -####################################### -# rewrite cluster.conf file -####################################### -sub reset_cluster_conf{ - if(exists $config{object}){ - foreach my $type (keys %{$config{object}}){ - foreach my $name (keys %{$config{object}{$type}}){ - &runcmd("echo \"[Object_node]\" >> $newclusterconffile"); - &runcmd("echo \"Name=$name\" >> $newclusterconffile"); - foreach my $attr (keys %{$config{object}{$type}{$name}}){ - &runcmd("echo \"$attr=$config{object}{$type}{$name}{$attr}\" >> $newclusterconffile"); - } - } - } - } - - if(exists $config{table}){ - foreach my $type (keys %{$config{table}}){ - &runcmd("echo \"[Table_$type]\" >> $newclusterconffile"); - foreach my $name (keys %{$config{table}{$type}}){ - &runcmd("echo \"$config{table}{$type}{$name}{__KEY__} = $name\" >> $newclusterconffile"); - foreach my $attr (keys %{$config{table}{$type}{$name}}){ - if($attr ne '__KEY__'){ - &runcmd("echo \"$attr=$config{table}{$type}{$name}{$attr}\" >> $newclusterconffile"); - } - } - } - } - } - - if(exists $config{var}){ - &runcmd("echo \"[System]\" >> $newclusterconffile"); - foreach my $varname (keys %{$config{var}}){ - &runcmd("echo \"$varname=$config{var}{$varname}\" >> $newclusterconffile"); - } - } - - return 0; -} -####################################### -# get netboot value -####################################### -sub get_netboot_value{ - my $osv=shift; - my $archv=shift; - my $mgtv=shift; - my $netbootv="none"; - if($archv =~ /x86/i){ - $netbootv="xnba"; - }elsif($archv =~ /^ppc64$/i){ - $osv =~ /(\D+)(.+)/; - my $version=$2; - if($1 =~ /rhel/i){ - if($version>=7){ - $netbootv="grub2"; - }else{ - $netbootv="yaboot"; - } - }elsif($1 =~ /sle/i){ - if($version<11.4){ - $netbootv="yaboot"; - }else{ - $netbootv="grub2"; - } - } - }elsif($archv =~ /ppc64le/i || $archv =~ /ppc64el/i){ - if($mgtv =~ /^ipmi$/i || $mgtv =~ /^openbmc$/i){ - $netbootv="petitboot"; - }else{ - $netbootv="grub2"; - } - } - return $netbootv; -} -####################################### -# init -####################################### -sub init{ - - $proid="$proname-$proruntime"; - $logfile="log.$proid"; - $logfiledir="$homedir/log/$proname/$proruntime"; - $xcatpackagesdir="$homedir/xcatpackages/$proname/$proruntime"; - $orgclusterconffile="$homedir/nodes/$cluster_name/default.conf"; - $newclusterconffile="$logfiledir/cluster.conf"; - $mailfile="$logfiledir/mail.$proid"; - if ($proname =~ /weekly/i) { - # If running weekly regression, give it an extra 2 hour - $timeout += 2; - } - if ($proname =~ /release/i) { - # If running release regression, give it an extra 4 hours - $timeout += 4; - } - - mkpath("$logfiledir") unless(-d "$logfiledir"); - mkpath("$xcatpackagesdir") unless(-d "$xcatpackagesdir"); - - return 0; -} - -####################################### -# read global conf file -####################################### -sub read_conf{ - my $myfile=undef; - my $line=undef; - - if (!open($myfile, "$globalconffile")) { - send_msg(0, "Open $globalconffile failed"); - return 1; - } - while ($line = <$myfile>) { - # $line =~ s/\s//g; Do not remove spaces for the line. - # Remove the newline character from each line. - chomp($line); - next if($line =~ /^#/); - next if($line eq ""); - my @attr=split(/=/,$line); - $confkeys{$attr[0]} = $attr[1]; - } - close($myfile); - - #for support both 'le' and 'el' - foreach my $k (keys %confkeys) { - if($k =~ /ppc64el/i || $k =~ /ppc64le/i){ - if($k =~ /(.+)-(.+)-(.+)/){ - my $newarch=$2; - my $tmp=$2; - my $os=$1; - my $flag=$3; - $newarch=~ s/ppc64el/ppc64le/g if($tmp =~ /ppc64el/i); - $newarch=~ s/ppc64le/ppc64el/g if($tmp =~ /ppc64le/i); - $confkeys{"$os-$newarch-iso"}=$confkeys{$k} if($flag=~/^iso$/); - $confkeys{"$os-$newarch-image"}=$confkeys{$k} if($flag=~/image/); - $confkeys{"$os-$newarch-miniiso"}=$confkeys{$k} if($flag=~/^miniiso$/); - } - } - } - return 0; -} - -####################################### -# usage for arguments -####################################### -sub usage{ - print "Usage:$pro_name - Run xcat test cases with jenkins.\n - Explanation for the options: - --os: Required, specify the test operating system and version\n - --cluster: Required, specify the cluster where to run the test.\n - --testcase: Required, specify the test case list. value \"all\" means running daily regression test\n - --project-name: Required, specify the project name.\n - --num: Required, specifys this is how many times does this project run.\n - --xcat-core: Required, a web address, specify where to download the xcat-core package\n - --xcat-dep: Required, a web address, specify where to download the xcat-dep package\n - --xcat-test: Optional, a URL to specify where to download the xcat-test package\n - --database: Optional, \`MySQL' by default, can be \`PostgreSQL'\n - --email: a mail address, sepcify who should receive the test result report\n - --quiet: don't output to screen, just keep output in log file. output to screen by default\n - --hold: hold environment for 24 hours if some case stop and need to hold environment\n\n"; - - print " $pro_name [-?|-h]\n"; - print " $pro_name --os --cluster --testcase --project-name --num --xcat-core --xcat-dep --email \n"; - print "\n"; - return; -} - - -####################################### -# get xcat-test package -####################################### -sub get_xcattest{ - return 0 unless($xcattest_addr); - - send_msg(2, "start to get xcat-test........"); - - my $xcat_test = (split("/", $xcattest_addr))[-1]; - my @output = runcmd("wget $xcattest_addr --retry-connrefused -nv -O $xcatpackagesdir/$xcat_test"); - if($::RUNCMD_RC){ - my $errstr = join(";", @output); - if($errstr){ - send_msg(0, "[get_xcattest] Can't download xcat-test package: $errstr"); - }else{ - send_msg(0, "[get_xcattest] Failed to download xcat-test due to network problem"); - } - return 1; - } - $xcattest_pkg = "$xcatpackagesdir/$xcat_test"; - return 0; -} -####################################### -# get build from build server -####################################### -sub get_build{ - send_msg(2, "start to get xcat build........"); - - my $xcat_core = (split("/", $xcatcore_addr))[-1]; - my @output = runcmd("wget $xcatcore_addr --retry-connrefused -nv -O $xcatpackagesdir/$xcat_core"); - if($::RUNCMD_RC){ - my $errstr = join(";", @output); - if($errstr){ - send_msg(0, "[get_build] Can't download xcat-core package: $errstr"); - }else{ - send_msg(0, "[get_build] Failed to download xcat-core due to network problem"); - } - return 1; - } - - my $xcat_dep = (split("/", $xcatdep_addr))[-1]; - @output = runcmd("wget $xcatdep_addr --retry-connrefused -nv -O $xcatpackagesdir/$xcat_dep"); - if($::RUNCMD_RC){ - my $errstr = join(";", @output); - if($errstr){ - send_msg(0, "[get_build] Can't download xcat-dep package: $errstr"); - }else{ - send_msg(0, "[get_build] Failed to download xcat-dep due to network problem"); - } - return 1; - } - - @output = runcmd("wget https://raw.githubusercontent.com/xcat2/xcat-core/master/xCAT-server/share/xcat/tools/go-xcat --no-check-certificate --retry-connrefused -nv -O $xcatpackagesdir/go-xcat"); - if($::RUNCMD_RC){ - my $errstr = join(";", @output); - if($errstr){ - send_msg(0, "[get_build] Can't download script go-xcat: $errstr"); - }else{ - send_msg(0, "[get_build] Failed to download go-xcat due to network problem"); - } - return 1; - } - - send_msg(2, "[get_build] get xcat build........[done]"); - return 0; -} - -####################################### -# get bundle from build -####################################### -sub get_bundle { - send_msg(2, "[get_bundle] start to collect case summary..."); - my $xcatcore = `ls -l /$xcatpackagesdir |grep core |grep "tar.bz2" |awk '{print \$9}'`; - chomp($xcatcore); - if ($xcatcore eq "") { - send_msg(0, "[get_bundle] can't find xcat core under /$xcatpackagesdir"); - return 1; - } - send_msg(2, "[get_bundle] xcat core = $xcatcore"); - - my $curpath = `pwd`; - chomp($curpath); - send_msg(2, "[get_bundle] The current workspace is $curpath"); - - &runcmd("cd /$xcatpackagesdir && tar xvf /$xcatpackagesdir/$xcatcore"); - if ($::RUNCMD_RC) { - send_msg(0, "[get_bundle] decompress /$xcatpackagesdir/$xcatcore failed"); - return 1; - } - send_msg(2, "[get_bundle] decompress /$xcatpackagesdir/$xcatcore to /$xcatpackagesdir succeed"); - - &runcmd("mkdir /$xcatpackagesdir/xcat-test"); - - if (-d "/$xcatpackagesdir/xcat-core/pool/main/x/xcat-test/") { - $xcattest_pkg="/$xcatpackagesdir/xcat-core/pool/main/x/xcat-test/xcat-test_*.deb" unless ($xcattest_pkg); - &runcmd("cp $xcattest_pkg /$xcatpackagesdir/xcat-test/"); - if ($::RUNCMD_RC) { - send_msg(0, "[get_bundle] cp $xcattest_pkg to /$xcatpackagesdir/xcat-test failed"); - return 1; - } - &runcmd("cd /$xcatpackagesdir/xcat-test/ && ar x /$xcatpackagesdir/xcat-test/xcat-test_*.deb && tar -Jxf data.tar.xz"); - if ($::RUNCMD_RC) { - send_msg(0, "[get_bundle] cd /$xcatpackagesdir/xcat-test/ && ar x /$xcatpackagesdir/xcat-test/xcat-test_*.deb && tar -Jxf data.tar.xz failed"); - return 1; - } - } elsif (-d "/$xcatpackagesdir/xcat-core/") { - if ((!-e "/usr/bin/rpm2cpio") && (-f "/etc/lsb-release")) { - &runcmd("apt-get install -y rpm2cpio"); - } - $xcattest_pkg="/$xcatpackagesdir/xcat-core/xCAT-test-*.rpm" unless ($xcattest_pkg); - &runcmd("rpm2cpio $xcattest_pkg | (cd /$xcatpackagesdir/xcat-test && cpio -idmv)"); - } else { - send_msg(0, "[get_bundle] can't find xcat-test package"); - return 1; - } - - my $bundle = undef; - if ($bucket =~ /^all$/i) { - $bundle = $os . "_" . $arch . ".bundle"; - } else { - $bundle = "customize.bundle"; - my @caselist = split(" ", $bucket); - my $fd; - if (!open($fd, "> $xcatpackagesdir/xcat-test/opt/xcat/share/xcat/tools/autotest/bundle/$bundle")) { - send_msg(0, "[get_bundle] Failed to create $bundle to write:$!"); - return 1; - } - foreach my $line (@caselist) { - if ($line =~ /^INCLUDE:/) { - $line =~ s/(.*)/#$1#/; - } - print $fd "$line\n"; - } - close($fd); - } - - chmod 0755, "/$xcatpackagesdir/xcat-test/opt/xcat/bin/xcattest"; - &runcmd("/$xcatpackagesdir/xcat-test/opt/xcat/bin/xcattest -l caselist -b $bundle > $logfiledir/$bundle"); - if ($::RUNCMD_RC) { - send_msg(0, "[get_bundle] xcattest calculate $bundle failed"); - return 1; - } - - return 0; -} -sub get_build_info{ - my $fd = undef; - if(!open($fd, "< /$xcatpackagesdir/xcat-core/buildinfo")){ - send_msg(0, "[get_build_info] Failed to open /$xcatpackagesdir/xcat-core/buildinfo:$!"); - return 1; - } - - while (my $line = <$fd>) { - $line =~ s/^\s+|\s+$//g; - if($line =~ /^COMMIT_ID=(.+)/){ - $commitnum = $1; - }elsif($line =~ /^BUILD_TIME=(.+)/){ - $buildtime = $1; - }elsif($line =~ /^VERSION=(.+)/){ - $xcatversion=$1; - }elsif($line =~ /^RELEASE=(.+)/){ - $xcatrelease=$1; - }elsif($line =~ /^BUILD_MACHINE=(.+)/){ - $buildserver=$1; - } - } - $xcatrelease = 'N/A' unless ($xcatrelease); - close($fd); - return 0; -} -####################################### -# do clean uo job when exit -####################################### -sub cleanup{ - unlink("/tmp/failed_case_detail.$proid") if(-e "/tmp/failed_case_detail.$proid"); - #rmdir("$xcatpackagesdir") if(-d "$xcatpackagesdir"); -} - -####################################### -# exit -####################################### -sub exit_test{ - my $rst=shift; - &cleanup; - send_msg(2, "project $proid exit $rst"); - exit $rst; -} - -####################################### -# environment check -####################################### -sub env_check { - send_msg(2, "start to environment checking.........."); - - if(! -d "$homedir/nodes/$cluster_name"){ - send_msg(0, "can't find $cluster_name under $homedir/nodes"); - return 1; - } - - if(! -e "$orgclusterconffile"){ - send_msg(0, "can't find $orgclusterconffile"); - return 1; - } - - if($cluster_name =~ /(.+)-(.+)/){ - $mn=$1; - #$arch=$2; - }else{ - send_msg(0, "the name of $cluster_name is invalid"); - return 1; - } - - - &load_cluster_conf; - if(!exists($config{object}{node}{$config{var}{CN}}{arch})){ - send_msg(0, "can't find arch of CN in $orgclusterconffile"); - return 1; - } - - $arch=$config{object}{node}{$config{var}{CN}}{arch}; - - if($arch !~ /^x86/i && - $arch !~ /^ppc64$/i && - $arch !~ /^ppc64le$/i && - $arch !~ /^ppc64el$/i){ - send_msg(0, "the arch $arch is invalid"); - return 1; - } - - if($plugin){ - if( ! -e "$plugindir/$plugin"){ - send_msg(0, "can't find customize plugin $plugin under $plugindir"); - return 1; - }else{ - chmod 0755, "$plugindir/$plugin"; - } - - } - - send_msg(2, "environment checking..........[done]"); - return 0; -} - -####################################### -# install mn -###################################### -sub mn_install { - send_msg(2, "[mn_install] start to install mn $mn......."); - - &runcmd("lsdef|grep $mn"); - if($::RUNCMD_RC){ - send_msg(0, "[mn_install] Can't find definition of $mn in current control node"); - return 1; - } - - if(!exists($confkeys{"$os-$arch-image"}) || !defined($confkeys{"$os-$arch-image"})){ - send_msg(0, "[mn_install] Can't find image definition for $mn in global conf file"); - return 1; - } - - my $osimage= $confkeys{"$os-$arch-image"}; - &runcmd("lsdef -t osimage|grep $osimage"); - if($::RUNCMD_RC){ - send_msg(0, "[mn_install] Can't find definition of $osimage in current control node"); - return 1; - } - send_msg(2, "[mn_install] plan to install $osimage on mn $mn................"); - - my $mgt = `lsdef $mn |grep mgt|awk -F'=' '{print \$2}'`; - chomp($mgt); - my $netboot=get_netboot_value("$os","$arch","$mgt"); - send_msg(2, "[mn_install] plan to set netboot of $mn [mgt=$mgt] to $netboot......"); - &runcmd("chdef $mn netboot=$netboot"); - if($::RUNCMD_RC){ - send_msg(0, "[mn_install] set netboot of $mn to $netboot failed"); - return 1; - } - send_msg(2, "[mn_install] set netboot of $mn to $netboot..[done]"); - - &runcmd("lsdef $mn -i postscripts|grep setupntp"); - if($::RUNCMD_RC){ - send_msg(2, "[mn_install] plan to set setupntp as $mn 's postscript......"); - &runcmd("chdef $mn -p postscripts=setupntp"); - if($::RUNCMD_RC){ - send_msg(0, "[mn_install] set setupntp as $mn 's postscript failed"); - return 1; - } - send_msg(2, "[mn_install] set setupntp as $mn 's postscript...[done]"); - } - - if($os =~ /ubuntu/i){ - if($arch =~ /le/i || $arch =~ /el/i){ - if(exists $confkeys{"$os-$arch-miniiso"}){ - my $miniisopath=$logfiledir; - my $downloadpath=$confkeys{"$os-$arch-miniiso"}; - my $miniisoname = (split("/", $downloadpath))[-1]; - my @output=runcmd("wget $downloadpath --retry-connrefused -nv -O $miniisopath/$miniisoname"); - if($::RUNCMD_RC){ - my $errstr = join(";", @output); - if($errstr){ - send_msg(0, "[mn_install] Can't download mini.iso: $errstr"); - }else{ - send_msg(0, "[mn_install] failed to download mini.iso due to network problem"); - } - return 1; - } - send_msg(2, "[mn_install] download mini.iso from $downloadpath ....[done]"); - mkpath("/install/$os/ppc64el/install/netboot") if(! -e "/install/$os/ppc64el/install/netboot"); - rename("/install/$os/ppc64el/install/netboot/initrd.gz", "/install/$os/ppc64el/install/netboot/initrd.gz.bakupby$proid") if(-e "/install/$os/ppc64el/install/netboot/initrd.gz"); - mkpath("$miniisopath/mountpoint"); - &runcmd("mount -o loop $miniisopath/mini.iso $miniisopath/mountpoint"); - &runcmd("cp $miniisopath/mountpoint/install/initrd.gz /install/$os/ppc64el/install/netboot/"); - &runcmd("umount $miniisopath/mountpoint"); - unlink("$miniisopath/mountpoint"); - }else{ - send_msg(2, "[mn_install] there is no miniiso configuration for $os"); - } - } - } - - my $installmnsuccess = 0; - my $tryreinstall = 5; - while($tryreinstall){ - send_msg(2, "[mn_install] [$tryreinstall] Try to install $mn ..."); - - my $tryreboot = 5; - my $returncode=0; - my @output = (); - my $rebootcmd = "rinstall $mn osimage=$osimage"; - while($tryreboot){ - @output = runcmd("$rebootcmd"); - $returncode = $::RUNCMD_RC; - send_msg(2, "[mn_install] [$tryreboot] $rebootcmd returncode=$returncode"); - last if (!$returncode); - --$tryreboot; - &runcmd("makeconservercf $mn") if($arch =~ /^ppc64$/i); - sleep 2; - } - - if($returncode){ - my $outputstr = join(";", @output); - send_msg(0, "[mn_install] reboot $mn error: $outputstr"); - last; - } - my $sleep_seconds = 300; - my $sleep_interval = 30; - my $sleep_loops = 40; # 20 min (40*30/60) - - send_msg(2, "[mn_install] reboot $mn ...[done], wait $sleep_seconds sec for install to start, then check node status every $sleep_interval sec for $sleep_loops iterations ..."); - - # initial sleep while waiting for installation - sleep $sleep_seconds; - - my $a = 1; - while ($a < $sleep_loops) { - my @output = runcmd("lsdef -l $mn -i status -c"); - my $status_output = join(";", @output); - send_msg(2, "[mn_install] [$a] $status_output"); - - if ($status_output =~ /failed/i) { - # If status=failed, nothing is changing so why retry? - send_msg(0, "[mn_install] [$a] install $osimage on mn $mn failed on postscripts."); - return 1; - } elsif ($status_output =~ /booted/i) { - last; - } - sleep $sleep_interval; - ++$a; - } - - &runcmd("lsdef -l $mn -i status -c | grep booted >/dev/null"); - my $tobooted = $::RUNCMD_RC; - - &runcmd("ping -c 2 $mn > /dev/null"); - my $pingable = $::RUNCMD_RC; - - &runcmd("xdsh $mn date > /dev/null"); - my $canruncmd = $::RUNCMD_RC; - - $installmnsuccess = !($canruncmd | $tobooted | $pingable); - last if($installmnsuccess); - --$tryreinstall; - } - - if(!$installmnsuccess){ - send_msg(0, "[mn_install] install $osimage on mn $mn failed"); - return 1; - } - - - if($os =~ /sle15/i){ - # For SLES15 disable all 3 types of snapper snapshots, too much disk space is taken - - # 1. Disable timeline snapshots (by default hourly) - &runcmd("xdsh $mn snapper --config root set-config 'TIMELINE_CREATE=no'"); - - # 2. Disable YaST snapshots - &runcmd("xdsh $mn sed -i 's/USE_SNAPPER=\"yes\"/USE_SNAPPER=\"no\"/g' /etc/sysconfig/yast2"); - - # 3. Disable zypper snapshots - remove RPM - my $snapper_rpm = "snapper-zypp-plugin"; - &runcmd("xdsh $mn zypper remove -y $snapper_rpm"); - if($::RUNCMD_RC){ - send_msg(0, "[mn_install] removal of $snapper_rpm from $mn failed"); - return 1; - } - send_msg(2, "[mn_install] removed $snapper_rpm from $mn ...[done]"); - } - - send_msg(2, "install mn $mn .....[done]"); - return 0; -} - - -####################################### -# prepare mn -# copy all necessary file to MN -###################################### -sub prepare_mn { - send_msg(2, "[prepare_mn] start to prepare mn $mn......."); - - if($os =~ /rhels7/i || $os =~ /ol7/i){ - &runcmd("xdsh $mn \"yum -y install bzip2 \" >/dev/null 2>&1"); - } - - # Attempt to insall on bzip2 on SLES. Some versions do not have it - # installed by default. If already there, command will do nothing - if($os =~ /sle/i){ - &runcmd("xdsh $mn \"zypper install -y bzip2 \" >/dev/null 2>&1"); - } - - my $xcatcore=`ls -l /$xcatpackagesdir |grep core |grep "tar.bz2" |awk '{print \$9}'`; - my $xcatdep=`ls -l /$xcatpackagesdir |grep dep |awk '{print \$9}'`; - chomp($xcatcore); - chomp($xcatdep); - if($xcatcore eq ""){ - send_msg(0, "[prepare_mn] can't find xcat core under /$xcatpackagesdir"); - return 1; - } - if($xcatdep eq ""){ - send_msg(0, "[prepare_mn] can't find xcat dep under /$xcatpackagesdir"); - return 1; - } - - send_msg(2, "[prepare_mn] starting to copy $xcatcore and $xcatdep to $mn"); - &runcmd("scp /$xcatpackagesdir/$xcatcore /$xcatpackagesdir/$xcatdep root\@$mn:/ >/dev/null"); - if($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] copy $xcatcore and $xcatdep to $mn failed"); - return 1; - } - send_msg(2, "[prepare_mn] copy $xcatcore and $xcatdep to $mn...[done]"); - - send_msg(2, "[prepare_mn] starting to copy go-xcat to $mn"); - &runcmd("scp /$xcatpackagesdir/go-xcat root\@$mn:/ >/dev/null"); - if($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] copy go-xcat to $mn failed"); - return 1; - } - send_msg(2, "[prepare_mn] copy go-xcat to $mn...[done]"); - - send_msg(2, "[prepare_mn] starting to decompress xcat packages....."); - &runcmd("xdsh $mn 'cd / && tar xvf /$xcatcore' >/dev/null 2>&1"); - if($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] decompress $xcatcore on $mn failed"); - return 1; - } - unless ($xcatcore =~ /^core/) { - &runcmd("xdsh $mn 'cd / && ln -s /$xcatcore core-testing-snap.tar.bz2' >/dev/null 2>&1"); - } - - &runcmd("xdsh $mn 'cd / && tar xvf /$xcatdep' >/dev/null 2>&1"); - if($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] decompress $xcatdep on $mn failed"); - return 1; - } - send_msg(2, "[prepare_mn] decompress xcat packages....[done]"); - - - &runcmd("scp $xcattest_pkg root\@$mn:/ >/dev/null"); - if($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] copy $xcattest_pkg to $mn failed"); - return 1; - } - - #prepare /etc/hosts file on MN - &runcmd("scp /etc/hosts root\@$mn:/etc >/dev/null"); - if ($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] generate /etc/hosts on $mn failed"); - return 1; - } - send_msg(2, "[prepare_mn] generate /etc/hosts on $mn...[done]"); - - #prepare specific files on mn for each platform - if($os =~ /rhel/i || $os =~ /ol/i){ - my $rpm_pgp_key_file="RPM-GPG-KEY-redhat-release"; - if($os =~ /ol/i){ - $rpm_pgp_key_file="RPM-GPG-KEY-oracle"; - } - my $osimage=$confkeys{"$os-$arch-image"}; - my @pkgdir=runcmd("lsdef -t osimage $osimage -i pkgdir -c|awk -F'=' '{print \$2}'"); - - send_msg(2, "[prepare_mn] the location of $rpm_pgp_key_file is $pkgdir[0]"); - &runcmd("scp $pkgdir[0]/$rpm_pgp_key_file root\@$mn:/ >/dev/null"); - if($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] copy $rpm_pgp_key_file to $mn failed"); - return 1; - } - send_msg(2, "[prepare_mn] copy $rpm_pgp_key_file to $mn...[done]"); - } - - my $iso= $confkeys{"$os-$arch-iso"}; - if ($iso eq ""){ - send_msg(0, "[prepare_mn] can't find iso for $mn in global conf file"); - return 1; - } - - - # In case there are multiple ISO files. - my @iso_array=split(' ', $iso); - - foreach my $each_iso (@iso_array){ - if(! -e "$isodir/$each_iso"){ - send_msg(0, "[prepare_mn] can't find $each_iso under $isodir"); - return 1; - } - send_msg(2, "[prepare_mn] find $each_iso for os=$os and arch=$arch"); - - &runcmd("scp $isodir/$each_iso root\@$mn:/ >/dev/null"); - if($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] copy $each_iso to $mn failed"); - return 1; - } - send_msg(2, "[prepare_mn] copy $each_iso to $mn...[done]"); - } - - if($os =~ /ubuntu/i){ - if($arch =~ /le/i || $arch =~ /el/i){ - if(exists $confkeys{"$os-$arch-miniiso"}){ - my $miniisopath=$logfiledir; - &runcmd("scp $miniisopath/mini.iso root\@$mn:/ >/dev/null 2>&1"); - if($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] copy $miniisopath/mini.iso to $mn failed"); - return 1; - } - send_msg(2, "[prepare_mn] copy $miniisopath/mini.iso to $mn...[done]"); - } - } - } - - &load_cluster_conf; - if(exists ($config{var}{SN}) && $config{var}{SN} ne "NULL"){ - if(!exists($config{object}{node}{$config{var}{SN}}{arch})){ - send_msg(0, "[prepare_mn] SN without arch attribute in $orgclusterconffile"); - return 1; - } - if(!exists($config{object}{node}{$config{var}{SN}}{mgt})){ - send_msg(0, "[prepare_mn] SN without mgt attribute in $orgclusterconffile"); - return 1; - } - $config{object}{node}{$config{var}{SN}}{netboot}=get_netboot_value("$os","$config{object}{node}{$config{var}{SN}}{arch}","$config{object}{node}{$config{var}{SN}}{mgt}"); - if($config{object}{node}{$config{var}{SN}}{netboot} eq "none"){ - send_msg(0, "[prepare_mn] can't find appropriate netboot value for $os+$config{object}{node}{$config{var}{SN}}{arch}+$config{object}{node}{$config{var}{SN}}{mgt} scenario"); - return 1; - } - $config{object}{node}{$config{var}{SN}}{os}=$os; - - if($arch =~ /ppc64le/i || $arch =~ /ppc64el/i){ - if($os =~ /ubuntu/i){ - $config{object}{node}{$config{var}{SN}}{arch}="ppc64el"; - }else{ - $config{object}{node}{$config{var}{SN}}{arch}="ppc64le"; - } - } - } - - if(exists ($config{var}{CN})){ - if(!exists($config{object}{node}{$config{var}{CN}}{arch})){ - send_msg(0, "[prepare_mn] CN without arch attribute in $orgclusterconffile"); - return 1; - } - if(!exists($config{object}{node}{$config{var}{CN}}{mgt})){ - send_msg(0, "[prepare_mn] CN without mgt attribute in $orgclusterconffile"); - return 1; - } - $config{object}{node}{$config{var}{CN}}{netboot}=get_netboot_value("$os","$config{object}{node}{$config{var}{CN}}{arch}","$config{object}{node}{$config{var}{CN}}{mgt}"); - if($config{object}{node}{$config{var}{CN}}{netboot} eq "none"){ - send_msg(0, "[prepare_mn] can't find appropriate netboot value for $os+$config{object}{node}{$config{var}{CN}}{arch}+$config{object}{node}{$config{var}{CN}}{mgt} scenario"); - return 1; - } - $config{object}{node}{$config{var}{CN}}{os}=$os; - - if($arch =~ /ppc64le/i || $arch =~ /ppc64el/i){ - if($os =~ /ubuntu/i){ - $config{object}{node}{$config{var}{CN}}{arch}="ppc64el"; - }else{ - $config{object}{node}{$config{var}{CN}}{arch}="ppc64le"; - } - } - } - - if(exists ($config{var}{ISO})){ - $config{var}{ISO}="/$iso"; - # Add "/" before additional ISO files. - $config{var}{ISO}=~ s/\s/ \//; - } - - if(exists ($config{var}{OS})){ - if($os =~ /(\D+)\d.*/){ - $config{var}{OS}="$1"; - } - } - - # the default.conf defined eth0/eth1/eth2 for nic name - # The confignetwork script failed for rehls8 because there are no such nic name - # eth0/eth1/eth2 nic name works for other interface except rhels8 - # replace with real interface name for rhels8 cluster instead of eth0/eth1/eth2 - if($os =~ /rhels8/i && $arch =~ /ppc64/i){ - if(exists ($config{var}{NICNAME})){ - $config{var}{NICNAME}="enp0s1"; - } - if (exists ($config{var}{SECONDNIC})){ - $config{var}{SECONDNIC}="enp0s2"; - } - if (exists ($config{var}{THIRDNIC})) { - $config{var}{THIRDNIC}="enp0s3"; - } - } - - $config{var}{XCAT_DATABASE}="$xcat_database"; - - &reset_cluster_conf; - - send_msg(2, "Try to mount extra resource directory to $mn"); - &runcmd("xdsh $mn 'mkdir -p $automation_mountpoint'"); - if($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] create automation mount point for extra resource on $mn failed"); - return 1; - } - # Insert login node as a nameserver so the GPFS server name can be resolved - &runcmd("xdsh $mn \"sed -i \'/nameserver.*/i nameserver $login_node_nameserver\' /etc/resolv.conf\""); - if($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] modifying /etc/resolv.conf to add nameserver $login_node_nameserver failed"); - return 1; - } - &runcmd("xdsh $mn 'mount $extra_resource_path $automation_mountpoint'"); - if($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] mount extra resource $extra_resource_path to $mn $automation_mountpoint failed"); - return 1; - } - - # Remove login node as a nameserver so the local nameserving resumes - &runcmd("xdsh $mn 'sed -i \'/$login_node_nameserver/d\' /etc/resolv.conf'"); - if($::RUNCMD_RC){ - send_msg(0, "[prepare_mn] modifying /etc/resolv.conf to restore original nameserver failed"); - return 1; - } - send_msg(2, "prepare mn $mn .....[done]"); - return 0; -} - - -############################################################ -# install xcat-test package and other dependency packages -############################################################ -sub install_xcattest { - send_msg(2, "[install_xcattest] starting to install xcat-test on $mn"); - send_msg(2, "[install_xcattest] xcat_database = $xcat_database"); - if($os =~ /rhel/i || $os =~ /ol/i || $os =~ /rocky/i){ - my $rpm_pgp_key_file="RPM-GPG-KEY-redhat-release"; - if($os =~ /ol/i){ - $rpm_pgp_key_file="RPM-GPG-KEY-oracle"; - } - $os =~ /(\D+)(\d+)\.?(\d?)/; - &runcmd("xdsh $mn \"cd /xcat-core && ./mklocalrepo.sh\" >/dev/null 2>&1"); - my $version=$2; - if($arch =~ /ppc64le/i || $arch =~ /ppc64el/i){ - &runcmd("xdsh $mn \"cd /xcat-dep/rh$version/ppc64le && ./mklocalrepo.sh\" >/dev/null 2>&1"); - }else{ - &runcmd("xdsh $mn \"cd /xcat-dep/rh$version/$arch && ./mklocalrepo.sh\" >/dev/null 2>&1"); - } - my $install_timeout = 300; # 5 min timeout for package installation - unless($os =~ /rocky/i) { # no pgp key file for rocky - &runcmd("xdsh $mn \"rpm --import /$rpm_pgp_key_file\" >/dev/null 2>&1"); - } - # Increase timeout for "yum install" command to 60 seconds (default is 30 seconds) - &runcmd("xdsh $mn \"echo timeout=60 >> /etc/yum.conf\" "); - &runcmd("xdsh $mn -t $install_timeout \"yum -y install createrepo\" 2>&1"); - if($::RUNCMD_RC){ - debug_pkg_install("createrepo"); - return 1; - } - &runcmd("xdsh $mn -t $install_timeout \"yum -y install expect perl-Getopt-Long perl-Data-Dumper\" 2>&1"); - if($::RUNCMD_RC){ - debug_pkg_install("expect perl-Getopt-Long perl-Data-Dumper"); - return 1; - } - &runcmd("xdsh $mn -t $install_timeout \"rpm -ivh /xCAT-test-*.rpm --nodeps > $installlog 2>&1 \" >/dev/null 2>&1"); - - if ($xcat_database eq "PostgreSQL") { - send_msg(2, "[install_xcattest] installing PostgreSQL rpms on $mn for $os"); - &runcmd("xdsh $mn -t $install_timeout \"yum -y install postgresql-server postgresql perl-DBD-Pg\" 2>&1"); - if($::RUNCMD_RC){ - debug_pkg_install("postgresql-server postgresql perl-DBD-Pg"); - return 1; - } - } else { - if($os =~ /rhels7/i || $os =~ /ol7/i){ - send_msg(2, "[install_xcattest] installing MariaDB rpms on $mn for $os"); - &runcmd("xdsh $mn \"yum -y install mariadb-libs mariadb-server mariadb mysql-connector-odbc perl-DBD-MySQL unixODBC\" >/dev/null 2>&1"); - } elsif ($os =~ /rhels6/i) { - send_msg(2, "[install_xcattest] installing MySQL rpms on $mn for $os"); - &runcmd("xdsh $mn \"yum -y install mysql-server mysql mysql-connector-odbc perl-DBD-MySQL\" >/dev/null 2>&1"); - } elsif ($os =~ /rhels8/i || $os =~ /ol8/i || $os =~ /rocky8/i){ - send_msg(2, "[install_xcattest] installing MariaDB rpms on $mn for $os"); - &runcmd("xdsh $mn -t $install_timeout \"yum -y install mariadb-server mariadb perl-DBD-MySQL mariadb-connector-odbc\" >/dev/null 2>&1"); - } - } - - if($arch =~ /x86/i){ - &runcmd("xdsh $mn \"yum install -y perl-Sys-Virt\" >/dev/null 2>&1"); - } - }elsif($os =~ /sle/i){ - $os =~ /(\D+)(\d+)\.?(\d?)/; - my $version=$2; - if($arch =~ /ppc64le/i || $arch =~ /ppc64el/i){ - &runcmd("xdsh $mn \"zypper ar file:///xcat-dep/sles$version/ppc64le xCAT-dep\" >/dev/null 2>&1"); - }else{ - &runcmd("xdsh $mn \"zypper ar file:///xcat-dep/sles$version/$arch xCAT-dep\" >/dev/null 2>&1"); - } - &runcmd("xdsh $mn \"zypper ar file:///xcat-core xCAT-core\" >/dev/null 2>&1"); - &runcmd("xdsh $mn \"zypper sl -U\" >/dev/null 2>&1"); - &runcmd("xdsh $mn \"zypper --gpg-auto-import-keys search --match-exact -s screen\" >/dev/null 2>&1"); - &runcmd("xdsh $mn \"rpm -ivh /xCAT-test-*.rpm --nosignature --nodeps > $installlog 2>&1 \" >/dev/null 2>&1"); - if ($os =~ /sle15/i){ - &runcmd("xdsh $mn \"zypper -n install createrepo_c expect\" >/dev/null 2>&1"); - } else { - &runcmd("xdsh $mn \"zypper -n install createrepo expect\" >/dev/null 2>&1"); - } - - if ($xcat_database eq "PostgreSQL") { - if ($os =~ /sle15/i){ - &runcmd("xdsh $mn \"zypper -n install perl-DBD-Pg postgresql postgresql-server >> $installlog 2>&1\">/dev/null 2>&1"); - } else { - &runcmd("xdsh $mn \"zypper -n install postgresql93 postgresql93-libs postgresql93-server perl-DBD-Pg >> $installlog 2>&1\">/dev/null 2>&1"); - } - } else { - if ($os =~ /sle15/i) { - &runcmd("xdsh $mn \"zypper -n install mariadb-client mariadb mariadb-errormessages perl-DBD-mysql libmariadb-devel mariadb-tools libmariadb_plugins >> $installlog 2>&1\">/dev/null 2>&1"); - } elsif ($os =~ /sles12/i) { - &runcmd("xdsh $mn \"zypper -n install mariadb-client mariadb mariadb-errormessages libmysqlclient18 perl-DBD-mysql >> $installlog 2>&1\">/dev/null 2>&1"); - } elsif ($os =~ /sles11/i) { - &runcmd("xdsh $mn \"zypper -n install mysql-client libmysqlclient_r15 libmysqlclient15 perl-DBD-mysql mysql unixODBC >> $installlog 2>&1\" >/dev/null 2>&1"); - } - } - if($arch =~ /ppc64le/i || $arch =~ /ppc64el/i) { - if ($os =~ /sles/i) { - &runcmd ("xdsh $mn \"zypper -n install perl-Net-DNS-0.80-1.ppc64le\">/dev/null 2>&1"); - } - } - if($arch =~ /x86/i){ - &runcmd("xdsh $mn \"zypper -n install perl-Sys-Virt\" >/dev/null 2>&1"); - } - }elsif($os =~ /ubuntu/i){ - &runcmd("xdsh $mn 'apt-get -y install software-properties-common' >/dev/null 2>&1"); - if($::RUNCMD_RC){ - send_msg(0, "[install_xcattest] apt-get -y install software-properties-common in $mn failed"); - return 1; - } - - my $mirror_location=""; - if($arch =~ /x86/i){ - $mirror_location="http://archive.ubuntu.com/ubuntu"; - } elsif($arch =~ /ppc64le/i || $arch =~ /ppc64el/i) { - $mirror_location="http://ports.ubuntu.com/ubuntu-ports"; - } - &runcmd("xdsh $mn 'add-apt-repository \"deb $mirror_location \$(lsb_release -sc) main\"' >/dev/null 2>&1"); - &runcmd("xdsh $mn 'add-apt-repository \"deb $mirror_location \$(lsb_release -sc)-updates main\"' >/dev/null 2>&1"); - &runcmd("xdsh $mn 'add-apt-repository \"deb $mirror_location \$(lsb_release -sc) universe\"' >/dev/null 2>&1"); - &runcmd("xdsh $mn 'add-apt-repository \"deb $mirror_location \$(lsb_release -sc)-updates universe\"' >/dev/null 2>&1"); - send_msg(2, "[install_xcattest] add $mirror_location to the source.list of $mn"); - - &runcmd("xdsh $mn \"/xcat-core/mklocalrepo.sh\" >/dev/null 2>&1"); - if($::RUNCMD_RC){ - send_msg(0, "[install_xcattest] /xcat-core/mklocalrepo.sh in $mn failed"); - return 1; - } - &runcmd("xdsh $mn \"/xcat-dep/mklocalrepo.sh\" >/dev/null 2>&1"); - if($::RUNCMD_RC){ - send_msg(0, "[install_xcattest] /xcat-dep/mklocalrepo.sh in $mn failed"); - return 1; - } - - &runcmd("xdsh $mn 'rm -rf /var/lib/apt/lists/*'"); - &runcmd("xdsh $mn 'apt-get clean all' >/dev/null 2>&1"); - if($::RUNCMD_RC){ - send_msg(0, "[install_xcattest] apt-get clean all in $mn failed"); - return 1; - } - &runcmd("xdsh $mn 'apt-get update' >/dev/null 2>&1"); - - my @output = runcmd("xdsh $mn \"wget \"http://xcat.org/files/xcat/repos/apt/apt.key\" --retry-connrefused -nv -O - >/tmp/apt.key\""); - if($::RUNCMD_RC){ - my $errstr = join(",", @output); - if($errstr){ - send_msg(0, "[install_xcattest] download apt.key error: $errstr"); - }else{ - send_msg(0, "[install_xcattest] failed to download apt.key due to network problem"); - } - return 1; - } - - #&runcmd("xdsh $mn 'apt-get -y install gnupg perl' >/dev/null 2>&1"); - @output=runcmd("xdsh $mn 'apt-get -y install gnupg perl' >/dev/null 2>&1"); - if($::RUNCMD_RC){ - my $errstr = join(",", @output); - if($errstr){ - send_msg(0, "[install_xcattest] apt-get -y install gnupg perl in $mn failed: $errstr"); - }else{ - send_msg(0, "[install_xcattest] apt-get -y install gnupg perl in $mn failed"); - } - return 1; - } - - &runcmd("xdsh $mn 'apt-key add /tmp/apt.key 2>&1'"); - if($::RUNCMD_RC){ - send_msg(0, "[install_xcattest] apt-key add /tmp/apt.key in $mn failed"); - return 1; - } - - &runcmd("xdsh $mn \"dpkg -i /xcat-test_*.deb > $installlog 2>&1\" >/dev/null 2>&1"); - if($::RUNCMD_RC){ - send_msg(0, "[install_xcattest] apt-get -y install xcat-test in $mn failed"); - }else{ - if($arch =~ /le/i || $arch =~ /el/i){ - &runcmd("xdsh $mn 'mkdir -p /install/$os/%arch/install/netboot '"); - &runcmd("scp /install/$os/%arch/install/netboot/initrd.gz $mn:/install/%os/%arch/install/netboot "); - } - } - } - - &runcmd("scp $mn:/$installlog $logfiledir/new_xcattest_installation.log >/dev/null 2>&1"); - - #check if xcat-test is installed successfully on mn - if($os =~ /rhel/i || $os =~ /sle/i || $os =~ /ol/i || $os =~ /rocky/i){ - &runcmd("xdsh $mn \"rpm -qa --nosignature |grep -i xCAT-test\" >/dev/null 2>&1"); - }else{ - &runcmd("xdsh $mn 'dpkg -l |grep -i xcat-test' >/dev/null 2>&1"); - } - - if($::RUNCMD_RC){ - # Installation of xcat-test failed, check if it was RPM DB library corruption on RHEL - if($os =~ /rhel/i) { - &runcmd("xdsh $mn \"rpm -qa --nosignature 2>&1 | grep -i 'Thread died in Berkeley DB library'\" "); - if(!$::RUNCMD_RC){ - # It was a RPM DB library corruption, try to fix it - send_msg(0, "[install_xcattest] install xcat-test in $mn failed, RPM DB library corruption"); - &runcmd("xdsh $mn \"rpm --rebuilddb\" >/dev/null 2>&1"); - &runcmd("xdsh $mn \"yum clean all\" >/dev/null 2>&1"); - send_msg(0, "[install_xcattest] RPM DB library corruption cleaned"); - return 2; # Return 2 to retry install_xcattest() - } - } - send_msg(0, "[install_xcattest] install xcat-test in $mn failed"); - return 1; - } - - #export some environment variables - &runcmd("xdsh $mn \"touch /etc/profile.d/xcatjk.sh; echo -e \\\"XCATROOT=/opt/xcat\nPATH=\$XCATROOT/bin:\$XCATROOT/sbin:\$XCATROOT/share/xcat/tools:\$PATH\nMANPATH=\$XCATROOT/share/man:\$MANPATH\nexport XCATROOT PATH MANPATH\nexport PERL_BADLANG=0\\\" >> /etc/profile.d/xcatjk.sh;source /etc/profile.d/xcatjk.sh\" >/dev/null 2>&1"); - if($::RUNCMD_RC){ - send_msg(2, "[install_xcattest] set environment variables failed"); - return 1; - }else{ - send_msg(2, "[install_xcattest] set environment variables succeeded"); - } - - send_msg(2, "[install_xcattest] install xcat-test in $mn successfully"); - return 0; - -} - -####################################### -# do test -####################################### -sub do_test { - my $casestop = 0; - my $installcasestop = 0; - - send_msg(2, "[do_test] starting to run regression test in $mn"); - - &runcmd("scp $newclusterconffile root\@$mn:/opt/xcat/share/xcat/tools/autotest/default.conf >/dev/null"); - if ($::RUNCMD_RC) { - send_msg(0, "[do_test] copy $newclusterconffile to $mn failed"); - return 1; - } - send_msg(2, "[do_test] copy $newclusterconffile to $mn successfully"); - - #this is a workaround in ubuntu environment - if ($os =~ /ubuntu/i) { - send_msg(2, "[do_test] change /bin/sh setting in ubuntu environment"); - runcmd("xdsh $mn \"rm -rf /bin/sh\" >/dev/null 2>&1"); - runcmd("xdsh $mn \"ln -s /bin/bash /bin/sh\""); - } - - #run the special install_xcat case first - my $rst1 = 0; - my @output1; - send_msg(2, "[do_test] doing test for case install_xcat in $mn....."); - if ($os !~ /ubuntu/i) { - @output1 = runcmd("xdsh $mn \"xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf:System -t install_xCAT_on_rhels_sles >/dev/null\""); - $rst1 = $::RUNCMD_RC; - } else { - @output1 = runcmd("ssh -t $mn 'exec bash -l -i -c \"xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf:System -t install_xCAT_on_ubuntu >/dev/null\"'"); - $rst1 = $::RUNCMD_RC; - } - - if ($rst1) { - $installcasestop = 1; - my $tmpoutput1 = join(' ', @output1); - send_msg(2, "[do_test] install_xcat output of trigger xcattest: $tmpoutput1"); - send_msg(2, "[do_test] the install_xcat case on $mn was STOPPED for some reason"); - } else { - send_msg(2, "[do_test] run install_xcat in $mn successful"); - } - - if ($installcasestop) - { - &runcmd("scp -r $mn:/opt/xcat/share/xcat/tools/autotest/result/* $logfiledir >/dev/null 2>&1"); - &runcmd("rm -rf $logfiledir/rpower.* $logfiledir/getcons.* >/dev/null 2>&1"); - if ($::RUNCMD_RC) { - send_msg(0, "[do_test] copy install_case result to $logfiledir failed"); - } - return 2; - } - - #if set PostgrepSQL as default DB, should running all commands test against PostgreSQL - if ($xcat_database eq "PostgreSQL") { - &runcmd("xdsh $mn \"XCATPGPW=12345 /opt/xcat/bin/pgsqlsetup -i -V 2>&1 >/tmp/PostgreSQL_setup.log\""); - if($::RUNCMD_RC){ - send_msg(0, "[do_test] pgsqlsetup -i -V failed"); - return 1; - } - &runcmd("xdsh $mn \"echo 'host all all 0.0.0.0/0 md5' >> /var/lib/pgsql/data/pg_hba.conf\""); - &runcmd("xdsh $mn \"echo 'host all all ::0/0 md5' >> /var/lib/pgsql/data/pg_hba.conf\""); - &runcmd("xdsh $mn \"service postgresql restart >> /tmp/PostgreSQL_setup.log \""); - - &runcmd("xdsh $mn \"lsxcatd -d\" |grep 'dbengine=Pg' > /dev/null"); - if($::RUNCMD_RC){ - send_msg(0, "[do_test] switch DB from SQLite to PostgreSQL failed"); - return 1; - } - } - - #then run other cases with the bundle file - my $bundle = undef; - if ($bucket =~ /^all$/i) { - $bundle = $os . "_" . $arch . ".bundle"; - } else { - $bundle = "customize.bundle"; - &runcmd("scp $logfiledir/$bundle $mn:/opt/xcat/share/xcat/tools/autotest/bundle/ >/dev/null 2>&1"); - if ($::RUNCMD_RC) { - send_msg(0, "[do_test] copy $logfiledir/$bundle to $mn:/opt/xcat/share/xcat/tools/autotest/bundle/ failed"); - return 1; - } - } - - my $rst = 0; - my @output; - send_msg(2, "[do_test] doing test [$bundle] in $mn....."); - if ($os !~ /ubuntu/i) { - @output = runcmd("xdsh $mn \"xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -b $bundle >/dev/null\""); - $rst = $::RUNCMD_RC; - } else { - @output = runcmd("ssh -t $mn 'exec bash -l -i -c \"xcattest -f /opt/xcat/share/xcat/tools/autotest/default.conf -b $bundle >/dev/null\"'"); - $rst = $::RUNCMD_RC; - } - my $tmpoutput = join(' ', @output); - send_msg(2, "[do_test] output of trigger xcattest: $tmpoutput"); - if ($rst) { - $casestop = 1; - send_msg(2, "[do_test] the regression job in $mn was STOPPED for some one case"); - } else { - send_msg(2, "[do_test] run the whole regression test in $mn finished"); - } - - &runcmd("scp -r $mn:/opt/xcat/share/xcat/tools/autotest/result/* $logfiledir >/dev/null 2>&1"); - &runcmd("rm -rf $logfiledir/rpower.* $logfiledir/getcons.* >/dev/null 2>&1"); - if ($::RUNCMD_RC) { - send_msg(0, "[do_test] copy regression result to $logfiledir failed"); - return 1; - } - send_msg(2, "[do_test] copy regression result to $logfiledir successfully"); - - return 2 if ($casestop); - return 0; -} - -####################################### -# create report -####################################### -sub create_report{ - send_msg(2, "[create_report] start to create test report"); - - #Due to trigger case "install_xCAT" independently, so add this case into bundle for xCAT Jenkins Mail Bot - my $fd = undef; - my $bundlefile = undef; - my $line=undef; - my @cases=(); - my $insertcase=undef; - - if($bucket =~ /^all$/i){ - $bundlefile = "$logfiledir/$os"."_"."$arch.bundle"; - }else{ - $bundlefile = "$logfiledir/customize.bundle"; - } - - if($os !~ /ubuntu/i){ - $insertcase="install_xCAT_on_rhels_sles"; - }else{ - $insertcase="install_xCAT_on_ubuntu"; - } - - if(!open($fd, "< $bundlefile")){ - send_msg(0, "[create_report] Failed to open $bundlefile to read:$!"); - return 1; - } - - push @cases, $line while ($line = <$fd>); - close($fd); - - unshift @cases, "$insertcase\n"; - - if(!open($fd, "> $bundlefile")){ - send_msg(0, "[create_report] Failed to open $bundlefile to write:$!"); - return 1; - } - - foreach my $line (@cases){ - next if($line =~ /^description/); - print $fd $line; - $line =~ s/^\s+|#.+|\s+$//g; - if(length($line) != 0){ - ++$totalcase; - } - } - close($fd); - - my $mailreport .= "======================================\n"; - $mailreport .= " Test Result for Project $proid\n"; - $mailreport .= "======================================\n\n"; - $mailreport .= "[$os+$arch]\n\n"; - - $regendtime=($regstarttime + $all_reg_time_consumption); - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); - my $datetime; - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($regstarttime); - $year += 1900; - $mon += 1; - $datetime = sprintf ("%d-%02d-%02d %02d:%02d:%02d", $year,$mon,$mday,$hour,$min,$sec); - $mailreport .= "\tStart time: $datetime\n\n"; - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($regendtime); - $year += 1900; - $mon += 1; - $datetime = sprintf ("%d-%02d-%02d %02d:%02d:%02d", $year,$mon,$mday,$hour,$min,$sec); - $mailreport .= "\tEnd time : $datetime\n\n"; - - if($sub_process_rt){ - my $h=int($all_reg_time_consumption/3600); - my $m=int(($all_reg_time_consumption - $h*3600)/60); - my $s=($all_reg_time_consumption - $h*3600)%60; - $mailreport .= "\tAll time consumption: $h hours $m minutes $s seconds\n\n"; - - if($env_dply_time_consumption){ - $h=int($env_dply_time_consumption/3600); - $m=int(($env_dply_time_consumption - $h*3600)/60); - $s=($env_dply_time_consumption- $h*3600)%60; - $mailreport .= "\tDeploy test environment time consumption: $h hours $m minutes $s seconds\n\n"; - } - }else{ - $mailreport .= "\tTime consumption exceeded $timeout hours!!!!!!\n\n"; - } - - $mailreport .= "\txcat core : $xcatversion-$xcatrelease\n\n"; - $mailreport .= "\txcat dep : $xcatdep_addr\n\n"; - $mailreport .= "\tcommit num: $commitnum\n\n" if(defined $commitnum); - - if($err_record ne ""){ - $mailreport .= "\tSetting test environment: $err_record\n\n"; - } - - if($plugin){ - send_msg(2, "[create_report] start to run $logfiledir/plugin.log"); - &runcmd("HOME_DIR=\"$homedir\" PROJECT_NAME=\"$proname\" PROJECT_RUNNUM=\"$proruntime\" $plugindir/$plugin > $logfiledir/plugin.log 2>&1 "); - my @output = runcmd("cat $logfiledir/plugin.log"); - my $content=0; - my $attachment=0; - foreach (@output){ - chomp($_); - if($_ =~ /\[content\]/){ - $content=1; - $attachment=0; - }elsif($_ =~ /\[attachment\]/){ - $content=0; - $attachment=1; - }elsif($content){ - $mailreport .= "\t$_\n"; - }elsif($attachment){ - push @attachfiles, "$_"; - } - } - $mailreport .= "\n"; - } - - my $totalcnt=0; - my $failcnt=0; - my $faillist=""; - my $longlist="None"; - my $toolong_time_min=30; - opendir(DIR, "$logfiledir"); - foreach my $file (readdir DIR){ - next if($file !~ /xcattest.log/); - my $cnt = `grep -c -- "------END::" "$logfiledir/$file"`; - $totalcnt+=int($cnt); - for(my $i=1;$i<$cnt+1;$i++){ - my $line=`grep -- "------END::" "$logfiledir/$file" |sed -n ${i}p`; - chomp($line); - if($line =~ /------END::([a-zA-Z0-9_-]+)::([a-zA-Z0-9_-]+)::Time.+/){ - my $failedcase=$1; - if($2 =~ /Failed/){ - $failcnt++; - $faillist.=$failedcase.", "; - } - } - # List all testcases that took longer than 30 min - if($line =~ /::Duration::([0-9_-]+) sec.+/){ - my $duration=$1; - if(scalar($duration >= $toolong_time_min*60)) { - if($longlist =~ /None/) { - $longlist=""; - } - my $long_time=sprintf("%02d h %02d min", $duration/3600, ($duration/60) % 60); - $longlist.=$line." ($long_time)\n"; - } - } - } - } - closedir(DIR); - - my $passcnt = $totalcnt - $failcnt; - my $noruncnt = $totalcase - $totalcnt; - $mailreport .= "\tTotalCase $totalcase Pass $passcnt Failed $failcnt NoRun $noruncnt\n\n\tFailed cases: $faillist\n\n\tCases longer than $toolong_time_min min:\n\n$longlist\n"; - - if($teststopflag){ - my $lastfile = `ls $logfiledir | grep "xcattest.log"| tail -1`; - chomp($lastfile); - my $lastline=`grep -- "------END::" "$logfiledir/$lastfile" | tail -1`; - chomp($lastline); - $lastcase=$1 if($lastline =~ /------END::([a-zA-Z0-9_-]+)::([a-zA-Z0-9_-]+)::Time.+/); - $mailreport .= "\tFinal environment stop at $lastcase\n"; - } - - $alltestpass=1 if($totalcase!=0 && $passcnt==$totalcase); - - $mailreport .= "\n-------------------------------------------\nCluster Information:\n"; - $mailreport .= "\t MN: $mn\n"; - $mailreport .= "\t SN: $config{var}{SN}\n"; - $mailreport .= "\t CN: $config{var}{CN}\n"; - $mailreport .= "\t Test result are saved under $mn:/opt/xcat/share/xcat/tools/autotest/result/\n" if($teststopflag && $hold); - - &runcmd("touch $mailfile && echo \"$mailreport\" > $mailfile"); - send_msg(2, "[create_report] created test report.....[done]"); - return 0; -} - -sub send_mail{ - my $passcnt = 0; - my $failcnt=0; - my $subject=""; - my $attachfile=""; - - my $buildflag = undef; - $buildflag=$1 if( $xcatcore_addr =~ /xcat2_autobuild_daily_builds\/([\d\.]+)\/.*/ ); - - my $output = `grep "TotalCase" "$mailfile" | grep "Failed"`; - $output =~ s/^\s+|\s+$//g; - if($output =~ /Pass (\d+) Failed (\d+)/){ - $passcnt=$1; - $failcnt=$2; - } - - if($failcnt > 0){ - $attachfile="/tmp/failed_case_detail.$proid"; - opendir(DIR, "$logfiledir"); - foreach my $file (readdir DIR){ - next if($file !~ /^failedcases/); - next if(-z "$logfiledir/$file"); - &runcmd("cat $logfiledir/$file >> $attachfile"); - } - close(DIR); - } - - push @attachfiles, "$attachfile"; - - my $passrate = $passcnt/$totalcase*100; - my $judgement = "FAILED"; - $judgement = "SUCCESS" if($alltestpass); - $judgement = "STOP for $lastcase" if($teststopflag); - if(defined ($buildflag)){ - $subject = sprintf "[%s][%s][%s][PassRate:%.2f%%]%s", $buildflag, $proid, $judgement, $passrate, $output; - }else{ - $subject = sprintf "[%s][%s][PassRate:%.2f%%]%s", $proid, $judgement, $passrate, $output; - } - - if($judgement ne "SUCCESS") { - send_msg(2, "[send_mail] Title: $subject"); - if(@attachfiles){ - my $attachstr =""; - foreach (@attachfiles){ - if(-e "$_"){ - $attachstr.= "-a $_ "; - } - } - send_msg(2, "/bin/mail -s \"$subject\" $attachstr \"$mail_list\" <$mailfile"); - &runcmd("/bin/mail -s \"$subject\" $attachstr \"$mail_list\" <$mailfile"); - }else{ - &runcmd("/bin/mail -s \"$subject\" \"$mail_list\" <$mailfile"); - } - } else { - send_msg(2, "[send_mail] Judgement is SUCCESS. Not sending email with Title: $subject"); - } - unlink($attachfile); -} - -####################################### -# Debug package installation -####################################### -sub debug_pkg_install { - my $pkg_name = shift; - send_msg(0, "[debug_pkg_install] error installing $pkg_name on mn $mn......."); - # try to ping the GPFS server and try to see if rpm command can run - my @output = runcmd("ping -c 3 server"); - my $outstr = join("\n", @output); - if ($outstr) { - send_msg(2, "[debug_pkg_install] ping of server: $outstr"); - } - @output = runcmd("xdsh $mn \"rpm -qa --nosignature 2>&1"); - $outstr = join("\n", @output); - if ($outstr) { - send_msg(2, "[debug_pkg_install] 'rpm -qa' after attempted installation of $pkg_name : $outstr"); - } - return 0; -} -############################################################### -# Mainfunction -############################################################### -if ( - !GetOptions("--help|h|?" => \$needhelp, - "--quiet" => \$quiet, - "--hold" => \$hold, - "os=s" => \$os, - "cluster=s" => \$cluster_name, - "testcase=s" => \$bucket, - "project-name=s" => \$proname, - "num=s" => \$proruntime, - "database=s" => \$xcat_database, - "xcat-core=s" => \$xcatcore_addr, - "xcat-dep=s" => \$xcatdep_addr, - "xcat-test=s" => \$xcattest_addr, - "plugin=s" => \$plugin, - "email=s" => \$mail_list) -){ - &usage; - send_msg(0, "step 0, PARSE ARGUMENTS returns error, exit"); - exit 1; -} - -if ($needhelp) -{ - &usage; - exit 0; -} - -unless(defined($os) && defined($proname) && defined($proruntime) && defined($bucket) && defined($cluster_name) && defined($xcatcore_addr) && defined($xcatdep_addr)){ - &usage; - exit 1; -} - -unless($xcat_database eq "MySQL" || $xcat_database eq "PostgreSQL") -{ - &usage; - exit 1; -} - -unless(defined($mail_list)){ - $mail_list = $defaultmail; -} -&init; - -my $rst=0; -my $progname=\$0;; -$$progname="$pro_name ($proid): main"; - -send_msg(2,"........................"); -send_msg(2,"........................"); -send_msg(2,".....ooooO.............."); -send_msg(2,"....(....)....Ooooo....."); -send_msg(2,".....\\..(.....(....)...."); -send_msg(2,"......\\__).....)../....."); -send_msg(2,"..............(_ /......"); -send_msg(2,"........................"); -send_msg(2,".........START ........."); -send_msg(2,"........................"); -send_msg(2,"........................"); -send_msg(2,"project $proid description:"); -send_msg(2,"cluster => $cluster_name"); -send_msg(2,"os => $os"); -send_msg(2,"case => $bucket"); -send_msg(2,"database => $xcat_database"); -send_msg(2,"xcatcore => $xcatcore_addr"); -send_msg(2,"xcatdep => $xcatdep_addr"); -send_msg(2,"xcattest => $xcattest_addr") if($xcattest_addr); -send_msg(2,"user => $mail_list"); -if($plugin){ - send_msg(2,"plugin => $plugin"); -} -if($hold){ - send_msg(2,"hold => ON"); -}else{ - send_msg(2,"hold => OFF"); -} -send_msg(2,"........................"); -####################################### -$rst = env_check(); -if($rst) { - send_msg(0, "environment check failed...........exit"); - exit_test 1; -} - -$rst = read_conf(); -if($rst) { - send_msg(0, "read global configuration file failed...........exit"); - exit_test 1; -} - -=pod -foreach my $k (keys %confkeys) { - print "$k = $confkeys{$k}\n"; -} -=cut - -$rst = get_build(); -if($rst) { - send_msg(0, "get xcat build failed...........exit"); - exit_test 1; -} - -$rst = get_xcattest(); -if($rst) { - send_msg(0, "get xcat-test failed...........exit"); - exit_test 1; -} - -$rst = get_bundle(); -if($rst) { - send_msg(0, "get bundle file failed...........exit"); - exit_test 1; -} - -$rst = get_build_info(); -if($rst){ - send_msg(0, "Get build information failed"); -}else{ - send_msg(2,"version => $xcatversion"); - send_msg(2,"release => $xcatrelease"); - send_msg(2,"commit number => $commitnum"); - send_msg(2,"build time => $buildtime"); - send_msg(2,"build server => $buildserver"); -} - -pipe CONTROLREAD,MNWRITE; -my $pid = fork(); -if ( !defined($pid) ) { - send_msg(0, "fork process for auto test error"); - exit_test 1; -} elsif ( $pid == 0 ) { # child process - $$progname="$pro_name ($proid): test on $cluster_name"; - - $SIG{INT} = sub { - send_msg(2, "sub proc $$ recrive INT signal to exit"); - exit 0; - }; - - send_msg(2, "..........fork process[pid=$$] for doing test.........."); - close CONTROLREAD; - my $res=0; - - #install mn - send_msg(2, "[$$]:Running mn_install..............."); - $res = mn_install(); - if ($res) { - syswrite MNWRITE,"[$$]:install $mn failed\n"; - exit 1; - } - send_msg(2, "[$$]:Run mn_install...............[OK]"); - - #prepare for installing xcat on mn - send_msg(2, "[$$]:Running prepare_mn..............."); - $res = prepare_mn(); - if ($res) { - syswrite MNWRITE,"[$$]:prepare $mn failed\n"; - exit 1; - } - send_msg(2, "[$$]:Run prepare_mn...............[OK]"); - - #install xcat-test on mn - send_msg(2, "[$$]:Running install_xcattest............."); - $res = install_xcattest(); - if ($res == 2) { - # install_xcattest() failed because of the RPM DB library corruption, try it again - $res = install_xcattest(); - } - if ($res) { - syswrite MNWRITE,"[$$]:install xcat-test on $mn failed\n"; - exit 1; - } - send_msg(2, "[$$]:Run install_xcattest..............[OK]"); - - my $deployenvtime=time(); - - send_msg(2, "[$$] Running do_test..............."); - $res = do_test(); - - #below code has nothing to do with xCAT autotest main job - #just in order to collect logs and data to do xCAT product further analyse - #----------start---------------- - &runcmd("scp -r $mn:/var/log/messages $mn:/var/log/xcat/computes.log $mn:/var/log/xcat/cluster.log $mn:/var/log/xcat/commands.log $logfiledir >/dev/null 2>&1"); - - #Depending on the OS, either httpd or apache2 directories will be present, check - #that the directory exists before copying files to avoid errors - if (-d "$mn:/var/log/httpd") { - &runcmd("scp -r $mn:/var/log/httpd/access* $logfiledir >/dev/null 2>&1"); - } - if (-d "$mn:/var/log/apache2") { - &runcmd("scp -r $mn:/var/log/apache2/access* $logfiledir >/dev/null 2>&1"); - } - - my $console_log = "$logfiledir/console_log"; - mkpath("$console_log") unless(-d "$console_log"); - &runcmd("scp -r $mn:/var/log/consoles/* $console_log >/dev/null 2>&1"); - #-----------end----------------- - - if ($res) { - if($res == 2){ - syswrite MNWRITE,"[$$][$deployenvtime]:do test stopped for some case\n"; - }else{ - syswrite MNWRITE,"[$$][$deployenvtime]:do test error\n"; - } - exit 1; - } - send_msg(2, "[$$] Run do_test...............[OK]"); - - send_msg(2, "[$$]:whole regression test on $cluster_name finished"); - syswrite MNWRITE,"[$$][$deployenvtime]:whole regression test are successful\n"; - close MNWRITE; - exit 0; -} - -$SIG{TERM} = $SIG{INT} = sub { - if($pid) { - my $try=0; - kill 'INT', $pid; - while(waitpid($pid, WNOHANG)==0){ - ++$try; - #try INT up to 4 times if need - if($try < 5){ - kill 'INT', $pid; - #try TERM up to 4 times if need - }elsif($try < 9){ - kill 'TERM', $pid; - #force to kill finally - }elsif($try < 100){ - kill 'KILL', $pid; - }else{ - last; - } - } - } - - &cleanup; - exit 0; -}; - -close MNWRITE; -$regstarttime = time(); -my $select = new IO::Select; -$select->add(\*CONTROLREAD); -while(! $sub_process_rt) { - my @hdls; - if (@hdls = $select->can_read(0)) { - my $hdl; - foreach $hdl (@hdls) { - if ($hdl == \*CONTROLREAD) { - my $line=""; - chomp($line=); - if ($line){ - my $tmp=$line; - if($line =~ /successful/){ - send_msg(2, "[[main]]: $line"); - } - if($line =~ /failed/){ - $line =~ s/(.+):(.+)/$2/g; - send_msg(0, "[[main]]: $line"); - $err_record = $line; - } - if($tmp =~ /\[(.+)\]\[(.+)\]:(.+)/){ - $env_dply_time_consumption= $2 - $regstarttime; - $teststopflag=1 if($3 =~ /do test stopped for some case/); - } - $sub_process_rt=1; - } - } - } - } - - if(time() - $regstarttime > $timeout * 3600) { - send_msg(1, "[timing] $timeout hours is expired"); - - #copy the test result which we have now back - &runcmd("scp -r $mn:/opt/xcat/share/xcat/tools/autotest/result/* $logfiledir >/dev/null 2>&1"); - &runcmd("rm -rf $logfiledir/rpower.* $logfiledir/getcons.* >/dev/null 2>&1"); - if($::RUNCMD_RC){ - send_msg(1, "[[main]]: copy regression result to $logfiledir failed"); - }else{ - send_msg(2, "[[main]]: copy regression result to $logfiledir successfully"); - } - - last; - } - sleep 1; -} - -close CONTROLREAD; - -if($sub_process_rt) { - send_msg(2, "[[main]]: regression test return on time"); -}else{ - send_msg(0, "[[main]]: regression test return out of time"); - if($pid) { - my $try=0; - kill 'INT', $pid; - while(waitpid($pid, WNOHANG)==0){ - ++$try; - #try INT up to 4 times if need - if($try < 5){ - kill 'INT', $pid; - send_msg(2, "send INT to subprocess $pid...[$try]"); - #try TERM up to 4 times if need - }elsif($try < 9){ - kill 'TERM', $pid; - send_msg(2, "send TERM to subprocess $pid...[$try]"); - #force to kill finally - }elsif($try < 100){ - kill 'KILL', $pid; - send_msg(2, "send KILL to subprocess $pid...[$try]"); - }else{ - send_msg(2, "Can't stop pid $pid"); - last; - } - sleep 1; - } - } -} - -$all_reg_time_consumption=time()-$regstarttime; - -send_msg(2, "[[main]]: create test result report..........."); -$rst = create_report(); -if($rst){ - send_msg(0, "[[main]]: create test result report failed"); - exit_test 1; -}else{ - send_msg(2, "[[main]]: create test result report....[done]"); - send_msg(2, "[[main]]: send test result by mail......."); - send_mail(); - send_msg(2, "[[main]]: send test result........[done]"); -} - -#used to hold the stop environment for developer to debug -if($teststopflag && $hold){ - send_msg(2, "[[main]]: hold environment for 24 hours.........."); - sleep(86400); - send_msg(2, "[[main]]: hold environment for 24 hours..........[done]"); -} - -if($alltestpass){ - exit_test 0; -}else{ - exit_test 1; -}