-
Notifications
You must be signed in to change notification settings - Fork 14
/
integration-test.sh
executable file
·188 lines (152 loc) · 4.87 KB
/
integration-test.sh
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/bin/bash
set -ex
if [ -f /etc/redhat-release ]; then
sudo dnf install -y inotify-tools docker-compose
else
sudo apt-get install inotify-tools docker-compose
fi
TOP=$(mktemp -d -p $HOME)
mkdir $TOP/.second-brain $TOP/Notes
# avoid losing my local env if testing locally :-)
test ! -f .env
cat > .env <<EOF
SRCDIR=$TOP/Notes
DSTDIR=$TOP/.second-brain
EOF
bash -x ./install-systemd-services.sh
sleep 5
# wait for chromadb to be started
TRY=0
while [ $TRY -lt 30 ]; do
TRY=$(( TRY + 1 ))
if docker-compose ps | grep -q " Up "; then
echo "*** Found finished marker"
break
fi
sleep 1
done
docker-compose ps
docker-compose ps | grep -q " Up "
TRY=0
while [ $TRY -lt 24 ]; do
TRY=$(( TRY + 1 ))
if docker-compose logs | grep -q "Application startup complete"; then
echo "*** Found finished marker"
break
fi
sleep 5
done
docker-compose logs
docker-compose logs | grep -q "Application startup complete"
# create the document
cat > $TOP/Notes/langchain.md <<EOF
## References
- https://docs.langchain.com/docs/
- https://blog.langchain.dev/conversational-retrieval-agents/
Plan-and-Solve Prompting: Improving Zero-Shot
Chain-of-Thought Reasoning by Large Language Models
https://arxiv.org/pdf/2305.04091.pdf
EOF
# wait for the document to be processed
TRY=0
while [ $TRY -lt 30 ]; do
TRY=$(( TRY + 1 ))
if journalctl --user -u sba-txt | grep -q "Storing .* chunks to the db for metadata={'type': 'notes', 'url': 'file://$TOP/Notes/langchain.md'}'"; then
echo "*** Found finished marker"
break
fi
journalctl --user -u sba-txt -u sba-md
sleep 1
done
journalctl --user -u sba-txt -u sba-md
# do another check to stop if it is not present
journalctl --user -u sba-md | grep -q "processed '$TOP/Notes/langchain.md'"
# test the vector store
RES=$(poetry run ./similarity.py "What is langchain?")
echo "$RES"
test -n "$RES"
# test the vector store and llm
RES=$(poetry run ./qa.py "What is langchain?")
echo "$RES"
if grep -q "I don't know." <<< "$RES"; then
exit 1
fi
# wait a bit to be sure to have all the logs in different seconds
# for the vacuum cleaning process to work
sleep 2
# test changing a document but not its content
sudo journalctl --user -u sba-md --rotate
sudo journalctl --user -u sba-md --vacuum-time=1s
touch $TOP/Notes/langchain.md
TRY=0
while [ $TRY -lt 30 ]; do
TRY=$(( TRY + 1 ))
if journalctl --user -u sba-md | grep "skipping $TOP/Notes/langchain.md / .* as content did not change"; then
echo "*** Found finished marker"
break
fi
sleep 1
done
journalctl --user -u sba-md
jq . $TOP/.second-brain/checksums.json
journalctl --user -u sba-md | grep "skipping $TOP/Notes/langchain.md / .* as content did not change"
# wait a bit to be sure to have all the logs in different seconds
# for the vacuum cleaning process to work
sleep 2
# test changing a document but not to all contents
sudo journalctl --user -u sba-md --rotate
sudo journalctl --user -u sba-md --vacuum-time=1s
cat >> $TOP/Notes/langchain.md <<EOF
## Links
- https://python.langchain.com/
EOF
TRY=0
while [ $TRY -lt 30 ]; do
TRY=$(( TRY + 1 ))
if journalctl --user -u sba-md | grep -q "processed '$TOP/Notes/langchain.md'"; then
echo "*** Found finished marker"
break
fi
sleep 1
done
journalctl --user -u sba-md
NB=$(journalctl --user -u sba-md | grep -c "content is the same for")
# pdf content is never processed again so the only ones are the 2 url
# in md doc
echo "*** NB=$NB"
test "$NB" -eq 2
# wait a bit to be sure to have all the logs in different seconds
# for the vacuum cleaning process to work
sleep 2
# test removing a document
sudo journalctl --user -u sba-md --rotate
sudo journalctl --user -u sba-md --vacuum-time=1s
sudo journalctl --user -u sba-txt --rotate
sudo journalctl --user -u sba-txt --vacuum-time=1s
rm "$TOP/Notes/langchain.md"
TRY=0
while [ $TRY -lt 5 ]; do
TRY=$(( TRY + 1 ))
if journalctl --user -u sba-md | grep -q "removing $TOP/Text/langchain.json as $TOP/Notes/langchain.md do not exist anymore"; then
echo "*** Found finished marker"
break
fi
sleep 1
done
journalctl --user -u sba-md
journalctl --user -u sba-md | grep -q "removing $TOP/.second-brain/Text/langchain.json as $TOP/Notes/langchain.md do not exist anymore"
TRY=0
while [ $TRY -lt 5 ]; do
TRY=$(( TRY + 1 ))
if journalctl --user -u sba-txt | grep -q "Removing .* related files to $TOP/.second-brain/Text/langchain.json:"; then
echo "*** Found finished marker"
break
fi
sleep 1
done
journalctl --user -u sba-txt
journalctl --user -u sba-txt | grep -q "Removing .* related files to $TOP/.second-brain/Text/langchain.json:"
# be sure we don't have anymore document in the vector database
poetry run ./similarity.py ""
poetry run ./similarity.py "" 2>&1 | grep "Number of documents in the vector store: 0"
# integration-test.sh ends here