From fbe706dccdd35bfdfd163b7107ea90f801830321 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Fri, 24 Oct 2014 10:02:41 +0200 Subject: controller: autoconfiscate #2 Move 'results_stats' and 'commit_results' binaries into libexec and adjust appropriately. Also html template is now in $pkgdatadir. * .gitignore: Add tags/ChangeLog generated files. * README: Just some random notes. Needs to be rewritten anyway. * controller/.gitignore: Add newly 'make'd files. * controller/Makefile.am: Generate libexec/bin files. * controller/commit_results: Move to controller/libexec as dtf-result-stats.in. * controller/configure.ac: Also substitute resulttemplatedir. * controller/etc/dtf.conf.d/config.sh.template: The DTF_DATABASE was misleading - use rather DTF_DATABASE_DEFAULT. * controller/libexec/dtf-commit-results.in: Moved from controller/commit_results. * controller/result_stats: Moved to controller/libexec/dtf-result-stats.in. * controller/libexec/dtf-result-stats.in: Moved from controller/result_stats. * controller/result_templates/html.tmpl: Moved to controller/share/dtf-controller/results-stats-templates/html.tmpl. --- .gitignore | 2 + README | 2 + controller/.gitignore | 2 + controller/Makefile.am | 17 ++++- controller/commit_results | 24 ------- controller/configure.ac | 1 + controller/etc/dtf.conf.d/config.sh.template | 2 +- controller/libexec/dtf-commit-results.in | 19 ++++++ controller/libexec/dtf-result-stats.in | 79 ++++++++++++++++++++++ controller/result_stats | 74 -------------------- controller/result_templates/html.tmpl | 42 ------------ .../results-stats-templates/html.tmpl | 42 ++++++++++++ 12 files changed, 163 insertions(+), 143 deletions(-) delete mode 100755 controller/commit_results create mode 100644 controller/libexec/dtf-commit-results.in create mode 100644 controller/libexec/dtf-result-stats.in delete mode 100755 controller/result_stats delete mode 100644 controller/result_templates/html.tmpl create mode 100644 controller/share/dtf-controller/results-stats-templates/html.tmpl diff --git a/.gitignore b/.gitignore index 74fe3dd..527b1a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.tar.gz +ChangeLog ostack.yml private +tags diff --git a/README b/README index 803aa71..de16e14 100644 --- a/README +++ b/README @@ -6,6 +6,8 @@ destructive and always performed under root account; test writer should only make sure that no test conflicts with others (so that all tests are able to run on one machine successfully in any order). +TODO: bash-only, unix.. + OVERVIEW ======== diff --git a/controller/.gitignore b/controller/.gitignore index 0ce42e7..ccbdbd2 100644 --- a/controller/.gitignore +++ b/controller/.gitignore @@ -2,7 +2,9 @@ build-aux config.* dtf.sh +dtf-commit-results dtf-get-machine +dtf-result-stats dtf-run-remote generated-vars.yml Makefile diff --git a/controller/Makefile.am b/controller/Makefile.am index 4df5e25..9fecd61 100644 --- a/controller/Makefile.am +++ b/controller/Makefile.am @@ -4,7 +4,9 @@ sysconf_DATA = etc/dtf.sh pkgdata_DATA = ./share/dtf-controller/parse_credsfile -libexec_SCRIPTS = libexec/dtf-wait-for-ssh +libexec_SCRIPTS = libexec/dtf-wait-for-ssh \ + libexec/dtf-commit-results \ + libexec/dtf-result-stats ansiblevarsdir = $(pkgdatadir)/ansible/vars ansibleplaybooksdir = $(pkgdatadir)/ansible/playbooks @@ -14,6 +16,9 @@ ansiblevars_DATA = share/dtf-controller/ansible/vars/generated-vars.yml dtfplaybookdir = $(pkgdatadir)/ansible/playbooks ansibleplaybooks_DATA = share/dtf-controller/ansible/playbooks/fedora.yml +resulttemplatedir = $(pkgdatadir)/results-stats-templates +resulttemplate_DATA = share/dtf-controller/results-stats-templates/html.tmpl + share/dtf-controller/ansible/vars/generated-vars.yml: \ share/dtf-controller/ansible/vars/generated-vars.yml.in .dep $(INSTANTIATE) @@ -21,6 +26,12 @@ share/dtf-controller/ansible/vars/generated-vars.yml: \ .dep: $(c_s) touch .dep +libexec/dtf-commit-results: libexec/dtf-commit-results.in .dep + $(INSTANTIATE_SCRIPT) + +libexec/dtf-result-stats: libexec/dtf-result-stats.in .dep + $(INSTANTIATE_SCRIPT) + bin/dtf-run-remote: bin/dtf-run-remote.in .dep $(INSTANTIATE_SCRIPT) @@ -32,6 +43,8 @@ etc/dtf.sh: etc/dtf.sh.in .dep GENERATED_FILES = $(bin_SCRIPTS) \ $(sysconf_DATA) \ - share/dtf-controller/ansible/vars/generated-vars.yml + share/dtf-controller/ansible/vars/generated-vars.yml \ + libexec/dtf-commit-results \ + libexec/dtf-result-stats CLEANFILES = $(GENERATED_FILES) diff --git a/controller/commit_results b/controller/commit_results deleted file mode 100755 index f18a361..0000000 --- a/controller/commit_results +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -srcdir=$(cd -P -- "$(dirname -- "$0")" && pwd -P) || exit 1 -. "$srcdir/config/config.sh" || { - echo >&2 "sorry, but $srcdir/config/config.sh not found" - exit 1 -} - -# argparse -resultdir="$1" -ressubdir="$2" -test -n "$ressubdir" || { "no path specified" ; exit 1 ; } -test -n "$3" && DTF_DATABASE="$2" - -# checks -test -z "$DTF_DATABASE" && exit 1 -test -f "$resultdir/dtf.tar.gz" || exit 1 - -# run -if test ! -d "$DTF_DATABASE/$ressubdir"; then - mkdir -p "$DTF_DATABASE/$ressubdir" -fi - -( cd "$resultdir" && tar -xf dtf.tar.gz && cp -r dtf "$DTF_DATABASE/$ressubdir" ) diff --git a/controller/configure.ac b/controller/configure.ac index 819680a..0c85544 100644 --- a/controller/configure.ac +++ b/controller/configure.ac @@ -18,6 +18,7 @@ sed_subst_var_pattern(libexecdir) sed_subst_var_pattern(pkgdatadir) sed_subst_var_pattern(pkgname) sed_subst_var_pattern(prefix) +sed_subst_var_pattern(resulttemplatedir) sed_subst_var_pattern(sysconfdir) sed_subst_var_pattern(top_srcdir) -e 's|@__FILE__[[@]]|\$@|g'" diff --git a/controller/etc/dtf.conf.d/config.sh.template b/controller/etc/dtf.conf.d/config.sh.template index 11aa40b..aae9f08 100644 --- a/controller/etc/dtf.conf.d/config.sh.template +++ b/controller/etc/dtf.conf.d/config.sh.template @@ -24,7 +24,7 @@ export DTF_OPENSTACK_DEFAULT_ID=dropbear # Directory where the testsuite should keep its (persistent) results. Make sure # that this directory is backed up. -export DTF_DATABASE=/var/lib/dtf_results +export DTF_DATABASE_DEFAULT=/var/lib/dtf_results # Presenter place # --------------- diff --git a/controller/libexec/dtf-commit-results.in b/controller/libexec/dtf-commit-results.in new file mode 100644 index 0000000..86b31d7 --- /dev/null +++ b/controller/libexec/dtf-commit-results.in @@ -0,0 +1,19 @@ +#!/bin/bash + +. "@sysconfdir@/dtf.sh" || exit 1 + +# argparse +resultdir="$1" + +db="$DTF_DATABASE_DEFAULT" +test -n "$2" && db="$2" + +if test -z "$db" \ + || test -z "$resultdir" \ + || test ! -f "$resultdir/dtf.tar.gz" +then + echo >&2 "something is wrong, try bash -x" + exit 1 +fi + +( cd "$resultdir" && tar -xf dtf.tar.gz && cp -r dtf "$db/$ressubdir" ) diff --git a/controller/libexec/dtf-result-stats.in b/controller/libexec/dtf-result-stats.in new file mode 100644 index 0000000..d4db46f --- /dev/null +++ b/controller/libexec/dtf-result-stats.in @@ -0,0 +1,79 @@ +#!/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 => ['@resulttemplatedir@']); + + my $content = $xslate->render("html.tmpl", { + results => $results, + task_ids => $task_ids, + }); + print encode_utf8($content); +} + +if (! defined $ARGV[0] || ! -d $ARGV[0]) { + print STDERR "Please specify correct working directory\n"; + exit (1); +} + +my $workdir = $ARGV[0]; + +my $data = []; + +my $task_ids = {}; + +# go through *each* result directory +my $olddir = getcwd; +for (`find "$workdir" -maxdepth 1 -type d`) { + 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/controller/result_stats b/controller/result_stats deleted file mode 100755 index a92d6d6..0000000 --- a/controller/result_stats +++ /dev/null @@ -1,74 +0,0 @@ -#!/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/controller/result_templates/html.tmpl b/controller/result_templates/html.tmpl deleted file mode 100644 index 8a09ad7..0000000 --- a/controller/result_templates/html.tmpl +++ /dev/null @@ -1,42 +0,0 @@ - - - - - -Results - - - -
- - - - -: for $task_ids.keys() -> $task_id { - -: } - - -: for $results -> $result { - : if ($result.exit_status) { - - : } else { - - : } - - : for $task_ids.keys() -> $task_id { - : if (not defined($result.tasks[$task_id].exit_status)) { - - : } elsif ($result.tasks[$task_id].exit_status == 0) { - - : } else { - - : } - : } - -:} - -
Run time<: $task_id :>
<: $result.dirname :>NOT AVAILABLEOKFAIL
-
- - diff --git a/controller/share/dtf-controller/results-stats-templates/html.tmpl b/controller/share/dtf-controller/results-stats-templates/html.tmpl new file mode 100644 index 0000000..8a09ad7 --- /dev/null +++ b/controller/share/dtf-controller/results-stats-templates/html.tmpl @@ -0,0 +1,42 @@ + + + + + +Results + + + +
+ + + + +: for $task_ids.keys() -> $task_id { + +: } + + +: for $results -> $result { + : if ($result.exit_status) { + + : } else { + + : } + + : for $task_ids.keys() -> $task_id { + : if (not defined($result.tasks[$task_id].exit_status)) { + + : } elsif ($result.tasks[$task_id].exit_status == 0) { + + : } else { + + : } + : } + +:} + +
Run time<: $task_id :>
<: $result.dirname :>NOT AVAILABLEOKFAIL
+
+ + -- cgit