Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce GitHub Action for CRON execution to detect regressions #8

Merged
merged 7 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
73 changes: 73 additions & 0 deletions .github/workflows/run-coach.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Coach

on:
push:
branches: [ "master", "automation" ]
schedule:
# every day at 12 CET
- cron: "0 14 * * *"
workflow_dispatch:
inputs:
qdrant_version:
description: "Version of qdrant to pull the container for (tags/v1.6.1, <commit-id>, my-branch)"
default: dev
coaching_time:
description: "Duration in seconds, default is 3600s (60 min) "
default: 3600

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Process inputs
id: default_inputs
run: |
qdrant_version="${{ inputs.qdrant_version }}"
if [ -z "$qdrant_version" ]; then
qdrant_version=dev
fi

coaching_time="${{ inputs.coaching_time }}"
if [ -z "$coaching_time" ]; then
coaching_time=3600
fi

echo "qdrant_version=$qdrant_version" >> $GITHUB_OUTPUT
echo "coaching_time=$coaching_time" >> $GITHUB_OUTPUT
- name: Install minimal stable
uses: dtolnay/rust-toolchain@stable
# checkout coach
- name: Checkout Coach
uses: actions/checkout@v4
- name: Build Coach (release)
run: cargo build --release
- name: Coach things
shell: bash
run: |
coaching_time="${{ steps.default_inputs.outputs.coaching_time }}"
qdrant_version="${{ steps.default_inputs.outputs.qdrant_version }}"

./coach-things.sh "$coaching_time" "$qdrant_version"
- name: Send Notification
if: failure() || cancelled()
uses: slackapi/[email protected]
with:
payload: |
{
"text": "Coach run status: ${{ job.status }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Something is wrong.\nView the results <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.COACH_CHANNEL_WEBHOOK_URL }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one needs additional setup

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a new webhook, ping me to get an url

SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
86 changes: 86 additions & 0 deletions coach-things.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env bash

set -e

RUN_TIME=${1:-300}
QDRANT_VERSION=${2:-dev}

REST_PORT="6333"
GRPC_PORT="6334"
QDRANT_HOST=localhost:${REST_PORT}

echo "Running for $RUN_TIME seconds"
echo "QDRANT_HOST: $QDRANT_HOST"
echo "QDRANT_VERSION: $QDRANT_VERSION"

# start qdrant docker
docker run -d --rm \
-p ${REST_PORT}:${REST_PORT} \
-p ${GRPC_PORT}:${GRPC_PORT} \
-e QDRANT__SERVICE__GRPC_PORT=${GRPC_PORT} \
--name qdrant_test qdrant/qdrant:"${QDRANT_VERSION}" ./qdrant --disable-telemetry

trap stop_docker SIGINT
trap stop_docker ERR

until $(curl --output /dev/null --silent --get --fail http://$QDRANT_HOST/collections); do
printf 'waiting for server to start...'
sleep 5
done

# start coach against qdrant
COACH_CMD=(
cargo run --release
--
-p 2 # number of concurrent workloads
--stop-at-first-error
--grpc-timeout-ms 10000
--grpc-health-check-timeout-ms 1000
)

echo ""
echo "${COACH_CMD[*]}"
"${COACH_CMD[@]}" &

pid=$!

echo "The coach PID is $pid"

function cleanup() {
if ps -p $pid >/dev/null
then
kill -KILL $pid
stop_docker
fi
}

function stop_docker()
{
echo "stopping qdrant_test"
docker stop qdrant_test
}


trap cleanup EXIT

trap 'exit $?' ERR
trap exit INT

started=$(date +%s)

while ps -p $pid >/dev/null && (( $(date +%s) - started < RUN_TIME ))
do
sleep 10
done

if ps -p $pid >/dev/null
then
echo "The process is still running. Stopping the process..."
kill $pid
stop_docker
echo "OK"
else
echo "The process has unexpectedly terminated on its own. Check the logs."
stop_docker
exit 1
fi
Loading