Robot changes for cord tester
Add a common resource robot for CORD to include from other cord robot files.
Add a cluster robot variant.

Change-Id: I4ece954e102aee3aa27234482287c04d49807ef9
diff --git a/src/test/robot/cluster.robot b/src/test/robot/cluster.robot
new file mode 100644
index 0000000..bc7cffb
--- /dev/null
+++ b/src/test/robot/cluster.robot
@@ -0,0 +1,45 @@
+*** Settings ***
+Documentation  Run Cord verification test cases for Cluster
+Resource  cord_resource.robot
+Suite Setup  Cord Cluster Setup
+Suite Teardown  Cord Teardown
+
+*** Variables ***
+${NODES}          3
+
+*** Test Cases ***
+Verify Onos DHCP Server Functionality
+  [Documentation]  Make a DHCP request to ONOS to get an IP
+  ${rc}=  Run Cord Tester  dhcp:dhcp_exchange.test_dhcp_1request
+  Should Be Equal As Integers  ${rc}  0
+
+Verify ONOS DHCP Relay Server Functionality
+  [Documentation]  Make a DHCP request to a relay server through ONOS to get an IP
+  ${rc}=  Run Cord Tester  dhcprelay:dhcprelay_exchange.test_dhcpRelay_1request
+  Should Be Equal As Integers  ${rc}  0
+
+Verify Onos AAA Functionality
+  [Documentation]  Make a TLS client request to a RADIUS server through ONOS AAA application
+  ${rc}=  Run Cord Tester  tls:eap_auth_exchange.test_eap_tls
+  Should Be Equal As Integers  ${rc}  0
+
+Verify Onos IGMP Functionality
+  [Documentation]  Make a IGMP join leave request through ONOS IGMP snooping application
+  ${rc}=  Run Cord Tester  igmp:igmp_exchange.test_igmp_join_verify_traffic
+  Should Be Equal As Integers  ${rc}  0
+
+Verify Cord SUBSCRIBER Functionality
+  [Documentation]  Simulate Channel Surfing experience
+  ${rc}=  Run Cord Tester  cordSubscriber:subscriber_exchange.test_cord_subscriber_join_jump
+  Should Be Equal As Integers  ${rc}  0
+
+Verify Cord VROUTER Functionality
+  [Documentation]  Start Quagga container, connect it to ONOS before validating ONOS routing works
+  ${rc}=  Run Cord Tester  vrouter:vrouter_exchange.test_vrouter_with_5_routes
+  Should Be Equal As Integers  ${rc}  0
+
+*** Keywords ***
+Cord Cluster Setup
+  [Documentation]  Configure a ${NODES} node ONOS cluster for cord tester
+  ${output}  Run  sudo docker ps |grep cord-onos | tr -s ' ' | awk '{print $NF}' | xargs docker kill
+  Cord Setup
\ No newline at end of file
diff --git a/src/test/robot/cord.robot b/src/test/robot/cord.robot
index c0c69d4..da58d9c 100644
--- a/src/test/robot/cord.robot
+++ b/src/test/robot/cord.robot
@@ -1,11 +1,8 @@
 *** Settings ***
 Documentation  Run Cord verification test cases
+Resource  cord_resource.robot
 Suite Setup  Cord Setup
 Suite Teardown  Cord Teardown
-Library    OperatingSystem
-
-*** Variables ***
-${CORD_TESTER}    %{HOME}/cord-tester/src/test/setup/cord-test.py
 
 *** Test Cases ***
 Verify Onos DHCP Server Functionality
@@ -37,22 +34,3 @@
   [Documentation]  Start Quagga container, connect it to ONOS before validating ONOS routing works
   ${rc}=  Run Cord Tester  vrouter:vrouter_exchange.test_vrouter_with_5_routes
   Should Be Equal As Integers  ${rc}  0
-
-*** Keywords ***
-Cord Setup
-  [Documentation]  Setup the cord tester
-  ${rc}=  Run and Return RC  sudo ${CORD_TESTER} setup --olt --start-switch
-  Should Be Equal As Integers  ${rc}  0
-  ${test_container}=  Run  sudo docker ps -l | tail -1 | tr -s ' ' | awk '{print $NF}'
-  Set Suite Variable  ${test_container}
-
-Cord Teardown
-  [Documentation]  Teardown the cord tester setup
-  ${output}=  Run  sudo ${CORD_TESTER} cleanup --olt
-
-Run Cord Tester
-  [Arguments]   ${test_case}
-  ${status}  ${output}=  Run and Return RC and Output  sudo ${CORD_TESTER} run --container=${test_container} -t ${test_case}
-  Log  ${output}
-  [Return]    ${status}
-
diff --git a/src/test/robot/cord_resource.robot b/src/test/robot/cord_resource.robot
new file mode 100644
index 0000000..42884d3
--- /dev/null
+++ b/src/test/robot/cord_resource.robot
@@ -0,0 +1,58 @@
+*** Settings ***
+Documentation  Common definitions of variables and keywords for running cord tester
+Library  OperatingSystem
+Library  Collections
+Library  RequestsLibrary
+
+*** Variables ***
+${CORD_TESTER}    %{HOME}/cord-tester/src/test/setup/cord-test.py
+${RESTPORT}  8181
+${NODES}  1
+
+*** Keywords ***
+Cord Setup
+  [Documentation]  Setup the cord tester
+  Cord Teardown
+  ${rc}=  Run and Return RC  sudo ${CORD_TESTER} setup --olt --start-switch -n ${NODES}
+  Should Be Equal As Integers  ${rc}  0
+  ${test_container}=  Run  sudo docker ps | grep cord-tester | tail -1 | tr -s ' ' | awk '{print $NF}'
+  ${controllers}=  Run  sudo docker ps | grep cord-onos | tr -s ' ' | awk '{print $NF}' | tr -s '\n' ' '
+  @{controller_names}=  Create List  ${controllers}
+  @{controller_list}=  Create List
+  : FOR  ${controller}  IN  @{controller_names}
+  \  ${ip}=  Run  sudo docker inspect -f '{{.NetworkSettings.Networks.bridge.IPAddress}}' ${controller}
+  \  Append To List  ${controller_list}  ${ip}
+
+  Set Suite Variable  ${test_container}
+  Set Suite Variable  @{controller_list}
+  Create HTTP Sessions
+  Wait Until Keyword Succeeds  30s  2s  Verify If All Controllers Are Up
+
+Cord Teardown
+  [Documentation]  Teardown the cord tester setup
+  ${output}=  Run  sudo ${CORD_TESTER} cleanup --olt
+
+Create HTTP Sessions
+  [Documentation]  Create controller http sessions
+  ${AUTH}=  Create List  karaf  karaf
+  : FOR  ${ip}  IN  @{controller_list}
+  \  Create Session  ${ip}  http://${ip}:${RESTPORT}  auth=${AUTH}
+
+Verify If All Controllers Are Up
+  [Documentation]  Make a rest call to the controller to see if its responding
+  : FOR  ${ip}  IN  @{controller_list}
+  \  ${resp}=  ONOS Get  ${ip}  devices
+  \  Should Be Equal As Strings  ${resp.status_code}  200
+
+ONOS Get
+  [Documentation]  Make a rest call to ONOS controller
+  [Arguments]  ${session}  ${noun}
+  ${resp}=  Get Request  ${session}  /onos/v1/${noun}
+  Log  ${resp.content}
+  [Return]  ${resp}
+
+Run Cord Tester
+  [Arguments]   ${test_case}
+  ${status}  ${output}=  Run and Return RC and Output  sudo ${CORD_TESTER} run --container=${test_container} -t ${test_case}
+  Log  ${output}
+  [Return]    ${status}