From 5a19f3167b640966c582e52abe4b55ef20bd79b2 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Wed, 24 Aug 2016 18:29:23 +0200 Subject: Add script to test Swift compilation across Linux distributions This adds the VagrantCrossDistributionTest.py script. The script allows testing the BuildTools/InstallSwiftDependencies.sh script, Swift compilation and the unit tests across different OSs. It is based on Vagrant, used publicly available VM boxes of different Linux distributions, uses Ansible to prepare the environment for compilation and finally installs the build dependencies, builds Swift and runs the unit tests. Test-Information: Ran the script on OS X 10.11.6 with Vagrant 1.8.5. It successfully build Swift and ran the tests on Ubuntu 16.04, Ubuntu 15.04, Debian 8.5, OpenSUSE Leap 42.1 and Fedora 24. Change-Id: I78e196f1a97a4fe2b5c9224f4ba19f6c7bdee03a diff --git a/QA/CrossDistributionTest/VagrantCrossDistributionTest.py b/QA/CrossDistributionTest/VagrantCrossDistributionTest.py new file mode 100755 index 0000000..ed0639c --- /dev/null +++ b/QA/CrossDistributionTest/VagrantCrossDistributionTest.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python + +# Required Python libraries: +# +# pip install python-vagrant tqdm +# +# Purpose of this script: +# +# This script tests +# a) InstallSwiftDependencies.sh installs all required packages for Swift and Swiften on system and +# b) all Swift projects build successfully on the system and their tests pass. + +from tqdm import tqdm +from time import sleep +import sys +import vagrant + +testSystems = [ + "bento/ubuntu-16.04", + "bento/ubuntu-15.04", + "bento/debian-8.5", + "bento/opensuse-leap-42.1", + "bento/fedora-24", +] + +progressBar = tqdm(testSystems) + +successfulSystems = [] +failedSystems = [] + +for testSystem in progressBar : + v = vagrant.Vagrant(quiet_stdout=False) + try : + progressBar.set_description("create Vagrantfile for %s" % testSystem) + with open('Vagrantfile', 'w') as vagrantfile : + vagrantfile.write(""" +Vagrant.configure("2") do |config| + config.vm.box = "%s" + + config.ssh.insert_key = false + + config.vm.provider "virtualbox" do |v| + v.memory = 3072 + v.cpus = 2 + end + + # This is needed because Fedora only comes with Python 3 and Ansible needs Python 2 + # on the target system for some features. + if config.vm.box.include? "fedora" + config.vm.provision "shell", inline: "sudo dnf install -y python2 python2-dnf libselinux-python" + end + + config.vm.synced_folder "../..", "/home/vagrant/swift-host", type: "rsync" + config.vm.synced_folder ".", "/vagrant", type: "rsync" + + config.vm.provision "ansible" do |ansible| + #ansible.verbose = "vvv" + ansible.playbook = "playbook.yml" + end +end""" % testSystem) + + progressBar.set_description("vagrant up") + v.up(testSystem, provision=True ) + + progressBar.set_description("start building swift on %s" % testSystem) + # unset QTDIR is needed, because Fedora 24 sets QTDIR to Qt 3, even though Qt 5 is installed. + # SCons will pick up the Qt installation from QTDIR if QTDIR is set. + v._call_vagrant_command(["ssh", "-c", "cd /home/vagrant/swift && unset QTDIR && ./scons test=unit -j 2"]) + + progressBar.set_description("vagrant destory %s" % testSystem) + v.destroy() + successfulSystems.append(testSystem) + except : + e = sys.exc_info()[0] + print("Exception: %s" % e) + progressBar.set_description("vagrant destory %s" % testSystem) + v.destroy() + failedSystems.append(testSystem) + +for system in successfulSystems: + print("SUCCESS: %s" % system) +for system in failedSystems: + print("FAILED: %s" % system) + +exit(len(failedSystems)) \ No newline at end of file diff --git a/QA/CrossDistributionTest/playbook.yml b/QA/CrossDistributionTest/playbook.yml new file mode 100644 index 0000000..bad4d30 --- /dev/null +++ b/QA/CrossDistributionTest/playbook.yml @@ -0,0 +1,31 @@ +- hosts: all + tasks: + - name: Install required packages via apt + apt: name=git state=latest update_cache=yes + become: true + when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' + - name: Install required packages via dnf + dnf: name={{item}} state=latest + with_items: + - git + - redhat-lsb + become: true + when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'RedHat' or ansible_distribution == 'Fedora' + - name: 'Install required packages via zypper' + zypper: name={{item}} state=latest + with_items: + - git-core + - lsb-release + become: true + when: ansible_distribution == 'openSUSE Leap' + - name: Clone git from host working directory + git: repo=/home/vagrant/swift-host dest=/home/vagrant/swift + + - name: 'Install Swift dependencies' + shell: ./BuildTools/InstallSwiftDependencies.sh --non-interactive chdir=/home/vagrant/swift + become: true + when: ansible_distribution == 'openSUSE Leap' + - name: 'Install Swift dependencies' + shell: yes | ./BuildTools/InstallSwiftDependencies.sh chdir=/home/vagrant/swift + become: true + when: ansible_distribution != 'openSUSE Leap' -- cgit v0.10.2-6-g49f6