From ef3d6fd06cf0712774e721eaf1d0b072f54e0b8a Mon Sep 17 00:00:00 2001 From: Raghavendra Talur Date: Wed, 20 Apr 2016 15:02:16 +0530 Subject: vagrant-test: added more options and centos6 base box Options added are 1. destroy-now option Now you can call run-tests-in-vagrant.sh with --destroy-now option to destroy the VM corresponding to the git branch and delete the corresponding vagrant dir. Usage: run-tests-in-vagrant.sh --destroy-now 2. os option With --os option you can specify the os to be used for VM. Default is fedora and this patch adds support for centos6. Usage: run-tests-in-vagrant.sh --os="centos6" 3. destroy-after-test option When specified the VM is deleted right after the tests are executed. If the script exited before running tests then the VM is left as is for further debugging. 4. verbose option Many log messages which were mainly added for initial debugging have been removed now. All vagrant and compilation outputs have been redirected to /dev/null. To enable these logs please use --verbose option. 5. ssh option --ssh option now allows one to ssh into the VM from topdir of source code thereby avoiding the hassle of cd'ing into the vagrant dir. Box added 1. This patch adds a centos6 base box which is currently made available at atlas.hashicorp.com. Template files for this box are available under tests/vagrant/vagrant-template-centos6 directory. The default box is moved under vagrant-template-fedora directory to keep up with the naming convention. Enhancements This patch also modifies the cpu and memory allocation mechanism for the VMs. All the cpus on the host are used and 1/4 of the memory available on host is used. Bug Fixes 1. Fix CFLAGS not passed to configure error If CFLAGS is assigned and then configure is called under sudo, the cflags are not passed onto configure. Change-Id: Iee1811a7d2b77785f6167f4706135a8f584a6bbd BUG: 1291537 Signed-off-by: Raghavendra Talur Reviewed-on: http://review.gluster.org/14046 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Jeff Darcy --- run-tests-in-vagrant.sh | 326 +++++++++++++-------- tests/vagrant/vagrant-template-centos6/Vagrantfile | 55 ++++ .../roles/daemon-services/tasks/main.yml | 3 + .../roles/fix-localhost/tasks/main.yml | 6 + .../roles/install-pkgs/tasks/main.yml | 91 ++++++ .../roles/iptables/tasks/main.yml | 3 + .../roles/mock-user/tasks/main.yml | 3 + .../roles/prepare-brick/tasks/main.yml | 6 + .../roles/remove-gluster-pkgs/tasks/main.yml | 4 + tests/vagrant/vagrant-template-centos6/setup.yml | 15 + tests/vagrant/vagrant-template-fedora/Vagrantfile | 56 ++++ .../roles/daemon-services/tasks/main.yml | 3 + .../roles/fix-localhost/tasks/main.yml | 6 + .../roles/install-pkgs/tasks/main.yml | 84 ++++++ .../roles/iptables/tasks/main.yml | 3 + .../roles/mock-user/tasks/main.yml | 3 + .../roles/prepare-brick/tasks/main.yml | 6 + .../roles/remove-gluster-pkgs/tasks/main.yml | 4 + .../roles/selinux/tasks/main.yml | 3 + tests/vagrant/vagrant-template-fedora/setup.yml | 16 + tests/vagrant/vagrant-template/Vagrantfile | 43 --- .../roles/daemon-services/tasks/main.yml | 3 - .../roles/fix-localhost/tasks/main.yml | 6 - .../roles/install-pkgs/tasks/main.yml | 84 ------ .../vagrant-template/roles/iptables/tasks/main.yml | 3 - .../roles/mock-user/tasks/main.yml | 3 - .../roles/prepare-brick/tasks/main.yml | 6 - .../roles/remove-gluster-pkgs/tasks/main.yml | 4 - .../vagrant-template/roles/selinux/tasks/main.yml | 3 - tests/vagrant/vagrant-template/setup.yml | 17 -- 30 files changed, 570 insertions(+), 298 deletions(-) create mode 100644 tests/vagrant/vagrant-template-centos6/Vagrantfile create mode 100644 tests/vagrant/vagrant-template-centos6/roles/daemon-services/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-centos6/roles/fix-localhost/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-centos6/roles/install-pkgs/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-centos6/roles/iptables/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-centos6/roles/mock-user/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-centos6/roles/prepare-brick/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-centos6/roles/remove-gluster-pkgs/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-centos6/setup.yml create mode 100644 tests/vagrant/vagrant-template-fedora/Vagrantfile create mode 100644 tests/vagrant/vagrant-template-fedora/roles/daemon-services/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-fedora/roles/fix-localhost/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-fedora/roles/install-pkgs/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-fedora/roles/iptables/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-fedora/roles/mock-user/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-fedora/roles/prepare-brick/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-fedora/roles/remove-gluster-pkgs/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-fedora/roles/selinux/tasks/main.yml create mode 100644 tests/vagrant/vagrant-template-fedora/setup.yml delete mode 100644 tests/vagrant/vagrant-template/Vagrantfile delete mode 100644 tests/vagrant/vagrant-template/roles/daemon-services/tasks/main.yml delete mode 100644 tests/vagrant/vagrant-template/roles/fix-localhost/tasks/main.yml delete mode 100644 tests/vagrant/vagrant-template/roles/install-pkgs/tasks/main.yml delete mode 100644 tests/vagrant/vagrant-template/roles/iptables/tasks/main.yml delete mode 100644 tests/vagrant/vagrant-template/roles/mock-user/tasks/main.yml delete mode 100644 tests/vagrant/vagrant-template/roles/prepare-brick/tasks/main.yml delete mode 100644 tests/vagrant/vagrant-template/roles/remove-gluster-pkgs/tasks/main.yml delete mode 100644 tests/vagrant/vagrant-template/roles/selinux/tasks/main.yml delete mode 100644 tests/vagrant/vagrant-template/setup.yml diff --git a/run-tests-in-vagrant.sh b/run-tests-in-vagrant.sh index 029439f68af..162b6893eb7 100755 --- a/run-tests-in-vagrant.sh +++ b/run-tests-in-vagrant.sh @@ -1,56 +1,75 @@ #!/bin/bash ############################################################################### -# TODO: Allow subset of tests to be executed when VM starts. # -# TODO: Provide option to destroy the VM. # +# TODO: Support other OSes. # ############################################################################### ORIGIN_DIR=$PWD autostart="no" +destroy_after_test="no" +os="fedora" +destroy_now="no" +run_tests_args="" +redirect=">/dev/null 2>&1" +ssh="no" +custom_cflags="" + + +pushd () { + command pushd "$@" >/dev/null +} + +popd () { + command popd "$@" >/dev/null +} function parse_args () { args=`getopt \ --options a \ - --long autostart \ + --long autostart,os:,destroy-now,destroy-after-test,verbose,ssh \ -n 'run-tests-in-vagrant.sh' \ -- "$@"` eval set -- "$args" while true; do case "$1" in -a|--autostart) autostart="yes"; shift ;; + --destroy-after-test) destroy_after_test="yes"; shift ;; + --destroy-now) destroy_now="yes"; shift ;; + --ssh) sshvm="yes"; shift ;; + --os) + case "$2" in + "") shift 2 ;; + *) os="$2" ; shift 2 ;; + esac ;; + --verbose) redirect=""; shift ;; --) shift ; break ;; *) echo "Internal error!" ; exit 1;; esac done + run_tests_args="$@" } function force_location() { current_dir=$(dirname $0); - if [ ! -f ${current_dir}/tests/vagrant/vagrant-template/Vagrantfile ]; then + if [ ! -f ${current_dir}/tests/vagrant/vagrant-template-fedora/Vagrantfile ]; then echo "Aborting." - echo echo "The tests/vagrant subdirectory seems to be missing." - echo echo "Please correct the problem and try again." - echo exit 1 fi } function vagrant_check() { - vagrant -v >/dev/null 2>&1; + vagrant -v >/dev/null 2>&1; if [ $? -ne 0 ]; then echo "Aborting" echo "Vagrant not found. Please install Vagrant and try again." echo "On Fedora, run "dnf install vagrant vagrant-libvirt" " exit 1 - else - echo "Found Vagrant, continuing...." - echo fi } @@ -63,142 +82,197 @@ function ansible_check() echo "Ansible not found. Please install Ansible and try again." echo "On Fedora, run "dnf install ansible" " exit 1 + fi +} + +function set_branchname_from_git_branch() +{ + BRANCHNAME=`git rev-parse --abbrev-ref HEAD` + if [ $? -ne 0 ]; then + echo "Could not get branch name from git, will exit" + exit 1 + fi +} + + +function destroy_vm_and_exit() +{ + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!CAUTION!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + echo "This will destroy VM and delete tests/vagrant/${BRANCHNAME} dir" + echo + while true; do + read -p "Do you want to continue?" yn + case $yn in + [Yy]* ) break;; + * ) echo "Did not get an yes, exiting."; exit 1 ;; + esac + done + if [ -d "tests/vagrant/${BRANCHNAME}" ]; then + pushd "tests/vagrant/${BRANCHNAME}" + eval vagrant destroy $redirect + popd + rm -rf "tests/vagrant/${BRANCHNAME}" + exit 0 else - echo "Found Ansible, continuing...." - echo + echo "Could not find vagrant dir for corresponding git branch, exiting" + exit 1 fi } -parse_args "$@" -echo "Checking current dir...." -force_location -echo -echo +function create_vagrant_dir() +{ + mkdir -p tests/vagrant/$BRANCHNAME + if [ -d "tests/vagrant/vagrant-template-${os}" ]; then + echo "Copying tests/vagrant/vagrant-template-${os} dir to tests/vagrant/${BRANCHNAME} ...." + cp -R tests/vagrant/vagrant-template-${os}/* tests/vagrant/$BRANCHNAME + else + echo "Could not find template files for requested os $os, exiting" + exit 1 + fi +} -echo "Testing for Vagrant...." -vagrant_check -echo -echo -echo "Testing for Ansible...." -ansible_check -echo -echo +function start_vm() +{ + echo "Doing vagrant up...." + pushd "tests/vagrant/${BRANCHNAME}" + eval vagrant up $redirect + if [ $? -eq 0 ] + then + popd + else + echo "Vagrant up failed, exiting...."; + popd + exit 1 + fi +} -BRANCHNAME=`git rev-parse --abbrev-ref HEAD` -echo "Copying tests/vagrant/vagrant-template dir to tests/vagrant/$BRANCHNAME" -mkdir -p tests/vagrant/$BRANCHNAME -cp -R tests/vagrant/vagrant-template/* tests/vagrant/$BRANCHNAME -echo "Change dir to vagrant dir: tests/vagrant/$BRANCHNAME" -echo "Vagrant directory is tests/vagrant/$BRANCHNAME" -echo -echo +function set_vm_attributes() +{ + if [ "x$autostart" == "xyes" ] ; then + virsh autostart ${BRANCHNAME}_vagrant-testVM + fi +} +function copy_source_code() +{ + echo "Copying source code from host machine to VM...." + pushd "tests/vagrant/${BRANCHNAME}" + vagrant ssh-config > ssh_config + rsync -az -e "ssh -F ssh_config" --rsync-path="sudo rsync" "$ORIGIN_DIR/." vagrant-testVM:/home/vagrant/glusterfs + if [ $? -eq 0 ] + then + popd + else + echo "Copy failed, exiting...." + popd + exit 1 + fi +} + +function compile_gluster() +{ + echo "Source compile and install Gluster...." + pushd "tests/vagrant/${BRANCHNAME}" + vagrant ssh -c "cd /home/vagrant/glusterfs ; sudo make clean $redirect" -- -t + vagrant ssh -c "cd /home/vagrant/glusterfs ; sudo ./autogen.sh $redirect" -- -t + if [ $? -ne 0 ] + then + echo "autogen failed, exiting...." + popd + exit 1 + fi + # GCC on fedora complains about uninitialized variables and + # GCC on centos6 does not under don't warn on uninitialized variables flag. + if [ "x$os" == "fedora" ] ; then + custom_cflags="CFLAGS='-g -O0 -Werror -Wall -Wno-error=cpp -Wno-error=maybe-uninitialized'" + else + custom_cflags="CFLAGS='-g -O0 -Werror -Wall'" + fi -echo "Doing vagrant up...." -cd tests/vagrant/$BRANCHNAME -vagrant up -if [ $? -eq 0 ] -then - echo "Vagrant up successful" - cd $ORIGIN_DIR -else - echo "Vagrant up failed, exiting...."; - cd $ORIGIN_DIR - exit 1 -fi -echo -echo + custom_cflags= + vagrant ssh -c "cd /home/vagrant/glusterfs ; \ + sudo \ + $custom_cflags \ + ./configure \ + --prefix=/usr \ + --exec-prefix=/usr \ + --bindir=/usr/bin \ + --sbindir=/usr/sbin \ + --sysconfdir=/etc \ + --datadir=/usr/share \ + --includedir=/usr/include \ + --libdir=/usr/lib64 \ + --libexecdir=/usr/libexec \ + --localstatedir=/var \ + --sharedstatedir=/var/lib \ + --mandir=/usr/share/man \ + --infodir=/usr/share/info \ + --libdir=/usr/lib64 \ + --enable-debug $redirect" -- -t + if [ $? -ne 0 ] + then + echo "configure failed, exiting...." + popd + exit 1 + fi + vagrant ssh -c "cd /home/vagrant/glusterfs; sudo make -j install $redirect" -- -t + if [ $? -ne 0 ] + then + echo "make failed, exiting...." + popd + exit 1 + fi + popd +} +function run_tests() +{ + pushd "tests/vagrant/${BRANCHNAME}" + vagrant ssh -c "cd /home/vagrant/glusterfs; sudo ./run-tests.sh $run_tests_args" -- -t + popd +} -if [ "x$autostart" == "xyes" ] ; then - echo "autostart option enabled, calling virsh autostart" - virsh autostart ${BRANCHNAME}_vagrant-testVM - echo - echo -fi +function ssh_into_vm_using_exec() +{ + pushd "tests/vagrant/${BRANCHNAME}" + exec vagrant ssh + popd +} -echo "Copying source code from host machine to VM" -cd tests/vagrant/$BRANCHNAME -vagrant ssh-config > ssh_config -rsync -az -e "ssh -F ssh_config" --rsync-path="sudo rsync" "$ORIGIN_DIR/." vagrant-testVM:/home/vagrant/glusterfs -if [ $? -eq 0 ] -then - echo "Copied." - cd $ORIGIN_DIR -else - echo "Copy failed, exiting...." - cd $ORIGIN_DIR - exit 1 -fi -echo echo +parse_args "$@" +# Check environment for dependencies +force_location +vagrant_check +ansible_check -cd tests/vagrant/$BRANCHNAME -vagrant ssh -c 'cd /home/vagrant/glusterfs ; sudo make clean' -- -t -cd $ORIGIN_DIR -echo -echo +# We have one vm per git branch, query git branch +set_branchname_from_git_branch -cd tests/vagrant/$BRANCHNAME -vagrant ssh -c 'cd /home/vagrant/glusterfs ; sudo ./autogen.sh' -- -t -if [ $? -ne 0 ] -then - echo "autogen failed, exiting...." - cd $ORIGIN_DIR - exit 1 +if [ "x$destroy_now" == "xyes" ] ; then + destroy_vm_and_exit fi -cd $ORIGIN_DIR -echo -echo -cd tests/vagrant/$BRANCHNAME -vagrant ssh -c 'cd /home/vagrant/glusterfs ; \ - CFLAGS="-g -O0 -Werror -Wall -Wno-error=cpp -Wno-error=maybe-uninitialized" \ - sudo ./configure \ - --prefix=/usr \ - --exec-prefix=/usr \ - --bindir=/usr/bin \ - --sbindir=/usr/sbin \ - --sysconfdir=/etc \ - --datadir=/usr/share \ - --includedir=/usr/include \ - --libdir=/usr/lib64 \ - --libexecdir=/usr/libexec \ - --localstatedir=/var \ - --sharedstatedir=/var/lib \ - --mandir=/usr/share/man \ - --infodir=/usr/share/info \ - --libdir=/usr/lib64 \ - --enable-debug' -- -t -if [ $? -ne 0 ] -then - echo "configure failed, exiting...." - cd $ORIGIN_DIR - exit 1 +if [ "x$sshvm" == "xyes" ] ; then + ssh_into_vm_using_exec fi -cd $ORIGIN_DIR -echo -echo -cd tests/vagrant/$BRANCHNAME -vagrant ssh -c 'cd /home/vagrant/glusterfs; sudo make -j install' -- -t -if [ $? -ne 0 ] -then - echo "make failed, exiting...." - cd $ORIGIN_DIR - exit 1 -fi -cd $ORIGIN_DIR -echo -echo -cd tests/vagrant/$BRANCHNAME -vagrant ssh -c "cd /home/vagrant/glusterfs; sudo ./run-tests.sh $*" -- -t -cd $ORIGIN_DIR -echo -echo +create_vagrant_dir +start_vm +set_vm_attributes + + + +copy_source_code +compile_gluster +run_tests + +if [ "x$destroy_after_test" == "xyes" ] ; then + destroy_vm_and_exit +fi diff --git a/tests/vagrant/vagrant-template-centos6/Vagrantfile b/tests/vagrant/vagrant-template-centos6/Vagrantfile new file mode 100644 index 00000000000..b276f90768d --- /dev/null +++ b/tests/vagrant/vagrant-template-centos6/Vagrantfile @@ -0,0 +1,55 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.define "vagrant-testVM" do |testvm| + testvm.vm.box = "raghavendra-talur/gluster-dev-centos6" + testvm.vm.hostname = "vagrant-testVM" + #testvm.ssh.insert_key = false + testvm.vm.synced_folder ".", "/vagrant", disabled: true + + host = RbConfig::CONFIG['host_os'] + # Give VM 1/4 system memory & access to all cpu cores on the host + if host =~ /darwin/ + cpus = `sysctl -n hw.ncpu`.to_i + # sysctl returns Bytes and we need to convert to MB + mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4 + elsif host =~ /linux/ + cpus = `nproc`.to_i + # meminfo shows KB and we need to convert to MB + mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4 + else # sorry Windows folks, I can't help you + cpus = 2 + mem = 1024 + end + + # Define basic config for VM, memory, cpu, storage pool + testvm.vm.provider "libvirt" do |lv| + lv.storage_pool_name = "default" + lv.memory = mem + lv.cpus = cpus + + + # We need a brick partition, lets have a 5G disk for that. + # If you need more bricks, just add more letters to the + # string below. + "b".split("").each do |i| + lv.storage :file, + #:path => "", + #:allow_existing => "", + :device => "vd#{i}", + :size => "5G", + :type => "qcow2", + :bus => "virtio", + :cache => "default" + end + end + + # Let's provision + testvm.vm.provision "ansible", run: "always" do |setup| + setup.verbose = "v" + setup.playbook = "setup.yml" + end + + end +end diff --git a/tests/vagrant/vagrant-template-centos6/roles/daemon-services/tasks/main.yml b/tests/vagrant/vagrant-template-centos6/roles/daemon-services/tasks/main.yml new file mode 100644 index 00000000000..0e4c83244cc --- /dev/null +++ b/tests/vagrant/vagrant-template-centos6/roles/daemon-services/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- name: stop and disable kernel nfs + service: name=nfs state=stopped enabled=no diff --git a/tests/vagrant/vagrant-template-centos6/roles/fix-localhost/tasks/main.yml b/tests/vagrant/vagrant-template-centos6/roles/fix-localhost/tasks/main.yml new file mode 100644 index 00000000000..84dd252b65b --- /dev/null +++ b/tests/vagrant/vagrant-template-centos6/roles/fix-localhost/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- name: remove IPv6 address for localhost + shell: sed -i '/::1/s/localhost //' /etc/hosts + +- name: add IPv4 address for localhost + shell: sed -i '/127.0.0.1/s/$/ localhost/' /etc/hosts diff --git a/tests/vagrant/vagrant-template-centos6/roles/install-pkgs/tasks/main.yml b/tests/vagrant/vagrant-template-centos6/roles/install-pkgs/tasks/main.yml new file mode 100644 index 00000000000..37dbc108d9f --- /dev/null +++ b/tests/vagrant/vagrant-template-centos6/roles/install-pkgs/tasks/main.yml @@ -0,0 +1,91 @@ +--- +- name: install deltarpm + yum: name=deltarpm state=present + +- name: remove samba3 + shell: yum -y remove samba* + +- name: update system + shell: yum -y update + +- name: install epel repo + yum: name=http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm state=present + +- name: install other packages + yum: name={{ item }} state=present + with_items: + - attr + - autoconf + - automake + - bison + #- libcmocka-devel + - dbench + - dos2unix + - e2fsprogs + - findutils + - flex + - fuse-devel + - fuse-libs + - gcc + - gdb + - git + - glib2-devel + #- hostname + - libacl-devel + - libaio-devel + - libattr-devel + - libibverbs-devel + - librdmacm-devel + - libselinux-python + - libsemanage-python + - libtool + - libxml2-devel + - lvm2-devel + - make + #- man-db + - mock + - net-tools + #- nfs-ganesha-gluster + - nfs-utils + - openssh-server + - openssl-devel + - perl-Test-Harness + - pkgconfig + #- procps-ng + - psmisc + - python-devel + - python-eventlet + - python-netifaces + - python-paste-deploy + - python-setuptools + - python-simplejson + - python-sphinx + - python-webob + - pyxattr + - readline-devel + - rpm-build + - screen + - strace + - supervisor + - systemtap-sdt-devel + - sqlite-devel + - samba4* + - userspace-rcu-devel + - vim + - wget + - which + - xfsprogs + - yajl-devel + +- name: install dev help packages, not required by Gluster + yum: name={{ item }} state=present + with_items: + - cgdb + - clang + - lsof + - perf + - sysstat + - systemtap + - systemtap-runtime + - tcpdump + - valgrind diff --git a/tests/vagrant/vagrant-template-centos6/roles/iptables/tasks/main.yml b/tests/vagrant/vagrant-template-centos6/roles/iptables/tasks/main.yml new file mode 100644 index 00000000000..768cb0e8668 --- /dev/null +++ b/tests/vagrant/vagrant-template-centos6/roles/iptables/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- name: disable iptables, need to add specific rules later + shell: iptables -F diff --git a/tests/vagrant/vagrant-template-centos6/roles/mock-user/tasks/main.yml b/tests/vagrant/vagrant-template-centos6/roles/mock-user/tasks/main.yml new file mode 100644 index 00000000000..c8e1209937e --- /dev/null +++ b/tests/vagrant/vagrant-template-centos6/roles/mock-user/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- name: Add mock user; required for rpm.t + user: name=mock group=mock diff --git a/tests/vagrant/vagrant-template-centos6/roles/prepare-brick/tasks/main.yml b/tests/vagrant/vagrant-template-centos6/roles/prepare-brick/tasks/main.yml new file mode 100644 index 00000000000..6b3f6b8d3ea --- /dev/null +++ b/tests/vagrant/vagrant-template-centos6/roles/prepare-brick/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- name: Format backend + filesystem: fstype=xfs dev=/dev/vdb + +- name: Add entry to fstab and mount + mount: name=/d src=/dev/vdb fstype=xfs state=mounted diff --git a/tests/vagrant/vagrant-template-centos6/roles/remove-gluster-pkgs/tasks/main.yml b/tests/vagrant/vagrant-template-centos6/roles/remove-gluster-pkgs/tasks/main.yml new file mode 100644 index 00000000000..c91efa9ba7c --- /dev/null +++ b/tests/vagrant/vagrant-template-centos6/roles/remove-gluster-pkgs/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- name: Erase gluster packages, keep dependencies; we will source install + shell: rpm -ev --nodeps `rpm -qa | grep ^gluster` + ignore_errors: True diff --git a/tests/vagrant/vagrant-template-centos6/setup.yml b/tests/vagrant/vagrant-template-centos6/setup.yml new file mode 100644 index 00000000000..520f1cdb019 --- /dev/null +++ b/tests/vagrant/vagrant-template-centos6/setup.yml @@ -0,0 +1,15 @@ +--- +- hosts: all + sudo: true + roles: + #Installing packages invoke dnf and metadata download takes a long time. + #The box used in Vagrantfile has all the packages installed. + #Refer to main.yml file in install-pkgs role to get list of packages. + #install-pkgs role is hence disabled by default. + #- install-pkgs + - remove-gluster-pkgs + - prepare-brick + - mock-user + - iptables + - fix-localhost + - daemon-services diff --git a/tests/vagrant/vagrant-template-fedora/Vagrantfile b/tests/vagrant/vagrant-template-fedora/Vagrantfile new file mode 100644 index 00000000000..df806c7aaee --- /dev/null +++ b/tests/vagrant/vagrant-template-fedora/Vagrantfile @@ -0,0 +1,56 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.define "vagrant-testVM" do |testvm| + testvm.vm.box = "gluster-dev-fedora" + testvm.vm.box_url = "http://download.gluster.org/pub/gluster/glusterfs/vagrant/gluster-dev-fedora/boxes/gluster-dev-fedora.json" + testvm.vm.hostname = "vagrant-testVM" + #testvm.ssh.insert_key = false + testvm.vm.synced_folder ".", "/vagrant", disabled: true + + host = RbConfig::CONFIG['host_os'] + # Give VM 1/4 system memory & access to all cpu cores on the host + if host =~ /darwin/ + cpus = `sysctl -n hw.ncpu`.to_i + # sysctl returns Bytes and we need to convert to MB + mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4 + elsif host =~ /linux/ + cpus = `nproc`.to_i + # meminfo shows KB and we need to convert to MB + mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4 + else # sorry Windows folks, I can't help you + cpus = 2 + mem = 1024 + end + + # Define basic config for VM, memory, cpu, storage pool + testvm.vm.provider "libvirt" do |lv| + lv.storage_pool_name = "default" + lv.memory = mem + lv.cpus = cpus + + + # We need a brick partition, lets have a 5G disk for that. + # If you need more bricks, just add more letters to the + # string below. + "b".split("").each do |i| + lv.storage :file, + #:path => "", + #:allow_existing => "", + :device => "vd#{i}", + :size => "5G", + :type => "qcow2", + :bus => "virtio", + :cache => "default" + end + end + + # Let's provision + testvm.vm.provision "ansible", run: "always" do |setup| + setup.verbose = "v" + setup.playbook = "setup.yml" + end + + end +end diff --git a/tests/vagrant/vagrant-template-fedora/roles/daemon-services/tasks/main.yml b/tests/vagrant/vagrant-template-fedora/roles/daemon-services/tasks/main.yml new file mode 100644 index 00000000000..98d077b1f2e --- /dev/null +++ b/tests/vagrant/vagrant-template-fedora/roles/daemon-services/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- name: stop and disable kernel nfs + service: name=nfs-server state=stopped enabled=no diff --git a/tests/vagrant/vagrant-template-fedora/roles/fix-localhost/tasks/main.yml b/tests/vagrant/vagrant-template-fedora/roles/fix-localhost/tasks/main.yml new file mode 100644 index 00000000000..84dd252b65b --- /dev/null +++ b/tests/vagrant/vagrant-template-fedora/roles/fix-localhost/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- name: remove IPv6 address for localhost + shell: sed -i '/::1/s/localhost //' /etc/hosts + +- name: add IPv4 address for localhost + shell: sed -i '/127.0.0.1/s/$/ localhost/' /etc/hosts diff --git a/tests/vagrant/vagrant-template-fedora/roles/install-pkgs/tasks/main.yml b/tests/vagrant/vagrant-template-fedora/roles/install-pkgs/tasks/main.yml new file mode 100644 index 00000000000..4e7d8d0d7b8 --- /dev/null +++ b/tests/vagrant/vagrant-template-fedora/roles/install-pkgs/tasks/main.yml @@ -0,0 +1,84 @@ +--- +- name: install deltarpm + dnf: name=deltarpm state=present + +- name: update system + shell: dnf update -y + +- name: install other packages + dnf: name={{ item }} state=present + with_items: + - attr + - autoconf + - automake + - bison + - libcmocka-devel + - cifs-utils + - dbench + - dos2unix + - e2fsprogs + - findutils + - flex + - fuse-devel + - fuse-libs + - gcc + - gdb + - git + - glib2-devel + - hostname + - libacl-devel + - libaio-devel + - libattr-devel + - libibverbs-devel + - librdmacm-devel + - libtool + - libxml2-devel + - lvm2-devel + - make + - man-db + - mock + - net-tools + - nfs-ganesha-gluster + - nfs-utils + - openssh-server + - openssl-devel + - perl-Test-Harness + - pkgconfig + - procps-ng + - psmisc + - python-devel + - python-eventlet + - python-netifaces + - python-paste-deploy + - python-setuptools + - python-simplejson + - python-sphinx + - python-webob + - pyxattr + - readline-devel + - rpm-build + - screen + - strace + - supervisor + - systemtap-sdt-devel + - sqlite-devel + - samba* + - userspace-rcu-devel + - vim + - wget + - which + - xfsprogs + - yajl-devel + +- name: install dev help packages, not required by Gluster + dnf: name={{ item }} state=present + with_items: + - cgdb + - clang + - lsof + - perf + - sysstat + - systemtap + - systemtap-runtime + - tcpdump + - valgrind diff --git a/tests/vagrant/vagrant-template-fedora/roles/iptables/tasks/main.yml b/tests/vagrant/vagrant-template-fedora/roles/iptables/tasks/main.yml new file mode 100644 index 00000000000..768cb0e8668 --- /dev/null +++ b/tests/vagrant/vagrant-template-fedora/roles/iptables/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- name: disable iptables, need to add specific rules later + shell: iptables -F diff --git a/tests/vagrant/vagrant-template-fedora/roles/mock-user/tasks/main.yml b/tests/vagrant/vagrant-template-fedora/roles/mock-user/tasks/main.yml new file mode 100644 index 00000000000..c8e1209937e --- /dev/null +++ b/tests/vagrant/vagrant-template-fedora/roles/mock-user/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- name: Add mock user; required for rpm.t + user: name=mock group=mock diff --git a/tests/vagrant/vagrant-template-fedora/roles/prepare-brick/tasks/main.yml b/tests/vagrant/vagrant-template-fedora/roles/prepare-brick/tasks/main.yml new file mode 100644 index 00000000000..6b3f6b8d3ea --- /dev/null +++ b/tests/vagrant/vagrant-template-fedora/roles/prepare-brick/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- name: Format backend + filesystem: fstype=xfs dev=/dev/vdb + +- name: Add entry to fstab and mount + mount: name=/d src=/dev/vdb fstype=xfs state=mounted diff --git a/tests/vagrant/vagrant-template-fedora/roles/remove-gluster-pkgs/tasks/main.yml b/tests/vagrant/vagrant-template-fedora/roles/remove-gluster-pkgs/tasks/main.yml new file mode 100644 index 00000000000..c91efa9ba7c --- /dev/null +++ b/tests/vagrant/vagrant-template-fedora/roles/remove-gluster-pkgs/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- name: Erase gluster packages, keep dependencies; we will source install + shell: rpm -ev --nodeps `rpm -qa | grep ^gluster` + ignore_errors: True diff --git a/tests/vagrant/vagrant-template-fedora/roles/selinux/tasks/main.yml b/tests/vagrant/vagrant-template-fedora/roles/selinux/tasks/main.yml new file mode 100644 index 00000000000..c9ba9618428 --- /dev/null +++ b/tests/vagrant/vagrant-template-fedora/roles/selinux/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- name: Allow gfapi in Samba to bind to other ports than well known smb ports + seboolean: name=samba_load_libgfapi state=yes persistent=yes diff --git a/tests/vagrant/vagrant-template-fedora/setup.yml b/tests/vagrant/vagrant-template-fedora/setup.yml new file mode 100644 index 00000000000..fc42a8157f3 --- /dev/null +++ b/tests/vagrant/vagrant-template-fedora/setup.yml @@ -0,0 +1,16 @@ +--- +- hosts: all + sudo: true + roles: + #Installing packages invoke dnf and metadata download takes a long time. + #The box used in Vagrantfile has all the packages installed. + #Refer to main.yml file in install-pkgs role to get list of packages. + #install-pkgs role is hence disabled by default. + #- install-pkgs + - remove-gluster-pkgs + - prepare-brick + - mock-user + - selinux + - iptables + - fix-localhost + - daemon-services diff --git a/tests/vagrant/vagrant-template/Vagrantfile b/tests/vagrant/vagrant-template/Vagrantfile deleted file mode 100644 index ccbbf60575d..00000000000 --- a/tests/vagrant/vagrant-template/Vagrantfile +++ /dev/null @@ -1,43 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -Vagrant.configure("2") do |config| - config.vm.define "vagrant-testVM" do |testvm| - testvm.vm.box = "gluster-dev-fedora" - testvm.vm.box_url = "http://download.gluster.org/pub/gluster/glusterfs/vagrant/gluster-dev-fedora/boxes/gluster-dev-fedora.json" - testvm.vm.hostname = "vagrant-testVM" - #testvm.ssh.insert_key = false - testvm.vm.synced_folder ".", "/vagrant", disabled: true - - - # Define basic config for VM, memory, cpu, storage pool - testvm.vm.provider "libvirt" do |lv| - lv.storage_pool_name = "default" - lv.memory = 1024 - lv.cpus = 1 - - - # We need a brick partition, lets have a 5G disk for that. - # If you need more bricks, just add more letters to the - # string below. - "b".split("").each do |i| - lv.storage :file, - #:path => "", - #:allow_existing => "", - :device => "vd#{i}", - :size => "5G", - :type => "qcow2", - :bus => "virtio", - :cache => "default" - end - end - - # Let's provision - testvm.vm.provision "ansible", run: "always" do |setup| - setup.verbose = "v" - setup.playbook = "setup.yml" - end - - end -end - diff --git a/tests/vagrant/vagrant-template/roles/daemon-services/tasks/main.yml b/tests/vagrant/vagrant-template/roles/daemon-services/tasks/main.yml deleted file mode 100644 index 98d077b1f2e..00000000000 --- a/tests/vagrant/vagrant-template/roles/daemon-services/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: stop and disable kernel nfs - service: name=nfs-server state=stopped enabled=no diff --git a/tests/vagrant/vagrant-template/roles/fix-localhost/tasks/main.yml b/tests/vagrant/vagrant-template/roles/fix-localhost/tasks/main.yml deleted file mode 100644 index 84dd252b65b..00000000000 --- a/tests/vagrant/vagrant-template/roles/fix-localhost/tasks/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: remove IPv6 address for localhost - shell: sed -i '/::1/s/localhost //' /etc/hosts - -- name: add IPv4 address for localhost - shell: sed -i '/127.0.0.1/s/$/ localhost/' /etc/hosts diff --git a/tests/vagrant/vagrant-template/roles/install-pkgs/tasks/main.yml b/tests/vagrant/vagrant-template/roles/install-pkgs/tasks/main.yml deleted file mode 100644 index 4e7d8d0d7b8..00000000000 --- a/tests/vagrant/vagrant-template/roles/install-pkgs/tasks/main.yml +++ /dev/null @@ -1,84 +0,0 @@ ---- -- name: install deltarpm - dnf: name=deltarpm state=present - -- name: update system - shell: dnf update -y - -- name: install other packages - dnf: name={{ item }} state=present - with_items: - - attr - - autoconf - - automake - - bison - - libcmocka-devel - - cifs-utils - - dbench - - dos2unix - - e2fsprogs - - findutils - - flex - - fuse-devel - - fuse-libs - - gcc - - gdb - - git - - glib2-devel - - hostname - - libacl-devel - - libaio-devel - - libattr-devel - - libibverbs-devel - - librdmacm-devel - - libtool - - libxml2-devel - - lvm2-devel - - make - - man-db - - mock - - net-tools - - nfs-ganesha-gluster - - nfs-utils - - openssh-server - - openssl-devel - - perl-Test-Harness - - pkgconfig - - procps-ng - - psmisc - - python-devel - - python-eventlet - - python-netifaces - - python-paste-deploy - - python-setuptools - - python-simplejson - - python-sphinx - - python-webob - - pyxattr - - readline-devel - - rpm-build - - screen - - strace - - supervisor - - systemtap-sdt-devel - - sqlite-devel - - samba* - - userspace-rcu-devel - - vim - - wget - - which - - xfsprogs - - yajl-devel - -- name: install dev help packages, not required by Gluster - dnf: name={{ item }} state=present - with_items: - - cgdb - - clang - - lsof - - perf - - sysstat - - systemtap - - systemtap-runtime - - tcpdump - - valgrind diff --git a/tests/vagrant/vagrant-template/roles/iptables/tasks/main.yml b/tests/vagrant/vagrant-template/roles/iptables/tasks/main.yml deleted file mode 100644 index 768cb0e8668..00000000000 --- a/tests/vagrant/vagrant-template/roles/iptables/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: disable iptables, need to add specific rules later - shell: iptables -F diff --git a/tests/vagrant/vagrant-template/roles/mock-user/tasks/main.yml b/tests/vagrant/vagrant-template/roles/mock-user/tasks/main.yml deleted file mode 100644 index c8e1209937e..00000000000 --- a/tests/vagrant/vagrant-template/roles/mock-user/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: Add mock user; required for rpm.t - user: name=mock group=mock diff --git a/tests/vagrant/vagrant-template/roles/prepare-brick/tasks/main.yml b/tests/vagrant/vagrant-template/roles/prepare-brick/tasks/main.yml deleted file mode 100644 index 6b3f6b8d3ea..00000000000 --- a/tests/vagrant/vagrant-template/roles/prepare-brick/tasks/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: Format backend - filesystem: fstype=xfs dev=/dev/vdb - -- name: Add entry to fstab and mount - mount: name=/d src=/dev/vdb fstype=xfs state=mounted diff --git a/tests/vagrant/vagrant-template/roles/remove-gluster-pkgs/tasks/main.yml b/tests/vagrant/vagrant-template/roles/remove-gluster-pkgs/tasks/main.yml deleted file mode 100644 index c91efa9ba7c..00000000000 --- a/tests/vagrant/vagrant-template/roles/remove-gluster-pkgs/tasks/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- name: Erase gluster packages, keep dependencies; we will source install - shell: rpm -ev --nodeps `rpm -qa | grep ^gluster` - ignore_errors: True diff --git a/tests/vagrant/vagrant-template/roles/selinux/tasks/main.yml b/tests/vagrant/vagrant-template/roles/selinux/tasks/main.yml deleted file mode 100644 index c9ba9618428..00000000000 --- a/tests/vagrant/vagrant-template/roles/selinux/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: Allow gfapi in Samba to bind to other ports than well known smb ports - seboolean: name=samba_load_libgfapi state=yes persistent=yes diff --git a/tests/vagrant/vagrant-template/setup.yml b/tests/vagrant/vagrant-template/setup.yml deleted file mode 100644 index a9e798da3f4..00000000000 --- a/tests/vagrant/vagrant-template/setup.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -- hosts: all - sudo: true - roles: - #Installing packages invoke dnf and metadata download takes a long time. - #The box used in Vagrantfile has all the packages installed. - #Refer to main.yml file in install-pkgs role to get list of packages. - #install-pkgs role is hence disabled by default. - #- install-pkgs - - remove-gluster-pkgs - - prepare-brick - - mock-user - - selinux - - iptables - - fix-localhost - - daemon-services - -- cgit