From c7560d4a0825819b78ca1766ee58a6fbd7558820 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Tue, 11 Sep 2018 15:56:37 -0400 Subject: [PATCH] multi-host support for live tester --- installer/wheezy/installer_installer2.sh | 3 + qa/id_rsa.pub | 1 + qa/test_runner.pl | 94 ++++++++++++++++++++++++ qa/test_runner.xml | 17 +++++ 4 files changed, 115 insertions(+) create mode 100755 installer/wheezy/installer_installer2.sh create mode 100644 qa/id_rsa.pub create mode 100755 qa/test_runner.pl create mode 100644 qa/test_runner.xml diff --git a/installer/wheezy/installer_installer2.sh b/installer/wheezy/installer_installer2.sh new file mode 100755 index 000000000..9e34cc638 --- /dev/null +++ b/installer/wheezy/installer_installer2.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cd $* +time sudo ./eg_wheezy_installer.sh -y -a -s -t diff --git a/qa/id_rsa.pub b/qa/id_rsa.pub new file mode 100644 index 000000000..49024b354 --- /dev/null +++ b/qa/id_rsa.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1Kezam0dTgn1bQ2tWadZI+IRGDIgxudYGLbtMwyO5xiDKexIvg5YBWSkF86+LKGsstJcoyPbd9qRY8QUjWgerV+/HOZf0UgBUiugpzye+BiI11mDNGjMvkgie6gXppybyvUgSdqnSefeOwMj9V9ZaFzVA8k+WcjxmJZr1hHgDpMBIFaEGQoV7d4zz8XUOaAB6Fr8avNqw+R4dRT78t2/1KXOmTdNGJlTwvZ2mVRJ8jV3mju9I5GXzYBe7jyv+yY/XNkA7tS9THBgDbl2jA2IKvkvBZGdrfwB00+FL0PcwToxI4W/0x1XvfA2JunHQOgJ60LsEBI1awPL73Ub7j/Rl live@testing.esilibrary.com diff --git a/qa/test_runner.pl b/qa/test_runner.pl new file mode 100755 index 000000000..4fc672529 --- /dev/null +++ b/qa/test_runner.pl @@ -0,0 +1,94 @@ +#!/usr/bin/perl +use strict; +use XML::LibXML; +use FindBin qw($Bin); + +my $parser = XML::LibXML->new(); +my $dom = $parser->parse_file($ARGV[1] || "$Bin/test_runner.xml"); +chomp (my $whoami = `whoami`); + +# XML file looks like this: +# +# +# ~/public_html/ +# /home/phasefx/git/random/ +# +# +# +# qa01 +# qa01 +# phasefx +# 192.168.1.79 +# +# installer/wheezy/ +# +# /home/phasefx/eg_installer/wheezy/installer_installer2.sh /home/phasefx/eg_installer/wheezy/ +# +# +# + +my $localconf = $dom->findnodes('//local')->[0]; +my $installer_path = $localconf->findvalue('./installer_path'); + +foreach my $host ($dom->findnodes('//host')) { + + my $pid; + next if $pid = fork; # Parent goes to next server. + die "fork failed: $!" unless defined $pid; + + # inside the child process + + my $name = $host->findvalue('./name'); + my $description = $host->findvalue('./description'); + my $target_ssh_user = $host->findvalue('./target_ssh_user') || $whoami; + my $target_ssh_host = $host->findvalue('./target_ssh_host'); + my $target_ssh_path = $host->findvalue('./target_ssh_path') || "/home/$whoami/eg_installer"; + my $installer_scripts = $host->findvalue('./installer_scripts'); + my $installer_invocation = $host->findvalue('./installer_invocation'); + my $output_path = $host->findvalue('./output_path') || "/home/$whoami/public_html/hosts/$name"; + my $output_parser = $host->findvalue('./output_parser') || "$Bin/test_output_webifier.pl"; + + print "$pid *** Ensuring $output_path and related paths exist\n"; + my @args = ('mkdir','-p',$output_path); + system(@args) == 0 or die "system @args failed: $?"; + @args = ('mkdir','-p',"$output_path/archive/"); + system(@args) == 0 or die "system @args failed: $?"; + chomp(my $month = `date +%Y-%m`); + @args = ('mkdir','-p',"$output_path/archive/$month/"); + system(@args) == 0 or die "system @args failed: $?"; + chomp(my $time = `date +%F_%T`); + @args = ('mkdir','-p',"$output_path/archive/$month/$time/"); + system(@args) == 0 or die "system @args failed: $?"; + + print "$pid *** Archiving previous output\n"; + `(cd $output_path && mv *.* $output_path/archive/$month/$time/ && cp $output_path/archive/$month/$time/*.hash .)`; + + print "$pid *** In Progress Page\n"; + `cp test_output.css $output_path/`; + open FILE, ">$output_path/test.html"; + print FILE '

Testing in progress

[Previous Runs]'; + close FILE; + `(cd $output_path && ln -s test.html index.html)`; + + print "$pid *** Ensuring $target_ssh_user\@$target_ssh_host:$target_ssh_path exists\n"; + my @args = ('ssh',"$target_ssh_user\@$target_ssh_host", 'mkdir','-p',$target_ssh_path); + system(@args) == 0 or die "system @args failed: $?"; + + print "$pid *** Pushing $installer_path$installer_scripts to $target_ssh_user\@$target_ssh_host:$target_ssh_path\n"; + @args = ('scp', '-r', $installer_path . $installer_scripts, "$target_ssh_user\@$target_ssh_host:$target_ssh_path"); + system(@args) == 0 or die "system @args failed: $?"; + + print "$pid *** Test starting, writing to $output_path/output.txt\n"; + my $cmd = "ssh $target_ssh_user\@$target_ssh_host $installer_invocation 1>$output_path/output.txt 2>&1"; + print "$cmd\n"; + `$cmd`; + + print "$pid *** Test complete, prettifying results\n"; + `cd $output_path && $output_parser output.txt`; + + exit; # end the child process +} + +1 while (wait() != -1); # wait for all child processes + +print "*** Finis\n"; diff --git a/qa/test_runner.xml b/qa/test_runner.xml new file mode 100644 index 000000000..b7f431c09 --- /dev/null +++ b/qa/test_runner.xml @@ -0,0 +1,17 @@ + + + ~/public_html/ + /home/live/git/random/ + + + + phasefx01 + debian wheezy + 192.168.1.79 + + installer/wheezy/ + + /home/phasefx/eg_installer/wheezy/installer_installer2.sh /home/phasefx/eg_installer/wheezy/ + + + -- 2.43.2