Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions jenkins/pipelines/QE/sgw/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ pipeline {
// string(name: 'CBL_VERSION', description: 'Couchbase Lite Version to use, eg : "4" for latest version-build, or "4.1.0-18" for specific version and build')
// string(name: 'SGW_VERSION', description: 'Sync Gateway Version to use, eg : its the same way, check out "resolveProgetVersion" function for more details)')
// string(name: 'TS_TEST_FILTER', description: 'An optional filter for running a subset of tests')
options {
ansiColor('xterm')
timestamps()
}
Comment thread
vipbhardwaj marked this conversation as resolved.
stages {
stage('Init') {
agent any
Expand Down
1 change: 1 addition & 0 deletions jenkins/pipelines/QE/sgw/teardown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -euo pipefail
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
source $SCRIPT_DIR/../../shared/config.sh

section_start "$COLOR_GREEN" "TEARDOWN"
Comment thread
vipbhardwaj marked this conversation as resolved.
export PYTHONPATH=$SCRIPT_DIR/../../../
pushd $AWS_ENVIRONMENT_DIR
# The tests now run from the tests/ root (both QE and dev_e2e in one session),
Expand Down
4 changes: 2 additions & 2 deletions jenkins/pipelines/QE/sgw/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ done
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
source "$SCRIPT_DIR"/../../shared/config.sh

echo "Setup backend..."
section_start "$COLOR_CYAN" "INFRA SETUP"
pushd "$AWS_ENVIRONMENT_DIR" >/dev/null
uv run "$SCRIPT_DIR"/setup_test.py "$CBL_VERSION" "$SGW_VERSION"
popd >/dev/null
Expand All @@ -56,7 +56,7 @@ fi
# this single-cluster topology does not provide; it is deferred until the
# multi-cluster topology is sorted out rather than left to fail every night. See CBL-8686

echo "Run tests..."
section_start "$COLOR_YELLOW" "RUN TESTS"
pushd "$TESTS_DIR" >/dev/null
if [ -n "$TEST_FILTER" ]; then
uv run pytest -v --no-header --config QE/config.json \
Expand Down
60 changes: 60 additions & 0 deletions jenkins/pipelines/shared/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,66 @@ print_box() {
echo "$border"
}

# Colored, timed section banners for Jenkins console output (rendered by the
# ansiColor('xterm') pipeline option; the raw escape codes are harmless on a
# plain terminal too). Usage: section_start "$COLOR_CYAN" "INFRA SETUP" ...
# work... ; the next section_start call (or script exit, via the EXIT trap
# below) closes the previous section and prints how long it took.
Comment thread
vipbhardwaj marked this conversation as resolved.
Outdated
readonly COLOR_RESET='\033[0m'
readonly COLOR_CYAN='\033[1;36m'
readonly COLOR_YELLOW='\033[1;33m'
readonly COLOR_GREEN='\033[1;32m'

_section_color=""
_section_label=""
_section_start_ts=""

_format_duration() {
local total=$1 h m s
h=$((total / 3600))
m=$(((total % 3600) / 60))
s=$((total % 60))
if [ "$h" -gt 0 ]; then
printf '%dh%dm%ds' "$h" "$m" "$s"
elif [ "$m" -gt 0 ]; then
printf '%dm%ds' "$m" "$s"
else
printf '%ds' "$s"
fi
}

# Closes whichever section is currently open (no-op if none is). Registered
# as an EXIT trap so the closing banner -- and the duration -- still prints
# even if the section's work fails (set -e / the caller's ERR trap exits the
# script from inside the section), not just on a clean finish.
_section_close() {
[ -z "$_section_label" ] && return 0
local end_ts
end_ts=$(date +%s)
echo -e "${_section_color}=== ${_section_label} END (took $(_format_duration $((end_ts - _section_start_ts)))) ===${COLOR_RESET}"
_section_label=""
}

section_start() {
_section_close
_section_color="$1"
_section_label="$2"
_section_start_ts=$(date +%s)
echo -e "${_section_color}=== ${_section_label} START ===${COLOR_RESET}"
}
Comment thread
vipbhardwaj marked this conversation as resolved.
Outdated

# Append to any existing EXIT trap instead of overwriting it (some pipeline scripts
# install their own EXIT traps before sourcing this file).
_existing_exit_trap=$(trap -p EXIT | awk -F"'" '{print $2}')
if [ -n "$_existing_exit_trap" ]; then
if [[ "$_existing_exit_trap" != *"_section_close"* ]]; then
trap "${_existing_exit_trap}; _section_close" EXIT
fi
else
trap _section_close EXIT
Comment thread
Copilot marked this conversation as resolved.
Outdated
fi
unset _existing_exit_trap
Comment thread
vipbhardwaj marked this conversation as resolved.
Outdated

if ! command -v uv >/dev/null 2>&1; then
echo "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
Expand Down
Loading