From 8207f11ae8c8269ae1c3c1fc71b1df9cc1508ad5 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Tue, 7 Jun 2016 15:55:24 +0800 Subject: [PATCH 01/11] [xCAT Jenkins Email Report] xCAT Jenkins Log Analyzer with email report --- .../xcat/tools/jenkins/testreport/email.sh | 398 +++++++++++++ .../tools/jenkins/testreport/send-report.sh | 333 +++++++++++ .../jenkins/testreport/xCATjkLogAnalyzer.sql | 545 ++++++++++++++++++ .../jenkins/testreport/xcatjk-log2sql.sh | 459 +++++++++++++++ .../testreport/xcatjk-scanlogs-last3days.sh | 33 ++ .../xcatjk-scanlogs-redo-everything.sh | 43 ++ .../jenkins/testreport/xcatjk-scanlogs.sh | 249 ++++++++ 7 files changed, 2060 insertions(+) create mode 100644 xCAT-server/share/xcat/tools/jenkins/testreport/email.sh create mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh create mode 100644 xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql create mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh create mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-scanlogs-last3days.sh create mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-scanlogs-redo-everything.sh create mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-scanlogs.sh diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh new file mode 100644 index 000000000..9c4d9c9d1 --- /dev/null +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh @@ -0,0 +1,398 @@ +#!/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 -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 -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 new file mode 100755 index 000000000..60e1ff1b7 --- /dev/null +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -0,0 +1,333 @@ +#!/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 + +# The configuration part + +MYSQL_HOST="localhost" +MYSQL_USER="root" +MYSQL_PASS="password" +MYSQL_DB="xCATjkLogAnalyzer" + +# The main part + +for c in mysql tail sed grep +do + ! type "${c}" >/dev/null 2>&1 && + echo "Command \"${c}\" not found" >&2 && exit 1 +done + +Email report + +$report_setTo "Alice" alice@example.org + +$report_setFrom "xCATjk Mail Bot" root@localhost.localdomain + +DateTime="$(date -R)" + +MYSQL_COMMAND=("mysql" "-h" "${MYSQL_HOST}" -u "${MYSQL_USER}" -p"${MYSQL_PASS}" "${MYSQL_DB}") +Subject="$("${MYSQL_COMMAND[@]}" <<<"SELECT CONCAT('Passed: ', SUM(Passed), ' Failed: ', SUM(Failed), ' No run: ', SUM(\`No run\`)) AS Summary FROM LatestDailyReport;" | tail -n 1)" + +$report_setSubject "[xCATjk] ${Subject}" + +$report_setHTML <<-EOF + + + + + +xCATjk Test Report + + + + + + + +

xCATjk Test Report

xCAT Logo
+

+ + + + + + + + + + + +$( +LatestDailyReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, Duration, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM LatestDailyReport;")" +oIFS="${IFS}" +IFS="|" +color="" +while read n title arch os duration passed failed no_run subtotal pass_rate n +do + [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" +done < <(grep -v -- ---- <<<"${LatestDailyReport}" | sed -e '1d' -e 's/ *| */|/g') +IFS="${oIFS}" + +LatestDailyReportSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))) AS Duration, SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM LatestDailyReport;")" +oIFS="${IFS}" +IFS="|" +read n duration passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${LatestDailyReportSummary}" | sed -e '1d' -e 's/ *| */|/g') +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +IFS="${oIFS}" +) +
ArchOSDurationPassedFailedNo runSubtotalPass rate
${arch}${os}${duration}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${duration}${passed}${failed}${no_run}${total}${pass_rate}
+
+

Failed Test Cases

+ + + + + + +$( +FailedTestCasesReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, \`Failed test cases\` FROM LatestDailyReport;")" +oIFS="${IFS}" +IFS="|" +color="" +while read n title arch os failed_test_cases n +do + [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" + [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" + echo "" + echo "" + echo "" + echo "" + echo "" +done < <(grep -v -- ---- <<<"${FailedTestCasesReport}" | sed -e '1d' -e 's/ *| */|/g') +) +
ArchOSFailed test cases
${arch}${os}${failed_test_cases}
+

Seven-day Look Back

+ + + + + + + + + + + +$( +SevenDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM SevenDayLookBack;")" +oIFS="${IFS}" +IFS="|" +color="" +while read n arch os test_runs passed failed no_run subtotal pass_rate n +do + [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" +done < <(grep -v -- ---- <<<"${SevenDayLookBack}" | sed -e '1d' -e 's/ *| */|/g') +IFS="${oIFS}" + +SevenDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM SevenDayLookBack;")" +oIFS="${IFS}" +IFS="|" +read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${SevenDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +IFS="${oIFS}" +) +
ArchOSTest runsPassedFailedNo runSubtotalPass rate
${arch}${os}${test_runs}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${test_runs}${passed}${failed}${no_run}${total}${pass_rate}
+

Thirty-day Look Back

+ + + + + + + + + + + +$( +ThirtyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM ThirtyDayLookBack;")" +oIFS="${IFS}" +IFS="|" +color="" +while read n arch os test_runs passed failed no_run subtotal pass_rate n +do + [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" +done < <(grep -v -- ---- <<<"${ThirtyDayLookBack}" | sed -e '1d' -e 's/ *| */|/g') +IFS="${oIFS}" + +ThirtyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM ThirtyDayLookBack;")" +oIFS="${IFS}" +IFS="|" +read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${ThirtyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +IFS="${oIFS}" +) +
ArchOSTest runsPassedFailedNo runSubtotalPass rate
${arch}${os}${test_runs}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${test_runs}${passed}${failed}${no_run}${total}${pass_rate}
+

Ninety-day Look Back

+ + + + + + + + + + + +$( +NinetyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM NinetyDayLookBack;")" +oIFS="${IFS}" +IFS="|" +color="" +while read n arch os test_runs passed failed no_run subtotal pass_rate n +do + [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" +done < <(grep -v -- ---- <<<"${NinetyDayLookBack}" | sed -e '1d' -e 's/ *| */|/g') +IFS="${oIFS}" + +NinetyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM NinetyDayLookBack;")" +oIFS="${IFS}" +IFS="|" +read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${NinetyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +IFS="${oIFS}" +) +
ArchOSTest runsPassedFailedNo runSubtotalPass rate
${arch}${os}${test_runs}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${test_runs}${passed}${failed}${no_run}${total}${pass_rate}
+

Top 50 Failed Test Cases

+ + + + + + + + + +$( +Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM FailedTestCasesTopList LIMIT 50;")" +oIFS="${IFS}" +IFS="|" +color="" +while read n test_case arch os last_seven_days last_thirty_days last_ninety_days n +do + [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" + [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" +done < <(grep -v -- ---- <<<"${Top50FailedTestCases}" | sed -e '1d' -e 's/ *| */|/g') +IFS="${oIFS}" +) +
Test caseArchOSLast 7 daysLast 30 daysLast 90 days
${test_case}${arch}${os}${last_seven_days}${last_thirty_days}${last_ninety_days}
+
+ + + + +

This email has been sent to you by xCATjk Mail Bot.
+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.
+All the times shown in this test report are the local times of the testing environment.

+

${DateTime}

+ + +EOF + +$report_send diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql new file mode 100644 index 000000000..d2f9a90d0 --- /dev/null +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql @@ -0,0 +1,545 @@ +-- 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) 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 `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) 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) 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) 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) NOT NULL, + `StartTime` datetime NOT NULL, + `EndTime` datetime NOT NULL, + `ArchId` int(11) NOT NULL, + `OSId` int(11) NOT NULL, + `xCATgitCommit` varchar(255) 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; + +-- +-- 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,`NinetyDayFailed`.`OSId` desc,`NinetyDayFailed`.`ArchId` desc */; +/*!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 max(`TestRun`.`TestRunId`)) */; +/*!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` */; +/*!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` */; +/*!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` */; +/*!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-06-07 1:14:01 diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh new file mode 100755 index 000000000..1dc323efa --- /dev/null +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh @@ -0,0 +1,459 @@ +#!/bin/bash + +function usage() +{ + local script="${0##*/}" + + while read ; 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 ; 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 ; do echo "${REPLY}" ; done <<-EOF + -- + -- Analysis file '${logfile}' + -- + + EOF + + while read test_case_name test_case_result duration + do + while read ; 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 ; 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 ; 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 test_case_name + do + # Need chomp ${test_case_name} + test_case_name=$(echo ${test_case_name}) + + while read ; 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 ; 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 ; 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 ; 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 ; 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 ; 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 ; do echo "${REPLY}" ; done < Date: Thu, 16 Jun 2016 11:15:45 +0800 Subject: [PATCH 02/11] [xCAT Jenkins Email Report] Change the subject line of the xCAT Jenkins mail test report --- .../share/xcat/tools/jenkins/testreport/send-report.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh index 60e1ff1b7..4012385ce 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -37,14 +37,14 @@ Email report $report_setTo "Alice" alice@example.org -$report_setFrom "xCATjk Mail Bot" root@localhost.localdomain +$report_setFrom "xCAT Jenkins Mail Bot" root@localhost.localdomain DateTime="$(date -R)" MYSQL_COMMAND=("mysql" "-h" "${MYSQL_HOST}" -u "${MYSQL_USER}" -p"${MYSQL_PASS}" "${MYSQL_DB}") Subject="$("${MYSQL_COMMAND[@]}" <<<"SELECT CONCAT('Passed: ', SUM(Passed), ' Failed: ', SUM(Failed), ' No run: ', SUM(\`No run\`)) AS Summary FROM LatestDailyReport;" | tail -n 1)" -$report_setSubject "[xCATjk] ${Subject}" +$report_setSubject "[xCAT Jenkins] ${Subject}" $report_setHTML <<-EOF From 7f45b7b551f2acdc55269e5fba25b73253925c9b Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Tue, 28 Jun 2016 05:50:34 -0400 Subject: [PATCH 03/11] [xCAT Jenkins Email Report] Change all the VARCHAR to VARCHAR BINARY for case sensitive string comparison --- .../jenkins/testreport/xCATjkLogAnalyzer.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql index d2f9a90d0..8759427f8 100644 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql @@ -1,6 +1,6 @@ -- MySQL dump 10.14 Distrib 5.5.47-MariaDB, for Linux (ppc64) -- --- Host: localhost Database: xcatjkloganalyzer +-- Host: localhost Database: xCATjkLogAnalyzer -- ------------------------------------------------------ -- Server version 5.5.47-MariaDB @@ -24,7 +24,7 @@ DROP TABLE IF EXISTS `ArchDict`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ArchDict` ( `ArchId` int(11) NOT NULL AUTO_INCREMENT, - `ArchName` varchar(255) NOT NULL, + `ArchName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`ArchId`), UNIQUE KEY `ArchName` (`ArchName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -133,7 +133,7 @@ DROP TABLE IF EXISTS `OSDict`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `OSDict` ( `OSId` int(11) NOT NULL AUTO_INCREMENT, - `OSName` varchar(255) NOT NULL, + `OSName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`OSId`), UNIQUE KEY `OSName` (`OSName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -148,7 +148,7 @@ DROP TABLE IF EXISTS `ResultDict`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ResultDict` ( `ResultId` int(11) NOT NULL AUTO_INCREMENT, - `ResultName` varchar(255) NOT NULL, + `ResultName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`ResultId`), UNIQUE KEY `ResultName` (`ResultName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -217,7 +217,7 @@ DROP TABLE IF EXISTS `TestCase`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `TestCase` ( `TestCaseId` int(11) NOT NULL AUTO_INCREMENT, - `TestCaseName` varchar(255) NOT NULL, + `TestCaseName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `Memo` text NOT NULL, PRIMARY KEY (`TestCaseId`), UNIQUE KEY `TestCaseName` (`TestCaseName`) @@ -254,12 +254,12 @@ DROP TABLE IF EXISTS `TestRun`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `TestRun` ( `TestRunId` int(11) NOT NULL AUTO_INCREMENT, - `TestRunName` varchar(255) NOT NULL, + `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) NOT NULL, + `xCATgitCommit` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `Memo` text NOT NULL, PRIMARY KEY (`TestRunId`), UNIQUE KEY `TestRunName` (`TestRunName`), @@ -542,4 +542,4 @@ SET character_set_client = @saved_cs_client; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2016-06-07 1:14:01 +-- Dump completed on 2016-06-29 4:52:47 From 20f186efa6fccf28d7715ce2055659e8045df3be Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 30 Jun 2016 15:23:02 +0800 Subject: [PATCH 04/11] [xCAT Jenkins Email Report] Order test results by OSName, then ArchName --- .../tools/jenkins/testreport/xCATjkLogAnalyzer.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql index 8759427f8..215df71fa 100644 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql @@ -338,7 +338,7 @@ SET character_set_client = @saved_cs_client; /*!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,`NinetyDayFailed`.`OSId` desc,`NinetyDayFailed`.`ArchId` desc */; +/*!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,`NinetyDayFailed`.`OSId` desc,`NinetyDayFailed`.`ArchId` desc, `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 */; @@ -357,7 +357,7 @@ SET character_set_client = @saved_cs_client; /*!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 max(`TestRun`.`TestRunId`)) */; +/*!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 */; @@ -395,7 +395,7 @@ SET character_set_client = @saved_cs_client; /*!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` */; +/*!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 */; @@ -452,7 +452,7 @@ SET character_set_client = @saved_cs_client; /*!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` */; +/*!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 */; @@ -509,7 +509,7 @@ SET character_set_client = @saved_cs_client; /*!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` */; +/*!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 */; From 38d00ce8d724c8c63e5275f7d5db55a9ae4a57ef Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 30 Jun 2016 16:50:42 +0800 Subject: [PATCH 05/11] [xCAT Jenkins Email Report] Add rank field to the `Top 50 Failed Test Cases' --- .../share/xcat/tools/jenkins/testreport/send-report.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh index 4012385ce..ae2d23624 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -289,6 +289,7 @@ IFS="${oIFS}"

Top 50 Failed Test Cases

+ @@ -297,15 +298,16 @@ IFS="${oIFS}" $( -Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM FailedTestCasesTopList LIMIT 50;")" +Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT @rank := @rank + 1 AS Rank, \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM FailedTestCasesTopList, (SELECT @rank := 0) AS RANK LIMIT 50;")" oIFS="${IFS}" IFS="|" color="" -while read n test_case arch os last_seven_days last_thirty_days last_ninety_days n +while read n rank test_case arch os last_seven_days last_thirty_days last_ninety_days n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" echo "" + echo "" echo "" echo "" echo "" From 329e64700efb2b79e713564e9564194ef99c1f2e Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 30 Jun 2016 16:54:41 +0800 Subject: [PATCH 06/11] [xCAT Jenkins Email Report] Rename xCATjk -> xCAT Jenkins --- .../share/xcat/tools/jenkins/testreport/send-report.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh index ae2d23624..61ea2ad61 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -37,7 +37,7 @@ Email report $report_setTo "Alice" alice@example.org -$report_setFrom "xCAT Jenkins Mail Bot" root@localhost.localdomain +$report_setFrom "xCAT Jenkins Mail Bot" root@localhost.localdomain DateTime="$(date -R)" @@ -52,12 +52,12 @@ $report_setHTML <<-EOF -xCATjk Test Report +xCAT Jenkins Test Report
Rank Test case Arch OSLast 90 days
${rank}${test_case}${arch}${os}
- +

xCATjk Test Report

xCAT Jenkins Test Report

xCAT Logo
@@ -322,7 +322,7 @@ IFS="${oIFS}"
- From aae45825c079ce7be15b9587cb5715be51ea53c2 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 30 Jun 2016 17:40:04 +0800 Subject: [PATCH 07/11] [xCAT Jenkins Email Report] Change all the `read' to `read -r' in bash script --- .../xcat/tools/jenkins/testreport/email.sh | 4 +-- .../tools/jenkins/testreport/send-report.sh | 20 +++++++------- .../jenkins/testreport/xCATjkLogAnalyzer.sql | 2 +- .../jenkins/testreport/xcatjk-log2sql.sh | 26 +++++++++---------- .../testreport/xcatjk-scanlogs-last3days.sh | 2 +- .../xcatjk-scanlogs-redo-everything.sh | 4 +-- .../jenkins/testreport/xcatjk-scanlogs.sh | 6 ++--- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh index 9c4d9c9d1..5a999f85a 100644 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh @@ -201,7 +201,7 @@ function Email_setSubject() while : do - read -n 1 + read -r -n 1 [[ -z "${REPLY}" || "${REPLY}" =~ [\x00-\x7f\xc0-\xff] ]] && (( ${#w} + ${#c} > limit )) && declare -g ${mailSubject}+="$(echo -n "${w}" | @@ -243,7 +243,7 @@ function Email_addAttachment() # 76 is a magic number, see RFC 2045 - while read -n 76 + while read -r -n 76 do inMessage+="${REPLY}" inMessage+=$'\n' diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh index 61ea2ad61..6e3b0b5af 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -78,7 +78,7 @@ LatestDailyReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, Durati oIFS="${IFS}" IFS="|" color="" -while read n title arch os duration passed failed no_run subtotal pass_rate n +while read -r n title arch os duration passed failed no_run subtotal pass_rate n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" echo "" @@ -97,7 +97,7 @@ IFS="${oIFS}" LatestDailyReportSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))) AS Duration, SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM LatestDailyReport;")" oIFS="${IFS}" IFS="|" -read n duration passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${LatestDailyReportSummary}" | sed -e '1d' -e 's/ *| */|/g') +read -r n duration passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${LatestDailyReportSummary}" | sed -e '1d' -e 's/ *| */|/g') echo "" echo "" echo "" @@ -124,7 +124,7 @@ FailedTestCasesReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, \` oIFS="${IFS}" IFS="|" color="" -while read n title arch os failed_test_cases n +while read -r n title arch os failed_test_cases n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" @@ -153,7 +153,7 @@ SevenDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, oIFS="${IFS}" IFS="|" color="" -while read n arch os test_runs passed failed no_run subtotal pass_rate n +while read -r n arch os test_runs passed failed no_run subtotal pass_rate n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" echo "" @@ -172,7 +172,7 @@ IFS="${oIFS}" SevenDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM SevenDayLookBack;")" oIFS="${IFS}" IFS="|" -read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${SevenDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') +read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${SevenDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') echo "" echo "" echo "" @@ -203,7 +203,7 @@ ThirtyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\` oIFS="${IFS}" IFS="|" color="" -while read n arch os test_runs passed failed no_run subtotal pass_rate n +while read -r n arch os test_runs passed failed no_run subtotal pass_rate n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" echo "" @@ -222,7 +222,7 @@ IFS="${oIFS}" ThirtyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM ThirtyDayLookBack;")" oIFS="${IFS}" IFS="|" -read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${ThirtyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') +read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${ThirtyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') echo "" echo "" echo "" @@ -253,7 +253,7 @@ NinetyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\` oIFS="${IFS}" IFS="|" color="" -while read n arch os test_runs passed failed no_run subtotal pass_rate n +while read -r n arch os test_runs passed failed no_run subtotal pass_rate n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" echo "" @@ -272,7 +272,7 @@ IFS="${oIFS}" NinetyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM NinetyDayLookBack;")" oIFS="${IFS}" IFS="|" -read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${NinetyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') +read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${NinetyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') echo "" echo "" echo "" @@ -302,7 +302,7 @@ Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT @rank := @rank + 1 A oIFS="${IFS}" IFS="|" color="" -while read n rank test_case arch os last_seven_days last_thirty_days last_ninety_days n +while read -r n rank test_case arch os last_seven_days last_thirty_days last_ninety_days n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql index 215df71fa..0c4ed1243 100644 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql @@ -338,7 +338,7 @@ SET character_set_client = @saved_cs_client; /*!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,`NinetyDayFailed`.`OSId` desc,`NinetyDayFailed`.`ArchId` desc, `TestCase`.`TestCaseName` */; +/*!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,`OSName`,`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 */; diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh index 1dc323efa..d3cff55e3 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh @@ -4,7 +4,7 @@ function usage() { local script="${0##*/}" - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF Usage: ${script} [OPTIONS] DIRECTORY Options: @@ -194,7 +194,7 @@ function xcattestlog2sql() [ -n "${test_run_name}" ] warn_if_bad "$?" "test run has no name" || return 1 - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF -- -- Test run has name '${test_run_name}' -- @@ -204,16 +204,16 @@ function xcattestlog2sql() [ -f "${logfile}" ] warn_if_bad "$?" "${logfile}: No such log file" || return 1 - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF -- -- Analysis file '${logfile}' -- EOF - while read test_case_name test_case_result duration + while read -r test_case_name test_case_result duration do - while read ; do echo "${REPLY}" ; done <<-EOF + 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 ( @@ -259,7 +259,7 @@ function xcattestbundle2sql() [ -n "${test_run_name}" ] warn_if_bad "$?" "test run has no name" || return 1 - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF -- -- Test run has name '${test_run_name}' -- @@ -269,7 +269,7 @@ function xcattestbundle2sql() [ -f "${logfile}" ] warn_if_bad "$?" "${logfile}: No such log file" || return 1 - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF -- -- Analysis file '${logfile}' -- @@ -282,12 +282,12 @@ function xcattestbundle2sql() EOF - while read test_case_name + while read -r test_case_name do # Need chomp ${test_case_name} test_case_name=$(echo ${test_case_name}) - while read ; do echo "${REPLY}" ; done <<-EOF + 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 ( @@ -330,7 +330,7 @@ function jenkinsprojectlog2sql() [ -f "${logfile}" ] warn_if_bad "$?" "${logfile}: No such log file" || return 1 - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF -- -- Analysis file '${logfile}' -- @@ -363,7 +363,7 @@ function jenkinsprojectlog2sql() memo="$(tr -d '\r' <"${logfile}" | grep -A 7 'project.*description' | cut -d ' ' -f 4-)" - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF INSERT INTO ArchDict (ArchId, ArchName) SELECT * FROM (SELECT NULL, '${arch}') AS tmp WHERE NOT EXISTS ( @@ -428,7 +428,7 @@ JenkinsMailLog="$(echo "${xCATjkLog_DIR}/mail."*)" [ -f "${JenkinsMailLog}" ] exit_if_bad "$?" "${JenkinsMailLog}: no such log file" -while read ; do echo "${REPLY}" ; done < Date: Wed, 6 Jul 2016 15:41:10 +0800 Subject: [PATCH 08/11] [xCAT Jenkins Email Report] Fix the rank field of the `Top 50 Failed Test Cases' --- xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh index 6e3b0b5af..36d8e3686 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -298,7 +298,7 @@ IFS="${oIFS}" $( -Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT @rank := @rank + 1 AS Rank, \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM FailedTestCasesTopList, (SELECT @rank := 0) AS RANK LIMIT 50;")" +Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT @rank := @rank + 1 AS Rank, \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM (SELECT \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM FailedTestCasesTopList LIMIT 50) AS TopFifty, (SELECT @rank := 0) AS Rank;")" oIFS="${IFS}" IFS="|" color="" From 39375683ae5b31d927cc26c9186c613885dd48b2 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Fri, 8 Jul 2016 00:04:18 +0800 Subject: [PATCH 09/11] [xCAT Jenkins Email Report] Create a MySQL database procedure for the mail report --- .../tools/jenkins/testreport/send-report.sh | 304 +------------ .../jenkins/testreport/xCATjkLogAnalyzer.sql | 417 +++++++++++++++++- 2 files changed, 421 insertions(+), 300 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh index 36d8e3686..0110776d9 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -17,6 +17,8 @@ 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 @@ -25,13 +27,9 @@ MYSQL_USER="root" MYSQL_PASS="password" MYSQL_DB="xCATjkLogAnalyzer" -# The main part +MYSQL_COMMAND=("mysql" -B -N -r -s "-h" "${MYSQL_HOST}" -u "${MYSQL_USER}" -p"${MYSQL_PASS}" "${MYSQL_DB}") -for c in mysql tail sed grep -do - ! type "${c}" >/dev/null 2>&1 && - echo "Command \"${c}\" not found" >&2 && exit 1 -done +# The main part Email report @@ -39,297 +37,7 @@ $report_setTo "Alice" alice@example.org $report_setFrom "xCAT Jenkins Mail Bot" root@localhost.localdomain -DateTime="$(date -R)" - -MYSQL_COMMAND=("mysql" "-h" "${MYSQL_HOST}" -u "${MYSQL_USER}" -p"${MYSQL_PASS}" "${MYSQL_DB}") -Subject="$("${MYSQL_COMMAND[@]}" <<<"SELECT CONCAT('Passed: ', SUM(Passed), ' Failed: ', SUM(Failed), ' No run: ', SUM(\`No run\`)) AS Summary FROM LatestDailyReport;" | tail -n 1)" - -$report_setSubject "[xCAT Jenkins] ${Subject}" - -$report_setHTML <<-EOF - - - - - -xCAT Jenkins Test Report - - -

This email has been sent to you by xCATjk Mail Bot.
+

This email has been sent to you by xCAT Jenkins Mail Bot.
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.
All the times shown in this test report are the local times of the testing environment.

${DateTime}

Total-
Total-
Total-
Total-Last 90 days
- - - - -

xCAT Jenkins Test Report

xCAT Logo
-

- - - - - - - - - - - -$( -LatestDailyReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, Duration, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM LatestDailyReport;")" -oIFS="${IFS}" -IFS="|" -color="" -while read -r n title arch os duration passed failed no_run subtotal pass_rate n -do - [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" -done < <(grep -v -- ---- <<<"${LatestDailyReport}" | sed -e '1d' -e 's/ *| */|/g') -IFS="${oIFS}" - -LatestDailyReportSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))) AS Duration, SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM LatestDailyReport;")" -oIFS="${IFS}" -IFS="|" -read -r n duration passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${LatestDailyReportSummary}" | sed -e '1d' -e 's/ *| */|/g') -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -IFS="${oIFS}" -) -
ArchOSDurationPassedFailedNo runSubtotalPass rate
${arch}${os}${duration}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${duration}${passed}${failed}${no_run}${total}${pass_rate}
-
-

Failed Test Cases

- - - - - - -$( -FailedTestCasesReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, \`Failed test cases\` FROM LatestDailyReport;")" -oIFS="${IFS}" -IFS="|" -color="" -while read -r n title arch os failed_test_cases n -do - [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" - [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" - echo "" - echo "" - echo "" - echo "" - echo "" -done < <(grep -v -- ---- <<<"${FailedTestCasesReport}" | sed -e '1d' -e 's/ *| */|/g') -) -
ArchOSFailed test cases
${arch}${os}${failed_test_cases}
-

Seven-day Look Back

- - - - - - - - - - - -$( -SevenDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM SevenDayLookBack;")" -oIFS="${IFS}" -IFS="|" -color="" -while read -r n arch os test_runs passed failed no_run subtotal pass_rate n -do - [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" -done < <(grep -v -- ---- <<<"${SevenDayLookBack}" | sed -e '1d' -e 's/ *| */|/g') -IFS="${oIFS}" - -SevenDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM SevenDayLookBack;")" -oIFS="${IFS}" -IFS="|" -read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${SevenDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -IFS="${oIFS}" -) -
ArchOSTest runsPassedFailedNo runSubtotalPass rate
${arch}${os}${test_runs}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${test_runs}${passed}${failed}${no_run}${total}${pass_rate}
-

Thirty-day Look Back

- - - - - - - - - - - -$( -ThirtyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM ThirtyDayLookBack;")" -oIFS="${IFS}" -IFS="|" -color="" -while read -r n arch os test_runs passed failed no_run subtotal pass_rate n -do - [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" -done < <(grep -v -- ---- <<<"${ThirtyDayLookBack}" | sed -e '1d' -e 's/ *| */|/g') -IFS="${oIFS}" - -ThirtyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM ThirtyDayLookBack;")" -oIFS="${IFS}" -IFS="|" -read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${ThirtyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -IFS="${oIFS}" -) -
ArchOSTest runsPassedFailedNo runSubtotalPass rate
${arch}${os}${test_runs}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${test_runs}${passed}${failed}${no_run}${total}${pass_rate}
-

Ninety-day Look Back

- - - - - - - - - - - -$( -NinetyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM NinetyDayLookBack;")" -oIFS="${IFS}" -IFS="|" -color="" -while read -r n arch os test_runs passed failed no_run subtotal pass_rate n -do - [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" -done < <(grep -v -- ---- <<<"${NinetyDayLookBack}" | sed -e '1d' -e 's/ *| */|/g') -IFS="${oIFS}" - -NinetyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM NinetyDayLookBack;")" -oIFS="${IFS}" -IFS="|" -read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${NinetyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -IFS="${oIFS}" -) -
ArchOSTest runsPassedFailedNo runSubtotalPass rate
${arch}${os}${test_runs}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${test_runs}${passed}${failed}${no_run}${total}${pass_rate}
-

Top 50 Failed Test Cases

- - - - - - - - - - -$( -Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT @rank := @rank + 1 AS Rank, \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM (SELECT \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM FailedTestCasesTopList LIMIT 50) AS TopFifty, (SELECT @rank := 0) AS Rank;")" -oIFS="${IFS}" -IFS="|" -color="" -while read -r n rank test_case arch os last_seven_days last_thirty_days last_ninety_days n -do - [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" - [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" -done < <(grep -v -- ---- <<<"${Top50FailedTestCases}" | sed -e '1d' -e 's/ *| */|/g') -IFS="${oIFS}" -) -
RankTest caseArchOSLast 7 daysLast 30 daysLast 90 days
${rank}${test_case}${arch}${os}${last_seven_days}${last_thirty_days}${last_ninety_days}
-
- - - - -

This email has been sent to you by xCAT Jenkins Mail Bot.
-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.
-All the times shown in this test report are the local times of the testing environment.

-

${DateTime}

- - -EOF +$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 index 0c4ed1243..93dd428b0 100644 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql @@ -48,6 +48,19 @@ SET character_set_client = utf8; ) 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` -- @@ -324,6 +337,387 @@ SET character_set_client = utf8; ) 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 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", +'', +SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))), '', "\n" +'', +SUM(Passed), '', "\n", +'', +SUM(Failed), '', "\n", +'', +SUM(`No run`), '', "\n", +'', +SUM(Subtotal), '', "\n", +'', +IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", +'', "\n" +) AS HTML +FROM LatestDailyReport +) AS LatestDailyReportSummary, ( +SELECT 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 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", +'', +SUM(`Test runs`), '', "\n", +'', +SUM(Passed), '', "\n", +'', +SUM(Failed), '', "\n", +'', +SUM(`No run`), '', "\n", +'', +SUM(Subtotal), '', "\n", +'', +IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", +'', "\n" +) AS HTML +FROM SevenDayLookBack +) AS SevenDayLookBackSummary, ( +SELECT 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", +'', +SUM(`Test runs`), '', "\n", +'', +SUM(Passed), '', "\n", +'', +SUM(Failed), '', "\n", +'', +SUM(`No run`), '', "\n", +'', +SUM(Subtotal), '', "\n", +'', +IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", +'', "\n" +) AS HTML +FROM ThirtyDayLookBack +) AS ThirtyDayLookBackSummary, ( +SELECT 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", +'', +SUM(`Test runs`), '', "\n", +'', +SUM(Passed), '', "\n", +'', +SUM(Failed), '', "\n", +'', +SUM(`No run`), '', "\n", +'', +SUM(Subtotal), '', "\n", +'', +IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", +'', "\n" +) AS HTML +FROM NinetyDayLookBack +) AS NinetyDayLookBackSummary, ( +SELECT 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` -- @@ -338,7 +732,26 @@ SET character_set_client = @saved_cs_client; /*!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,`OSName`,`ArchName`,`TestCase`.`TestCaseName` */; +/*!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: ',sum(`LatestDailyReport`.`Passed`),' Failed: ',sum(`LatestDailyReport`.`Failed`),' No run: ',sum(`LatestDailyReport`.`No run`)) 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 */; @@ -542,4 +955,4 @@ SET character_set_client = @saved_cs_client; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2016-06-29 4:52:47 +-- Dump completed on 2016-07-07 11:48:15 From 3b92cfb5c4cace00a3d55053f31fcb0d703ac02a Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 18 Jul 2016 20:49:05 +0800 Subject: [PATCH 10/11] [xCAT Jenkins Email Report] Remove comment from test bundle file, and do chomp()ing --- .../share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh index d3cff55e3..bc83667e1 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh @@ -284,8 +284,11 @@ function xcattestbundle2sql() while read -r test_case_name do - # Need chomp ${test_case_name} + # 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) From 310ba8c1aaeaca569f58df1236e302308b599abc Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 22 Aug 2016 15:53:21 +0800 Subject: [PATCH 11/11] [xCAT Jenkins Email Report] Fix a issue while no test was run in a day. Handle NULL properly --- .../jenkins/testreport/xCATjkLogAnalyzer.sql | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql index 93dd428b0..e10e9eda0 100644 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql @@ -466,7 +466,7 @@ NOW(), ' ', REPLACE(CONCAT('+', TIME_FORMAT(TIMEDIFF(NOW(), UTC_TIMESTAMP), '%H% '' ) AS HTML FROM ( -SELECT GROUP_CONCAT(HTML SEPARATOR '') AS HTML +SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML FROM ( SELECT CONCAT( 'Total', "\n", '-', "\n", '', -SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))), '', "\n" +IFNULL(SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))), 'N/A'), '', "\n" '', -SUM(Passed), '', "\n", +IFNULL(SUM(Passed), 'N/A'), '', "\n", '', -SUM(Failed), '', "\n", +IFNULL(SUM(Failed), 'N/A'), '', "\n", '', -SUM(`No run`), '', "\n", +IFNULL(SUM(`No run`), 'N/A'), '', "\n", '', -SUM(Subtotal), '', "\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 GROUP_CONCAT(HTML SEPARATOR '') AS HTML +SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML FROM ( SELECT CONCAT( 'Total', "\n", '-', "\n", '', -SUM(`Test runs`), '', "\n", +IFNULL(SUM(`Test runs`), 'N/A'), '', "\n", '', -SUM(Passed), '', "\n", +IFNULL(SUM(Passed), 'N/A'), '', "\n", '', -SUM(Failed), '', "\n", +IFNULL(SUM(Failed), 'N/A'), '', "\n", '', -SUM(`No run`), '', "\n", +IFNULL(SUM(`No run`), 'N/A'), '', "\n", '', -SUM(Subtotal), '', "\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 GROUP_CONCAT(HTML SEPARATOR '') AS HTML +SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML FROM ( SELECT CONCAT( 'Total', "\n", '-', "\n", '', -SUM(`Test runs`), '', "\n", +IFNULL(SUM(`Test runs`), 'N/A'), '', "\n", '', -SUM(Passed), '', "\n", +IFNULL(SUM(Passed), 'N/A'), '', "\n", '', -SUM(Failed), '', "\n", +IFNULL(SUM(Failed), 'N/A'), '', "\n", '', -SUM(`No run`), '', "\n", +IFNULL(SUM(`No run`), 'N/A'), '', "\n", '', -SUM(Subtotal), '', "\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 GROUP_CONCAT(HTML SEPARATOR '') AS HTML +SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML FROM ( SELECT CONCAT( 'Total', "\n", '-', "\n", '', -SUM(`Test runs`), '', "\n", +IFNULL(SUM(`Test runs`), 'N/A'), '', "\n", '', -SUM(Passed), '', "\n", +IFNULL(SUM(Passed), 'N/A'), '', "\n", '', -SUM(Failed), '', "\n", +IFNULL(SUM(Failed), 'N/A'), '', "\n", '', -SUM(`No run`), '', "\n", +IFNULL(SUM(`No run`), 'N/A'), '', "\n", '', -SUM(Subtotal), '', "\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 GROUP_CONCAT(HTML SEPARATOR '') AS HTML +SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML FROM ( SELECT CONCAT( '