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
|
#!/bin/sh
# PCP QA Test No. 1358
# Exercise the podman PMDA.
#
# Copyright (c) 2018,2021 Red Hat.
#
seq=`basename $0`
echo "QA output created by $seq"
. ./common.containers
[ -f $PCP_PMDAS_DIR/podman/pmdapodman ] || _notrun "podman pmda not installed"
[ "$PCPQA_SYSTEMD" = yes ] || _notrun "systemctl not installed or not active"
_check_containers
_check_podman_binary
_check_podman_images busybox
iam=podman
status=1 # failure is the default!
pmdapodman_install()
{
# start from known starting points
cd $PCP_PMDAS_DIR/podman
$sudo ./Remove >/dev/null 2>&1
echo
echo "=== podman agent installation ==="
$sudo ./Install </dev/null >$tmp.out 2>&1
cat $tmp.out >>$seq_full
# Check podman metrics have appeared ... X metrics and Y values
_filter_pmda_install <$tmp.out \
| sed \
-e 's/[0-9][0-9]* warnings, //' \
| $PCP_AWK_PROG '
/Check podman metrics have appeared/ { if ($7 >= 20) $7 = "X"
if ($10 >= 0) $10 = "Y"
}
{ print }'
}
# Note:
# a couple of the metrics have floating point values, but
# if the fraction part is zero, they look like integer
# values ... the awk at the end fixes this
#
_filter()
{
grep -E "^podman|$container1|$container2" | \
sed \
-e "s/$container1/CONTAINER/g" \
-e "s/$container2/CONTAINER/g" \
-e 's/ value [0-9]\+\.\?[0-9]*[eE][+-][0-9]\+/ value FLOAT/g' \
-e 's/ value [0-9]\+\.[0-9]\+/ value FLOAT/g' \
-e 's/ value [0-9]\+/ value INTEGER/g' \
-e 's/ value ".*"/ value STRING/g' \
-e 's/inst \[[[0-9]\+ or/ inst [NNN or/g' \
| $PCP_AWK_PROG '
$1 == "podman.container.stats.cpu" || $1 == "podman.container.stats.mem_perc" {
print
xpect_float = 1
next
}
$1 ~ /^podman\./ { xpect_float = 0 }
xpect_float == 1 { sub(/INTEGER/, "FLOAT") }
{ print }'
}
_cleanup()
{
if [ -n "$container1" -o -n "$container2" ]
then
echo "== removing containers" | tee -a $seq_full
_remove_podman_containers $container1 $container2
container2=""
container1=""
fi
if [ -n "$pod1" -o -n "$pod2" ]
then
echo "== removing pods" | tee -a $seq_full
_remove_podman_pods $pod1 $pod2
pod2=""
pod1=""
fi
_restore_pmda_install $iam
$sudo rm -f $tmp.*
}
_prepare_pmda podman
trap "_cleanup; exit \$status" 0 1 2 3 15
# real QA test starts here
$sudo systemctl restart podman.service
pmdapodman_install
# create some new podman containers
container1=`$podman run -d busybox sleep 10`
echo "== container1: $container1" >> $seq_full
container2=`$podman run -d busybox sleep 10`
echo "== container2: $container2" >> $seq_full
[ -z "$container1" -o -z "$container2" ] && _fail "Failed to create containers"
# RHBZ #1958732
# create some new podman pods
#pod1=`$podman pod create`
#echo "== pod1: $pod1" >> $seq_full
#pod2=`$podman pod create`
#echo "== pod2: $pod2" >> $seq_full
#[ -z "$pod1" -o -z "$pod2" ] && _fail "Failed to create PODs"
# fetch new state, check for new containers and pods
echo "=== podman metric verification ==="
pminfo --fetch podman.container | tee -a $seq_full | _filter
echo
echo "=== remove $iam agent ==="
$sudo ./Remove >$tmp.out 2>&1
_filter_pmda_remove <$tmp.out
# success, all done
status=0
exit
|