diff options
-rw-r--r-- | config.sh.template | 8 | ||||
-rwxr-xr-x | controller | 60 | ||||
-rwxr-xr-x | runner/result_stats | 74 | ||||
-rw-r--r-- | runner/result_templates/html.tmpl | 40 |
4 files changed, 182 insertions, 0 deletions
diff --git a/config.sh.template b/config.sh.template new file mode 100644 index 0000000..5eae1c9 --- /dev/null +++ b/config.sh.template @@ -0,0 +1,8 @@ +# Where we keep all the results +export DTF_DATABASE=/var/lib/dtf_results + +# SSH user/host where the generated statistics & results will be uploaded +export DTF_PRESENTER_SSHID=userdi@fedorapeople.org + +# Directory on remote host where the we upload the results +export DTF_PRESENTER_RESULTDIR=/home/fedora/praiskup/public_html/proj/postgresql-setup/tests/dtf diff --git a/controller b/controller new file mode 100755 index 0000000..938bab5 --- /dev/null +++ b/controller @@ -0,0 +1,60 @@ +#!/bin/bash + +. config.sh || { echo >&2 "sorry, but config.sh not found" ; exit 1 ; } + +# (still) local variables +distro=fedora +distro_ver=20 +arch=x86_64 +starttime=$(date -u +%Y%m%d_%H%M%S_%N) + +die() { echo "$@"; exit 1; } + +prereq_resultdir() +{ + test -d "$DTF_DATABASE" || mkdir -p "$DTF_DATABASE" +} + +unpack_results() +{ + local where="$1" + local workdir=$(mktemp -d "/tmp/.dtf.XXXXXX") || die "can not create workdir" + + pushd "$workdir" + tar -xf /var/tmp/dtf.tar.gz + + pushd dtf + for i in *.log; do + pwd + local task_id="${i%%.log}" + local mydir="" + while read dirname; do + test -z "$mydir" && mydir="$dirname" + done <<<"$(tar xvf "$task_id.tar.gz")" + + rm "$task_id.tar.gz" + + mv "$mydir" "$task_id.dir" + done + + + popd + popd + + mkdir -p "$(dirname "$where")" || die "can not create resultdir" + mv "$workdir/dtf" "$where" +} + +prereq_resultdir + +workdir=$(mktemp -d "/var/tmp/dtf_postgresql_setup-XXXXXX") + +./run_remote \ + --distro="$distro" \ + --distro-version="$distro_ver" \ + --workdir="$workdir" + +resultdir="$DTF_DATABASE/$distro/$distro_ver/$arch" +unpack_results "$resultdir/result_$starttime" + +./runner/result_stats "$resultdir" diff --git a/runner/result_stats b/runner/result_stats new file mode 100755 index 0000000..a92d6d6 --- /dev/null +++ b/runner/result_stats @@ -0,0 +1,74 @@ +#!/bin/perl + +use strict; +use warnings; +use utf8; + +use Data::Dumper; +use File::Basename; +use Cwd; +use Encode 'encode_utf8'; + +# teplates +use Text::Xslate; + +# yaml (quick) parser +use YAML::Syck; + +our $srcdir = dirname(__FILE__); + +sub html_printer +{ + my $results = $_[0]; + my $task_ids = $_[1]; + + my $xslate = Text::Xslate->new(path => ["$srcdir/result_templates"]); + + my $content = $xslate->render("html.tmpl", { + results => $results, + task_ids => $task_ids, + }); + print encode_utf8($content); +} + +my $workdir = $ARGV[0]; + +my $data = []; + +my $task_ids = {}; + +# go through *each* result directory +my $olddir = getcwd; +for (`find "$workdir" -maxdepth 1 -type d -name 'result_*'`) { + chomp; + chdir $_; + + my $run_results = {}; + $run_results->{dirname} = basename($_); + $run_results->{tasks} = {}; + $run_results->{exit_status} = 0; + + # go through each task + for (`find -maxdepth 1 -type f -name '*.result'`) { + chomp; + + (my $task_id = $_) =~ s/\.result$//; + $task_id =~ s/.*\///; + $task_ids->{$task_id} = 1; + + my $yaml_file = $_; + open my $fd, '<', $yaml_file + or die "can't open yaml file '$yaml_file'"; + + my $config = YAML::Syck::LoadFile($fd); + if ($config->{exit_status} != 0) { + $run_results->{exit_status} = 1; + } + $run_results->{tasks}->{$task_id} = $config; + } + + push @{$data}, $run_results; +} +chdir $olddir; + +html_printer $data, $task_ids; diff --git a/runner/result_templates/html.tmpl b/runner/result_templates/html.tmpl new file mode 100644 index 0000000..14696c2 --- /dev/null +++ b/runner/result_templates/html.tmpl @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset="UTF-8" /> +<meta name="keywords" content="" /> +<title>Results</title> +<link href="https://praiskup.fedorapeople.org/staticdata/patternfly-1.1/css/patternfly.css" rel="stylesheet" media="screen, print"> +</head> +<body> +<div class="table-responsive"> +<table class="table table-condensed table-hover"> +<thead> + <tr> + <th>Run time</th> +: for $task_ids.keys() -> $task_id { + <th><: $task_id :></th> +: } + </tr> +</thead><tbody> +: for $results -> $result { + : if ($result.exit_status) { + <tr class="danger"> + : } else { + <tr> + : } + <td><: $result.dirname :></td> + : for $task_ids.keys() -> $task_id { + : if $result.tasks[$task_id].exit_status == 0 { + <td>OK</td> + : } else { + <td class="danger">FAIL</td> + : } + : } + <tr> +:} +</tbody> +</table> +</div> +</body> +</html> |