qa: update 660 to generate index.html, fixing pcp-testsuite runs
[pcp.git] / qa / 527
blobf89bcfa903c24c21f1c290e9c19819ab07413862
1 #!/bin/sh
2 # PCP QA Test No. 527
3 # Check that timestamps are monotonic increasing for archives
4 # created by libpcp_import. Based on
5 # https://bugzilla.redhat.com/show_bug.cgi?id=958745
7 # Copyright (c) 2013 Red Hat, Inc. and Ken McDonell. All Rights Reserved.
10 seq=`basename $0`
11 echo "QA output created by $seq"
13 # get standard environment, filters and checks
14 . ./common.product
15 . ./common.filter
16 . ./common.check
18 [ $PCP_VER -ge 30801 ] || _notrun libpcp_import fix is in PCP 3.8.1
19 [ -f ${PCP_LIB_DIR}/libpcp_import.${DSO_SUFFIX} ] || \
20 _notrun "No support for libpcp_import"
21 perl -e "use PCP::LogImport" 2>/dev/null || \
22 _notrun "Perl PCP::LogImport module is not installed"
25 _filter()
27 sed \
28 -e "s;$tmp;TMP;g"
31 status=1 # failure is the default!
32 $sudo rm -rf $tmp.* $seq.full
33 trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
35 # first data file
37 cat <<'End-of-File' >$tmp.gfs_inodes.csv
38 Date,Time,Device,inodes
39 2013-04-18,13:40,/dev/dm-12,102808
40 2013-04-18,13:45,/dev/dm-12,102798
41 2013-04-18,13:50,/dev/dm-12,102799
42 2013-04-18,13:55,/dev/dm-12,102808
43 2013-04-18,14:00,/dev/dm-12,102804
44 2013-04-18,14:05,/dev/dm-12,103182
45 2013-04-18,14:10,/dev/dm-12,102864
46 2013-04-18,14:15,/dev/dm-12,102810
47 2013-04-18,14:20,/dev/dm-12,102805
48 End-of-File
50 # second data file
52 cat <<'End-of-File' >$tmp.gfs_metadata.csv
53 Date,Time,Device,fmb
54 2013-04-18,13:40,/dev/dm-12,3712689
55 2013-04-18,13:45,/dev/dm-12,3712699
56 2013-04-18,13:50,/dev/dm-12,3712698
57 2013-04-18,13:55,/dev/dm-12,3712689
58 2013-04-18,14:00,/dev/dm-12,3712693
59 2013-04-18,14:05,/dev/dm-12,3712273
60 2013-04-18,14:10,/dev/dm-12,3712349
61 2013-04-18,14:15,/dev/dm-12,3711980
62 2013-04-18,14:20,/dev/dm-12,3711842
63 End-of-File
65 # Perl script
67 cat <<'End-of-File' >$tmp.pl
68 #!/usr/bin/perl
70 use strict;
71 use warnings;
72 use Date::Parse;
73 use Date::Format;
74 use PCP::LogImport;
76 End-of-File
77 echo "pmiStart(\"$tmp.gfs\", 0);" >>$tmp.pl
78 cat <<'End-of-File' >>$tmp.pl
79 $_ = pmiSetTimezone('UTC');
80 $_ == 0 || die "pmiSetTimezone(UTC): " . pmiErrStr($_);
82 $_ = pmiAddMetric("gfs.inodes",
83 PM_ID_NULL, PM_TYPE_DOUBLE, PM_INDOM_NULL,
84 PM_SEM_INSTANT, pmiUnits(0,0,1,0,0,PM_COUNT_ONE));
85 $_ == 0 || die "pmiAddMetric(gfs.inodes): " . pmiErrStr($_);
88 End-of-File
89 echo "open(INFILE, \"<$tmp.gfs_inodes.csv\");" >>$tmp.pl
90 cat <<'End-of-File' >>$tmp.pl
91 while (<INFILE>) {
92 next if $. == 1;
93 chomp;
94 my @part = split(/,/, $_);
96 $_ = pmiPutValue("gfs.inodes", "", $part[3]);
97 $_ == 0 || die "pmiPutValue(gfs.inodes): " . pmiErrStr($_);
99 $_ = pmiWrite(str2time($part[0] . "T" . $part[1] . ":00", 'UTC'), 0);
100 $_ == 0 || die "pmiWrite(gfs.fmb): " . pmiErrStr($_);
102 close(INFILE);
105 $_ = pmiAddMetric("gfs.fmb",
106 PM_ID_NULL, PM_TYPE_DOUBLE, PM_INDOM_NULL,
107 PM_SEM_INSTANT, pmiUnits(0,0,1,0,0,PM_COUNT_ONE));
108 $_ == 0 || die "pmiAddMetric(gfs.fmb): " . pmiErrStr($_);
110 End-of-File
111 echo "open(INFILE, \"<$tmp.gfs_metadata.csv\");" >>$tmp.pl
112 cat <<'End-of-File' >>$tmp.pl
113 while (<INFILE>) {
114 next if $. == 1;
115 chomp;
116 my @part = split(/,/, $_);
118 $_ = pmiPutValue("gfs.fmb", "", $part[3]);
119 $_ == 0 || die "pmiPutValue(gfs.fmb): " . pmiErrStr($_);
121 $_ = pmiWrite(str2time($part[0] . "T" . $part[1] . ":00", 'UTC'), 0);
122 $_ == 0 || die "pmiWrite(gfs.fmb): " . pmiErrStr($_);
124 close(INFILE);
127 pmiEnd();
128 End-of-File
130 # real QA test starts here
131 perl $tmp.pl 2>&1 | _filter
133 for part in 0 meta index
135 [ -f $tmp.$part ] && echo "oops, .$part file created"
136 done
138 # success, all done
139 status=0
141 exit