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
|
#!/bin/sh
# PCP QA Test No. 794
# Copyright (c) 2015 Red Hat. All Rights Reserved.
#
# Exercise "container switching" using pmStore.
#
seq=`basename $0`
echo "QA output created by $seq"
. ./common.containers
_check_containers
_check_docker_binary
_check_docker_images busybox
count=`_count_docker_containers`
[ "$count" -gt 0 ] && \
_notrun "Needs quiesced docker setup ($count running containers found)"
_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()
{
tee -a $seq_full \
| sed \
-e "s/\[.*\]: /[INST]: /g" \
-e "s/$container/CONTAINER/g" \
-e "s/$container_hostname/CONTAINER_HOSTNAME/g" \
-e "s/$localhost_hostname/LOCALHOST_HOSTNAME/g" \
-e "/pmcd.client.whoami/d" \
#end
}
_exclude_clients()
{
# remove any long-running clients (pmlogger/pmie) or
# anonymous clients (whoami == "")
#
pminfo -f pmcd.client.whoami | \
grep -E 'pmlogger|pmie|""' | \
sed -e 's/ *inst \[\([0-9][0-9]*\) or .*/-x \1 /g'
}
# real QA test starts here
xargs=`_exclude_clients`
echo "Exclusions: $xargs" >> $seq_full
container=`$docker run -d busybox sleep 15`
echo "== container: $container" >> $seq_full
echo "== get host and container hostname " | 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
eval container_hostname=`awk '{ print $3 }' $tmp.chost`
eval 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
# switch to container, then back, reporting pmcd.hostname
echo "== switch to container, reset, repeat" | tee -a $seq_full
$here/src/storepmcd $xargs "$container" "" "$container" "" | _filter
# success, all done
status=0
exit
|