File: 1157

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (104 lines) | stat: -rwxr-xr-x 2,317 bytes parent folder | download
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
#!/bin/sh
# PCP QA Test No. 1157
# Exercise the BCC PMDA tcpretrans module - install, remove and values.
#
# Copyright (c) 2018 Andreas Gerstmayr.
#

seq=`basename $0`
echo "QA output created by $seq"

. ./common.bcc

_pmdabcc_check
_bcc_check_ArgString || _notrun "bcc is broken (ArgString bug) on this platform"
case "`uname -srm`"
in
    Linux\ 5.2.*)
    		_notrun "Bad Linux 5.2 kernel headers will cause BPF to fail"
		;;
esac

# sch_netem is part of optional kernel-modules-extra on Fedora
$sudo modprobe sch_netem
lsmod | grep sch_netem >/dev/null 2>&1 \
  || _notrun "sch_netem kernel module not available"
which curl >/dev/null 2>&1 || _notrun "No curl binary installed"

target_ip=1.1.1.1
net_dev=$(ip route get ${target_ip} | awk '{print $5; exit}')

status=1       # failure is the default!
signal=$PCP_BINADM_DIR/pmsignal

# Some combinations of distro and kernel are known to be "bad"
# for some BPF modules
#
kernel=`uname -r`
echo "$kernel" >>$seq_full
case `admin/whatami`
in
    *Ubuntu\ 19.10\ *)
	_notrun "bcc tcpretrans module will not compile on Ubuntu 19.10"
	;;
    *Ubuntu\ 20.04\ *)
	# works on 5.4 kernel, not on 5.8.0-1033-azure
	#
	case "$kernel"
	in
	    5.8.0-*-azure)
		_notrun "bcc tcpretrans module will not compile on Ubuntu kernel $kernel"
		;;
	esac
	;;
esac

_simulate_network_troubles()
{
    echo Simulate packet loss
    $sudo tc qdisc add dev ${net_dev} root netem loss 100%
}

_revert_network_troubles()
{
    echo Revert intentional packet loss
    $sudo tc qdisc del dev ${net_dev} root 2>>$seq_full
}

_value_filter()
{
    awk '/inst .*::'${target_ip}':80"] value/ {print "OK"; exit}'
}

cat <<EOF >$tmp.conf
# Installed by PCP QA test $seq on `date`
[pmda]
modules = tcpretrans
prefix = bcc.
[tcpretrans]
module = tcpretrans
cluster = 9
EOF

_pmdabcc_try_compile $tmp.conf

_prepare_pmda bcc
trap "_revert_network_troubles; _pmdabcc_cleanup; exit \$status" 0 1 2 3 15
_stop_auto_restart pmcd

_pmdabcc_install <$tmp.conf
_pmdabcc_wait_for_metric

# Generate system activity for the BCC tcpretrans module
_simulate_network_troubles
curl -s --connect-timeout 5 http://${target_ip}
_revert_network_troubles

echo "=== report metric values for count ==="
pminfo -dfmtT bcc.io.net.tcp.retrans.count 2>&1 | tee -a $seq_full \
| _value_filter

_pmdabcc_remove

status=0
exit