forked from ufs-community/ufs-srweather-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[develop] Feature/cicd metrics adds methods to collect resource usage…
… data from major stages of the SRW pipeline build job (ufs-community#1058) Updated SRW Jenkinsfile with some run-time stats collection, and adds a final stage that triggers ufs-srw-metrics stats collection job for reporting metrics. The SRW pipeline job that uses this Jenkinsfile will now use the 'time' command when executing major stages: init, build, test. This will collect CPU, Memory, and DiskUsage measurements that can be later used in trend plots on a metrics dashboard. Additionally, it adds options to the pipeline job that allow the operator to select just a single test, or no test suite (default is still 'coverage' suite), and allows an option to select the depth of wrapper script tasks to execute during functional testing (default is still all 9 scripts).
- Loading branch information
1 parent
aa1678b
commit a609196
Showing
7 changed files
with
153 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Output a CSV report of disk usage on subdirs of some path | ||
# Usage: | ||
# [JOB_NAME=<ci_job>] [BUILD_NUMBER=<n>] [SRW_COMPILER=<intel>] [SRW_PLATFORM=<machine>] disk_usage path depth size outfile.csv | ||
# | ||
# args: | ||
# directory=$1 | ||
# depth=$2 | ||
# size=$3 | ||
# outfile=$4 | ||
|
||
[[ -n ${WORKSPACE} ]] || WORKSPACE=$(pwd) | ||
[[ -n ${SRW_PLATFORM} ]] || SRW_PLATFORM=$(hostname -s 2>/dev/null) || SRW_PLATFORM=$(hostname 2>/dev/null) | ||
[[ -n ${SRW_COMPILER} ]] || SRW_COMPILER=compiler | ||
|
||
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" | ||
|
||
# Get repository root from Jenkins WORKSPACE variable if set, otherwise, set | ||
# relative to script directory. | ||
declare workspace | ||
if [[ -n "${WORKSPACE}/${SRW_PLATFORM}" ]]; then | ||
workspace="${WORKSPACE}/${SRW_PLATFORM}" | ||
else | ||
workspace="$(cd -- "${script_dir}/../.." && pwd)" | ||
fi | ||
|
||
echo "STAGE_NAME=${STAGE_NAME}" # from pipeline | ||
outfile="${4:-${workspace}-${SRW_COMPILER}-disk-usage${STAGE_NAME}.csv}" | ||
|
||
function disk_usage() { | ||
local directory=${1:-${PWD}} | ||
local depth=${2:-1} | ||
local size=${3:-k} | ||
echo "Disk usage: ${JOB_NAME:-ci}/${SRW_PLATFORM}/$(basename $directory)" | ||
( | ||
cd $directory || exit 1 | ||
echo "Platform,Build,Owner,Group,Inodes,${size:-k}bytes,Access Time,Filename" | ||
du -Px -d ${depth:-1} --inode --exclude='./workspace' | \ | ||
while read line ; do | ||
arr=($line); inode=${arr[0]}; filename=${arr[1]}; | ||
echo "${SRW_PLATFORM}-${SRW_COMPILER:-compiler},${JOB_NAME:-ci}/${BUILD_NUMBER:-0},$(stat -c '%U,%G' $filename),${inode:-0},$(du -Px -s -${size:-k} --time $filename)" | tr '\t' ',' ; | ||
done | sort -t, -k5 -n #-r | ||
) | ||
echo "" | ||
} | ||
|
||
disk_usage $1 $2 $3 | tee ${outfile} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# A unified init script for the SRW application. This script is expected to | ||
# fetch initial source for the SRW application for all supported platforms. | ||
# | ||
set -e -u -x | ||
|
||
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" | ||
|
||
# Get repository root from Jenkins WORKSPACE variable if set, otherwise, set | ||
# relative to script directory. | ||
declare workspace | ||
if [[ -n "${WORKSPACE}/${SRW_PLATFORM}" ]]; then | ||
workspace="${WORKSPACE}/${SRW_PLATFORM}" | ||
else | ||
workspace="$(cd -- "${script_dir}/../.." && pwd)" | ||
fi | ||
|
||
# Normalize Parallel Works cluster platform value. | ||
declare platform | ||
if [[ "${SRW_PLATFORM}" =~ ^(az|g|p)clusternoaa ]]; then | ||
platform='noaacloud' | ||
else | ||
platform="${SRW_PLATFORM}" | ||
fi | ||
|
||
# Build and install | ||
cd ${workspace} | ||
set +e | ||
/usr/bin/time -p -f '{\n "cpu": "%P"\n, "memMax": "%M"\n, "mem": {"text": "%X", "data": "%D", "swaps": "%W", "context": "%c", "waits": "%w"}\n, "pagefaults": {"major": "%F", "minor": "%R"}\n, "filesystem": {"inputs": "%I", "outputs": "%O"}\n, "time": {"real": "%e", "user": "%U", "sys": "%S"}\n}' -o ${WORKSPACE}/${SRW_PLATFORM}-${SRW_COMPILER}-time-srw_init.json \ | ||
./manage_externals/checkout_externals | ||
init_exit=$? | ||
echo "STAGE_NAME=${STAGE_NAME}" | ||
env | grep = | sort > ${WORKSPACE}/${SRW_PLATFORM}-${SRW_COMPILER}-env.txt | ||
set -e | ||
cd - | ||
|
||
exit $init_exit |
Oops, something went wrong.