Debian Codegraph @

third_party/rust/glean/tests/test-pending-gets-removed.sh

raw
1 #!/bin/bash
2
3 # Test harness for testing the RLB processes from the outside.
4 #
5 # Some behavior can only be observed when properly exiting the process running Glean,
6 # e.g. when an uploader runs in another thread.
7 # On exit the threads will be killed, regardless of their state.
8
9 # Remove the temporary data path on all exit conditions
10 cleanup() {
11 if [ -n "$datapath" ]; then
12 rm -r "$datapath"
13 fi
14 }
15 trap cleanup INT ABRT TERM EXIT
16
17 set -e
18
19 tmp="${TMPDIR:-/tmp}"
20 datapath=$(mktemp -d "${tmp}/pending-gets-removed.XXXX")
21
22 # Build it once
23 cargo build -p glean --example pending-gets-removed
24
25 cmd="cargo run -q -p glean --example pending-gets-removed -- $datapath"
26
27 $cmd 1
28 count=$(ls -1q "$datapath/pending_pings" | wc -l)
29 if [[ "$count" -ne 2 ]]; then
30 echo "1: test result: FAILED."
31 exit 101
32 fi
33
34 $cmd 2
35 count=$(ls -1q "$datapath/pending_pings" | wc -l)
36 if [[ "$count" -ne 1 ]]; then
37 echo "2: test result: FAILED."
38 exit 101
39 fi
40
41 if ! grep -q "/submit/glean-pending-removed/nofollows/" "$datapath/pending_pings"/*; then
42 echo "3: test result: FAILED."
43 exit 101
44 fi
45
46 $cmd 3
47 count=$(ls -1q "$datapath/pending_pings" | wc -l)
48 if [[ "$count" -ne 0 ]]; then
49 echo "4: test result: FAILED."
50 exit 101
51 fi
52
53 echo "test result: ok."
54 exit 0