Skip to content

Commit

Permalink
Improve CI scripts (#1372)
Browse files Browse the repository at this point in the history
- If server tag is present, use it. Otherise, just return sha1
- If server is not running after 2s, fail script
  • Loading branch information
hubcio authored Dec 1, 2024
1 parent f052350 commit a135c10
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
5 changes: 4 additions & 1 deletion scripts/performance/run-standard-performance-suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ for (( i=0; i<${#SUITES[@]} ; i+=2 )) ; do
# Start iggy-server
echo "Starting iggy-server..."
target/release/iggy-server &> /dev/null &
IGGY_SERVER_PID=$!
sleep 2
echo

# Check if the server is running
exit_if_process_is_not_running "$IGGY_SERVER_PID"

# Start send bench
echo "Running ${SEND_BENCH}"
Expand Down
36 changes: 25 additions & 11 deletions scripts/performance/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,42 @@

COMMON_ARGS="--warmup-time 0"

# Function to get the current git tag or commit
function get_git_commit_or_tag() {
local dir=$1
# Function to get the current git tag containing "server" or commit SHA1
function get_git_iggy_server_tag_or_sha1() {
local dir="$1"

if [ -d "$dir" ]; then
pushd "$dir" > /dev/null || exit 1
pushd "$dir" > /dev/null || {
echo "Error: Failed to enter directory '$dir'." >&2
exit 1
}

if git rev-parse --git-dir > /dev/null 2>&1; then
# Get the short commit hash
local commit_hash
commit_hash=$(git rev-parse --short HEAD)
local tag
tag=$(git describe --exact-match --tags HEAD 2> /dev/null)

popd > /dev/null || exit 1
# Get all tags pointing to HEAD that contain "server" (case-insensitive)
local matching_tags
matching_tags=$(git tag --points-at HEAD | grep -i "server" || true)

popd > /dev/null || {
echo "Error: Failed to return from directory '$dir'." >&2
exit 1
}

if [ -n "$tag" ]; then
echo "$tag"
if [ -n "$matching_tags" ]; then
# If multiple tags match, you can choose to return the first one
# or handle them as needed. Here, we'll return the first match.
local first_matching_tag
first_matching_tag=$(echo "$matching_tags" | head -n 1)
echo "$first_matching_tag"
else
# No matching tag found; return the commit hash
echo "$commit_hash"
fi
else
echo "Error: Not a git repository." >&2
echo "Error: Directory '$dir' is not a git repository." >&2
popd > /dev/null || exit 1
return 1
fi
Expand Down Expand Up @@ -62,7 +76,7 @@ function construct_bench_command() {
local streams=${count}

local superdir
superdir="performance_results_$(get_git_commit_or_tag .)" || { echo "Failed to get git commit or tag."; exit 1; }
superdir="performance_results_$(get_git_iggy_server_tag_or_sha1 .)" || { echo "Failed to get git commit or tag."; exit 1; }
local output_directory="${superdir}/${type}_${count}${type:0:1}_${message_size}_${messages_per_batch}_${message_batches}_${protocol}"

echo "$bench_command \
Expand Down
11 changes: 11 additions & 0 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ function send_signal() {
fi
}

# Function to exit with error if a process with the given PID is running
exit_if_process_is_not_running() {
local pid="$1"

if kill -0 "$pid" 2>/dev/null; then
return 0 # Process is running
else
exit 1 # Process is not running
fi
}

# Exit hook for profile.sh
function on_exit_profile() {
# Gracefully stop the server
Expand Down

0 comments on commit a135c10

Please sign in to comment.