Difference between revisions of "CSIT/Tutorials/Vagrant/Virtualbox/MacOsX"

From fd.io
Jump to: navigation, search
(MAC OSX specific changes)
(Replaced content with "'''<span style="color: red">This tutorial page needs updating.</span>'''")
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This page describes how to run the CSIT test suites on a Mac OS X (El Capitan / 10.11.x).
+
'''<span style="color: red">This tutorial page needs updating.</span>'''
 
+
===Prerequisites===
+
This procedure requires the following software be installed on the host PRIOR to following the directions:
+
* [https://www.virtualbox.org/wiki/Downloads Virtualbox 5.x or greater]
+
* [https://www.vagrantup.com/downloads.html Vagrant]
+
* vagrant-cachier (vagrant plugin install vagrant-cachier)
+
* pip (sudo easy_install pip)
+
* virtualenv (pip install virtualenv)
+
* [http://brew.sh Homebrew]
+
* [https://git-scm.com/download/mac git]
+
* ssh-copy-id (brew install ssh-copy-id)
+
 
+
Install instructions (to be run in "Terminal") after installing Virtualbox and Vagrant:
+
<pre>sudo easy_install pip
+
pip install virtualenv
+
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
+
brew update
+
brew install git
+
brew install ssh-copy-id
+
vagrant plugin install vagrant-cachier
+
</pre>
+
 
+
* [https://gerrit.fd.io/r/#/admin/projects/csit CSIT project source code]
+
<pre>cd <CSIT repo directory>
+
export CSIT_DIR=$(pwd)
+
</pre>
+
Optional
+
* [https://gerrit.fd.io/r/#/admin/projects/vpp VPP project source code]
+
<pre>cd <VPP repo directory>
+
export VPP_DIR=$(pwd)
+
</pre>
+
The following wiki page describes how to build VPP in a VM locally:
+
[[VPP/Pulling,_Building,_Running,_Hacking_and_Pushing_VPP_Code| Pulling, Building, Hacking, and Pushing VPP Code]]
+
 
+
 
+
This guide was verified on a Mac OS X MacBook Pro /w 16GB ram running Mac OS X 10.11.5 (El Capitan). In addition to the host OS, there are 4 Virtualbox VM's required for test development: 1 VM for building VPP (vpp) and 3 VM's used by CSIT to run the test suites.  The standard 3 node CSIT topology consists of a traffic generator (tg) and two Device-Under-Test machines (dut1 and dut2).
+
 
+
This guide goes through setup of the management network that is interconnecting all VMs. This network is used by the test framework to connect to topology nodes and execute test code on them. Furthermore it explains how to start the Vagrant VMs, how to install prepared deb packages on DUTs, and how to start tests.
+
 
+
===Start Vagrant VM environment===
+
Run the "Terminal" application to get access to the bash command line prompt.  Create a folder where your Vagrant environment is going to exist, and copy the Vagrantfile and install_debs.sh from ${CSIT_DIR}/resources/tools/vagrant into that folder.  Also copy all of the vpp packages to be tested into the same folder.
+
 
+
<pre>mkdir csit-vagrant
+
cd csit-vagrant
+
export CSIT_VAGRANT=$(pwd)
+
cp ${CSIT_DIR}/resources/tools/vagrant/* .
+
cp ${VPP_DIR}/build-root/vpp*.deb .
+
vagrant up --parallel --provision
+
</pre>
+
<pre>Bringing machine 'tg' up with 'virtualbox' provider...
+
Bringing machine 'dut1' up with 'virtualbox' provider...
+
Bringing machine 'dut2' up with 'virtualbox' provider...
+
...
+
</pre>
+
 
+
Vagrant will download base disk images and install the VPP debian packages to bring those machines to required state.  VPP will NOT be started automatically.
+
 
+
Optionally, verify that VPP successfully starts on one of the dut VMs:
+
<pre>vagrant ssh dut1
+
sudo service vpp start
+
sudo vppctl sh int
+
sudo cat /var/log/upstart/vpp.log
+
sudo service vpp stop
+
exit
+
</pre>
+
 
+
===Copy your ssh-key to Vagrant VMs===
+
This steps has to be repeated every time your Vagrant VMs are re-created (i.e. vagrant destroy command was issued)
+
<pre>echo csit@192.168.255.10{0,1,2} | xargs -n 1 ssh-copy-id </pre>
+
 
+
Respond with "csit" as password (without quotes). From now on you have password-less access from this account to csit@vagrant-vms via SSH.
+
 
+
<span style="color:#ff0000">'''WARNING:'''</span> Use of ''Cisco AnyConnect Secure Mobile Client'' will break IPv4 connectivity to the virtualbox VMs.
+
After disconnecting the VPN connection, the arp table may still be incorrect.  The following may resolve the issue:
+
 
+
<pre>cd ${CSIT_VAGRANT}
+
arp -a
+
vagrant ssh tg
+
ping 192.168.255.1
+
exit
+
vagrant ssh dut1
+
ping 192.168.255.1
+
exit
+
vagrant ssh dut2
+
ping 192.168.255.1
+
exit
+
arp -a
+
</pre>
+
If the issue still persists, a reboot may be required to fix the problem.
+
 
+
===Set up your virtualenv===
+
<pre>cd ${CSIT_DIR}
+
rm -rf env
+
virtualenv env
+
source ./env/bin/activate
+
pip install -r requirements.txt
+
</pre>
+
 
+
You should now see '(env) ' in front of your bash prompt:
+
<pre>(env) <hostname>:csit <username>$ </pre>
+
 
+
===Create topology file===
+
CSIT framework uses YAML format to describe the nodes of the topology the testcases are going to run on. There are such data as IP addresses, login information, type of the node in the topology file. CSIT framework uses PCI addresses of the NICs on the topology nodes to map them to the node topology information. Luckily, PCI addresses stay at constant values in between "Vagrant up" cycles, therefore the PCI addresses are pre-stored for you in topologies/available/vagrant.yaml. BUT, within the test cases, and concretely in code that matches topology interfaces against VPP reported interfaces, MAC addreses are used. These are different every time you create new Vagrant instances of those VMs, therefore you have to scrape the PCI_ADDRESS to MAC_ADDRESS map from current topology instance.
+
 
+
Update your topology file with MAC addresses from current running VMs by running the following python script:
+
<pre>cd ${CSIT_DIR}
+
export PYTHONPATH=$(pwd)
+
./resources/tools/topology/update_topology.py -f -v -o topologies/available/vagrant_pci.yaml topologies/available/vagrant.yaml
+
</pre>
+
<pre>
+
192.168.255.101: Found MAC address of PCI device 0000:00:0a.0: 08:00:27:66:a5:75
+
192.168.255.101: Found MAC address of PCI device 0000:00:09.0: 08:00:27:bf:ed:90
+
192.168.255.100: Found MAC address of PCI device 0000:00:0a.0: 08:00:27:ae:26:e9
+
192.168.255.100: Found MAC address of PCI device 0000:00:09.0: 08:00:27:50:cf:7e
+
192.168.255.102: Found MAC address of PCI device 0000:00:0a.0: 08:00:27:2c:25:6e
+
192.168.255.102: Found MAC address of PCI device 0000:00:09.0: 08:00:27:41:45:7d
+
</pre>
+
 
+
===MAC OSX specific changes===
+
MAC OSX does not support "--exclude-vcs" option used in Linux to exclude version control system files from archiving, so the following change needs to be applied in resources/libraries/python/SetupFramework.py :
+
 
+
<pre>
+
diff --git a/resources/libraries/python/SetupFramework.py b/resources/libraries/python/SetupFramework.py
+
index ddc5514..4ccbf86 100644
+
--- a/resources/libraries/python/SetupFramework.py
+
+++ b/resources/libraries/python/SetupFramework.py
+
@@ -40,7 +40,7 @@ def pack_framework_dir():
+
    tmpfile.close()
+
 
+
    proc = Popen(
+
-        split("tar --exclude-vcs -zcf {0} .".format(file_name)),
+
+        split("tar -zcf {0} .".format(file_name)),
+
        stdout=PIPE, stderr=PIPE)
+
    (stdout, stderr) = proc.communicate()</pre>
+
 
+
Create a file ${CSIT_DIR}/sf.patch with the above diff output, then apply it with the following instruction:
+
<pre>patch -p1 <${CSIT_DIR}/sf.patch</pre>
+
 
+
===Executing test cases for Vagrant setup===
+
<pre>cd ${CSIT_DIR}
+
pybot -L TRACE -v TOPOLOGY_PATH:topologies/available/vagrant_pci.yaml --exclude 3_node_double_link_topoNOT3_node_single_link_topo --include VM_ENV --exclude PERFTEST tests/</pre>
+
 
+
This command executes tests with TRACE logging enabled, on the topology you just updated with proper MAC addresses, and starts only testcases that are made for single-link-topology (what we have in Vagrant currently), that are made for VM environment, and are not performance tests.
+
 
+
One can modify the above command to start for example only ipv4 tests:
+
<pre>pybot -L TRACE -v TOPOLOGY_PATH:topologies/available/vagrant_pci.yaml -s ipv4 tests/</pre>
+
 
+
Or a single test case:
+
<pre>pybot -L TRACE -v TOPOLOGY_PATH:topologies/available/vagrant_pci.yaml -t "VPP replies to ICMPv4 echo request" tests/</pre>
+
 
+
===Install New VPP packages on DUTs===
+
To test a different set of VPP packages, either built locally in ${VPP_DIR}/build-root or downloaded from [http://nexus.fd.io]:
+
<pre>${CSIT_VAGRANT}/install_debs.sh ${DIRECTORY_WITH_YOUR_VPP_PACKAGES}/vpp*.deb</pre>
+

Latest revision as of 06:22, 9 August 2019

This tutorial page needs updating.