aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/vagrant
diff options
context:
space:
mode:
authorLudovit Mikula <ludovit.mikula@pantheon.tech>2019-02-06 15:47:23 +0100
committerĽudovít Mikula <ludovit.mikula@pantheon.tech>2019-04-09 15:10:12 +0200
commit374ea2f45d17f361aa612becba657ecaade0d0b5 (patch)
treeca29e9c804c52aa14cc577299443958491f4e994 /resources/tools/vagrant
parent42e6c422a5ce4f58813a8c3a44ba0e9ac9238c9a (diff)
Add vagrant setup for testing VPP device locally
Fixed trailing whitespaces Fixed tabs vs. spaces Removed dead code Changed network interface naming Changed default number of retries for VPP startup to 120 Updated number of hugepages during provisioning Externalized CSIT related sysctl settings to 90-csit.conf Removed hardcoded local docker image name. Added new interface required for honeycomb device testing. Change-Id: I5eb38c8b1a4d96e4220dbd2e202e94f1d47e804e Signed-off-by: Ludovit Mikula <ludovit.mikula@pantheon.tech>
Diffstat (limited to 'resources/tools/vagrant')
-rw-r--r--resources/tools/vagrant/Vagrantfile185
-rw-r--r--resources/tools/vagrant/ansible/group_vars/vppdevice.yml12
-rw-r--r--resources/tools/vagrant/ansible/master.yml3
-rw-r--r--resources/tools/vagrant/ansible/roles/common/tasks/main.yml22
-rw-r--r--resources/tools/vagrant/ansible/roles/csit/files/99-vppdevice.yaml28
-rw-r--r--resources/tools/vagrant/ansible/roles/csit/tasks/main.yml120
-rw-r--r--resources/tools/vagrant/ansible/vppdevice4
-rw-r--r--resources/tools/vagrant/ansible/vppdevice.yml6
-rwxr-xr-xresources/tools/vagrant/install_debs.sh27
-rwxr-xr-xresources/tools/vagrant/install_hc_debs.sh29
10 files changed, 275 insertions, 161 deletions
diff --git a/resources/tools/vagrant/Vagrantfile b/resources/tools/vagrant/Vagrantfile
index 86e78602aa..0c4a5d8fd6 100644
--- a/resources/tools/vagrant/Vagrantfile
+++ b/resources/tools/vagrant/Vagrantfile
@@ -1,115 +1,90 @@
-# Copyright (c) 2016 Cisco and/or its affiliates.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
-# http://www.apache.org/licenses/LICENSE-2.0
+Vagrant.configure("2") do |config|
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+ # Base box definition, currently using
+ # Official Ubuntu 18.04 LTS (Bionic Beaver) Daily Build
+ config.vm.box = "ubuntu/bionic64"
-# -*- mode: ruby -*-
-# vi: set ts=2 sw=2 sts=2 et ft=ruby :
-
-$user_addition = <<-SHELL
- sudo deluser csit
- sudo adduser --disabled-password --gecos "" csit
- echo csit:csit | sudo chpasswd
- sudo adduser csit vagrant
- id csit
- echo "csit ALL=(root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/csit
- sudo chmod 0440 /etc/sudoers.d/csit
-SHELL
-
-$install_prereqs = <<-SHELL
- sudo apt-get -y update
- sudo apt-get -y -f install
- sudo apt-get -y install python-virtualenv python-dev iproute2 debhelper dkms
- sudo update-alternatives --install /bin/sh sh /bin/bash 100
-SHELL
-
-$install_vpp = <<-SHELL
- sudo apt-get -y purge vpp\*
- cd /vagrant
- vpp_pkgs="$(echo vpp*.deb)"
- if [ "$vpp_pkgs" != "vpp*.deb" ]; then
- sudo dpkg -i vpp*.deb
- fi
-SHELL
-
-
-def add_dut(config, name, mgmt_ip, port1, port2, port3, port4)
- config.vm.box_check_update = false
- config.vm.define name do |node|
- node.vm.box = "fdio-csit/ubuntu-14.04.4_2016-05-25_1.0"
- node.vm.hostname = name
- node.vm.provision "shell", inline: $user_addition
- node.vm.provision "shell", inline: $install_prereqs
- node.vm.provision "shell", inline: $install_vpp
-
- node.vm.network "private_network", ip: mgmt_ip
- node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port1
- node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port2
- node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port3
- node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port4
- node.vm.provider "virtualbox" do |vb|
- vb.memory = "3232"
- vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
- vb.customize ["modifyvm", :id, "--nicpromisc4", "allow-all"]
- vb.customize ["modifyvm", :id, "--nicpromisc5", "allow-all"]
- vb.customize ["modifyvm", :id, "--nicpromisc6", "allow-all"]
- end
- end
-end
+ # Disable automatic box update checking
+ config.vm.box_check_update = false
-net_prefix = ''
-if ENV.key?('VPP_VAGRANT_NET_PREFIX')
- net_prefix = ENV['VPP_VAGRANT_NET_PREFIX'] + '_'
-end
+ # Configure cached packages to be shared between instances of the same base box.
+ if Vagrant.has_plugin?("vagrant-cachier")
+ config.cache.scope = :box
+ end
-def add_tg(config, name, mgmt_ip, port1, port2, port3, port4, port5, port6)
- config.vm.box_check_update = false
- config.vm.define name do |node|
+ # Configure proxy if needed
if Vagrant.has_plugin?("vagrant-proxyconf")
- if ENV["http_proxy"]
- config.proxy.http = ENV["http_proxy"]
- end
- if ENV["https_proxy"]
- config.proxy.https = ENV["https_proxy"]
- end
- if ENV["no_proxy"]
- config.proxy.no_proxy = ENV["no_proxy"]
- end
+ config.proxy.http = "http://192.168.0.2:3128/"
+ config.proxy.https = "http://192.168.0.2:3128/"
+ config.proxy.ftp = "http://192.168.0.2:3128/"
+ config.proxy.no_proxy = "localhost,127.0.0.1"
end
- node.vm.box = "fdio-csit/ubuntu-14.04.4_2016-05-25_1.0"
- node.vm.hostname = name
- node.vm.provision "shell", inline: $user_addition
- node.vm.provision "shell", inline: $install_prereqs
-
- node.vm.network "private_network", ip: mgmt_ip
- node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port1
- node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port2
- node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port3
- node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port4
- node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port5
- node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port6
- node.vm.provider "virtualbox" do |vb|
- vb.memory = "2048"
- vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
- vb.customize ["modifyvm", :id, "--nicpromisc4", "allow-all"]
- vb.customize ["modifyvm", :id, "--nicpromisc5", "allow-all"]
- vb.customize ["modifyvm", :id, "--nicpromisc6", "allow-all"]
- vb.customize ["modifyvm", :id, "--nicpromisc7", "allow-all"]
- vb.customize ["modifyvm", :id, "--nicpromisc8", "allow-all"]
+
+ # Configure testing network interfaces (TG)
+ config.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: "link1", nic_type: "82545EM", mac: "0800270fe04d"
+ config.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: "link2", nic_type: "82545EM", mac: "08002761f7ad"
+ config.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: "link3", nic_type: "82545EM", mac: "080027dc5da4"
+
+ # Configure testing network interfaces (SUT)
+ config.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: "link1", nic_type: "82545EM", mac: "080027385e58"
+ config.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: "link2", nic_type: "82545EM", mac: "080027e3f542"
+ config.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: "link3", nic_type: "82545EM", mac: "0800274f7c63"
+
+ # Virtualbox machine configuration
+ config.vm.provider "virtualbox" do |vb|
+ vb.name = "vppdevice-bionic"
+ # Run in headless mode
+ vb.gui = false
+
+ # Customize the amount of memory and CPUs assigned:
+ # - for VPP at least 3GB RAM and 2 cores is recommended
+ vb.memory = "8192"
+ vb.cpus = "4"
+
+ # Configure network testing interfaces
+ vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
+ vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
+ vb.customize ["modifyvm", :id, "--nicpromisc4", "allow-all"]
+ vb.customize ["modifyvm", :id, "--nicpromisc5", "allow-all"]
+ vb.customize ["modifyvm", :id, "--nicpromisc6", "allow-all"]
+ vb.customize ["modifyvm", :id, "--nicpromisc7", "allow-all"]
end
- end
-end
-Vagrant.configure(2) do |config|
- add_tg(config, "tg", "192.168.255.100/24", net_prefix + "tg_tg", net_prefix + "tg_tg", net_prefix + "tg_dut1_1", net_prefix + "tg_dut1_2", net_prefix + "tg_dut2_1", net_prefix + "tg_dut2_2")
- add_dut(config, "dut1", "192.168.255.101/24", net_prefix + "tg_dut1_1", net_prefix + "tg_dut1_2", net_prefix + "dut1_dut2_1", net_prefix + "dut1_dut2_2")
- add_dut(config, "dut2", "192.168.255.102/24", net_prefix + "tg_dut2_1", net_prefix + "tg_dut2_2", net_prefix + "dut1_dut2_1", net_prefix + "dut1_dut2_2")
+ # Provision the box using ansible local (no Ansible installation needed on host)
+ config.vm.provision "ansible_local" do |ansible|
+ ansible.version = "latest"
+ ansible.compatibility_mode = "2.0"
+ ansible.become = true
+ ansible.verbose = false
+ ansible.limit = "all"
+ ansible.inventory_path = "ansible/vppdevice"
+ ansible.playbook = "ansible/master.yml"
+ end
+
+ config.vm.post_up_message = <<-MESSAGE
+
+ Your virtual machine is configured!
+
+ Login to the box using command:
+ vagrant ssh
+
+ To run some tests use the VPP Device bootstrap script, eg:
+ cd /home/vagrant/csit/resources/libraries/bash/entry
+ ./bootstrap_vpp_device.sh csit-vpp-device-master-ubuntu1804-1n-vbox
+
+ To run only selected tests based on TAGS, export environment variables
+ before running the test suite:
+ export GERRIT_EVENT_TYPE="comment-added"
+ export GERRIT_EVENT_COMMENT_TEXT="devicetest memif"
+ ./bootstrap_vpp_device.sh csit-vpp-device-master-ubuntu1804-1n-vbox
+
+ For more information please visit:
+ https://docs.fd.io/csit/rls1810/report/index.html
+ https://docs.fd.io/csit/master/trending/
+
+ MESSAGE
+
end
diff --git a/resources/tools/vagrant/ansible/group_vars/vppdevice.yml b/resources/tools/vagrant/ansible/group_vars/vppdevice.yml
new file mode 100644
index 0000000000..ffa60e2295
--- /dev/null
+++ b/resources/tools/vagrant/ansible/group_vars/vppdevice.yml
@@ -0,0 +1,12 @@
+---
+# Settings for VPP Device host group
+csit:
+ home: '/home/vagrant/csit'
+ test_user:
+ name: 'testuser'
+ password: '$6$/mAr/JDJc0u6/i$sLBptji85Xo/vdAv43bP4NpTaAfSBY8p3G7Uj9p4fKysrvs7XF8.FmlC56j4AzOun6nnf7PA.elytvfWoEHCL1'
+ home: '/home/testuser'
+ shell: '/bin/bash'
+ repository:
+ url: 'https://gerrit.fd.io/r/csit'
+ version: 'HEAD'
diff --git a/resources/tools/vagrant/ansible/master.yml b/resources/tools/vagrant/ansible/master.yml
new file mode 100644
index 0000000000..ffce5bc6fc
--- /dev/null
+++ b/resources/tools/vagrant/ansible/master.yml
@@ -0,0 +1,3 @@
+---
+# file: master.yml
+- import_playbook: vppdevice.yml
diff --git a/resources/tools/vagrant/ansible/roles/common/tasks/main.yml b/resources/tools/vagrant/ansible/roles/common/tasks/main.yml
new file mode 100644
index 0000000000..d5857da05c
--- /dev/null
+++ b/resources/tools/vagrant/ansible/roles/common/tasks/main.yml
@@ -0,0 +1,22 @@
+---
+# file: common/tasks/main.yml
+
+- name: Update and upgrade system packages and update cache if it's older then 1 hour
+ apt:
+ upgrade: dist
+ cache_valid_time: 3600
+
+- name: Install required common system packages
+ apt:
+ name:
+ - apt-transport-https
+ - ca-certificates
+ - curl
+ - software-properties-common
+ state: latest
+
+- name: Set /bin/sh to bash instead of dash
+ alternatives:
+ name: sh
+ link: /bin/sh
+ path: /bin/bash \ No newline at end of file
diff --git a/resources/tools/vagrant/ansible/roles/csit/files/99-vppdevice.yaml b/resources/tools/vagrant/ansible/roles/csit/files/99-vppdevice.yaml
new file mode 100644
index 0000000000..bcaa67099d
--- /dev/null
+++ b/resources/tools/vagrant/ansible/roles/csit/files/99-vppdevice.yaml
@@ -0,0 +1,28 @@
+network:
+ version: 2
+ renderer: networkd
+ ethernets:
+ enp0s8:
+ match:
+ macaddress: 08:00:27:0f:e0:4d
+ set-name: enpTGa
+ enp0s9:
+ match:
+ macaddress: 08:00:27:61:f7:ad
+ set-name: enpTGb
+ enp0s17:
+ match:
+ macaddress: 08:00:27:dc:5d:a4
+ set-name: enpTGc
+ enp0s10:
+ match:
+ macaddress: 08:00:27:38:5e:58
+ set-name: enpSUTa
+ enp0s16:
+ match:
+ macaddress: 08:00:27:e3:f5:42
+ set-name: enpSUTb
+ enp0s18:
+ match:
+ macaddress: 08:00:27:4f:7c:63
+ set-name: enpSUTc
diff --git a/resources/tools/vagrant/ansible/roles/csit/tasks/main.yml b/resources/tools/vagrant/ansible/roles/csit/tasks/main.yml
new file mode 100644
index 0000000000..9431fd53be
--- /dev/null
+++ b/resources/tools/vagrant/ansible/roles/csit/tasks/main.yml
@@ -0,0 +1,120 @@
+---
+# file: csit/tasks/main.yml
+
+- name: Upload config to rename network interfaces
+ copy:
+ src: files/99-vppdevice.yaml
+ dest: /etc/netplan/99-vppdevice.yaml
+ owner: root
+ group: root
+ mode: 0644
+
+- name: Apply network config changes
+ command: /usr/sbin/netplan apply
+
+- name: Install required system tools and packages
+ apt:
+ name:
+ - wget
+ - curl
+ - python-pip
+ - virtualenv
+ - libpcap-dev
+ state: present
+
+- name: Adjust number of hugepages
+ sysctl:
+ name: vm.nr_hugepages
+ value: 512
+ state: present
+ sysctl_file: /etc/sysctl.d/90-csit.conf
+ reload: yes
+
+- name: Add an Apt signing key, for docker-ce repository
+ apt_key:
+ url: https://download.docker.com/linux/ubuntu/gpg
+ state: present
+
+- name: Add docker-ce apt repository if not present
+ apt_repository:
+ repo: "deb https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
+ state: present
+
+- name: Install docker-ce if it's not already installed
+ apt:
+ name: docker-ce
+ state: present
+
+- name: "Add user for running tests: {{ csit.test_user.name }}"
+ user:
+ name: "{{ csit.test_user.name }}"
+ password: "{{ csit.test_user.password }}"
+ home: "{{ csit.test_user.home }}"
+ shell: "{{ csit.test_user.shell }}"
+
+- name: "Allow passwordless sudo for user: {{ csit.test_user.name }}"
+ lineinfile:
+ path: "/etc/sudoers.d/{{ csit.test_user.name }}"
+ line: "{{ csit.test_user.name }} ALL=(ALL) NOPASSWD:ALL"
+ create: yes
+
+- name: Add vagrant user to docker group
+ user:
+ name: vagrant
+ groups:
+ - docker
+
+- name: Reload groups for current session
+ command: /usr/bin/newgrp docker
+
+- name: Load required kernel modules
+ modprobe:
+ name: "{{ item }}"
+ state: present
+ with_items:
+ - vfio-pci
+
+- name: Enable required kernel modules on boot
+ lineinfile:
+ path: /etc/modules
+ line: "{{ item }}"
+ state: present
+ insertafter: EOF
+ with_items:
+ - vfio-pci
+
+- name: Clone CSIT repository
+ become_user: vagrant
+ git:
+ repo: "{{ csit.repository.url }}"
+ dest: "{{ csit.home }}"
+ accept_hostkey: yes
+ version: "{{ csit.repository.version }}"
+
+- name: Install and update pip and virtualenv
+ become_user: vagrant
+ pip:
+ name:
+ - pip
+ - virtualenv
+ state: latest
+
+- name: Prepare python virtual environmant for CSIT
+ become_user: vagrant
+ command: "/usr/bin/virtualenv {{ csit.home }}/env"
+ args:
+ chdir: "{{ csit.home }}"
+ creates: "{{ csit.home }}/env/bin/activate"
+
+- name: Install python dependencies (from {{ csit.home }}/requirements.txt)
+ become_user: vagrant
+ shell: source {{ csit.home }}/env/bin/activate && pip install --timeout 300 -r {{ csit.home }}/requirements.txt
+ args:
+ executable: /bin/bash
+
+- name: Load csit docker image from local drive if it exists (/vagrant/csit-sut.tar)
+ shell: |
+ if [ -z "$(docker images -q `cat {{ csit.home }}/VPP_DEVICE_IMAGE`)" ] && [ -e /vagrant/csit-sut.tar ]; then
+ docker load -i /vagrant/csit-sut.tar;
+ fi;
+ ignore_errors: yes
diff --git a/resources/tools/vagrant/ansible/vppdevice b/resources/tools/vagrant/ansible/vppdevice
new file mode 100644
index 0000000000..3273c644a0
--- /dev/null
+++ b/resources/tools/vagrant/ansible/vppdevice
@@ -0,0 +1,4 @@
+# Inventory file for VPP Device box environment
+
+[vppdevice]
+localhost ansible_connection=local
diff --git a/resources/tools/vagrant/ansible/vppdevice.yml b/resources/tools/vagrant/ansible/vppdevice.yml
new file mode 100644
index 0000000000..7c3992cf26
--- /dev/null
+++ b/resources/tools/vagrant/ansible/vppdevice.yml
@@ -0,0 +1,6 @@
+---
+# file: vppdevice.yml
+- hosts: vppdevice
+ roles:
+ - common
+ - csit \ No newline at end of file
diff --git a/resources/tools/vagrant/install_debs.sh b/resources/tools/vagrant/install_debs.sh
deleted file mode 100755
index 121337695a..0000000000
--- a/resources/tools/vagrant/install_debs.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2016 Cisco and/or its affiliates.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-set -x
-
-USERNAME=csit
-
-function ssh_do_duts {
- ssh ${USERNAME}@192.168.255.101 ${@} || exit
- ssh ${USERNAME}@192.168.255.102 ${@} || exit
-}
-
-rsync -avz ${@} ${USERNAME}@192.168.255.101:/tmp/ || exit
-rsync -avz ${@} ${USERNAME}@192.168.255.102:/tmp/ || exit
-
-ssh_do_duts "sudo apt-get -y purge 'vpp.*' ; exit 0"
-ssh_do_duts "sudo dpkg -i /tmp/vpp*.deb"
diff --git a/resources/tools/vagrant/install_hc_debs.sh b/resources/tools/vagrant/install_hc_debs.sh
deleted file mode 100755
index edb15fa05f..0000000000
--- a/resources/tools/vagrant/install_hc_debs.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2016 Cisco and/or its affiliates.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-set -x
-
-USERNAME=csit
-
-function ssh_do_all {
- # ssh ${USERNAME}@192.168.255.100 ${@} || exit
- ssh ${USERNAME}@192.168.255.101 ${@} || exit
- ssh ${USERNAME}@192.168.255.102 ${@} || exit
-}
-
-# rsync -avz ${@} ${USERNAME}@192.168.255.100:/tmp/ || exit
-rsync -avz ${@} ${USERNAME}@192.168.255.101:/tmp/ || exit
-rsync -avz ${@} ${USERNAME}@192.168.255.102:/tmp/ || exit
-
-ssh_do_all "sudo apt-get -y purge 'honeycomb*' ; exit 0"
-ssh_do_all "sudo dpkg -i /tmp/honeycomb*.deb"