# Purpose
+1)
Creates VMs running CentOS 7.0 x64 with OpenVSwitch.
Please use the Vagrant environment variable OVS_NODES to set the number of VMs that would be created. Default value is 2 (ovs1 and ovs2).
+2)
+Sets up Robot framework in the first VM (ovs1). Subsequent VMs are will only have OVS
+
# About the included OVS rpm
To improve provisioning time, "openvswitch-2.3.1-1.x86_64.rpm" is pulled from dropbox. You can add rpm files for other OVS version if desired. Default ovs version is 2.3.1.
Line 19: ovsversion = "<desired_ovs_release>"
Line 50: puppet.manifest_file = "ovsnode_build.pp"
+# Running integration tests for OVSDB
+
+After the VMs are provisioned. ssh into ovs1 to run integration tests for OVSDB
+
+ user@machine$ vagrant ssh ovs1
+ vagrant@ovs1:~\> sh run_robot_tests.sh
+
+# OpenDaylight Controller
+
+The controller should be running on the host machine before you run the integration tests. The VMs are setup with environmental variable $CONTROLLER with the default IP: 192.168.100.1
+
+# Output and log from each test
+
+The output and logs for each test will be left in ovs1 home directory. For convinience of accessing the test results at a later time from the host machine, check "robot/scripts/results" for the result of the current and previous tests. Those are timestamped and cumulated over time. You are responsible for cleaning up this cache.
+
+# To run specific patches
+
+This script will automatically download the latest version of the master branch of the integration project. If you need to test a specific patch, open run_robot_tests.sh on the home directory of ovs1
+
+Edit the git clone url as desired
+
+ sudo git clone https://git.opendaylight.org/gerrit/integration
+
+# To run integration tests for other projects
+
+If this is temporary, edit line 17 of run_robot_tests.sh in the home directory of ovs1.
+ export test_suite_dir="$HOME/integration/test/csit/suites/ovsdb/"
+For a permanent change, make the edits described above in the version of this file in robot/scripts and re-provision your VM.
# Create boxes
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
- # Get the number of OVS VMs to create
- num_ovs_vms = (ENV['OVS_NODES'] || 2).to_i
-
- base_name = "ovs"
- base_ip = "192.168.100."
- controller_ip = "192.168.100.10"
- os = "puppetlabs/centos-7.0-64-puppet"
- ram = "512"
- ovsversion = "2.3.1"
- ovs_node_ips = num_ovs_vms.times.collect { |n| base_ip + "#{n+21}" }
-
- num_ovs_vms.times do |n|
+# Get the number of OVS VMs to create
+num_ovs_vms = (ENV['OVS_NODES'] || 2).to_i
+
+base_name = "ovs"
+base_ip = "192.168.100."
+controller_ip = "192.168.100.1"
+os = "puppetlabs/centos-7.0-64-puppet"
+ram = "512"
+ovsversion = "2.3.1"
+vagrant_pwd="vagrant"
+ovs_node_ips = num_ovs_vms.times.collect { |n| base_ip + "#{n+21}" }
+
+num_ovs_vms.times do |n|
+ #config.ssh.password = vagrant_pwd
config.vm.define base_name + "#{n+1}", autostart: true do |srv|
## Extract yaml variables
hostname = base_name + "#{n+1}"
local_ip = ovs_node_ips[n]
- srv.vm.hostname = hostname
+ srv.vm.hostname = hostname
srv.vm.box = os
srv.vm.network "private_network", ip: local_ip
srv.vm.provider :virtualbox do |vb|
vb.name = hostname
vb.memory = ram
- end # vb
+ end # vb
# Set guest environment variables
command1 = 'export CONTROLLER=\"' + controller_ip + '\"'
- command2 = 'export LOCAL_IP=\"' + local_ip + '\"'
srv.vm.provision :shell, privileged: true, inline: 'echo ' + command1 + ' >> /etc/profile'
- srv.vm.provision :shell, privileged: true, inline: 'echo ' + command2 + ' >> /etc/profile'
+
+ # Create the mininet vm ips
+ num_ovs_vms.times do |m|
+ mininet_ip = ovs_node_ips[m]
+ command = 'export MININET' + "#{m}" + '=\"' + mininet_ip + '\"'
+ srv.vm.provision :shell, privileged: true, inline: 'echo ' + command + ' >> /etc/profile'
+ end
+
srv.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
## SSH config
## puppet
srv.vm.provision "puppet" do |puppet|
- puppet.working_directory = "/vagrant/puppet"
- puppet.manifests_path = "puppet/manifests"
- puppet.manifest_file = "ovsnode.pp"
- puppet.options = "--verbose --debug"
- puppet.facter = {
- "ovsversion" => ovsversion,
- }
+ puppet.working_directory = "/vagrant/puppet"
+ puppet.manifests_path = "puppet/manifests"
+ puppet.manifest_file = "ovsnode.pp"
+ puppet.options = "--verbose --debug"
+ puppet.facter = {
+ "ovsversion" => ovsversion,
+ }
end # puppet
+ # process setup commands for ovs
+ #srv.vm.provision "shell", path: "puppet/scripts/setup_defaults.sh"
+
+ if n==0
+ # setup robot framework
+ srv.vm.provision "shell", path: "scripts/setup_robot_framework.sh", privileged: false
+
+ # create the ssh key
+ srv.vm.provision "shell", path: "scripts/create_ssh_key.sh", privileged: false
+ else
+ # run special configurations on the mininet
+ srv.vm.provision "shell", path: "scripts/setup_other_mininets.sh", privileged: false
+ end
+
+ # perform special configuration - requires root permission
+ srv.vm.provision "shell", path: "scripts/special_robot_configuration.sh"
+
+ # set the guest vm date and time from the host machine
+ # this only works for debian based linux
+ # hopefully we can add other OS compatible commands in the future
+
+ time_zone = ""
+
+ begin
+ time_zone = `sudo cat /etc/timezone`
+ rescue Exception => e
+ srv.vm.provision "shell", inline: "failed to get host OS time-zone, default to EST"
+
+ # default to EST
+ time_zone = "America/New_York"
+ end
- #process setup commands for ovs
- srv.vm.provision "shell", path: "puppet/scripts/setup_defaults.sh"
+ # set the time zone in the guest OS
+ srv.vm.provision "shell", path: "scripts/ovs_vm_host_timezone_map.sh", args:time_zone
end # srv
end #end num_ovs_vms
--- /dev/null
+# create the ssh key
+if [ ! -f ~/.ssh/id_rsa ]; then
+ echo "creating ssh key..."
+ ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
+ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
+ sudo chmod 600 ~/.ssh/authorized_keys
+fi
+
+# copy this key to vagrant folder
+cp ~/.ssh/id_rsa.pub /vagrant/shared
+
+#Modify the user prompt termination from "$" to ">"
+echo "PS1='\u@\h:\w\> '" >> ~/.bashrc
+source ~/.bashrc
--- /dev/null
+# set the time zone of the guest OS
+sudo timedatectl set-timezone $1
--- /dev/null
+# down the integration codes
+if [ -d integration/test/csit/suites ]; then
+ echo "refreshing test scripts"
+ cd integration
+ sudo git pull
+ cd ~
+else
+ echo "downloading integration..."
+ sudo git clone https://git.opendaylight.org/gerrit/integration
+fi
+
+# show the environmental variables
+printf "CONTROLLER IP:%s\n" "$CONTROLLER"
+printf "MININET VM IP:%s\n" "$MININET0"
+printf "MININETII VM IP:%s\n" "$MININET1"
+
+export test_suite_dir="$HOME/integration/test/csit/suites/ovsdb/"
+
+sudo pybot -v CONTROLLER:$CONTROLLER -v MININET:$MININET0 -v MININET:$MININET1 -v USER_HOME:$HOME -v MININET_USER:$USER $test_suite_dir
+
+# export the results
+if [ ! -d /vagrant/scripts/results ]; then
+ echo "creating results folder"
+ mkdir /vagrant/scripts/results
+fi
+
+# move test output to the shared results folder
+# the output.xml, log.html and report.html generated
+# after each run is saved in a shared timestamp folder
+# under /vagrant/scripts/results
+timestamp=$(date +'%Y.%m.%d-%H.%M.%S')
+mkdir /vagrant/scripts/results/$timestamp
+cp $PWD/output.xml /vagrant/scripts/results/$timestamp/output.xml
+cp $PWD/log.html /vagrant/scripts/results/$timestamp/log.html
+cp $PWD/report.html /vagrant/scripts/results/$timestamp/report.html
+
+
+
+
--- /dev/null
+# add the ssh to authorized keys
+cat /vagrant/shared/id_rsa.pub >> ~/.ssh/authorized_keys
+sudo chmod 600 ~/.ssh/authorized_keys
+
+#Modify the user prompt termination from "$" to ">"
+echo "PS1='\u@\h:\w\> '" >> ~/.bashrc
+source ~/.bashrc
+
--- /dev/null
+#ensure that CentOS5/EL5 repo is setup
+cd /tmp
+sudo wget -r --no-parent -A 'epel-release-*.rpm' http://dl.fedoraproject.org/pub/epel/7/x86_64/e/
+sudo rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-*.rpm
+
+#install git
+sudo yum install -y git
+
+# python is already installed.
+# install python-pip and python-paramiko
+sudo yum install -y python-pip
+sudo yum install -y python-paramiko
+
+#install the robot framework and required libraries
+sudo pip install requests
+sudo pip install robotframework
+sudo pip install robotframework-sshlibrary
+sudo pip install -U robotframework-requests
+sudo pip install --upgrade robotframework-httplibrary
+
+#copy the robot trigger code to user home
+cp /vagrant/scripts/run_robot_tests.sh ~/
--- /dev/null
+#Allow sudo access with no password
+echo "vagrant ALL=NOPASSWD: ALL" >>/etc/sudoers
+
+#disable reverse IP resolution on the VM
+echo "UseDNS no" >>/etc/ssh/sshd_config
+
+echo "Provisioning complete"