File: test-delayed-ping-data.sh

package info (click to toggle)
firefox 147.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,532 kB
  • sloc: cpp: 7,607,356; javascript: 6,533,348; ansic: 3,775,236; python: 1,415,508; xml: 634,561; asm: 438,949; java: 186,241; sh: 62,760; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (53 lines) | stat: -rwxr-xr-x 1,633 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

# Test harness for testing the RLB processes from the outside.
#
# Some behavior can only be observed when properly exiting the process running Glean,
# e.g. when an uploader runs in another thread.
# On exit the threads will be killed, regardless of their state.

# Remove the temporary data path on all exit conditions
cleanup() {
  if [ -n "$datapath" ]; then
    rm -r "$datapath"
  fi
}
trap cleanup INT ABRT TERM EXIT

tmp="${TMPDIR:-/tmp}"
datapath=$(mktemp -d "${tmp}/glean_ping_lifetime_flush.XXXX")

cmd="cargo run -p glean --example delayed-ping-data -- $datapath"

# First run "crashes" -> no increment stored
$cmd accumulate_one_and_pretend_crash
count=$(find "$datapath/sent_pings" -name '*.json' -exec grep -e "url.*prototype" {} ';' | wc -l)
if [[ "$count" -ne 0 ]]; then
  echo "test result: FAILED."
  exit 101
fi

# Second run increments and orderly shuts down -> increment flushed to disk.
# No ping is sent.
$cmd accumulate_ten_and_orderly_shutdown
count=$(find "$datapath/sent_pings" -name '*.json' -exec grep -e "url.*prototype" {} ';' | wc -l)
if [[ "$count" -ne 0 ]]; then
  echo "1/3 test result: FAILED. Expected 0, got $count pings"
  exit 101
fi

# Third run sends the ping.
$cmd submit_ping
count=$(find "$datapath/sent_pings" -name '*.json' -exec grep -e "url.*prototype" {} ';' | wc -l)
if [[ "$count" -ne 1 ]]; then
  echo "2/3 test result: FAILED. Expect 1, got $count pings"
  exit 101
fi

if ! grep -q '"test.metrics.sample_counter":10' "$datapath"/sent_pings/*; then
  echo "3/3 test result: FAILED. Inaccurate number of sample counts."
  exit 101
fi

echo "test result: ok."
exit 0