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 125 126
|
#!/bin/sh
# PCP QA Test No. 042
# Exercise fixes for some containers issues.
#
# Copyright (c) 2015 Red Hat. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
. ./common.containers
_check_containers
_check_docker_binary
_check_docker_images busybox
_cleanup()
{
if [ -n "$container" ]
then
echo "== removing container" | tee -a $seq_full
_remove_docker_containers $container
container=""
fi
rm -rf $tmp.*
}
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_filter_pminfo()
{
# filter ip_vti tunnel type connections that may exist on (some) machines
tee -a $seq_full >$tmp.tmp
sed <$tmp.tmp \
-e '/ip_vti/d' \
-e '2q' \
# end
sed <$tmp.tmp \
-e '1,2d' \
-e 's/\[[0-9][0-9]* or ".*"\]/[INST or NAME]/' \
-e 's/value [-?0-9.e+][-?0-9.e+]*/value NUMBER/' \
-e 's/value ".*"$/value STRING/' \
| LC_COLLATE=POSIX sort \
| uniq
}
# real QA test starts here
container=`$docker run -d busybox sleep 15`
echo "== container: $container" >> $seq_full
echo "== kernel PMDA (LINUX_NAMESPACE_NET for network interfaces)" | tee -a $seq_full
# expect 2 interfaces (lo/eth0)
metrics="network.interface.in.bytes"
for m in $metrics
do
pminfo --fetch --container=$container $m | _filter_pminfo
done
echo
if false
then
# this part does not work as of Feb 2025
# someone may wish to revisit it at some point in the future
#
echo "== procfs PMDA" | tee -a $seq_full
# expect values for a single process (sleep) and one cgroup
metrics="proc.memory.rss cgroup.memory.stat.pgfault"
for m in $metrics
do
pminfo --fetch --container=$container $m | _filter_pminfo
done
echo
fi
echo "== pmcd PMDA (LINUX_NAMESPACE_UTS for uname)" | tee -a $seq_full
# expect a different hostname to local hostname
pmprobe --values --container=$container pmcd.hostname > $tmp.chost
pmprobe --values pmcd.hostname > $tmp.host
container_hostname=`awk '{ print $3 }' $tmp.chost`
localhost_hostname=`awk '{ print $3 }' $tmp.host`
cat $tmp.chost $tmp.host >> $seq_full
echo container hostname: $container_hostname >> $seq_full
echo localhost hostname: $localhost_hostname >> $seq_full
if [ "$container_hostname" != "$localhost_hostname" ]
then
echo
echo "OK: host and container names are different"
echo
else
echo "FAIL: hostnames match when they should not"
echo "localhost: $localhost_hostname"
echo "container: $container_hostname"
status=1
exit
fi
echo "== kernel PMDA (LINUX_NAMESPACE_MNT for filesystem mounts)" | tee -a $seq_full
# expect a different mount device for "/"
pminfo --fetch --container=$container filesys.mountdir > $tmp.chost
pminfo --fetch filesys.mountdir > $tmp.host
container_rootdev=`awk '$NF == "\"/\"" { print $4 }' $tmp.chost`
localhost_rootdev=`awk '$NF == "\"/\"" { print $4 }' $tmp.host`
cat $tmp.chost $tmp.host >> $seq_full
echo container root dev: $container_rootdev >> $seq_full
echo localhost root dev: $localhost_rootdev >> $seq_full
if [ "$container_rootdev" != "$localhost_rootdev" ]
then
echo
echo "OK: host and container mount device for / are different"
echo
else
echo "FAIL: mount device for / match when they should not"
echo "localhost: $localhost_rootdev"
echo "container: $container_rootdev"
status=1
exit
fi
# success, all done
status=0
exit
|