Skip to content

Commit 759f2c2

Browse files
committed
fix(ci): update to the latest changes
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent 17b32b6 commit 759f2c2

1 file changed

Lines changed: 76 additions & 28 deletions

File tree

.github/workflows/integration-test.yml

Lines changed: 76 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -199,26 +199,87 @@ jobs:
199199
ls -la context_chat_backend/persistent_storage/*
200200
sleep 30 # Wait for the em server to get ready
201201
202-
- name: Scan files, baseline
203-
run: |
204-
./occ files:scan admin
205-
./occ context_chat:scan admin -m text/plain
206-
207-
- name: Check python memory usage
202+
- name: Initial memory usage check
208203
run: |
209204
ps -p $(cat pid.txt) -o pid,cmd,%mem,rss --sort=-%mem
210205
ps -p $(cat pid.txt) -o %mem --no-headers > initial_mem.txt
211206
212-
- name: Scan files
213-
run: |
214-
./occ files:scan admin
215-
./occ context_chat:scan admin -m text/markdown &
216-
./occ context_chat:scan admin -m text/x-rst
217-
218-
- name: Check python memory usage
207+
- name: Periodically check context_chat stats for 15 minutes to allow the backend to index the files
219208
run: |
220-
ps -p $(cat pid.txt) -o pid,cmd,%mem,rss --sort=-%mem
221-
ps -p $(cat pid.txt) -o %mem --no-headers > after_scan_mem.txt
209+
success=0
210+
for i in {1..90}; do
211+
echo "Checking stats, attempt $i..."
212+
213+
mkfifo error_pipe
214+
stats=$(timeout 5 ./occ context_chat:stats 2>error_pipe)
215+
echo "Stats output:"
216+
echo "$stats"
217+
echo "---"
218+
219+
# Check for critical errors in output
220+
if echo "$stats" | grep -q "Error during request"; then
221+
echo "Backend connection error detected, retrying..."
222+
rm -f error_pipe
223+
sleep 10
224+
continue
225+
fi
226+
227+
# Extract Total eligible files
228+
total_files=$(echo "$stats" | grep -oP 'Total eligible files:\s*\K\d+' || echo "")
229+
230+
# Extract Indexed documents count (files__default)
231+
indexed_count=$(echo "$stats" | grep -oP "'files__default'\s*=>\s*\K\d+" || echo "")
232+
233+
# Validate parsed values
234+
if [ -z "$total_files" ] || [ -z "$indexed_count" ]; then
235+
echo "Error: Could not parse stats output properly"
236+
if echo "$stats" | grep -q "Indexed documents:"; then
237+
echo " Indexed documents section found but could not extract count"
238+
fi
239+
rm -f error_pipe
240+
sleep 10
241+
continue
242+
fi
243+
244+
echo "Total eligible files: $total_files"
245+
echo "Indexed documents (files__default): $indexed_count"
246+
247+
# Calculate absolute difference
248+
diff=$((total_files - indexed_count))
249+
if [ $diff -lt 0 ]; then
250+
diff=$((-diff))
251+
fi
252+
253+
# Calculate 2% threshold using bc for floating point support
254+
threshold=$(echo "scale=4; $total_files * 0.02" | bc)
255+
256+
# Check if difference is within tolerance
257+
if (( $(echo "$diff <= $threshold" | bc -l) )); then
258+
echo "Indexing within 2% tolerance (diff=$diff, threshold=$threshold)"
259+
rm -f error_pipe
260+
success=1
261+
break
262+
else
263+
pct=$(echo "scale=2; ($diff / $total_files) * 100" | bc)
264+
echo "Outside 2% tolerance: diff=$diff (${pct}%), threshold=$threshold"
265+
fi
266+
267+
# Check if backend is still alive
268+
ccb_alive=$(ps -p $(cat pid.txt) -o cmd= | grep -c "main.py" || echo "0")
269+
if [ "$ccb_alive" -eq 0 ]; then
270+
echo "Error: Context Chat Backend process is not running. Exiting."
271+
rm -f error_pipe
272+
exit 1
273+
fi
274+
275+
rm -f error_pipe
276+
sleep 10
277+
done
278+
279+
if [ $success -ne 1 ]; then
280+
echo "Max attempts reached"
281+
exit 1
282+
fi
222283
223284
- name: Run the prompts
224285
run: |
@@ -252,19 +313,6 @@ jobs:
252313
echo "Memory usage during scan is stable. No memory leak detected."
253314
fi
254315
255-
- name: Compare memory usage and detect leak
256-
run: |
257-
initial_mem=$(cat after_scan_mem.txt | tr -d ' ')
258-
final_mem=$(cat after_prompt_mem.txt | tr -d ' ')
259-
echo "Initial Memory Usage: $initial_mem%"
260-
echo "Memory Usage after prompt: $final_mem%"
261-
262-
if (( $(echo "$final_mem > $initial_mem" | bc -l) )); then
263-
echo "Memory usage has increased during prompt. Possible memory leak detected!"
264-
else
265-
echo "Memory usage during prompt is stable. No memory leak detected."
266-
fi
267-
268316
- name: Show server logs
269317
if: always()
270318
run: |

0 commit comments

Comments
 (0)