Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 047
blobeb8b8ae978527d3d2e710d64d5654ab2effa0bbe
1 #!/bin/sh
2 # PCP QA Test No. 047
3 # Exercise fix for a containers networking issue.
5 # Copyright (c) 2015 Red Hat. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 . ./common.docker
13 _check_containers
14 _check_docker_images busybox
16 _cleanup()
18 if [ -n "$container" ]
19 then
20 echo "== removing container" | tee -a $seq.full
21 _remove_docker_containers $container
22 container=""
24 rm -rf $tmp.*
27 status=1 # failure is the default!
28 $sudo rm -rf $tmp.* $seq.full
29 trap "_cleanup; exit \$status" 0 1 2 3 15
31 _pminfo_value()
33 inst="$1"
35 fgrep " or \"$inst\"" | \
36 sed \
37 -e "s/^ *inst .* or \"$inst\". value //g" \
38 #end
41 _compare_value()
43 label=$1
44 if_value=$2
45 pcp_value=$3
47 echo "$label - ifconfig=\"$if_value\" pcp=\"$pcp_value\"" >>$seq.full
49 if [ "$pcp_value" = "$if_value" ]
50 then
51 echo "$label matches"
52 else
53 echo "$label mismatch - ifconfig=\"$if_value\" pcp=\"$pcp_value\""
54 status=1
58 # real QA test starts here
59 container=`$docker run -d busybox sleep 15`
60 echo "== container: $container" >> $seq.full
62 echo "== extract values from pmdalinux"
63 metrics="network.interface.hw_addr network.interface.inet_addr"
64 pminfo --fetch --container=$container network.interface.hw_addr >$tmp.pcp_hw
65 pminfo --fetch --container=$container network.interface.inet_addr >$tmp.pcp_inet
67 eval pcp_hw_addr=`cat $tmp.pcp_hw | _pminfo_value eth0`
68 eval pcp_inet_addr=`cat $tmp.pcp_inet | _pminfo_value eth0`
69 echo "== pcp values:" >> $seq.full
70 cat $tmp.pcp_hw $tmp.pcp_inet >> $seq.full
71 echo "hw_addr:" >> $seq.full
72 echo "inet_addr:" >> $seq.full
74 echo "== extract values from docker" | tee -a $seq.full
75 $docker exec $container ifconfig eth0 | tee -a $seq.full >$tmp.ifconfig
77 eval if_inet_addr=`cat $tmp.ifconfig | grep 'inet addr' \
78 | sed -e 's/.*inet addr://g' -e 's/ .*//g'`
79 eval if_hw_addr=`cat $tmp.ifconfig | grep 'HWaddr' \
80 | sed -e 's/.*HWaddr //g' -e 's/ .*//g' -e 's/.*/\L&/'`
82 echo "== comparing values" | tee -a $seq.full
83 _compare_value hw_addr $if_hw_addr $pcp_hw_addr
84 _compare_value inet_addr $if_inet_addr $pcp_inet_addr
86 # success, all done
87 status=0
88 exit