52 lines
1.5 KiB
Bash
Executable file
52 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# If nix is available and we are not already in a nix shell, re-enter via nix develop
|
|
if [[ -z "${IN_NIX_SHELL:-}" ]] && command -v nix >/dev/null 2>&1; then
|
|
exec nix develop -c "$0" "$@"
|
|
fi
|
|
|
|
cleanup() {
|
|
if [[ -n "${SERVER_PID:-}" ]]; then
|
|
kill "$SERVER_PID" >/dev/null 2>&1 || true
|
|
fi
|
|
if [[ -n "${PD_PID:-}" ]]; then
|
|
kill "$PD_PID" >/dev/null 2>&1 || true
|
|
fi
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
echo "Building workspace..."
|
|
cargo build
|
|
|
|
echo "Running tests..."
|
|
cargo test
|
|
|
|
echo "Starting PD..."
|
|
cargo run --bin rdb-pd -- --addr 127.0.0.1:2479 >/tmp/rdb-pd.log 2>&1 &
|
|
PD_PID=$!
|
|
sleep 2
|
|
|
|
echo "Starting Server..."
|
|
cargo run --bin rdb-server -- --pd-addr 127.0.0.1:2479 --addr 127.0.0.1:50052 --data-dir /tmp/rdb-server >/tmp/rdb-server.log 2>&1 &
|
|
SERVER_PID=$!
|
|
sleep 2
|
|
|
|
echo "Running Client Verification..."
|
|
|
|
echo "Testing TSO..."
|
|
cargo run --bin rdb-client -- --pd-addr 127.0.0.1:2479 --addr 127.0.0.1:50052 tso
|
|
|
|
echo "Testing Raw Put/Get..."
|
|
cargo run --bin rdb-client -- --pd-addr 127.0.0.1:2479 --addr 127.0.0.1:50052 raw-put --key foo --value bar
|
|
cargo run --bin rdb-client -- --pd-addr 127.0.0.1:2479 --addr 127.0.0.1:50052 raw-get --key foo
|
|
|
|
echo "Testing CAS success..."
|
|
cargo run --bin rdb-client -- --pd-addr 127.0.0.1:2479 --addr 127.0.0.1:50052 cas --key cas1 --value v1 --expected 0
|
|
|
|
echo "Testing CAS conflict..."
|
|
set +e
|
|
cargo run --bin rdb-client -- --pd-addr 127.0.0.1:2479 --addr 127.0.0.1:50052 cas --key cas1 --value v2 --expected 0
|
|
set -e
|
|
|
|
echo "Verification Complete!"
|