Permalink
Browse files

include some tools into git + minor change in AUTHORS + tar.index update

  • Loading branch information...
1 parent 3361193 commit 6c103bf0b5fb0b1b0a3cab82c59a8dd6c7257ffb @beaud76 committed Jul 28, 2012
Showing with 286 additions and 21 deletions.
  1. +2 −1 AUTHORS
  2. +20 −20 tar.index
  3. +79 −0 tools/gen_emaj.pl
  4. +185 −0 tools/regress.sh
View
3 AUTHORS
@@ -5,7 +5,8 @@ Philippe Beaudoin <phb.emaj@free.fr>
implementation in plpgsql (initial idea taken from
Andreas Scherbaum's table_log contrib)
-With some comments from:
+With some useful comments from:
- JP.Argudo and Dalibo team.
- K.Rosensteel (Bull)
+- R.Dunklau
View
40 tar.index
@@ -1,20 +1,20 @@
-emaj-0.11.0/README
-emaj-0.11.0/CHANGES
-emaj-0.11.0/LICENSE
-emaj-0.11.0/AUTHORS
-emaj-0.11.0/META.json
-emaj-0.11.0/sql/emaj.sql
-emaj-0.11.0/sql/emaj-0.10.0-to-0.10.1.sql
-emaj-0.11.0/sql/emaj-0.10.1-to-0.11.0.sql
-emaj-0.11.0/sql/emaj-0.11.0-to-0.11.1.sql
-emaj-0.11.0/sql/emaj--0.10.0--unpackaged.sql
-emaj-0.11.0/sql/emaj--0.10.1--unpackaged.sql
-emaj-0.11.0/sql/demo.sql
-emaj-0.11.0/sql/prep-pr.sql
-emaj-0.11.0/sql/uninstall.sql
-emaj-0.11.0/sql/check-0.10.1-to-0.11.0-conditions.sql
-emaj-0.11.0/doc/Emaj.0.11.1_doc_en.pdf
-emaj-0.11.0/doc/Emaj.0.11.1_doc_fr.pdf
-emaj-0.11.0/doc/Emaj.0.11.1_pres_en.pdf
-emaj-0.11.0/doc/Emaj.0.11.1_pres_fr.pdf
-emaj-0.11.0/php/emajParallelRollback.php
+emaj-0.11.1/README
+emaj-0.11.1/CHANGES
+emaj-0.11.1/LICENSE
+emaj-0.11.1/AUTHORS
+emaj-0.11.1/META.json
+emaj-0.11.1/sql/emaj.sql
+emaj-0.11.1/sql/emaj-0.10.0-to-0.10.1.sql
+emaj-0.11.1/sql/emaj-0.10.1-to-0.11.0.sql
+emaj-0.11.1/sql/emaj-0.11.0-to-0.11.1.sql
+emaj-0.11.1/sql/emaj--0.10.0--unpackaged.sql
+emaj-0.11.1/sql/emaj--0.10.1--unpackaged.sql
+emaj-0.11.1/sql/demo.sql
+emaj-0.11.1/sql/prep-pr.sql
+emaj-0.11.1/sql/uninstall.sql
+emaj-0.11.1/sql/check-0.10.1-to-0.11.0-conditions.sql
+emaj-0.11.1/doc/Emaj.0.11.1_doc_en.pdf
+emaj-0.11.1/doc/Emaj.0.11.1_doc_fr.pdf
+emaj-0.11.1/doc/Emaj.0.11.1_pres_en.pdf
+emaj-0.11.1/doc/Emaj.0.11.1_pres_fr.pdf
+emaj-0.11.1/php/emajParallelRollback.php
View
79 tools/gen_emaj.pl
@@ -0,0 +1,79 @@
+#! /usr/bin/perl -w
+#
+# gen_emaj.pl
+#
+# This perl procedure generates script files that will be used to install E-Maj extension:
+# - either with a script run from psql in pg version prior 9.1,
+# - or with a CREATE EXTENSION statement in pg 9.1+.
+# This procedure uses an source file named emaj_src.sql containing code for both scripts.
+# Special patterns, placed at the beginning ot lines, activate or deactivate portion of code destinated to one output script or the other:
+# - #gen_extension_start# : marks the begining of a code portion for the CREATE EXTENSION script
+# - #gen_extension_stop# : marks the end of a code portion for the CREATE EXTENSION script
+# - #gen_psql_start# : marks the begining of a code portion for the psql script
+# - #gen_psql_stop# : marks the end of a code portion for the psql script
+
+use warnings; use strict;
+
+# The 2 variables below are to be customized
+ my $version = '0.11.1';
+ my $dir = "/home/postgres/proj/emaj-0.11.1";
+
+ my $fic_src = $dir."/sql/emaj_src.sql";
+ my $fic_ext = $dir."/sql/emaj--".$version.".sql";
+ my $fic_psql = $dir."/sql/emaj.sql";
+ my $line;
+ my $gen_ext = 0;
+ my $gen_psql = 0;
+ my $nbl_src = 0;
+ my $nbl_ext = 0;
+ my $nbl_psql = 0;
+
+### initialisation
+ print ("E-Maj scripts generation\n");
+ print ("------------------------\n");
+ open (FICSRC,$fic_src) || die ("Error in opening ".$fic_src." file\n");
+ open (FICEXT,">".$fic_ext) || die ("Error in opening ".$fic_ext." file\n");
+ open (FICPSQL,">".$fic_psql) || die ("Error in opening ".$fic_psql." file\n");
+
+### scan and process input file
+ while (<FICSRC>){
+ $nbl_src++;
+ $line=$_;
+
+### pattern detection
+ if ($line=~/^#gen_extension_start#/) {
+ $gen_ext=1;
+ next;
+ }
+ if ($line=~/^#gen_extension_stop#/) {
+ $gen_ext=0;
+ next;
+ }
+ if ($line=~/^#gen_psql_start#/) {
+ $gen_psql=1;
+ next;
+ }
+ if ($line=~/^#gen_psql_stop#/) {
+ $gen_psql=0;
+ next;
+ }
+
+### write other lines to output files
+ if ($gen_ext) {
+ print FICEXT $line;
+ $nbl_ext++;
+ }
+ if ($gen_psql) {
+ print FICPSQL $line;
+ $nbl_psql++;
+ }
+ }
+
+### complete the processing
+ close (FICSRC);
+ close (FICEXT);
+ close (FICPSQL);
+ print ("=> $nbl_src lines read from $fic_src\n");
+ print ("=> $nbl_ext lines written to $fic_ext\n");
+ print ("=> $nbl_psql lines written to $fic_psql\n");
+
View
185 tools/regress.sh
@@ -0,0 +1,185 @@
+#!/bin/sh
+# E-Maj 0.11.1
+# Regression tests
+
+#---------------------------------------------#
+# Parameters definition #
+#---------------------------------------------#
+EMAJ_HOME="/home/postgres/proj/emaj-0.11.1"
+
+PGBIN82="/usr/local/pg8221/bin"
+PGPORT82="8221"
+PGREG82="/home/postgres/postgresql-8.2.21/src/test/regress"
+
+PGBIN83="/usr/local/pg8315/bin"
+PGPORT83="8315"
+PGREG83="/home/postgres/postgresql-8.3.15/src/test/regress"
+
+PGBIN84="/usr/local/pg848/bin"
+PGPORT84="5848"
+PGREG84="/home/postgres/postgresql-8.4.8/src/test/regress"
+
+PGBIN90="/usr/local/pg904/bin"
+PGPORT90="5904"
+PGREG90="/home/postgres/postgresql-9.0.4/src/test/regress"
+
+PGBIN91="/usr/local/pg913/bin"
+PGPORT91="5913"
+PGREG91="/home/postgres/postgresql-9.1.3/src/test/regress"
+
+PGBIN92="/usr/local/pg92beta2/bin"
+PGPORT92="5922"
+PGREG92="/home/postgres/postgresql-9.2beta2/src/test/regress"
+
+#---------------------------------------------#
+# Functions definition #
+#---------------------------------------------#
+
+# Function reg_test_version(): regression tests for one postgres version
+# arguments: $1 pg major version
+# $2 emaj_sched suffix
+function reg_test_version()
+{
+# initialisation
+ eval RTVBIN=\${PGBIN$1}
+ eval RTVPORT=\${PGPORT$1}
+ eval RTVREG=\${PGREG$1}
+ cd $EMAJ_HOME/test/$1
+ echo ""
+
+# regression test by itself
+ echo "Run regression test"
+ if [ $1 -lt "91" ]
+ then
+ $RTVREG/pg_regress --schedule=../emaj_sched_$2 --load-language plpgsql --port $RTVPORT
+ else
+ $RTVREG/pg_regress --schedule=../emaj_sched_$2 --port $RTVPORT
+ fi
+
+# pg_dump test
+ echo "Dump regression database"
+ $RTVBIN/pg_dump -p $RTVPORT regression >results/regression.dump
+
+# Parallel rollback tests for scenario that doesn't mix work with 2 Emaj versions
+ if [[ ! $2 =~ "_mx_mig" ]];
+ then
+ echo "Parallel rollback test 1"
+ ../../php/emajParallelRollback.php -p $RTVPORT -d regression -g "myGroup1,myGroup2" -m Multi-1 -s 3 -l >results/prlb1.out
+ diff results/prlb1.out expected/prlb1.out
+ echo "Parallel rollback test 2"
+ ../../php/emajParallelRollback.php -p $RTVPORT -d regression -g myGroup1 -m Multi-1 -s 3 >results/prlb2.out
+ diff results/prlb2.out expected/prlb2.out
+ fi
+ cd ../..
+ return
+}
+
+# Function migrat_test(): test of a pg version 8.4 to 9.1 migration
+# arguments: $1 pg major version for target database
+# $2 pg major version for source dump
+function migrat_test()
+{
+ echo "Reload $1 regression database from $2 dump"
+ eval RTVBIN=\${PGBIN$1}
+ eval RTVPORT=\${PGPORT$1}
+ eval RTVREG=\${PGREG$1}
+ cd $EMAJ_HOME/test/$1
+ $RTVBIN/dropdb -p $RTVPORT regression
+ $RTVBIN/createdb -p $RTVPORT regression
+ $RTVBIN/psql -p $RTVPORT regression <../$2/results/regression.dump >results/restore.out
+ diff results/restore.out expected/restore.out
+ cat ../sql/afterRest.sql|$RTVBIN/psql -p $RTVPORT regression >results/afterRest.out
+ diff results/afterRest.out expected/afterRest.out
+ cd ../..
+ return
+}
+
+#---------------------------------------------#
+# Script body #
+#---------------------------------------------#
+
+cd $EMAJ_HOME
+
+# update the emaj.control files with the proper emaj version
+sed 's/<directory containing installation scripts, if not SHAREDIR>/\/home\/postgres\/proj\/emaj-0.11.1\/sql/' sql/emaj.control_base >/usr/local/pg913/share/postgresql/extension/emaj.control
+sed -i 's/0.11.1/0.10.1/g' /usr/local/pg913/share/postgresql/extension/emaj.control
+cp /usr/local/pg913/share/postgresql/extension/emaj.control /usr/local/pg92beta2/share/postgresql/extension/emaj.control
+
+# refresh both installation scripts before running tests
+echo " "
+perl ${EMAJ_HOME}/tools/gen_emaj.pl
+
+# choose a test
+echo " "
+echo "--- E-Maj regression tests ---"
+echo " "
+echo "Available tests:"
+echo "----------------"
+echo " A- pg 8.2.21 (port $PGPORT82) standart test"
+echo " B- pg 8.3.15 (port $PGPORT83) standart test"
+echo " C- pg 8.4.8 (port $PGPORT84) standart test"
+echo " D- pg 9.0.4 (port $PGPORT90) standart test"
+echo " E- pg 9.1.3 (port $PGPORT91) standart test"
+echo " F- pg 9.2.beta2 (port $PGPORT92) standart test"
+echo " M- pg 8.4 dump and 9.1 restore"
+#echo " N- pg 9.1 dump and 9.1 restore"
+echo " P- pg 8.2.21 (port $PGPORT82) starting with E-Maj migration"
+echo " Q- pg 8.3.15 (port $PGPORT83) starting with E-Maj migration"
+echo " R- pg 8.4.8 (port $PGPORT84) starting with E-Maj migration"
+echo " S- pg 9.0.4 (port $PGPORT90) starting with E-Maj migration"
+echo " T- pg 9.1.2 (port $PGPORT91) starting with E-Maj migration"
+echo " U- pg 9.2.beta2 (port $PGPORT92) starting with E-Maj migration"
+echo " V- pg 9.0.4 (port $PGPORT90) mixed with E-Maj migration"
+echo " W- pg 9.1.3 (port $PGPORT91) mixed with E-Maj migration"
+echo " X- pg 9.2.beta2 (port $PGPORT92) mixed with E-Maj migration"
+echo " Y- all tests with E-Maj migration, from P to U"
+echo " Z- all tests, from A to M"
+echo " "
+echo "Test to run ?"
+read ANSWER
+
+# execute the test
+case $ANSWER in
+ A|a) reg_test_version "82" "psql";;
+ B|b) reg_test_version "83" "psql" ;;
+ C|c) reg_test_version "84" "psql" ;;
+ D|d) reg_test_version "90" "psql" ;;
+# E|e) reg_test_version "91" "ext";;
+ E|e) reg_test_version "91" "psql";;
+ F|f) reg_test_version "92" "psql";;
+ M|m) migrat_test "91" "84";;
+# N|n) migrat_test "91" "91";;
+ P|p) reg_test_version "82" "psql_mig" ;;
+ Q|q) reg_test_version "83" "psql_mig" ;;
+ R|r) reg_test_version "84" "psql_mig" ;;
+ S|s) reg_test_version "90" "psql_mig" ;;
+# T|t) reg_test_version "91" "ext_mig";;
+ T|t) reg_test_version "91" "psql_mig";;
+ U|u) reg_test_version "92" "psql_mig";;
+ V|v) reg_test_version "90" "psql_mx_mig";;
+# U|u) reg_test_version "82" "psql_mx_mig";;
+# V|v) reg_test_version "91" "ext_mx_mig";;
+ W|w) reg_test_version "91" "psql_mx_mig";;
+ X|x) reg_test_version "92" "psql_mx_mig";;
+ Y|y)
+ reg_test_version "82" "psql_mig"
+ reg_test_version "83" "psql_mig"
+ reg_test_version "84" "psql_mig"
+ reg_test_version "90" "psql_mig"
+# reg_test_version "91" "ext_mig"
+ reg_test_version "91" "psql_mig"
+ reg_test_version "92" "psql_mig"
+ ;;
+ Z|z)
+ reg_test_version "82" "psql"
+ reg_test_version "83" "psql"
+ reg_test_version "84" "psql"
+ reg_test_version "90" "psql"
+# reg_test_version "91" "ext"
+ reg_test_version "91" "psql"
+ reg_test_version "92" "psql"
+ migrat_test "91" "84"
+ ;;
+ *) echo "Bad answer..." && exit 2 ;;
+esac
+

0 comments on commit 6c103bf

Please sign in to comment.