From 031c62c663d5df7f07b073d6119e451d133392b7 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Sun, 20 Oct 2013 01:02:10 +0200 Subject: [PATCH] Allow for some automated testing using vagrant. --- Vagrantfile | 11 ++++++ bootstrap.sh | 69 +++++++++++++++++++++++++++++++++ pgloader.lisp | 2 +- postmodern-send-copy-done.patch | 29 ++++++++++++++ 4 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 Vagrantfile create mode 100644 bootstrap.sh create mode 100644 postmodern-send-copy-done.patch diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..3a4c332 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,11 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure("2") do |config| + config.vm.box = "wheezy64" + + config.vm.provision :shell, :path => "bootstrap.sh" +end diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 0000000..27408f7 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +echo "deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main" > /etc/apt/sources.list.d/pgdg.list + +wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - + +apt-get update +apt-get install -y postgresql-9.3 postgresql-contrib-9.3 +apt-get install -y sbcl libmysqlclient-dev git patch unzip + +HBA=/etc/postgresql/9.3/main/pg_hba.conf +echo "local all all trust" | sudo tee $HBA +echo "host all all 127.0.0.1/32 trust" | sudo tee -a $HBA + +sudo pg_ctlcluster 9.3 main reload +createuser -U postgres -SdR `whoami` +createdb pgloader + +wget --quiet http://beta.quicklisp.org/quicklisp.lisp +sbcl --load quicklisp.lisp < $REGISTRY/projects.conf + +# echo "BUILDING PGLOADER SELF-CONTAINED BINARY" + +# /home/vagrant/buildapp --logfile /tmp/build.log \ +# --asdf-tree ~/quicklisp/dists \ +# --asdf-tree /vagrant \ +# --load-system pgloader \ +# --entry pgloader:main \ +# --dynamic-space-size 4096 \ +# --output pgloader.exe + +echo "TESTING" + +/vagrant/pgloader.lisp --help + +for test in /vagrant/test/*.load +do + echo " TEST: $test" + /vagrant/pgloader.lisp $test + echo +done diff --git a/pgloader.lisp b/pgloader.lisp index c909236..8d66703 100755 --- a/pgloader.lisp +++ b/pgloader.lisp @@ -1,4 +1,4 @@ -#! /usr/local/bin/sbcl --script +#! /usr/bin/sbcl --script ;;; load the necessary components then parse the command line ;;; and launch the work diff --git a/postmodern-send-copy-done.patch b/postmodern-send-copy-done.patch new file mode 100644 index 0000000..221489d --- /dev/null +++ b/postmodern-send-copy-done.patch @@ -0,0 +1,29 @@ +diff --git a/cl-postgres/bulk-copy.lisp b/cl-postgres/bulk-copy.lisp +index f8efdb3..0f020d6 100644 +--- a/cl-postgres/bulk-copy.lisp ++++ b/cl-postgres/bulk-copy.lisp +@@ -120,13 +120,18 @@ + (with-syncing + (copy-done-message socket) + (force-output socket) +- (message-case socket +- (#\C (let* ((command-tag (read-str socket)) +- (space (position #\Space command-tag :from-end t))) +- (when space +- (parse-integer command-tag :junk-allowed t :start (1+ space)))))) ++ (handler-case ++ (message-case socket ++ (#\C (let* ((command-tag (read-str socket)) ++ (space (position #\Space command-tag :from-end t))) ++ (when space ++ (parse-integer command-tag :junk-allowed t :start (1+ space)))))) ++ (condition (e) ++ ;; In case of error in the COPY stream we need to wait for an ++ ;; explicit ReadyForQuery message. Then we re-signal the error. ++ (message-case socket (#\Z (read-uint1 socket))) ++ (error e))) + (loop (message-case socket + (#\Z (read-uint1 socket) + (return-from send-copy-done)) + (t :skip))))) +-