From 9a45664b4bff8e65b206f1f21f27812467a4662b Mon Sep 17 00:00:00 2001 From: Joona Hoikkala Date: Thu, 17 Nov 2016 18:22:20 +0200 Subject: [PATCH] Added Vagrantfile for PostgreSQL integration tests --- Vagrantfile | 34 ++++++++++++++++++++++++++++++++++ test/pgsql.sh | 4 ++++ test/run_integration.sh | 7 +++++++ 3 files changed, 45 insertions(+) create mode 100644 Vagrantfile create mode 100755 test/pgsql.sh create mode 100755 test/run_integration.sh diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..b6fe4f5 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,34 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagratnfile for running integration tests with PostgreSQL + +VAGRANTFILE_API_VERSION = "2" + +$ubuntu_setup_script = <> /home/vagrant/.profile +echo "export GOPATH=/home/vagrant" >> /home/vagrant/.profile +mkdir -p /home/vagrant/src/acme-dns +chown -R vagrant /home/vagrant/src +cp /vagrant/test/run_integration.sh /home/vagrant +bash /vagrant/test/pgsql.sh +echo "To run integration tests run /home/vagrant/run_integration.sh" +SETUP_SCRIPT + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.define "ad-ubuntu-trusty", primary: true do |ad_ubuntu_trusty| + ad_ubuntu_trusty.vm.box = "ubuntu/trusty64" + ad_ubuntu_trusty.vm.provision "shell", inline: $ubuntu_setup_script + ad_ubuntu_trusty.vm.network "forwarded_port", guest: 8080, host: 8008 + ad_ubuntu_trusty + ad_ubuntu_trusty.vm.provider "virtualbox" do |v| + v.memory = 2048 + end + end + +end diff --git a/test/pgsql.sh b/test/pgsql.sh new file mode 100755 index 0000000..66f44da --- /dev/null +++ b/test/pgsql.sh @@ -0,0 +1,4 @@ +#!/bin/sh +sudo -u postgres createdb acmedns +sudo -u postgres psql -c "CREATE USER acmedns WITH PASSWORD 'acmedns'" +sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE acmedns TO acmedns" diff --git a/test/run_integration.sh b/test/run_integration.sh new file mode 100755 index 0000000..2e8357d --- /dev/null +++ b/test/run_integration.sh @@ -0,0 +1,7 @@ +#!/bin/sh +source /home/vagrant/.profile +rm -rf /home/vagrant/src/acme-dns/* +cp -R /vagrant/* /home/vagrant/src/acme-dns/ +cd /home/vagrant/src/acme-dns/ +go get +go test -postgres