Repository navigation
Expand file tree
/
Copy pathtest-integration.sh
More file actions
executable file
·82 lines (59 loc) · 2.45 KB
/
Copy pathtest-integration.sh
File metadata and controls
executable file
·82 lines (59 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
set -euo pipefail
# semquery integration test script
# Usage: cargo build && ./test-integration.sh
#
# Runs with a temporary workspace and user config.
# Models use the shared cache. The first run downloads them.
# Windows semquery uses LocalAppData through the Known Folder API.
# HOME and XDG_CONFIG_HOME cannot isolate that config path.
case "$(uname -s)" in
CYGWIN* | MINGW* | MSYS*)
echo "error: test-integration.sh supports Unix-like semquery binaries only." >&2
exit 1
;;
esac
SEMQ=./target/debug/semq
if [[ ! -x "$SEMQ" ]]; then
echo "error: $SEMQ not found. Run 'cargo build' first." >&2
exit 1
fi
TEST_ROOT="$(mktemp -d)"
trap 'rm -rf "$TEST_ROOT"' EXIT
WORKSPACE="$TEST_ROOT/workspace"
# Save this path before HOME changes.
MODEL_CACHE="${SEMQ_MODEL_CACHE:-$HOME/.cache/semq/models}"
export HOME="$TEST_ROOT/home"
export XDG_CONFIG_HOME="$TEST_ROOT/config"
mkdir -p "$HOME" "$XDG_CONFIG_HOME"
SEMQ_ARGS=(
--workspace "$WORKSPACE"
--model-cache "$MODEL_CACHE"
)
GREEN='\033[0;32m'
RESET='\033[0m'
echo -e "\n${GREEN}=== Init (workspace: $WORKSPACE) ===${RESET}"
"$SEMQ" "${SEMQ_ARGS[@]}" init
echo -e "\n${GREEN}=== Add collection (indexes on add) ===${RESET}"
"$SEMQ" "${SEMQ_ARGS[@]}" add ./testdata/md --name notes -v --log-stdout
echo -e "\n${GREEN}=== Ask ===${RESET}"
"$SEMQ" "${SEMQ_ARGS[@]}" ask "What are the improvements of Multi-Paxos over the Paxos algorithm?" -vv
echo -e "\n${GREEN}=== Ask (Chinese) ===${RESET}"
"$SEMQ" "${SEMQ_ARGS[@]}" ask "multi paxos 相比 paxos 算法的改进点?" -vv
echo -e "\n${GREEN}=== Search ===${RESET}"
"$SEMQ" "${SEMQ_ARGS[@]}" search "Multi-Paxos" --explain
echo -e "\n${GREEN}=== Status ===${RESET}"
"$SEMQ" "${SEMQ_ARGS[@]}" status
echo -e "\n${GREEN}=== Delete a single document (del --file) ===${RESET}"
"$SEMQ" "${SEMQ_ARGS[@]}" del --file ./testdata/md/forward.md
echo -e "\n${GREEN}=== Status after deleting one document ===${RESET}"
"$SEMQ" "${SEMQ_ARGS[@]}" status
echo -e "\n${GREEN}=== Delete the collection (del) ===${RESET}"
"$SEMQ" "${SEMQ_ARGS[@]}" del notes
echo -e "\n${GREEN}=== Status after deleting the collection ===${RESET}"
"$SEMQ" "${SEMQ_ARGS[@]}" status
echo -e "\n${GREEN}=== Search after deletion ===${RESET}"
"$SEMQ" "${SEMQ_ARGS[@]}" search "Multi-Paxos"
echo -e "\n${GREEN}=== Ask after deletion ===${RESET}"
"$SEMQ" "${SEMQ_ARGS[@]}" ask "What are the improvements of Multi-Paxos over the Paxos algorithm?" -vv
echo -e "\n${GREEN}=== Done ===${RESET}"