diff options
author | Pavel Raiskup <praiskup@redhat.com> | 2014-10-22 08:54:05 +0200 |
---|---|---|
committer | Pavel Raiskup <praiskup@redhat.com> | 2014-10-22 08:54:05 +0200 |
commit | 2422a081a5be0d5ac5afb122361bc283da67341f (patch) | |
tree | cb255582060af6547dd9318c56ba0e8c761846a1 /controller/result_stats | |
parent | 922089746e1029de9be986672fcdeb6bc82e18d7 (diff) | |
download | postgresql-setup-tests-2422a081a5be0d5ac5afb122361bc283da67341f.tar.gz postgresql-setup-tests-2422a081a5be0d5ac5afb122361bc283da67341f.tar.xz postgresql-setup-tests-2422a081a5be0d5ac5afb122361bc283da67341f.zip |
big reorg: prepare for generalization
Try to split into three separate components -> controller, tester,
and 'tasks' (postgresql-tasks in our case). The controller
component is the main part which is able to run the task remotely.
Tester is more-like library for 'tasks' component (should be
reusable on the raw git level).
* controller: Almost separated component.
* postgresql-tasks: Likewise.
* tester: Likewise.
Diffstat (limited to 'controller/result_stats')
-rwxr-xr-x | controller/result_stats | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/controller/result_stats b/controller/result_stats new file mode 100755 index 0000000..a92d6d6 --- /dev/null +++ b/controller/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; |