#!/bin/sh # PCP QA Test No. 776 # Test using the pmfind app to find pmcd servers using the active probing # discovery mechanism # # Copyright (c) 2014 Red Hat. All Rights Reserved. # seq=`basename $0` echo "QA output created by $seq" # get standard environment, filters and checks . ./common.product . ./common.filter . ./common.check _get_libpcp_config $service_discovery || _notrun "No support for service discovery" signal=$PCP_BINADM_DIR/pmsignal $sudo $signal -a pmproxy pmwebd status=1 # failure is the default! $sudo rm -rf $tmp.* $seq.full trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15 _sought_filter() { # Only pmcd is guaranteed to be running, but other services may also be. # Transform two cases - no servers vs found servers - into deterministic # output for the --all invocations sed \ -e 's/No \(pmproxy servers\) discovered/Sought \1/g' \ -e 's/No \(pmwebd servers\) discovered/Sought \1/g' \ -e 's/Discovered \(pmproxy servers\):/Sought \1/g' \ -e 's/Discovered \(pmwebd servers\):/Sought \1/g' \ # end } _unresolved_filter() { sed -e '/ pcp:/d; / proxy:/d; / http:/d' \ | _sought_filter } _resolved_filter() { # Pass unresolved urls, filter the resolved ones. sed -e '/ pcp:\/\/[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/{p;b}; / proxy:\/\/[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/{p;b}; / http:\/\/[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/{p;b}; / pcp:/d; / proxy:/d; / http:/d' \ | _sought_filter } # real QA test starts here # Obtain the ipv6 address of an active network interface # We're extracting a metric of the form: # # inst [0 or "eth0"] value "fe80::3ea9:f4ff:fe76:6c24/64" # metric=`pminfo -f network.interface.ipv6_addr | \ tail -n +3 | \ grep -v ::1 | \ head -n1` [ -z metric ] && _notrun "no active ipv6 interfaces" # Extract the address addr=`echo $metric | \ awk '{ print $6 }' | \ sed -e 's/\"//g' -e 's|/.*$||'` # Extract the interface interface=`echo $metric | \ awk '{ print $4 }' | \ sed -e 's/\"//g' -e 's/\]//'` # combine the address and the interface form a complete address of the form # # fe80::3ea9:f4ff:fe76:6c24%eth0 # addr=$addr"%"$interface # Probe the obtained network. # Test various combinations of service queries and subnet sizes. Keep the # subnet size small -- say max 4 bits. echo "-m probe=$addr/128" >> $seq.full echo "-m probe=IPV6_ADDR/128" pmfind -m probe=$addr/128 | _unresolved_filter echo "Exit status: $?" | tee -a $seq.full echo "-s pmcd -m probe=$addr/127 -r" >> $seq.full echo "-s pmcd -m probe=IPV6_ADDR/127 -r" pmfind -s pmcd -m probe=$addr/126 -r | _resolved_filter echo "Exit status: $?" | tee -a $seq.full echo "-q -m probe=$addr/126" >> $seq.full echo "-q -m probe=IPV6_ADDR/126" pmfind -q -m probe=$addr/125 | _unresolved_filter echo "Exit status: $?" | tee -a $seq.full echo "-q -s pmcd -m probe=$addr/125 --resolve" >> $seq.full echo "-q -s pmcd -m probe=IPV6_ADDR/125 --resolve" pmfind -q -s pmcd -m probe=$addr/124 --resolve | _resolved_filter echo "Exit status: $?" | tee -a $seq.full echo "-q -s pmcd -m probe=$addr/124,maxThreads=8" >> $seq.full echo "-q -s pmcd -m probe=IPV6_ADDR/124,maxThreads=8" pmfind -q -s pmcd -m probe=$addr/124,maxThreads=8 | _unresolved_filter echo "Exit status: $?" | tee -a $seq.full # success, all done status=0 exit