From bef3113b6126742f79299d0ff14743524beeae75 Mon Sep 17 00:00:00 2001 From: ronivay Date: Thu, 26 Jul 2018 16:32:44 +0300 Subject: [PATCH] Add vagrant configurations for testing, readme update and fix to setting permissions for custom user --- .gitignore | 9 +++++++ README.md | 7 ++--- tests/CentOS/Vagrantfile | 48 +++++++++++++++++++++++++++++++++++ tests/Debian/Vagrantfile | 48 +++++++++++++++++++++++++++++++++++ tests/Ubuntu/Vagrantfile | 48 +++++++++++++++++++++++++++++++++++ tests/run-tests.sh | 55 ++++++++++++++++++++++++++++++++++++++++ xo-install.sh | 2 +- 7 files changed, 213 insertions(+), 4 deletions(-) create mode 100644 tests/CentOS/Vagrantfile create mode 100644 tests/Debian/Vagrantfile create mode 100644 tests/Ubuntu/Vagrantfile create mode 100755 tests/run-tests.sh diff --git a/.gitignore b/.gitignore index b7a118f..7b0685d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,10 @@ xo-install.log +tests/*/* +tests/* +!tests/Ubuntu +!tests/Ubuntu/Vagrantfile +!tests/CentOS +!tests/CentOS/Vagrantfile +!tests/Debian +!tests/Debian/Vagrantfile +!tests/run-tests.sh diff --git a/README.md b/README.md index b9f555a..7f8cd78 100644 --- a/README.md +++ b/README.md @@ -63,10 +63,11 @@ docker run -p 80:80 -v /path/to/xodata:/var/lib/xo-server -v /path/to/redisdata: Tool has been tested to work with following distros: - CentOS 7 -- Debian 8 -- Ubuntu 16.05 +- Debian 9 +- Ubuntu 16.04 -CentOS was tested without SELinux. You need to deal with labels and permissions yourself if you want to use it. +CentOS setup is confirmed to work with fresh minimal installation and SELinux enabled. +Although script doesn't do any SELinux checks or modifications, so you need to take care of possible changes by yourself according to your system. Tool makes all necessary changes required for Xen-Orchestra to run (including packages, user creation, permissions). Please evaluate script if needed. I take no responsibility of possible damage caused by this tool. diff --git a/tests/CentOS/Vagrantfile b/tests/CentOS/Vagrantfile new file mode 100644 index 0000000..a13c5f5 --- /dev/null +++ b/tests/CentOS/Vagrantfile @@ -0,0 +1,48 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure(2) do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://atlas.hashicorp.com/search. + config.vm.box = "centos/7" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + config.vm.network "private_network", ip: "192.168.33.101" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + config.vm.synced_folder "../../", "/vagrant" + + config.vm.provider "virtualbox" do |vb| + # Display the VirtualBox GUI when booting the machine + # Customize the amount of memory on the VM: + vb.memory = "2048" + end + + # Disable the new default behavior introduced in Vagrant 1.7, to + # ensure that all Vagrant machines will use the same SSH key pair. + # See https://github.com/mitchellh/vagrant/issues/5005 + config.ssh.insert_key = false + + # + # Run automated test installation + # + config.vm.provision :shell, path: "../../xo-install.sh", args: "--run-test", run: 'always' + +end diff --git a/tests/Debian/Vagrantfile b/tests/Debian/Vagrantfile new file mode 100644 index 0000000..4949ea2 --- /dev/null +++ b/tests/Debian/Vagrantfile @@ -0,0 +1,48 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure(2) do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://atlas.hashicorp.com/search. + config.vm.box = "debian/stretch64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + config.vm.network "private_network", ip: "192.168.33.101" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + config.vm.synced_folder "../../", "/vagrant" + + config.vm.provider "virtualbox" do |vb| + # Display the VirtualBox GUI when booting the machine + # Customize the amount of memory on the VM: + vb.memory = "2048" + end + + # Disable the new default behavior introduced in Vagrant 1.7, to + # ensure that all Vagrant machines will use the same SSH key pair. + # See https://github.com/mitchellh/vagrant/issues/5005 + config.ssh.insert_key = false + + # + # Run automated test installation + # + config.vm.provision :shell, path: "../../xo-install.sh", args: "--run-test", run: 'always' + +end diff --git a/tests/Ubuntu/Vagrantfile b/tests/Ubuntu/Vagrantfile new file mode 100644 index 0000000..93ec4cf --- /dev/null +++ b/tests/Ubuntu/Vagrantfile @@ -0,0 +1,48 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure(2) do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://atlas.hashicorp.com/search. + config.vm.box = "ubuntu/xenial64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + config.vm.network "private_network", ip: "192.168.33.101" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + config.vm.synced_folder "../../", "/vagrant" + + config.vm.provider "virtualbox" do |vb| + # Display the VirtualBox GUI when booting the machine + # Customize the amount of memory on the VM: + vb.memory = "2048" + end + + # Disable the new default behavior introduced in Vagrant 1.7, to + # ensure that all Vagrant machines will use the same SSH key pair. + # See https://github.com/mitchellh/vagrant/issues/5005 + config.ssh.insert_key = false + + # + # Run automated test installation + # + config.vm.provision :shell, path: "../../xo-install.sh", args: "--run-test", run: 'always' + +end diff --git a/tests/run-tests.sh b/tests/run-tests.sh new file mode 100755 index 0000000..b83b3fb --- /dev/null +++ b/tests/run-tests.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +function RunTestsSingle { + + export VAGRANT_CWD="$(dirname $0)/$1" + local LOGFILE="$(dirname $0)/$1/installation-test.log" + vagrant up &> $LOGFILE + sleep 5 + echo "" >> $LOGFILE + curl -s -L 192.168.33.101 >> $LOGFILE 2>&1 || false + + if [[ $? == "1" ]]; then + echo "$1 HTTP Check: failed" + else + echo "$1 HTTP Check: success" + fi + sleep 5 + vagrant destroy -f &> $LOGFILE + unset VAGRANT_CWD + +echo $1 + +} + +function RunTestsAll { + +for x in CentOS Debian Ubuntu; do + + export VAGRANT_CWD="$(dirname $0)/$x" + local LOGFILE="$(dirname $0)/$x/installation-test.log" + vagrant up &> $LOGFILE + sleep 5 + echo "" >> $LOGFILE + echo "Curl output:" >> $LOGFILE + curl -s -L -m 5 192.168.33.101 >> $LOGFILE 2>&1 || false + + if [[ $? == "1" ]]; then + echo "$x HTTP Check: failed" + else + echo "$x HTTP Check: success" + fi + sleep 5 + vagrant destroy -f &> $LOGFILE + unset VAGRANT_CWD +done + +} + +if [[ $# == "1" ]]; then + RunTestsSingle "$1" + exit 0 +else + RunTestsAll + exit 0 +fi diff --git a/xo-install.sh b/xo-install.sh index bfd7ee4..ab3acbd 100755 --- a/xo-install.sh +++ b/xo-install.sh @@ -282,7 +282,7 @@ function InstallXO { mkdir /var/lib/xo-server 2>/dev/null fi - chown $XOUSER:$XOUSER /var/lib/xo-server + chown -R $XOUSER:$XOUSER /var/lib/xo-server fi echo