Robot test case for cluster controller restart tests.
Also increase polling retries for the lldp flows during onos boot.

Change-Id: Icf16f935addc394f43dd8fe2b223543ca3043e80
diff --git a/src/test/robot/cluster.robot b/src/test/robot/cluster.robot
index bc7cffb..fe1d2fd 100644
--- a/src/test/robot/cluster.robot
+++ b/src/test/robot/cluster.robot
@@ -6,6 +6,7 @@
 
 *** Variables ***
 ${NODES}          3
+${EXTRA_OPTS}     -v
 
 *** Test Cases ***
 Verify Onos DHCP Server Functionality
diff --git a/src/test/robot/cluster_controller.robot b/src/test/robot/cluster_controller.robot
new file mode 100644
index 0000000..6a2d0b6
--- /dev/null
+++ b/src/test/robot/cluster_controller.robot
@@ -0,0 +1,21 @@
+*** 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
+${EXTRA_OPTS}     -v
+
+*** Test Cases ***
+Verify Onos Controller Restart Functionality
+  [Documentation]  Verify ONOS cluster by restarting controllers iteratively
+  ${rc}=  Run Cord Tester  cluster:cluster_exchange.test_cluster_controller_restarts
+  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
diff --git a/src/test/robot/cord_resource.robot b/src/test/robot/cord_resource.robot
index 42884d3..67219e5 100644
--- a/src/test/robot/cord_resource.robot
+++ b/src/test/robot/cord_resource.robot
@@ -8,12 +8,13 @@
 ${CORD_TESTER}    %{HOME}/cord-tester/src/test/setup/cord-test.py
 ${RESTPORT}  8181
 ${NODES}  1
+${EXTRA_OPTS}
 
 *** Keywords ***
 Cord Setup
   [Documentation]  Setup the cord tester
   Cord Teardown
-  ${rc}=  Run and Return RC  sudo ${CORD_TESTER} setup --olt --start-switch -n ${NODES}
+  ${rc}=  Run and Return RC  sudo ${CORD_TESTER} setup --olt --start-switch -n ${NODES} ${EXTRA_OPTS}
   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' ' '
@@ -53,6 +54,6 @@
 
 Run Cord Tester
   [Arguments]   ${test_case}
-  ${status}  ${output}=  Run and Return RC and Output  sudo ${CORD_TESTER} run --container=${test_container} -t ${test_case}
+  ${status}  ${output}=  Run and Return RC and Output  sudo ${CORD_TESTER} run --onos-instances=${NODES} --container=${test_container} -t ${test_case}
   Log  ${output}
   [Return]    ${status}
diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
index 252216d..4f76d43 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -117,7 +117,7 @@
         status = 1
         ## Wait for the LLDP flows to be added to the switch
         tries = 0
-        while status != 0 and tries < 200:
+        while status != 0 and tries < 500:
             cmd = 'sudo ovs-ofctl dump-flows {0} | grep \"type=0x8942\"'.format(self.switch)
             status = self.execute_switch(cmd, shell = True)
             tries += 1
@@ -628,6 +628,8 @@
     Onos.PREFIX = args.prefix
     Onos.TAG = onos_cnt['tag']
     cluster_mode = True if args.onos_instances > 1 else False
+    existing_list = [ c['Names'][0][1:] for c in Container.dckr.containers() if c['Image'] == args.onos ]
+    setup_cluster = False if len(existing_list) == args.onos_instances else True
     onos = None
     if onos_ip is None:
         data_volume = '{}-data'.format(Onos.NAME) if args.shared_volume else None
@@ -647,7 +649,8 @@
                         data_volume = data_volume)
             onos_instances.append(onos)
             onos_ips.append(onos.ipaddr)
-        Onos.setup_cluster(onos_instances)
+        if setup_cluster is True:
+            Onos.setup_cluster(onos_instances)
 
     ctlr_addr = ','.join(onos_ips)
     print('Onos IP %s' %ctlr_addr)