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 19, 2023
1 parent aea81d1 commit 56fc01f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,10 @@ jobs:
cp ../xline-test-utils/{private,public}.pem .
docker build . -t ghcr.io/xline-kv/xline:latest
docker pull gcr.io/etcd-development/etcd:v3.5.5
bash ./validation_test.sh
bash ./validation_test.sh
- name: upload logs
if: failure()
uses: actions/upload-artifact@v1
with:
name: Xline logs
path: scripts/logs
33 changes: 22 additions & 11 deletions scripts/quick_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ run_container() {
size=${1}
image="ghcr.io/xline-kv/xline:latest"
for ((i = 1; i <= ${size}; i++)); do
docker run \
-e RUST_LOG=debug -e HOSTNAME=node${i} -e MEMBERS=${MEMBERS} -e INIT_LEADER=node1\
-e AUTH_PUBLIC_KEY=/mnt/public.pem -e AUTH_PRIVATE_KEY=/mnt/private.pem \
-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="docker run -e RUST_LOG=debug -e HOSTNAME=node${i} -e MEMBERS=${MEMBERS} -e INIT_LEADER=node1"
command_str="${command_str} -e AUTH_PUBLIC_KEY=/mnt/public.pem -e AUTH_PRIVATE_KEY=/mnt/private.pem"
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 @@ -41,8 +44,16 @@ run_container() {
echo container started
}

stop_all
docker network create --subnet=172.20.0.0/24 xline_net >/dev/null 2>&1
echo "A Docker network named 'xline_net' is created for communication among various xline nodes. You can use the command 'docker network rm xline_net' to remove it after use."

run_container 3
if [ -z "$1" ]; then
stop_all
docker network create --subnet=172.20.0.0/24 xline_net >/dev/null 2>&1
echo "A Docker network named 'xline_net' is created for communication among various xline nodes. You can use the command 'docker network rm xline_net' to remove it after use."
run_container 3
exit 0
elif [ "$1" == "stop" ]; then
stop_all
exit 0
else
echo "Unexpected argument: $1"
exit 1
fi
7 changes: 7 additions & 0 deletions scripts/start_xline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ if [ "$HOSTNAME" = "$INIT_LEADER" ]; then
cmd="${cmd} --is-leader"
fi

if [ -n "$LOG_FILE"]; then
cmd="${cmd} \
--log-file $LOG_FILE \
--log-level $RUST_LOG \
"
fi

RUST_LOG=$RUST_LOG ${cmd}
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 56fc01f

Please sign in to comment.