Skip to content

Commit

Permalink
chore: upload xline logs if validation failed
Browse files Browse the repository at this point in the history
Signed-off-by: themanforfree <[email protected]>
  • Loading branch information
themanforfree committed Dec 12, 2023
1 parent 7c25762 commit afdacf5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 33 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ jobs:
docker build . -t ghcr.io/xline-kv/xline:latest
docker pull gcr.io/etcd-development/etcd:v3.5.5
bash ./validation_test.sh
- name: upload logs
if: failure()
uses: actions/upload-artifact@v1
with:
name: Xline logs
path: scripts/logs
36 changes: 21 additions & 15 deletions scripts/quick_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,17 @@ run_container() {
size=${1}
image="ghcr.io/xline-kv/xline:latest"
for ((i = 1; i <= ${size}; i++)); do
command_str="docker run -e RUST_LOG=debug -e HOSTNAME=node${i} -e MEMBERS=${MEMBERS}"
if [ "$i" -eq 1 ]; then
docker run \
-e RUST_LOG=debug -e HOSTNAME=node${i} -e MEMBERS=${MEMBERS} -e IS_LEADER=true \
-d -it --rm --name=node${i} \
--net=xline_net --ip=${SERVERS[$i]} --cap-add=NET_ADMIN \
--cpu-shares=1024 -m=512M -v ${DIR}:/mnt ${image} &
else
docker run \
-e RUST_LOG=debug -e HOSTNAME=node${i} -e MEMBERS=${MEMBERS} \
-d -it --rm --name=node${i} \
--net=xline_net --ip=${SERVERS[$i]} --cap-add=NET_ADMIN \
--cpu-shares=1024 -m=512M -v ${DIR}:/mnt ${image} &
command_str="${command_str} -e IS_LEADER=true"
fi
if [ -n "$LOG_PATH" ]; then
command_str="${command_str} -e LOG_FILE=${LOG_PATH}/node${i}"
fi
command_str="${command_str} -d -it --rm --name=node${i}"
command_str="${command_str} --net=xline_net --ip=${SERVERS[$i]} --cap-add=NET_ADMIN"
command_str="${command_str} --cpu-shares=1024 -m=512M -v ${DIR}:/mnt ${image}"
eval ${command_str}
done
docker run -d -it --rm --name=client \
--net=xline_net --ip=${SERVERS[0]} --cap-add=NET_ADMIN \
Expand All @@ -48,7 +46,15 @@ run_container() {
echo container started
}

stop_all
docker network create --subnet=172.20.0.0/24 xline_net >/dev/null 2>&1

run_container 3
if [ -z "$1" ]; then
stop_all
docker network create --subnet=172.20.0.0/24 xline_net >/dev/null 2>&1
run_container 3
exit 0
elif [ "$1" == "stop" ]; then
stop_all
exit 0
else
echo "Unexpected argument: $1"
exit 1
fi
39 changes: 22 additions & 17 deletions scripts/start_xline.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

if [ -z "$HOSTNAME" ]; then
if [ -z "${HOSTNAME}" ]; then
echo -e "Env HOSTNAME is not set"
exit 1
fi

if [ -z "$MEMBERS" ]; then
if [ -z "${MEMBERS}" ]; then
echo -e "Env MEMBERS is not set"
exit 1
fi
Expand All @@ -15,22 +15,27 @@ ENGINE="${STORAGE_ENGINE:-rocksdb}"
DATA_DIR="${DATA_DIR:-/usr/local/xline/data-dir}"
PUBLIC_KEY="${PUBLIC_KEY:-/mnt/public.pem}"
PRIVATE_KEY="${PRIVATE_KEY:-/mnt/private.pem}"
LOG_FILE="${LOG_FILE:-/var/log/xline}"

if [ -z "$IS_LEADER" ]; then
RUST_LOG=$RUST_LOG /usr/local/bin/xline \
--name $HOSTNAME \
--members $MEMBERS \
--storage-engine rocksdb \
--data-dir /usr/local/xline/data-dir \
--auth-public-key /mnt/public.pem \
--auth-private-key /mnt/private.pem
if [ -z "${IS_LEADER}" ]; then
RUST_LOG=${RUST_LOG} /usr/local/bin/xline \
--name ${HOSTNAME} \
--members ${MEMBERS} \
--storage-engine ${ENGINE} \
--data-dir ${DATA_DIR} \
--auth-public-key ${PUBLIC_KEY} \
--auth-private-key ${PRIVATE_KEY} \
--log-file ${LOG_FILE} \
--log-level ${RUST_LOG}
else
RUST_LOG=$RUST_LOG /usr/local/bin/xline \
--name $HOSTNAME \
--members $MEMBERS \
--storage-engine rocksdb \
--data-dir /usr/local/xline/data-dir \
--auth-public-key /mnt/public.pem \
--auth-private-key /mnt/private.pem \
RUST_LOG=${RUST_LOG} /usr/local/bin/xline \
--name ${HOSTNAME} \
--members ${MEMBERS} \
--storage-engine ${ENGINE} \
--data-dir ${DATA_DIR} \
--auth-public-key ${PUBLIC_KEY} \
--auth-private-key ${PRIVATE_KEY} \
--log-file ${LOG_FILE} \
--log-level ${RUST_LOG} \
--is-leader
fi
4 changes: 3 additions & 1 deletion scripts/validation_test.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
DIR="$(dirname $0)"
QUICK_START="${DIR}/quick_start.sh"
bash ${QUICK_START}
LOG_PATH=/mnt/logs bash ${QUICK_START}
ETCDCTL="docker exec -i client etcdctl --endpoints=http://172.20.0.3:2379,http://172.20.0.4:2380"
LOCK_CLIENT="docker exec -i client /mnt/validation_lock_client --endpoints=http://172.20.0.3:2379"

Expand All @@ -21,6 +21,7 @@ run_with_expect() {
echo "command: ${cmd}"
echo "expect: ${expect}"
echo "result: ${res}"
bash ${QUICK_START} stop
exit 1
fi
}
Expand All @@ -40,6 +41,7 @@ run_with_match() {
echo "command: ${cmd}"
echo "expect: ${expect}"
echo "result: ${res}"
bash ${QUICK_START} stop
exit 1
fi
}
Expand Down

0 comments on commit afdacf5

Please sign in to comment.