Merge branch 'ONOS-Next' of https://github.com/OPENNETWORKINGLAB/ONLabTest into ONOS-Next
Conflicts:
TestON/drivers/common/cli/onosclidriver.py
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.params b/TestON/tests/HATestClusterRestart/HATestClusterRestart.params
new file mode 100644
index 0000000..0a8bd57
--- /dev/null
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.params
@@ -0,0 +1,63 @@
+<PARAMS>
+ <testcases>1,2,8,3,4,5,[6],7,8,4,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+ <ENV>
+ <cellName>HA</cellName>
+ </ENV>
+ <Git>False</Git>
+
+ <CTRL>
+ <ip1>10.128.30.11</ip1>
+ <port1>6633</port1>
+
+ <ip2>10.128.30.12</ip2>
+ <port2>6633</port2>
+
+ <ip3>10.128.30.13</ip3>
+ <port3>6633</port3>
+
+ <ip4>10.128.30.14</ip4>
+ <port4>6633</port4>
+
+ <ip5>10.128.30.15</ip5>
+ <port5>6633</port5>
+
+ <ip6>10.128.30.16</ip6>
+ <port6>6633</port6>
+
+ <ip7>10.128.30.17</ip7>
+ <port7>6633</port7>
+ </CTRL>
+ <TESTONUSER>admin</TESTONUSER>
+ <TESTONIP>10.128.30.10</TESTONIP>
+ <PING>
+ <source1>h8</source1>
+ <source2>h9</source2>
+ <source3>h10</source3>
+ <source4>h11</source4>
+ <source5>h12</source5>
+ <source6>h13</source6>
+ <source7>h14</source7>
+ <source8>h15</source8>
+ <source9>h16</source9>
+ <source10>h17</source10>
+ <target1>10.0.0.18</target1>
+ <target2>10.0.0.19</target2>
+ <target3>10.0.0.20</target3>
+ <target4>10.0.0.21</target4>
+ <target5>10.0.0.22</target5>
+ <target6>10.0.0.23</target6>
+ <target7>10.0.0.24</target7>
+ <target8>10.0.0.25</target8>
+ <target9>10.0.0.26</target9>
+ <target10>10.0.0.27</target10>
+ </PING>
+ <timers>
+ <LinkDiscovery>2</LinkDiscovery>
+ <SwitchDiscovery>2</SwitchDiscovery>
+ </timers>
+ <MNtcpdump>
+ <intf>eth0</intf>
+ <port> </port>
+ <folder>~/packet_captures/</folder>
+ </MNtcpdump>
+</PARAMS>
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.py b/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
new file mode 100644
index 0000000..47dc744
--- /dev/null
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.py
@@ -0,0 +1,1202 @@
+'''
+Description: This test is to determine if ONOS can handle
+ all of it's nodes restarting
+
+List of test cases:
+CASE1: Compile ONOS and push it to the test machines
+CASE2: Assign mastership to controllers
+CASE3: Assign intents
+CASE4: Ping across added host intents
+CASE5: Reading state of ONOS
+CASE6: The Failure case.
+CASE7: Check state after control plane failure
+CASE8: Compare topo
+CASE9: Link s3-s28 down
+CASE10: Link s3-s28 up
+CASE11: Switch down
+CASE12: Switch up
+CASE13: Clean up
+'''
+class HATestClusterRestart:
+
+ def __init__(self) :
+ self.default = ''
+
+ def CASE1(self,main) :
+ '''
+ CASE1 is to compile ONOS and push it to the test machines
+
+ Startup sequence:
+ git pull
+ mvn clean install
+ onos-package
+ cell <name>
+ onos-verify-cell
+ NOTE: temporary - onos-remove-raft-logs
+ onos-install -f
+ onos-wait-for-start
+ '''
+ import time
+ main.log.report("ONOS HA test: Restart all ONOS nodes - initialization")
+ main.case("Setting up test environment")
+
+ # load some vairables from the params file
+ PULL_CODE = False
+ if main.params['Git'] == 'True':
+ PULL_CODE = True
+ cell_name = main.params['ENV']['cellName']
+
+ #set global variables
+ global ONOS1_ip
+ global ONOS1_port
+ global ONOS2_ip
+ global ONOS2_port
+ global ONOS3_ip
+ global ONOS3_port
+ global ONOS4_ip
+ global ONOS4_port
+ global ONOS5_ip
+ global ONOS5_port
+ global ONOS6_ip
+ global ONOS6_port
+ global ONOS7_ip
+ global ONOS7_port
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS1_port = main.params['CTRL']['port1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS2_port = main.params['CTRL']['port2']
+ ONOS3_ip = main.params['CTRL']['ip3']
+ ONOS3_port = main.params['CTRL']['port3']
+ ONOS4_ip = main.params['CTRL']['ip4']
+ ONOS4_port = main.params['CTRL']['port4']
+ ONOS5_ip = main.params['CTRL']['ip5']
+ ONOS5_port = main.params['CTRL']['port5']
+ ONOS6_ip = main.params['CTRL']['ip6']
+ ONOS6_port = main.params['CTRL']['port6']
+ ONOS7_ip = main.params['CTRL']['ip7']
+ ONOS7_port = main.params['CTRL']['port7']
+
+
+ main.step("Applying cell variable to environment")
+ cell_result = main.ONOSbench.set_cell(cell_name)
+ verify_result = main.ONOSbench.verify_cell()
+
+ #FIXME:this is short term fix
+ main.log.report("Removing raft logs")
+ main.ONOSbench.onos_remove_raft_logs()
+ main.log.report("Uninstalling ONOS")
+ main.ONOSbench.onos_uninstall(ONOS1_ip)
+ main.ONOSbench.onos_uninstall(ONOS2_ip)
+ main.ONOSbench.onos_uninstall(ONOS3_ip)
+ main.ONOSbench.onos_uninstall(ONOS4_ip)
+ main.ONOSbench.onos_uninstall(ONOS5_ip)
+ main.ONOSbench.onos_uninstall(ONOS6_ip)
+ main.ONOSbench.onos_uninstall(ONOS7_ip)
+
+ clean_install_result = main.TRUE
+ git_pull_result = main.TRUE
+
+ main.step("Compiling the latest version of ONOS")
+ if PULL_CODE:
+ main.step("Git checkout and pull master")
+ main.ONOSbench.git_checkout("master")
+ git_pull_result = main.ONOSbench.git_pull()
+
+ main.step("Using mvn clean & install")
+ clean_install_result = main.TRUE
+ if git_pull_result == main.TRUE:
+ clean_install_result = main.ONOSbench.clean_install()
+ else:
+ main.log.warn("Did not pull new code so skipping mvn "+ \
+ "clean install")
+ main.ONOSbench.get_version(report=True)
+
+ main.step("Creating ONOS package")
+ package_result = main.ONOSbench.onos_package()
+
+ main.step("Installing ONOS package")
+ onos1_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS1_ip)
+ onos2_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS2_ip)
+ onos3_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS3_ip)
+ onos4_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS4_ip)
+ onos5_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS5_ip)
+ onos6_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS6_ip)
+ onos7_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS7_ip)
+ onos_install_result = onos1_install_result and onos2_install_result\
+ and onos3_install_result and onos4_install_result\
+ and onos5_install_result and onos6_install_result\
+ and onos7_install_result
+ '''
+ #FIXME: work around until onos is less fragile
+ main.ONOSbench.handle.sendline("onos-cluster-install")
+ print main.ONOSbench.handle.expect("\$")
+ onos_install_result = main.TRUE
+ '''
+
+
+ main.step("Checking if ONOS is up yet")
+ #TODO: Refactor
+ # check bundle:list?
+ onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+ if not onos1_isup:
+ main.log.report("ONOS1 didn't start!")
+ onos2_isup = main.ONOSbench.isup(ONOS2_ip)
+ if not onos2_isup:
+ main.log.report("ONOS2 didn't start!")
+ onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+ if not onos3_isup:
+ main.log.report("ONOS3 didn't start!")
+ onos4_isup = main.ONOSbench.isup(ONOS4_ip)
+ if not onos4_isup:
+ main.log.report("ONOS4 didn't start!")
+ onos5_isup = main.ONOSbench.isup(ONOS5_ip)
+ if not onos5_isup:
+ main.log.report("ONOS5 didn't start!")
+ onos6_isup = main.ONOSbench.isup(ONOS6_ip)
+ if not onos6_isup:
+ main.log.report("ONOS6 didn't start!")
+ onos7_isup = main.ONOSbench.isup(ONOS7_ip)
+ if not onos7_isup:
+ main.log.report("ONOS7 didn't start!")
+ onos_isup_result = onos1_isup and onos2_isup and onos3_isup\
+ and onos4_isup and onos5_isup and onos6_isup and onos7_isup
+ # TODO: if it becomes an issue, we can retry this step a few times
+
+
+ cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip)
+ cli_result2 = main.ONOScli2.start_onos_cli(ONOS2_ip)
+ cli_result3 = main.ONOScli3.start_onos_cli(ONOS3_ip)
+ cli_result4 = main.ONOScli4.start_onos_cli(ONOS4_ip)
+ cli_result5 = main.ONOScli5.start_onos_cli(ONOS5_ip)
+ cli_result6 = main.ONOScli6.start_onos_cli(ONOS6_ip)
+ cli_result7 = main.ONOScli7.start_onos_cli(ONOS7_ip)
+ cli_results = cli_result1 and cli_result2 and cli_result3 and\
+ cli_result4 and cli_result5 and cli_result6 and cli_result7
+
+ main.step("Start Packet Capture MN")
+ main.Mininet2.start_tcpdump(
+ str(main.params['MNtcpdump']['folder'])+str(main.TEST)+"-MN.pcap",
+ intf = main.params['MNtcpdump']['intf'],
+ port = main.params['MNtcpdump']['port'])
+
+
+ case1_result = (clean_install_result and package_result and
+ cell_result and verify_result and onos_install_result and
+ onos_isup_result and cli_results)
+
+ utilities.assert_equals(expect=main.TRUE, actual=case1_result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful")
+
+
+ #if case1_result==main.FALSE:
+ # main.cleanup()
+ # main.exit()
+
+ def CASE2(self,main) :
+ '''
+ Assign mastership to controllers
+ '''
+ import time
+ import json
+ import re
+
+
+ '''
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS1_port = main.params['CTRL']['port1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS2_port = main.params['CTRL']['port2']
+ ONOS3_ip = main.params['CTRL']['ip3']
+ ONOS3_port = main.params['CTRL']['port3']
+ ONOS4_ip = main.params['CTRL']['ip4']
+ ONOS4_port = main.params['CTRL']['port4']
+ ONOS5_ip = main.params['CTRL']['ip5']
+ ONOS5_port = main.params['CTRL']['port5']
+ ONOS6_ip = main.params['CTRL']['ip6']
+ ONOS6_port = main.params['CTRL']['port6']
+ ONOS7_ip = main.params['CTRL']['ip7']
+ ONOS7_port = main.params['CTRL']['port7']
+ '''
+
+
+ main.log.report("Assigning switches to controllers")
+ main.case("Assigning Controllers")
+ main.step("Assign switches to controllers")
+
+ for i in range (1,29):
+ main.Mininet1.assign_sw_controller(sw=str(i),count=7,
+ ip1=ONOS1_ip,port1=ONOS1_port,
+ ip2=ONOS2_ip,port2=ONOS2_port,
+ ip3=ONOS3_ip,port3=ONOS3_port,
+ ip4=ONOS4_ip,port4=ONOS4_port,
+ ip5=ONOS5_ip,port5=ONOS5_port,
+ ip6=ONOS6_ip,port6=ONOS6_port,
+ ip7=ONOS7_ip,port7=ONOS7_port)
+
+ mastership_check = main.TRUE
+ for i in range (1,29):
+ response = main.Mininet1.get_sw_controller("s"+str(i))
+ try:
+ main.log.info(str(response))
+ except:
+ main.log.info(repr(response))
+ if re.search("tcp:"+ONOS1_ip,response)\
+ and re.search("tcp:"+ONOS2_ip,response)\
+ and re.search("tcp:"+ONOS3_ip,response)\
+ and re.search("tcp:"+ONOS4_ip,response)\
+ and re.search("tcp:"+ONOS5_ip,response)\
+ and re.search("tcp:"+ONOS6_ip,response)\
+ and re.search("tcp:"+ONOS7_ip,response):
+ mastership_check = mastership_check and main.TRUE
+ else:
+ mastership_check = main.FALSE
+ if mastership_check == main.TRUE:
+ main.log.report("Switch mastership assigned correctly")
+ utilities.assert_equals(expect = main.TRUE,actual=mastership_check,
+ onpass="Switch mastership assigned correctly",
+ onfail="Switches not assigned correctly to controllers")
+
+ #TODO: If assign roles is working reliably then manually
+ # assign mastership to the controller we want
+
+
+ def CASE3(self,main) :
+ """
+ Assign intents
+
+ """
+ import time
+ import json
+ import re
+ main.log.report("Adding host intents")
+ main.case("Adding host Intents")
+
+ main.step("Discovering Hosts( Via pingall for now)")
+ #FIXME: Once we have a host discovery mechanism, use that instead
+
+ #REACTIVE FWD test
+ ping_result = main.FALSE
+ time1 = time.time()
+ ping_result = main.Mininet1.pingall()
+ time2 = time.time()
+ main.log.info("Time for pingall: %2f seconds" % (time2 - time1))
+
+ #uninstall onos-app-fwd
+ main.log.info("Uninstall reactive forwarding app")
+ main.ONOScli1.feature_uninstall("onos-app-fwd")
+ main.ONOScli2.feature_uninstall("onos-app-fwd")
+ main.ONOScli3.feature_uninstall("onos-app-fwd")
+ main.ONOScli4.feature_uninstall("onos-app-fwd")
+ main.ONOScli5.feature_uninstall("onos-app-fwd")
+ main.ONOScli6.feature_uninstall("onos-app-fwd")
+ main.ONOScli7.feature_uninstall("onos-app-fwd")
+
+ main.step("Add host intents")
+ #TODO: move the host numbers to params
+ import json
+ intents_json= json.loads(main.ONOScli1.hosts())
+ intent_add_result = main.FALSE
+ for i in range(8,18):
+ main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+ host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+ host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+ #NOTE: get host can return None
+ #TODO: handle this
+ host1_id = main.ONOScli1.get_host(host1)['id']
+ host2_id = main.ONOScli1.get_host(host2)['id']
+ tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
+ intent_add_result = intent_add_result and tmp_result
+ #TODO Check if intents all exist in datastore
+ #NOTE: Do we need to print this once the test is working?
+ #main.log.info(json.dumps(json.loads(main.ONOScli1.intents(json_format=True)),
+ # sort_keys=True, indent=4, separators=(',', ': ') ) )
+
+ def CASE4(self,main) :
+ """
+ Ping across added host intents
+ """
+ description = " Ping across added host intents"
+ main.log.report(description)
+ main.case(description)
+ Ping_Result = main.TRUE
+ for i in range(8,18):
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+ Ping_Result = Ping_Result and ping
+ if ping==main.FALSE:
+ main.log.warn("Ping failed between h"+str(i)+" and h" + str(i+10))
+ elif ping==main.TRUE:
+ main.log.info("Ping test passed!")
+ Ping_Result = main.TRUE
+ if Ping_Result==main.FALSE:
+ main.log.report("Intents have not been installed correctly, pings failed.")
+ if Ping_Result==main.TRUE:
+ main.log.report("Intents have been installed correctly and verified by pings")
+ utilities.assert_equals(expect = main.TRUE,actual=Ping_Result,
+ onpass="Intents have been installed correctly and pings work",
+ onfail ="Intents have not been installed correctly, pings failed." )
+
+ def CASE5(self,main) :
+ '''
+ Reading state of ONOS
+ '''
+ import time
+ import json
+ from subprocess import Popen, PIPE
+ from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+
+ main.log.report("Setting up and gathering data for current state")
+ main.case("Setting up and gathering data for current state")
+ #The general idea for this test case is to pull the state of (intents,flows, topology,...) from each ONOS node
+ #We can then compare them with eachother and also with past states
+
+ main.step("Get the Mastership of each switch from each controller")
+ global mastership_state
+ ONOS1_mastership = main.ONOScli1.roles()
+ ONOS2_mastership = main.ONOScli2.roles()
+ ONOS3_mastership = main.ONOScli3.roles()
+ ONOS4_mastership = main.ONOScli4.roles()
+ ONOS5_mastership = main.ONOScli5.roles()
+ ONOS6_mastership = main.ONOScli6.roles()
+ ONOS7_mastership = main.ONOScli7.roles()
+ #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+ if "Error" in ONOS1_mastership or not ONOS1_mastership\
+ or "Error" in ONOS2_mastership or not ONOS2_mastership\
+ or "Error" in ONOS3_mastership or not ONOS3_mastership\
+ or "Error" in ONOS4_mastership or not ONOS4_mastership\
+ or "Error" in ONOS5_mastership or not ONOS5_mastership\
+ or "Error" in ONOS6_mastership or not ONOS6_mastership\
+ or "Error" in ONOS7_mastership or not ONOS7_mastership:
+ main.log.report("Error in getting ONOS roles")
+ main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+ main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership))
+ main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership))
+ main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership))
+ main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership))
+ main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership))
+ main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership))
+ consistent_mastership = main.FALSE
+ elif ONOS1_mastership == ONOS2_mastership\
+ and ONOS1_mastership == ONOS3_mastership\
+ and ONOS1_mastership == ONOS4_mastership\
+ and ONOS1_mastership == ONOS5_mastership\
+ and ONOS1_mastership == ONOS6_mastership\
+ and ONOS1_mastership == ONOS7_mastership:
+ mastership_state = ONOS1_mastership
+ consistent_mastership = main.TRUE
+ main.log.report("Switch roles are consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ consistent_mastership = main.FALSE
+ utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+ onpass="Switch roles are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of switch roles")
+
+
+ main.step("Get the intents from each controller")
+ global intent_state
+ ONOS1_intents = main.ONOScli1.intents( json_format=True )
+ ONOS2_intents = main.ONOScli2.intents( json_format=True )
+ ONOS3_intents = main.ONOScli3.intents( json_format=True )
+ ONOS4_intents = main.ONOScli4.intents( json_format=True )
+ ONOS5_intents = main.ONOScli5.intents( json_format=True )
+ ONOS6_intents = main.ONOScli6.intents( json_format=True )
+ ONOS7_intents = main.ONOScli7.intents( json_format=True )
+ intent_check = main.FALSE
+ if "Error" in ONOS1_intents or not ONOS1_intents\
+ or "Error" in ONOS2_intents or not ONOS2_intents\
+ or "Error" in ONOS3_intents or not ONOS3_intents\
+ or "Error" in ONOS4_intents or not ONOS4_intents\
+ or "Error" in ONOS5_intents or not ONOS5_intents\
+ or "Error" in ONOS6_intents or not ONOS6_intents\
+ or "Error" in ONOS7_intents or not ONOS7_intents:
+ main.log.report("Error in getting ONOS intents")
+ main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+ main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents))
+ main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents))
+ main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents))
+ main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents))
+ main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents))
+ main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents))
+ elif ONOS1_intents == ONOS2_intents\
+ and ONOS1_intents == ONOS3_intents\
+ and ONOS1_intents == ONOS4_intents\
+ and ONOS1_intents == ONOS5_intents\
+ and ONOS1_intents == ONOS6_intents\
+ and ONOS1_intents == ONOS7_intents:
+ intent_state = ONOS1_intents
+ intent_check = main.TRUE
+ main.log.report("Intents are consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+ onpass="Intents are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of intents")
+
+
+ main.step("Get the flows from each controller")
+ global flow_state
+ ONOS1_flows = main.ONOScli1.flows( json_format=True )
+ ONOS2_flows = main.ONOScli2.flows( json_format=True )
+ ONOS3_flows = main.ONOScli3.flows( json_format=True )
+ ONOS4_flows = main.ONOScli4.flows( json_format=True )
+ ONOS5_flows = main.ONOScli5.flows( json_format=True )
+ ONOS6_flows = main.ONOScli6.flows( json_format=True )
+ ONOS7_flows = main.ONOScli7.flows( json_format=True )
+ flow_check = main.FALSE
+ if "Error" in ONOS1_flows or not ONOS1_flows\
+ or "Error" in ONOS2_flows or not ONOS2_flows\
+ or "Error" in ONOS3_flows or not ONOS3_flows\
+ or "Error" in ONOS4_flows or not ONOS4_flows\
+ or "Error" in ONOS5_flows or not ONOS5_flows\
+ or "Error" in ONOS6_flows or not ONOS6_flows\
+ or "Error" in ONOS7_flows or not ONOS7_flows:
+ main.log.report("Error in getting ONOS intents")
+ main.log.warn("ONOS1 flows repsponse: "+ ONOS1_flows)
+ main.log.warn("ONOS2 flows repsponse: "+ ONOS2_flows)
+ main.log.warn("ONOS3 flows repsponse: "+ ONOS3_flows)
+ main.log.warn("ONOS4 flows repsponse: "+ ONOS4_flows)
+ main.log.warn("ONOS5 flows repsponse: "+ ONOS5_flows)
+ main.log.warn("ONOS6 flows repsponse: "+ ONOS6_flows)
+ main.log.warn("ONOS7 flows repsponse: "+ ONOS7_flows)
+ elif len(json.loads(ONOS1_flows)) == len(json.loads(ONOS2_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS3_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS4_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS5_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS6_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS7_flows)):
+ #TODO: Do a better check, maybe compare flows on switches?
+ flow_state = ONOS1_flows
+ flow_check = main.TRUE
+ main.log.report("Flow count is consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 flows: "+ json.dumps(json.loads(ONOS1_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 flows: "+ json.dumps(json.loads(ONOS2_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 flows: "+ json.dumps(json.loads(ONOS3_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 flows: "+ json.dumps(json.loads(ONOS4_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 flows: "+ json.dumps(json.loads(ONOS5_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 flows: "+ json.dumps(json.loads(ONOS6_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 flows: "+ json.dumps(json.loads(ONOS7_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ utilities.assert_equals(expect = main.TRUE,actual=flow_check,
+ onpass="The flow count is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different flow counts")
+
+
+ main.step("Get the OF Table entries")
+ global flows
+ flows=[]
+ for i in range(1,29):
+ flows.append(main.Mininet2.get_flowTable("s"+str(i),1.0))
+
+ #TODO: Compare switch flow tables with ONOS flow tables
+
+ main.step("Start continuous pings")
+ main.Mininet2.pingLong(src=main.params['PING']['source1'],
+ target=main.params['PING']['target1'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source2'],
+ target=main.params['PING']['target2'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source3'],
+ target=main.params['PING']['target3'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source4'],
+ target=main.params['PING']['target4'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source5'],
+ target=main.params['PING']['target5'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source6'],
+ target=main.params['PING']['target6'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source7'],
+ target=main.params['PING']['target7'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source8'],
+ target=main.params['PING']['target8'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source9'],
+ target=main.params['PING']['target9'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source10'],
+ target=main.params['PING']['target10'],pingTime=500)
+
+ main.step("Create TestONTopology object")
+ ctrls = []
+ count = 1
+ while True:
+ temp = ()
+ if ('ip' + str(count)) in main.params['CTRL']:
+ temp = temp + (getattr(main,('ONOS' + str(count))),)
+ temp = temp + ("ONOS"+str(count),)
+ temp = temp + (main.params['CTRL']['ip'+str(count)],)
+ temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+ ctrls.append(temp)
+ count = count + 1
+ else:
+ break
+ MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+ main.step("Collecting topology information from ONOS")
+ devices = []
+ devices.append( main.ONOScli1.devices() )
+ devices.append( main.ONOScli2.devices() )
+ devices.append( main.ONOScli3.devices() )
+ devices.append( main.ONOScli4.devices() )
+ devices.append( main.ONOScli5.devices() )
+ devices.append( main.ONOScli6.devices() )
+ devices.append( main.ONOScli7.devices() )
+ '''
+ hosts = []
+ hosts.append( main.ONOScli1.hosts() )
+ hosts.append( main.ONOScli2.hosts() )
+ hosts.append( main.ONOScli3.hosts() )
+ hosts.append( main.ONOScli4.hosts() )
+ hosts.append( main.ONOScli5.hosts() )
+ hosts.append( main.ONOScli6.hosts() )
+ hosts.append( main.ONOScli7.hosts() )
+ '''
+ ports = []
+ ports.append( main.ONOScli1.ports() )
+ ports.append( main.ONOScli2.ports() )
+ ports.append( main.ONOScli3.ports() )
+ ports.append( main.ONOScli4.ports() )
+ ports.append( main.ONOScli5.ports() )
+ ports.append( main.ONOScli6.ports() )
+ ports.append( main.ONOScli7.ports() )
+ links = []
+ links.append( main.ONOScli1.links() )
+ links.append( main.ONOScli2.links() )
+ links.append( main.ONOScli3.links() )
+ links.append( main.ONOScli4.links() )
+ links.append( main.ONOScli5.links() )
+ links.append( main.ONOScli6.links() )
+ links.append( main.ONOScli7.links() )
+
+
+ main.step("Comparing ONOS topology to MN")
+ devices_results = main.TRUE
+ ports_results = main.TRUE
+ links_results = main.TRUE
+ for controller in range(7): #TODO parameterize the number of controllers
+ if devices[controller] or not "Error" in devices[controller]:
+ current_devices_result = main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+ else:
+ current_devices_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+ onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+ onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+ if ports[controller] or not "Error" in ports[controller]:
+ current_ports_result = main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+ else:
+ current_ports_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+ onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+ onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+ if links[controller] or not "Error" in links[controller]:
+ current_links_result = main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+ else:
+ current_links_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+ onpass="ONOS"+str(int(controller+1))+" links view is correct",
+ onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+
+ devices_results = devices_results and current_devices_result
+ ports_results = ports_results and current_ports_result
+ links_results = links_results and current_links_result
+
+ topo_result = devices_results and ports_results and links_results
+ utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful")
+
+ final_assert = main.TRUE
+ final_assert = final_assert and topo_result and flow_check \
+ and intent_check and consistent_mastership
+ utilities.assert_equals(expect=main.TRUE, actual=final_assert,
+ onpass="State check successful",
+ onfail="State check NOT successful")
+
+
+ def CASE6(self,main) :
+ '''
+ The Failure case.
+ '''
+ main.log.report("Restart entire ONOS cluster")
+ main.log.case("Restart entire ONOS cluster")
+ main.ONOSbench.onos_kill(ONOS1_ip)
+ main.ONOSbench.onos_kill(ONOS2_ip)
+ main.ONOSbench.onos_kill(ONOS3_ip)
+ main.ONOSbench.onos_kill(ONOS4_ip)
+ main.ONOSbench.onos_kill(ONOS5_ip)
+ main.ONOSbench.onos_kill(ONOS6_ip)
+ main.ONOSbench.onos_kill(ONOS7_ip)
+
+ main.step("Checking if ONOS is up yet")
+ count = 0
+ onos_isup_result = main.FALSE
+ while onos_isup_result == main.FALSE and count < 10:
+ onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+ onos2_isup = main.ONOSbench.isup(ONOS2_ip)
+ onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+ onos4_isup = main.ONOSbench.isup(ONOS4_ip)
+ onos5_isup = main.ONOSbench.isup(ONOS5_ip)
+ onos6_isup = main.ONOSbench.isup(ONOS6_ip)
+ onos7_isup = main.ONOSbench.isup(ONOS7_ip)
+ onos_isup_result = onos1_isup and onos2_isup and onos3_isup\
+ and onos4_isup and onos5_isup and onos6_isup and onos7_isup
+ count = count + 1
+ # TODO: if it becomes an issue, we can retry this step a few times
+
+
+ cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip)
+ cli_result2 = main.ONOScli2.start_onos_cli(ONOS2_ip)
+ cli_result3 = main.ONOScli3.start_onos_cli(ONOS3_ip)
+ cli_result4 = main.ONOScli4.start_onos_cli(ONOS4_ip)
+ cli_result5 = main.ONOScli5.start_onos_cli(ONOS5_ip)
+ cli_result6 = main.ONOScli6.start_onos_cli(ONOS6_ip)
+ cli_result7 = main.ONOScli7.start_onos_cli(ONOS7_ip)
+ cli_results = cli_result1 and cli_result2 and cli_result3\
+ and cli_result4 and cli_result5 and cli_result6\
+ and cli_result7
+
+ case_results = main.TRUE and onos_isup_result and cli_results
+ utilities.assert_equals(expect=main.TRUE, actual=case_results,
+ onpass="ONOS restart successful",
+ onfail="ONOS restart NOT successful")
+
+
+ def CASE7(self,main) :
+ '''
+ Check state after ONOS failure
+ '''
+ import os
+ import json
+ main.case("Running ONOS Constant State Tests")
+
+ main.step("Check if switch roles are consistent across all nodes")
+ ONOS1_mastership = main.ONOScli1.roles()
+ ONOS2_mastership = main.ONOScli2.roles()
+ ONOS3_mastership = main.ONOScli3.roles()
+ ONOS4_mastership = main.ONOScli4.roles()
+ ONOS5_mastership = main.ONOScli5.roles()
+ ONOS6_mastership = main.ONOScli6.roles()
+ ONOS7_mastership = main.ONOScli7.roles()
+ #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+ if "Error" in ONOS1_mastership or not ONOS1_mastership\
+ or "Error" in ONOS2_mastership or not ONOS2_mastership\
+ or "Error" in ONOS3_mastership or not ONOS3_mastership\
+ or "Error" in ONOS4_mastership or not ONOS4_mastership\
+ or "Error" in ONOS5_mastership or not ONOS5_mastership\
+ or "Error" in ONOS6_mastership or not ONOS6_mastership\
+ or "Error" in ONOS7_mastership or not ONOS7_mastership:
+ main.log.error("Error in getting ONOS mastership")
+ main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+ main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership))
+ main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership))
+ main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership))
+ main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership))
+ main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership))
+ main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership))
+ consistent_mastership = main.FALSE
+ elif ONOS1_mastership == ONOS2_mastership\
+ and ONOS1_mastership == ONOS3_mastership\
+ and ONOS1_mastership == ONOS4_mastership\
+ and ONOS1_mastership == ONOS5_mastership\
+ and ONOS1_mastership == ONOS6_mastership\
+ and ONOS1_mastership == ONOS7_mastership:
+ #mastership_state = ONOS1_mastership
+ consistent_mastership = main.TRUE
+ main.log.report("Switch roles are consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ consistent_mastership = main.FALSE
+ utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+ onpass="Switch roles are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of switch roles")
+
+
+ description2 = "Compare switch roles from before failure"
+ main.step(description2)
+
+ current_json = json.loads(ONOS1_mastership)
+ old_json = json.loads(mastership_state)
+ mastership_check = main.TRUE
+ for i in range(1,29):
+ switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i)))
+
+ current = [switch['master'] for switch in current_json if switchDPID in switch['id']]
+ old = [switch['master'] for switch in old_json if switchDPID in switch['id']]
+ if current == old:
+ mastership_check = mastership_check and main.TRUE
+ else:
+ main.log.warn("Mastership of switch %s changed" % switchDPID)
+ mastership_check = main.FALSE
+ if mastership_check == main.TRUE:
+ main.log.report("Mastership of Switches was not changed")
+ utilities.assert_equals(expect=main.TRUE,actual=mastership_check,
+ onpass="Mastership of Switches was not changed",
+ onfail="Mastership of some switches changed")
+ #NOTE: we expect mastership to change on controller failure
+ mastership_check = mastership_check #and consistent_mastership
+
+
+
+ main.step("Get the intents and compare across all nodes")
+ ONOS1_intents = main.ONOScli1.intents( json_format=True )
+ ONOS2_intents = main.ONOScli2.intents( json_format=True )
+ ONOS3_intents = main.ONOScli3.intents( json_format=True )
+ ONOS4_intents = main.ONOScli4.intents( json_format=True )
+ ONOS5_intents = main.ONOScli5.intents( json_format=True )
+ ONOS6_intents = main.ONOScli6.intents( json_format=True )
+ ONOS7_intents = main.ONOScli7.intents( json_format=True )
+ intent_check = main.FALSE
+ if "Error" in ONOS1_intents or not ONOS1_intents\
+ or "Error" in ONOS2_intents or not ONOS2_intents\
+ or "Error" in ONOS3_intents or not ONOS3_intents\
+ or "Error" in ONOS4_intents or not ONOS4_intents\
+ or "Error" in ONOS5_intents or not ONOS5_intents\
+ or "Error" in ONOS6_intents or not ONOS6_intents\
+ or "Error" in ONOS7_intents or not ONOS7_intents:
+ main.log.report("Error in getting ONOS intents")
+ main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+ main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents))
+ main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents))
+ main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents))
+ main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents))
+ main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents))
+ main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents))
+ elif ONOS1_intents == ONOS2_intents\
+ and ONOS1_intents == ONOS3_intents\
+ and ONOS1_intents == ONOS4_intents\
+ and ONOS1_intents == ONOS5_intents\
+ and ONOS1_intents == ONOS6_intents\
+ and ONOS1_intents == ONOS7_intents:
+ intent_check = main.TRUE
+ main.log.report("Intents are consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+ onpass="Intents are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of intents")
+
+ main.step("Compare current intents with intents before the failure")
+ if intent_state == ONOS1_intents:
+ same_intents = main.TRUE
+ main.log.report("Intents are consistent with before failure")
+ #TODO: possibly the states have changed? we may need to figure out what the aceptable states are
+ else:
+ same_intents = main.FALSE
+ utilities.assert_equals(expect = main.TRUE,actual=same_intents,
+ onpass="Intents are consistent with before failure",
+ onfail="The Intents changed during failure")
+ intent_check = intent_check and same_intents
+
+
+
+ main.step("Get the OF Table entries and compare to before component failure")
+ Flow_Tables = main.TRUE
+ flows2=[]
+ for i in range(28):
+ main.log.info("Checking flow table on s" + str(i+1))
+ tmp_flows = main.Mininet2.get_flowTable("s"+str(i+1),1.0)
+ flows2.append(tmp_flows)
+ Flow_Tables = Flow_Tables and main.Mininet2.flow_comp(flow1=flows[i],flow2=tmp_flows)
+ if Flow_Tables == main.FALSE:
+ main.log.info("Differences in flow table for switch: "+str(i+1))
+ break
+ if Flow_Tables == main.TRUE:
+ main.log.report("No changes were found in the flow tables")
+ utilities.assert_equals(expect=main.TRUE,actual=Flow_Tables,
+ onpass="No changes were found in the flow tables",
+ onfail="Changes were found in the flow tables")
+
+ main.step("Check the continuous pings to ensure that no packets were dropped during component failure")
+ #FIXME: This check is always failing. Investigate cause
+ #NOTE: this may be something to do with file permsissions
+ # or slight change in format
+ main.Mininet2.pingKill(main.params['TESTONUSER'], main.params['TESTONIP'])
+ Loss_In_Pings = main.FALSE
+ #NOTE: checkForLoss returns main.FALSE with 0% packet loss
+ for i in range(8,18):
+ main.log.info("Checking for a loss in pings along flow from s" + str(i))
+ Loss_In_Pings = Loss_In_Pings or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i))
+ if Loss_In_Pings == main.TRUE:
+ main.log.info("Loss in ping detected")
+ elif Loss_In_Pings == main.ERROR:
+ main.log.info("There are multiple mininet process running")
+ elif Loss_In_Pings == main.FALSE:
+ main.log.info("No Loss in the pings")
+ main.log.report("No loss of dataplane connectivity")
+ utilities.assert_equals(expect=main.FALSE,actual=Loss_In_Pings,
+ onpass="No Loss of connectivity",
+ onfail="Loss of dataplane connectivity detected")
+
+
+ #TODO:add topology to this or leave as a seperate case?
+ result = mastership_check and intent_check and Flow_Tables and (not Loss_In_Pings)
+ result = int(result)
+ if result == main.TRUE:
+ main.log.report("Constant State Tests Passed")
+ utilities.assert_equals(expect=main.TRUE,actual=result,
+ onpass="Constant State Tests Passed",
+ onfail="Constant state tests failed")
+
+ def CASE8 (self,main):
+ '''
+ Compare topo
+ '''
+ import sys
+ sys.path.append("/home/admin/sts") # Trying to remove some dependancies, #FIXME add this path to params
+ from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+ import json
+ import time
+
+ description ="Compare ONOS Topology view to Mininet topology"
+ main.case(description)
+ main.log.report(description)
+ main.step("Create TestONTopology object")
+ ctrls = []
+ count = 1
+ while True:
+ temp = ()
+ if ('ip' + str(count)) in main.params['CTRL']:
+ temp = temp + (getattr(main,('ONOS' + str(count))),)
+ temp = temp + ("ONOS"+str(count),)
+ temp = temp + (main.params['CTRL']['ip'+str(count)],)
+ temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+ ctrls.append(temp)
+ count = count + 1
+ else:
+ break
+ MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+ main.step("Comparing ONOS topology to MN")
+ devices_results = main.TRUE
+ ports_results = main.TRUE
+ links_results = main.TRUE
+ topo_result = main.FALSE
+ start_time = time.time()
+ elapsed = 0
+ count = 0
+ while topo_result == main.FALSE and elapsed < 120:
+ count = count + 1
+ try:
+ main.step("Collecting topology information from ONOS")
+ devices = []
+ devices.append( main.ONOScli1.devices() )
+ devices.append( main.ONOScli2.devices() )
+ devices.append( main.ONOScli3.devices() )
+ devices.append( main.ONOScli4.devices() )
+ devices.append( main.ONOScli5.devices() )
+ devices.append( main.ONOScli6.devices() )
+ devices.append( main.ONOScli7.devices() )
+ '''
+ hosts = []
+ hosts.append( main.ONOScli1.hosts() )
+ hosts.append( main.ONOScli2.hosts() )
+ hosts.append( main.ONOScli3.hosts() )
+ hosts.append( main.ONOScli4.hosts() )
+ hosts.append( main.ONOScli5.hosts() )
+ hosts.append( main.ONOScli6.hosts() )
+ hosts.append( main.ONOScli7.hosts() )
+ '''
+ ports = []
+ ports.append( main.ONOScli1.ports() )
+ ports.append( main.ONOScli2.ports() )
+ ports.append( main.ONOScli3.ports() )
+ ports.append( main.ONOScli4.ports() )
+ ports.append( main.ONOScli5.ports() )
+ ports.append( main.ONOScli6.ports() )
+ ports.append( main.ONOScli7.ports() )
+ links = []
+ links.append( main.ONOScli1.links() )
+ links.append( main.ONOScli2.links() )
+ links.append( main.ONOScli3.links() )
+ links.append( main.ONOScli4.links() )
+ links.append( main.ONOScli5.links() )
+ links.append( main.ONOScli6.links() )
+ links.append( main.ONOScli7.links() )
+
+ for controller in range(7): #TODO parameterize the number of controllers
+ if devices[controller] or not "Error" in devices[controller]:
+ current_devices_result = main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+ else:
+ current_devices_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+ onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+ onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+ if ports[controller] or not "Error" in ports[controller]:
+ current_ports_result = main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+ else:
+ current_ports_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+ onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+ onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+ if links[controller] or not "Error" in links[controller]:
+ current_links_result = main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+ else:
+ current_links_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+ onpass="ONOS"+str(int(controller+1))+" links view is correct",
+ onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+ except:
+ main.log.error("something went wrong in topo comparison")
+ main.log.warn( repr( devices ) )
+ main.log.warn( repr( ports ) )
+ main.log.warn( repr( links ) )
+
+ devices_results = devices_results and current_devices_result
+ ports_results = ports_results and current_ports_result
+ links_results = links_results and current_links_result
+ topo_result = devices_results and ports_results and links_results
+ elapsed = time.time() - start_time
+ time_threshold = elapsed < 1
+ topo_result = topo_result and time_threshold
+ #TODO make sure this step is non-blocking. IE add a timeout
+ main.log.report("Very crass estimate for topology discovery/convergence: " +\
+ str(elapsed) + " seconds, " + str(count) +" tries" )
+ utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful")
+ if topo_result == main.TRUE:
+ main.log.report("ONOS topology view matches Mininet topology")
+
+
+ def CASE9 (self,main):
+ '''
+ Link s3-s28 down
+ '''
+ #NOTE: You should probably run a topology check after this
+
+ link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+ description = "Turn off a link to ensure that Link Discovery is working properly"
+ main.log.report(description)
+ main.case(description)
+
+
+ main.step("Kill Link between s3 and s28")
+ Link_Down = main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
+ main.log.info("Waiting " + str(link_sleep) + " seconds for link down to be discovered")
+ time.sleep(link_sleep)
+ utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
+ onpass="Link down succesful",
+ onfail="Failed to bring link down")
+ #TODO do some sort of check here
+
+ def CASE10 (self,main):
+ '''
+ Link s3-s28 up
+ '''
+ #NOTE: You should probably run a topology check after this
+
+ link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+ description = "Restore a link to ensure that Link Discovery is working properly"
+ main.log.report(description)
+ main.case(description)
+
+ main.step("Bring link between s3 and s28 back up")
+ Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
+ main.log.info("Waiting " + str(link_sleep) + " seconds for link up to be discovered")
+ time.sleep(link_sleep)
+ utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
+ onpass="Link up succesful",
+ onfail="Failed to bring link up")
+ #TODO do some sort of check here
+
+
+ def CASE11 (self, main) :
+ '''
+ Switch Down
+ '''
+ #NOTE: You should probably run a topology check after this
+ import time
+
+ switch_sleep = int(main.params['timers']['SwitchDiscovery'])
+
+ description = "Killing a switch to ensure it is discovered correctly"
+ main.log.report(description)
+ main.case(description)
+
+ #TODO: Make this switch parameterizable
+ main.step("Kill s28 ")
+ main.log.report("Deleting s28")
+ #FIXME: use new dynamic topo functions
+ main.Mininet1.del_switch("s28")
+ main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered")
+ time.sleep(switch_sleep)
+ #Peek at the deleted switch
+ main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+ #TODO do some sort of check here
+
+ def CASE12 (self, main) :
+ '''
+ Switch Up
+ '''
+ #NOTE: You should probably run a topology check after this
+ import time
+ #FIXME: use new dynamic topo functions
+ description = "Adding a switch to ensure it is discovered correctly"
+ main.log.report(description)
+ main.case(description)
+
+ main.step("Add back s28")
+ main.log.report("Adding back s28")
+ main.Mininet1.add_switch("s28", dpid = '0000000000002800')
+ #TODO: New dpid or same? Ask Thomas?
+ main.Mininet1.add_link('s28', 's3')
+ main.Mininet1.add_link('s28', 's6')
+ main.Mininet1.add_link('s28', 'h28')
+ main.Mininet1.assign_sw_controller(sw="28",count=7,
+ ip1=ONOS1_ip,port1=ONOS1_port,
+ ip2=ONOS2_ip,port2=ONOS2_port,
+ ip3=ONOS3_ip,port3=ONOS3_port,
+ ip4=ONOS4_ip,port4=ONOS4_port,
+ ip5=ONOS5_ip,port5=ONOS5_port,
+ ip6=ONOS6_ip,port6=ONOS6_port,
+ ip7=ONOS7_ip,port7=ONOS7_port)
+ main.log.info("Waiting " + str(switch_sleep) + " seconds for switch up to be discovered")
+ time.sleep(switch_sleep)
+ #Peek at the added switch
+ main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+ #TODO do some sort of check here
+
+ def CASE13 (self, main) :
+ '''
+ Clean up
+ '''
+ import os
+ import time
+ description = "Test Cleanup"
+ main.log.report(description)
+ main.case(description)
+ main.step("Killing tcpdumps")
+ main.Mininet2.stop_tcpdump()
+
+ main.step("Copying MN pcap and ONOS log files to test station")
+ testname = main.TEST
+ #NOTE: MN Pcap file is being saved to ~/packet_captures
+ # scp this file as MN and TestON aren't necessarily the same vm
+ #FIXME: scp
+ #####mn files
+ #TODO: Load these from params
+ #NOTE: must end in /
+ log_folder = "/opt/onos/log/"
+ log_files = ["karaf.log", "karaf.log.1"]
+ #NOTE: must end in /
+ dst_dir = "~/packet_captures/"
+ for f in log_files:
+ main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS1-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS2_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS2-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS3_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS3-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS4_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS4-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS5_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS5-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS6_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS6-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS7_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS7-"+f )
+
+ #std*.log's
+ #NOTE: must end in /
+ log_folder = "/opt/onos/var/"
+ log_files = ["stderr.log", "stdout.log"]
+ #NOTE: must end in /
+ dst_dir = "~/packet_captures/"
+ for f in log_files:
+ main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS1-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS2_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS2-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS3_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS3-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS4_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS4-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS5_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS5-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS6_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS6-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS7_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS7-"+f )
+
+
+
+
+ #sleep so scp can finish
+ time.sleep(10)
+ main.step("Packing and rotating pcap archives")
+ os.system("~/TestON/dependencies/rotate.sh "+ str(testname))
+
+
+ #TODO: actually check something here
+ utilities.assert_equals(expect=main.TRUE, actual=main.TRUE,
+ onpass="Test cleanup successful",
+ onfail="Test cleanup NOT successful")
diff --git a/TestON/tests/HATestClusterRestart/HATestClusterRestart.topo b/TestON/tests/HATestClusterRestart/HATestClusterRestart.topo
new file mode 100644
index 0000000..4d4156c
--- /dev/null
+++ b/TestON/tests/HATestClusterRestart/HATestClusterRestart.topo
@@ -0,0 +1,173 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli1>
+
+ <ONOScli2>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli2>
+
+ <ONOScli3>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli3>
+
+
+ <ONOScli4>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli4>
+
+
+ <ONOScli5>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli5>
+
+
+ <ONOScli6>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli6>
+
+
+ <ONOScli7>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli7>
+
+ <ONOS1>
+ <host>10.128.30.11</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.30.12</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>10</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.30.13</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>11</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <ONOS4>
+ <host>10.128.30.14</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>12</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4>
+
+ <ONOS5>
+ <host>10.128.30.15</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>13</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5>
+
+ <ONOS6>
+ <host>10.128.30.16</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>14</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6>
+
+ <ONOS7>
+ <host>10.128.30.17</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>15</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7>
+
+ <Mininet1>
+ <host>10.128.30.9</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>16</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ <Mininet2>
+ <host>10.128.30.9</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>17</connect_order>
+ <COMPONENTS>
+ # Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo --arp</arg2>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet2>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/HATestClusterRestart/__init__.py b/TestON/tests/HATestClusterRestart/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/HATestClusterRestart/__init__.py
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params
new file mode 100644
index 0000000..0a8bd57
--- /dev/null
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.params
@@ -0,0 +1,63 @@
+<PARAMS>
+ <testcases>1,2,8,3,4,5,[6],7,8,4,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+ <ENV>
+ <cellName>HA</cellName>
+ </ENV>
+ <Git>False</Git>
+
+ <CTRL>
+ <ip1>10.128.30.11</ip1>
+ <port1>6633</port1>
+
+ <ip2>10.128.30.12</ip2>
+ <port2>6633</port2>
+
+ <ip3>10.128.30.13</ip3>
+ <port3>6633</port3>
+
+ <ip4>10.128.30.14</ip4>
+ <port4>6633</port4>
+
+ <ip5>10.128.30.15</ip5>
+ <port5>6633</port5>
+
+ <ip6>10.128.30.16</ip6>
+ <port6>6633</port6>
+
+ <ip7>10.128.30.17</ip7>
+ <port7>6633</port7>
+ </CTRL>
+ <TESTONUSER>admin</TESTONUSER>
+ <TESTONIP>10.128.30.10</TESTONIP>
+ <PING>
+ <source1>h8</source1>
+ <source2>h9</source2>
+ <source3>h10</source3>
+ <source4>h11</source4>
+ <source5>h12</source5>
+ <source6>h13</source6>
+ <source7>h14</source7>
+ <source8>h15</source8>
+ <source9>h16</source9>
+ <source10>h17</source10>
+ <target1>10.0.0.18</target1>
+ <target2>10.0.0.19</target2>
+ <target3>10.0.0.20</target3>
+ <target4>10.0.0.21</target4>
+ <target5>10.0.0.22</target5>
+ <target6>10.0.0.23</target6>
+ <target7>10.0.0.24</target7>
+ <target8>10.0.0.25</target8>
+ <target9>10.0.0.26</target9>
+ <target10>10.0.0.27</target10>
+ </PING>
+ <timers>
+ <LinkDiscovery>2</LinkDiscovery>
+ <SwitchDiscovery>2</SwitchDiscovery>
+ </timers>
+ <MNtcpdump>
+ <intf>eth0</intf>
+ <port> </port>
+ <folder>~/packet_captures/</folder>
+ </MNtcpdump>
+</PARAMS>
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
new file mode 100644
index 0000000..2af775d
--- /dev/null
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.py
@@ -0,0 +1,1202 @@
+'''
+Description: This test is to determine if ONOS can handle
+ a minority of it's nodes restarting
+
+List of test cases:
+CASE1: Compile ONOS and push it to the test machines
+CASE2: Assign mastership to controllers
+CASE3: Assign intents
+CASE4: Ping across added host intents
+CASE5: Reading state of ONOS
+CASE6: The Failure case.
+CASE7: Check state after control plane failure
+CASE8: Compare topo
+CASE9: Link s3-s28 down
+CASE10: Link s3-s28 up
+CASE11: Switch down
+CASE12: Switch up
+CASE13: Clean up
+'''
+class HATestMinorityRestart:
+
+ def __init__(self) :
+ self.default = ''
+
+ def CASE1(self,main) :
+ '''
+ CASE1 is to compile ONOS and push it to the test machines
+
+ Startup sequence:
+ git pull
+ mvn clean install
+ onos-package
+ cell <name>
+ onos-verify-cell
+ NOTE: temporary - onos-remove-raft-logs
+ onos-install -f
+ onos-wait-for-start
+ '''
+ import time
+ main.log.report("ONOS HA test: Restart minority of ONOS nodes - initialization")
+ main.case("Setting up test environment")
+
+ # load some vairables from the params file
+ PULL_CODE = False
+ if main.params['Git'] == 'True':
+ PULL_CODE = True
+ cell_name = main.params['ENV']['cellName']
+
+ #set global variables
+ global ONOS1_ip
+ global ONOS1_port
+ global ONOS2_ip
+ global ONOS2_port
+ global ONOS3_ip
+ global ONOS3_port
+ global ONOS4_ip
+ global ONOS4_port
+ global ONOS5_ip
+ global ONOS5_port
+ global ONOS6_ip
+ global ONOS6_port
+ global ONOS7_ip
+ global ONOS7_port
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS1_port = main.params['CTRL']['port1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS2_port = main.params['CTRL']['port2']
+ ONOS3_ip = main.params['CTRL']['ip3']
+ ONOS3_port = main.params['CTRL']['port3']
+ ONOS4_ip = main.params['CTRL']['ip4']
+ ONOS4_port = main.params['CTRL']['port4']
+ ONOS5_ip = main.params['CTRL']['ip5']
+ ONOS5_port = main.params['CTRL']['port5']
+ ONOS6_ip = main.params['CTRL']['ip6']
+ ONOS6_port = main.params['CTRL']['port6']
+ ONOS7_ip = main.params['CTRL']['ip7']
+ ONOS7_port = main.params['CTRL']['port7']
+
+
+ main.step("Applying cell variable to environment")
+ cell_result = main.ONOSbench.set_cell(cell_name)
+ verify_result = main.ONOSbench.verify_cell()
+
+ #FIXME:this is short term fix
+ main.log.report("Removing raft logs")
+ main.ONOSbench.onos_remove_raft_logs()
+ main.log.report("Uninstalling ONOS")
+ main.ONOSbench.onos_uninstall(ONOS1_ip)
+ main.ONOSbench.onos_uninstall(ONOS2_ip)
+ main.ONOSbench.onos_uninstall(ONOS3_ip)
+ main.ONOSbench.onos_uninstall(ONOS4_ip)
+ main.ONOSbench.onos_uninstall(ONOS5_ip)
+ main.ONOSbench.onos_uninstall(ONOS6_ip)
+ main.ONOSbench.onos_uninstall(ONOS7_ip)
+
+ clean_install_result = main.TRUE
+ git_pull_result = main.TRUE
+
+ main.step("Compiling the latest version of ONOS")
+ if PULL_CODE:
+ main.step("Git checkout and pull master")
+ main.ONOSbench.git_checkout("master")
+ git_pull_result = main.ONOSbench.git_pull()
+
+ main.step("Using mvn clean & install")
+ clean_install_result = main.TRUE
+ if git_pull_result == main.TRUE:
+ clean_install_result = main.ONOSbench.clean_install()
+ else:
+ main.log.warn("Did not pull new code so skipping mvn "+ \
+ "clean install")
+ main.ONOSbench.get_version(report=True)
+
+ main.step("Creating ONOS package")
+ package_result = main.ONOSbench.onos_package()
+
+ main.step("Installing ONOS package")
+ onos1_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS1_ip)
+ onos2_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS2_ip)
+ onos3_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS3_ip)
+ onos4_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS4_ip)
+ onos5_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS5_ip)
+ onos6_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS6_ip)
+ onos7_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS7_ip)
+ onos_install_result = onos1_install_result and onos2_install_result\
+ and onos3_install_result and onos4_install_result\
+ and onos5_install_result and onos6_install_result\
+ and onos7_install_result
+ '''
+ #FIXME: work around until onos is less fragile
+ main.ONOSbench.handle.sendline("onos-cluster-install")
+ print main.ONOSbench.handle.expect("\$")
+ onos_install_result = main.TRUE
+ '''
+
+
+ main.step("Checking if ONOS is up yet")
+ #TODO: Refactor
+ # check bundle:list?
+ onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+ if not onos1_isup:
+ main.log.report("ONOS1 didn't start!")
+ onos2_isup = main.ONOSbench.isup(ONOS2_ip)
+ if not onos2_isup:
+ main.log.report("ONOS2 didn't start!")
+ onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+ if not onos3_isup:
+ main.log.report("ONOS3 didn't start!")
+ onos4_isup = main.ONOSbench.isup(ONOS4_ip)
+ if not onos4_isup:
+ main.log.report("ONOS4 didn't start!")
+ onos5_isup = main.ONOSbench.isup(ONOS5_ip)
+ if not onos5_isup:
+ main.log.report("ONOS5 didn't start!")
+ onos6_isup = main.ONOSbench.isup(ONOS6_ip)
+ if not onos6_isup:
+ main.log.report("ONOS6 didn't start!")
+ onos7_isup = main.ONOSbench.isup(ONOS7_ip)
+ if not onos7_isup:
+ main.log.report("ONOS7 didn't start!")
+ onos_isup_result = onos1_isup and onos2_isup and onos3_isup\
+ and onos4_isup and onos5_isup and onos6_isup and onos7_isup
+ # TODO: if it becomes an issue, we can retry this step a few times
+
+
+ cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip)
+ cli_result2 = main.ONOScli2.start_onos_cli(ONOS2_ip)
+ cli_result3 = main.ONOScli3.start_onos_cli(ONOS3_ip)
+ cli_result4 = main.ONOScli4.start_onos_cli(ONOS4_ip)
+ cli_result5 = main.ONOScli5.start_onos_cli(ONOS5_ip)
+ cli_result6 = main.ONOScli6.start_onos_cli(ONOS6_ip)
+ cli_result7 = main.ONOScli7.start_onos_cli(ONOS7_ip)
+ cli_results = cli_result1 and cli_result2 and cli_result3 and\
+ cli_result4 and cli_result5 and cli_result6 and cli_result7
+
+ main.step("Start Packet Capture MN")
+ main.Mininet2.start_tcpdump(
+ str(main.params['MNtcpdump']['folder'])+str(main.TEST)+"-MN.pcap",
+ intf = main.params['MNtcpdump']['intf'],
+ port = main.params['MNtcpdump']['port'])
+
+
+ case1_result = (clean_install_result and package_result and
+ cell_result and verify_result and onos_install_result and
+ onos_isup_result and cli_results)
+
+ utilities.assert_equals(expect=main.TRUE, actual=case1_result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful")
+
+
+ #if case1_result==main.FALSE:
+ # main.cleanup()
+ # main.exit()
+
+ def CASE2(self,main) :
+ '''
+ Assign mastership to controllers
+ '''
+ import time
+ import json
+ import re
+
+
+ '''
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS1_port = main.params['CTRL']['port1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS2_port = main.params['CTRL']['port2']
+ ONOS3_ip = main.params['CTRL']['ip3']
+ ONOS3_port = main.params['CTRL']['port3']
+ ONOS4_ip = main.params['CTRL']['ip4']
+ ONOS4_port = main.params['CTRL']['port4']
+ ONOS5_ip = main.params['CTRL']['ip5']
+ ONOS5_port = main.params['CTRL']['port5']
+ ONOS6_ip = main.params['CTRL']['ip6']
+ ONOS6_port = main.params['CTRL']['port6']
+ ONOS7_ip = main.params['CTRL']['ip7']
+ ONOS7_port = main.params['CTRL']['port7']
+ '''
+
+
+ main.log.report("Assigning switches to controllers")
+ main.case("Assigning Controllers")
+ main.step("Assign switches to controllers")
+
+ for i in range (1,29):
+ main.Mininet1.assign_sw_controller(sw=str(i),count=7,
+ ip1=ONOS1_ip,port1=ONOS1_port,
+ ip2=ONOS2_ip,port2=ONOS2_port,
+ ip3=ONOS3_ip,port3=ONOS3_port,
+ ip4=ONOS4_ip,port4=ONOS4_port,
+ ip5=ONOS5_ip,port5=ONOS5_port,
+ ip6=ONOS6_ip,port6=ONOS6_port,
+ ip7=ONOS7_ip,port7=ONOS7_port)
+
+ mastership_check = main.TRUE
+ for i in range (1,29):
+ response = main.Mininet1.get_sw_controller("s"+str(i))
+ try:
+ main.log.info(str(response))
+ except:
+ main.log.info(repr(response))
+ if re.search("tcp:"+ONOS1_ip,response)\
+ and re.search("tcp:"+ONOS2_ip,response)\
+ and re.search("tcp:"+ONOS3_ip,response)\
+ and re.search("tcp:"+ONOS4_ip,response)\
+ and re.search("tcp:"+ONOS5_ip,response)\
+ and re.search("tcp:"+ONOS6_ip,response)\
+ and re.search("tcp:"+ONOS7_ip,response):
+ mastership_check = mastership_check and main.TRUE
+ else:
+ mastership_check = main.FALSE
+ if mastership_check == main.TRUE:
+ main.log.report("Switch mastership assigned correctly")
+ utilities.assert_equals(expect = main.TRUE,actual=mastership_check,
+ onpass="Switch mastership assigned correctly",
+ onfail="Switches not assigned correctly to controllers")
+
+ #TODO: If assign roles is working reliably then manually
+ # assign mastership to the controller we want
+
+
+ def CASE3(self,main) :
+ """
+ Assign intents
+
+ """
+ import time
+ import json
+ import re
+ main.log.report("Adding host intents")
+ main.case("Adding host Intents")
+
+ main.step("Discovering Hosts( Via pingall for now)")
+ #FIXME: Once we have a host discovery mechanism, use that instead
+
+ #REACTIVE FWD test
+ ping_result = main.FALSE
+ time1 = time.time()
+ ping_result = main.Mininet1.pingall()
+ time2 = time.time()
+ main.log.info("Time for pingall: %2f seconds" % (time2 - time1))
+
+ #uninstall onos-app-fwd
+ main.log.info("Uninstall reactive forwarding app")
+ main.ONOScli1.feature_uninstall("onos-app-fwd")
+ main.ONOScli2.feature_uninstall("onos-app-fwd")
+ main.ONOScli3.feature_uninstall("onos-app-fwd")
+ main.ONOScli4.feature_uninstall("onos-app-fwd")
+ main.ONOScli5.feature_uninstall("onos-app-fwd")
+ main.ONOScli6.feature_uninstall("onos-app-fwd")
+ main.ONOScli7.feature_uninstall("onos-app-fwd")
+
+ main.step("Add host intents")
+ #TODO: move the host numbers to params
+ import json
+ intents_json= json.loads(main.ONOScli1.hosts())
+ intent_add_result = main.FALSE
+ for i in range(8,18):
+ main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+ host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+ host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+ #NOTE: get host can return None
+ #TODO: handle this
+ host1_id = main.ONOScli1.get_host(host1)['id']
+ host2_id = main.ONOScli1.get_host(host2)['id']
+ tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
+ intent_add_result = intent_add_result and tmp_result
+ #TODO Check if intents all exist in datastore
+ #NOTE: Do we need to print this once the test is working?
+ #main.log.info(json.dumps(json.loads(main.ONOScli1.intents(json_format=True)),
+ # sort_keys=True, indent=4, separators=(',', ': ') ) )
+
+ def CASE4(self,main) :
+ """
+ Ping across added host intents
+ """
+ description = " Ping across added host intents"
+ main.log.report(description)
+ main.case(description)
+ Ping_Result = main.TRUE
+ for i in range(8,18):
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+ Ping_Result = Ping_Result and ping
+ if ping==main.FALSE:
+ main.log.warn("Ping failed between h"+str(i)+" and h" + str(i+10))
+ elif ping==main.TRUE:
+ main.log.info("Ping test passed!")
+ Ping_Result = main.TRUE
+ if Ping_Result==main.FALSE:
+ main.log.report("Intents have not been installed correctly, pings failed.")
+ if Ping_Result==main.TRUE:
+ main.log.report("Intents have been installed correctly and verified by pings")
+ utilities.assert_equals(expect = main.TRUE,actual=Ping_Result,
+ onpass="Intents have been installed correctly and pings work",
+ onfail ="Intents have not been installed correctly, pings failed." )
+
+ def CASE5(self,main) :
+ '''
+ Reading state of ONOS
+ '''
+ import time
+ import json
+ from subprocess import Popen, PIPE
+ from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+
+ main.log.report("Setting up and gathering data for current state")
+ main.case("Setting up and gathering data for current state")
+ #The general idea for this test case is to pull the state of (intents,flows, topology,...) from each ONOS node
+ #We can then compare them with eachother and also with past states
+
+ main.step("Get the Mastership of each switch from each controller")
+ global mastership_state
+ ONOS1_mastership = main.ONOScli1.roles()
+ ONOS2_mastership = main.ONOScli2.roles()
+ ONOS3_mastership = main.ONOScli3.roles()
+ ONOS4_mastership = main.ONOScli4.roles()
+ ONOS5_mastership = main.ONOScli5.roles()
+ ONOS6_mastership = main.ONOScli6.roles()
+ ONOS7_mastership = main.ONOScli7.roles()
+ #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+ if "Error" in ONOS1_mastership or not ONOS1_mastership\
+ or "Error" in ONOS2_mastership or not ONOS2_mastership\
+ or "Error" in ONOS3_mastership or not ONOS3_mastership\
+ or "Error" in ONOS4_mastership or not ONOS4_mastership\
+ or "Error" in ONOS5_mastership or not ONOS5_mastership\
+ or "Error" in ONOS6_mastership or not ONOS6_mastership\
+ or "Error" in ONOS7_mastership or not ONOS7_mastership:
+ main.log.report("Error in getting ONOS roles")
+ main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+ main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership))
+ main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership))
+ main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership))
+ main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership))
+ main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership))
+ main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership))
+ consistent_mastership = main.FALSE
+ elif ONOS1_mastership == ONOS2_mastership\
+ and ONOS1_mastership == ONOS3_mastership\
+ and ONOS1_mastership == ONOS4_mastership\
+ and ONOS1_mastership == ONOS5_mastership\
+ and ONOS1_mastership == ONOS6_mastership\
+ and ONOS1_mastership == ONOS7_mastership:
+ mastership_state = ONOS1_mastership
+ consistent_mastership = main.TRUE
+ main.log.report("Switch roles are consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ consistent_mastership = main.FALSE
+ utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+ onpass="Switch roles are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of switch roles")
+
+
+ main.step("Get the intents from each controller")
+ global intent_state
+ ONOS1_intents = main.ONOScli1.intents( json_format=True )
+ ONOS2_intents = main.ONOScli2.intents( json_format=True )
+ ONOS3_intents = main.ONOScli3.intents( json_format=True )
+ ONOS4_intents = main.ONOScli4.intents( json_format=True )
+ ONOS5_intents = main.ONOScli5.intents( json_format=True )
+ ONOS6_intents = main.ONOScli6.intents( json_format=True )
+ ONOS7_intents = main.ONOScli7.intents( json_format=True )
+ intent_check = main.FALSE
+ if "Error" in ONOS1_intents or not ONOS1_intents\
+ or "Error" in ONOS2_intents or not ONOS2_intents\
+ or "Error" in ONOS3_intents or not ONOS3_intents\
+ or "Error" in ONOS4_intents or not ONOS4_intents\
+ or "Error" in ONOS5_intents or not ONOS5_intents\
+ or "Error" in ONOS6_intents or not ONOS6_intents\
+ or "Error" in ONOS7_intents or not ONOS7_intents:
+ main.log.report("Error in getting ONOS intents")
+ main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+ main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents))
+ main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents))
+ main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents))
+ main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents))
+ main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents))
+ main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents))
+ elif ONOS1_intents == ONOS2_intents\
+ and ONOS1_intents == ONOS3_intents\
+ and ONOS1_intents == ONOS4_intents\
+ and ONOS1_intents == ONOS5_intents\
+ and ONOS1_intents == ONOS6_intents\
+ and ONOS1_intents == ONOS7_intents:
+ intent_state = ONOS1_intents
+ intent_check = main.TRUE
+ main.log.report("Intents are consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+ onpass="Intents are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of intents")
+
+
+ main.step("Get the flows from each controller")
+ global flow_state
+ ONOS1_flows = main.ONOScli1.flows( json_format=True )
+ ONOS2_flows = main.ONOScli2.flows( json_format=True )
+ ONOS3_flows = main.ONOScli3.flows( json_format=True )
+ ONOS4_flows = main.ONOScli4.flows( json_format=True )
+ ONOS5_flows = main.ONOScli5.flows( json_format=True )
+ ONOS6_flows = main.ONOScli6.flows( json_format=True )
+ ONOS7_flows = main.ONOScli7.flows( json_format=True )
+ flow_check = main.FALSE
+ if "Error" in ONOS1_flows or not ONOS1_flows\
+ or "Error" in ONOS2_flows or not ONOS2_flows\
+ or "Error" in ONOS3_flows or not ONOS3_flows\
+ or "Error" in ONOS4_flows or not ONOS4_flows\
+ or "Error" in ONOS5_flows or not ONOS5_flows\
+ or "Error" in ONOS6_flows or not ONOS6_flows\
+ or "Error" in ONOS7_flows or not ONOS7_flows:
+ main.log.report("Error in getting ONOS intents")
+ main.log.warn("ONOS1 flows repsponse: "+ ONOS1_flows)
+ main.log.warn("ONOS2 flows repsponse: "+ ONOS2_flows)
+ main.log.warn("ONOS3 flows repsponse: "+ ONOS3_flows)
+ main.log.warn("ONOS4 flows repsponse: "+ ONOS4_flows)
+ main.log.warn("ONOS5 flows repsponse: "+ ONOS5_flows)
+ main.log.warn("ONOS6 flows repsponse: "+ ONOS6_flows)
+ main.log.warn("ONOS7 flows repsponse: "+ ONOS7_flows)
+ elif len(json.loads(ONOS1_flows)) == len(json.loads(ONOS2_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS3_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS4_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS5_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS6_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS7_flows)):
+ #TODO: Do a better check, maybe compare flows on switches?
+ flow_state = ONOS1_flows
+ flow_check = main.TRUE
+ main.log.report("Flow count is consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 flows: "+ json.dumps(json.loads(ONOS1_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 flows: "+ json.dumps(json.loads(ONOS2_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 flows: "+ json.dumps(json.loads(ONOS3_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 flows: "+ json.dumps(json.loads(ONOS4_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 flows: "+ json.dumps(json.loads(ONOS5_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 flows: "+ json.dumps(json.loads(ONOS6_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 flows: "+ json.dumps(json.loads(ONOS7_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ utilities.assert_equals(expect = main.TRUE,actual=flow_check,
+ onpass="The flow count is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different flow counts")
+
+
+ main.step("Get the OF Table entries")
+ global flows
+ flows=[]
+ for i in range(1,29):
+ flows.append(main.Mininet2.get_flowTable("s"+str(i),1.0))
+
+ #TODO: Compare switch flow tables with ONOS flow tables
+
+ main.step("Start continuous pings")
+ main.Mininet2.pingLong(src=main.params['PING']['source1'],
+ target=main.params['PING']['target1'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source2'],
+ target=main.params['PING']['target2'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source3'],
+ target=main.params['PING']['target3'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source4'],
+ target=main.params['PING']['target4'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source5'],
+ target=main.params['PING']['target5'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source6'],
+ target=main.params['PING']['target6'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source7'],
+ target=main.params['PING']['target7'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source8'],
+ target=main.params['PING']['target8'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source9'],
+ target=main.params['PING']['target9'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source10'],
+ target=main.params['PING']['target10'],pingTime=500)
+
+ main.step("Create TestONTopology object")
+ ctrls = []
+ count = 1
+ while True:
+ temp = ()
+ if ('ip' + str(count)) in main.params['CTRL']:
+ temp = temp + (getattr(main,('ONOS' + str(count))),)
+ temp = temp + ("ONOS"+str(count),)
+ temp = temp + (main.params['CTRL']['ip'+str(count)],)
+ temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+ ctrls.append(temp)
+ count = count + 1
+ else:
+ break
+ MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+ main.step("Collecting topology information from ONOS")
+ devices = []
+ devices.append( main.ONOScli1.devices() )
+ devices.append( main.ONOScli2.devices() )
+ devices.append( main.ONOScli3.devices() )
+ devices.append( main.ONOScli4.devices() )
+ devices.append( main.ONOScli5.devices() )
+ devices.append( main.ONOScli6.devices() )
+ devices.append( main.ONOScli7.devices() )
+ '''
+ hosts = []
+ hosts.append( main.ONOScli1.hosts() )
+ hosts.append( main.ONOScli2.hosts() )
+ hosts.append( main.ONOScli3.hosts() )
+ hosts.append( main.ONOScli4.hosts() )
+ hosts.append( main.ONOScli5.hosts() )
+ hosts.append( main.ONOScli6.hosts() )
+ hosts.append( main.ONOScli7.hosts() )
+ '''
+ ports = []
+ ports.append( main.ONOScli1.ports() )
+ ports.append( main.ONOScli2.ports() )
+ ports.append( main.ONOScli3.ports() )
+ ports.append( main.ONOScli4.ports() )
+ ports.append( main.ONOScli5.ports() )
+ ports.append( main.ONOScli6.ports() )
+ ports.append( main.ONOScli7.ports() )
+ links = []
+ links.append( main.ONOScli1.links() )
+ links.append( main.ONOScli2.links() )
+ links.append( main.ONOScli3.links() )
+ links.append( main.ONOScli4.links() )
+ links.append( main.ONOScli5.links() )
+ links.append( main.ONOScli6.links() )
+ links.append( main.ONOScli7.links() )
+
+
+ main.step("Comparing ONOS topology to MN")
+ devices_results = main.TRUE
+ ports_results = main.TRUE
+ links_results = main.TRUE
+ for controller in range(7): #TODO parameterize the number of controllers
+ if devices[controller] or not "Error" in devices[controller]:
+ current_devices_result = main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+ else:
+ current_devices_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+ onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+ onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+ if ports[controller] or not "Error" in ports[controller]:
+ current_ports_result = main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+ else:
+ current_ports_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+ onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+ onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+ if links[controller] or not "Error" in links[controller]:
+ current_links_result = main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+ else:
+ current_links_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+ onpass="ONOS"+str(int(controller+1))+" links view is correct",
+ onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+
+ devices_results = devices_results and current_devices_result
+ ports_results = ports_results and current_ports_result
+ links_results = links_results and current_links_result
+
+ topo_result = devices_results and ports_results and links_results
+ utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful")
+
+ final_assert = main.TRUE
+ final_assert = final_assert and topo_result and flow_check \
+ and intent_check and consistent_mastership
+ utilities.assert_equals(expect=main.TRUE, actual=final_assert,
+ onpass="State check successful",
+ onfail="State check NOT successful")
+
+
+ def CASE6(self,main) :
+ '''
+ The Failure case.
+ '''
+ main.log.report("Killing 3 ONOS nodes")
+ main.log.case("Restart minority of ONOS nodes")
+ #TODO: Randomize these nodes
+ main.ONOSbench.onos_kill(ONOS1_ip)
+ main.ONOSbench.onos_kill(ONOS2_ip)
+ main.ONOSbench.onos_kill(ONOS3_ip)
+
+ main.step("Checking if ONOS is up yet")
+ count = 0
+ onos_isup_result = main.FALSE
+ while onos_isup_result == main.FALSE and count < 10:
+ onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+ onos2_isup = main.ONOSbench.isup(ONOS2_ip)
+ onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+ onos_isup_result = onos1_isup and onos2_isup and onos3_isup
+ count = count + 1
+ # TODO: if it becomes an issue, we can retry this step a few times
+
+
+ cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip)
+ cli_result2 = main.ONOScli2.start_onos_cli(ONOS2_ip)
+ cli_result3 = main.ONOScli3.start_onos_cli(ONOS3_ip)
+ cli_results = cli_result1 and cli_result2 and cli_result3
+
+ case_results = main.TRUE and onos_isup_result and cli_results
+ utilities.assert_equals(expect=main.TRUE, actual=case_results,
+ onpass="ONOS restart successful",
+ onfail="ONOS restart NOT successful")
+
+
+ def CASE7(self,main) :
+ '''
+ Check state after ONOS failure
+ '''
+ import os
+ import json
+ main.case("Running ONOS Constant State Tests")
+
+ main.step("Check if switch roles are consistent across all nodes")
+ ONOS1_mastership = main.ONOScli1.roles()
+ ONOS2_mastership = main.ONOScli2.roles()
+ ONOS3_mastership = main.ONOScli3.roles()
+ ONOS4_mastership = main.ONOScli4.roles()
+ ONOS5_mastership = main.ONOScli5.roles()
+ ONOS6_mastership = main.ONOScli6.roles()
+ ONOS7_mastership = main.ONOScli7.roles()
+ print type(ONOS1_mastership)
+ print ONOS1_mastership
+ print type(ONOS2_mastership)
+ print ONOS2_mastership
+ print type(ONOS3_mastership)
+ print ONOS3_mastership
+ print type(ONOS4_mastership)
+ print ONOS4_mastership
+ print type(ONOS5_mastership)
+ print ONOS5_mastership
+ print type(ONOS6_mastership)
+ print ONOS6_mastership
+ print type(ONOS7_mastership)
+ print ONOS7_mastership
+ #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+ if "Error" in ONOS1_mastership or not ONOS1_mastership\
+ or "Error" in ONOS2_mastership or not ONOS2_mastership\
+ or "Error" in ONOS3_mastership or not ONOS3_mastership\
+ or "Error" in ONOS4_mastership or not ONOS4_mastership\
+ or "Error" in ONOS5_mastership or not ONOS5_mastership\
+ or "Error" in ONOS6_mastership or not ONOS6_mastership\
+ or "Error" in ONOS7_mastership or not ONOS7_mastership:
+ main.log.error("Error in getting ONOS mastership")
+ main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+ main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership))
+ main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership))
+ main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership))
+ main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership))
+ main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership))
+ main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership))
+ consistent_mastership = main.FALSE
+ elif ONOS1_mastership == ONOS2_mastership\
+ and ONOS1_mastership == ONOS3_mastership\
+ and ONOS1_mastership == ONOS4_mastership\
+ and ONOS1_mastership == ONOS5_mastership\
+ and ONOS1_mastership == ONOS6_mastership\
+ and ONOS1_mastership == ONOS7_mastership:
+ #mastership_state = ONOS1_mastership
+ consistent_mastership = main.TRUE
+ main.log.report("Switch roles are consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ consistent_mastership = main.FALSE
+ utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+ onpass="Switch roles are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of switch roles")
+
+
+ description2 = "Compare switch roles from before failure"
+ main.step(description2)
+
+ current_json = json.loads(ONOS1_mastership)
+ old_json = json.loads(mastership_state)
+ mastership_check = main.TRUE
+ for i in range(1,29):
+ switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i)))
+
+ current = [switch['master'] for switch in current_json if switchDPID in switch['id']]
+ old = [switch['master'] for switch in old_json if switchDPID in switch['id']]
+ if current == old:
+ mastership_check = mastership_check and main.TRUE
+ else:
+ main.log.warn("Mastership of switch %s changed" % switchDPID)
+ mastership_check = main.FALSE
+ if mastership_check == main.TRUE:
+ main.log.report("Mastership of Switches was not changed")
+ utilities.assert_equals(expect=main.TRUE,actual=mastership_check,
+ onpass="Mastership of Switches was not changed",
+ onfail="Mastership of some switches changed")
+ #NOTE: we expect mastership to change on controller failure
+ mastership_check = mastership_check #and consistent_mastership
+
+
+
+ main.step("Get the intents and compare across all nodes")
+ ONOS1_intents = main.ONOScli1.intents( json_format=True )
+ ONOS2_intents = main.ONOScli2.intents( json_format=True )
+ ONOS3_intents = main.ONOScli3.intents( json_format=True )
+ ONOS4_intents = main.ONOScli4.intents( json_format=True )
+ ONOS5_intents = main.ONOScli5.intents( json_format=True )
+ ONOS6_intents = main.ONOScli6.intents( json_format=True )
+ ONOS7_intents = main.ONOScli7.intents( json_format=True )
+ intent_check = main.FALSE
+ if "Error" in ONOS1_intents or not ONOS1_intents\
+ or "Error" in ONOS2_intents or not ONOS2_intents\
+ or "Error" in ONOS3_intents or not ONOS3_intents\
+ or "Error" in ONOS4_intents or not ONOS4_intents\
+ or "Error" in ONOS5_intents or not ONOS5_intents\
+ or "Error" in ONOS6_intents or not ONOS6_intents\
+ or "Error" in ONOS7_intents or not ONOS7_intents:
+ main.log.report("Error in getting ONOS intents")
+ main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+ main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents))
+ main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents))
+ main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents))
+ main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents))
+ main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents))
+ main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents))
+ elif ONOS1_intents == ONOS2_intents\
+ and ONOS1_intents == ONOS3_intents\
+ and ONOS1_intents == ONOS4_intents\
+ and ONOS1_intents == ONOS5_intents\
+ and ONOS1_intents == ONOS6_intents\
+ and ONOS1_intents == ONOS7_intents:
+ intent_check = main.TRUE
+ main.log.report("Intents are consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+ onpass="Intents are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of intents")
+
+ main.step("Compare current intents with intents before the failure")
+ if intent_state == ONOS1_intents:
+ same_intents = main.TRUE
+ main.log.report("Intents are consistent with before failure")
+ #TODO: possibly the states have changed? we may need to figure out what the aceptable states are
+ else:
+ same_intents = main.FALSE
+ utilities.assert_equals(expect = main.TRUE,actual=same_intents,
+ onpass="Intents are consistent with before failure",
+ onfail="The Intents changed during failure")
+ intent_check = intent_check and same_intents
+
+
+
+ main.step("Get the OF Table entries and compare to before component failure")
+ Flow_Tables = main.TRUE
+ flows2=[]
+ for i in range(28):
+ main.log.info("Checking flow table on s" + str(i+1))
+ tmp_flows = main.Mininet2.get_flowTable("s"+str(i+1),1.0)
+ flows2.append(tmp_flows)
+ Flow_Tables = Flow_Tables and main.Mininet2.flow_comp(flow1=flows[i],flow2=tmp_flows)
+ if Flow_Tables == main.FALSE:
+ main.log.info("Differences in flow table for switch: "+str(i+1))
+ break
+ if Flow_Tables == main.TRUE:
+ main.log.report("No changes were found in the flow tables")
+ utilities.assert_equals(expect=main.TRUE,actual=Flow_Tables,
+ onpass="No changes were found in the flow tables",
+ onfail="Changes were found in the flow tables")
+
+ main.step("Check the continuous pings to ensure that no packets were dropped during component failure")
+ #FIXME: This check is always failing. Investigate cause
+ #NOTE: this may be something to do with file permsissions
+ # or slight change in format
+ main.Mininet2.pingKill(main.params['TESTONUSER'], main.params['TESTONIP'])
+ Loss_In_Pings = main.FALSE
+ #NOTE: checkForLoss returns main.FALSE with 0% packet loss
+ for i in range(8,18):
+ main.log.info("Checking for a loss in pings along flow from s" + str(i))
+ Loss_In_Pings = Loss_In_Pings or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i))
+ if Loss_In_Pings == main.TRUE:
+ main.log.info("Loss in ping detected")
+ elif Loss_In_Pings == main.ERROR:
+ main.log.info("There are multiple mininet process running")
+ elif Loss_In_Pings == main.FALSE:
+ main.log.info("No Loss in the pings")
+ main.log.report("No loss of dataplane connectivity")
+ utilities.assert_equals(expect=main.FALSE,actual=Loss_In_Pings,
+ onpass="No Loss of connectivity",
+ onfail="Loss of dataplane connectivity detected")
+
+
+ #TODO:add topology to this or leave as a seperate case?
+ result = mastership_check and intent_check and Flow_Tables and (not Loss_In_Pings)
+ result = int(result)
+ if result == main.TRUE:
+ main.log.report("Constant State Tests Passed")
+ utilities.assert_equals(expect=main.TRUE,actual=result,
+ onpass="Constant State Tests Passed",
+ onfail="Constant state tests failed")
+
+ def CASE8 (self,main):
+ '''
+ Compare topo
+ '''
+ import sys
+ sys.path.append("/home/admin/sts") # Trying to remove some dependancies, #FIXME add this path to params
+ from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+ import json
+ import time
+
+ description ="Compare ONOS Topology view to Mininet topology"
+ main.case(description)
+ main.log.report(description)
+ main.step("Create TestONTopology object")
+ ctrls = []
+ count = 1
+ while True:
+ temp = ()
+ if ('ip' + str(count)) in main.params['CTRL']:
+ temp = temp + (getattr(main,('ONOS' + str(count))),)
+ temp = temp + ("ONOS"+str(count),)
+ temp = temp + (main.params['CTRL']['ip'+str(count)],)
+ temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+ ctrls.append(temp)
+ count = count + 1
+ else:
+ break
+ MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+ main.step("Comparing ONOS topology to MN")
+ devices_results = main.TRUE
+ ports_results = main.TRUE
+ links_results = main.TRUE
+ topo_result = main.FALSE
+ start_time = time.time()
+ elapsed = 0
+ count = 0
+ while topo_result == main.FALSE and elapsed < 120:
+ count = count + 1
+ try:
+ main.step("Collecting topology information from ONOS")
+ devices = []
+ devices.append( main.ONOScli1.devices() )
+ devices.append( main.ONOScli2.devices() )
+ devices.append( main.ONOScli3.devices() )
+ devices.append( main.ONOScli4.devices() )
+ devices.append( main.ONOScli5.devices() )
+ devices.append( main.ONOScli6.devices() )
+ devices.append( main.ONOScli7.devices() )
+ '''
+ hosts = []
+ hosts.append( main.ONOScli1.hosts() )
+ hosts.append( main.ONOScli2.hosts() )
+ hosts.append( main.ONOScli3.hosts() )
+ hosts.append( main.ONOScli4.hosts() )
+ hosts.append( main.ONOScli5.hosts() )
+ hosts.append( main.ONOScli6.hosts() )
+ hosts.append( main.ONOScli7.hosts() )
+ '''
+ ports = []
+ ports.append( main.ONOScli1.ports() )
+ ports.append( main.ONOScli2.ports() )
+ ports.append( main.ONOScli3.ports() )
+ ports.append( main.ONOScli4.ports() )
+ ports.append( main.ONOScli5.ports() )
+ ports.append( main.ONOScli6.ports() )
+ ports.append( main.ONOScli7.ports() )
+ links = []
+ links.append( main.ONOScli1.links() )
+ links.append( main.ONOScli2.links() )
+ links.append( main.ONOScli3.links() )
+ links.append( main.ONOScli4.links() )
+ links.append( main.ONOScli5.links() )
+ links.append( main.ONOScli6.links() )
+ links.append( main.ONOScli7.links() )
+
+ for controller in range(7): #TODO parameterize the number of controllers
+ if devices[controller] or not "Error" in devices[controller]:
+ current_devices_result = main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+ else:
+ current_devices_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+ onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+ onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+ if ports[controller] or not "Error" in ports[controller]:
+ current_ports_result = main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+ else:
+ current_ports_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+ onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+ onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+ if links[controller] or not "Error" in links[controller]:
+ current_links_result = main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+ else:
+ current_links_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+ onpass="ONOS"+str(int(controller+1))+" links view is correct",
+ onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+ except:
+ main.log.error("something went wrong in topo comparison")
+ main.log.warn( repr( devices ) )
+ main.log.warn( repr( ports ) )
+ main.log.warn( repr( links ) )
+
+ devices_results = devices_results and current_devices_result
+ ports_results = ports_results and current_ports_result
+ links_results = links_results and current_links_result
+ topo_result = devices_results and ports_results and links_results
+ elapsed = time.time() - start_time
+ time_threshold = elapsed < 1
+ topo_result = topo_result and time_threshold
+ #TODO make sure this step is non-blocking. IE add a timeout
+ main.log.report("Very crass estimate for topology discovery/convergence: " +\
+ str(elapsed) + " seconds, " + str(count) +" tries" )
+ utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful")
+ if topo_result == main.TRUE:
+ main.log.report("ONOS topology view matches Mininet topology")
+
+
+ def CASE9 (self,main):
+ '''
+ Link s3-s28 down
+ '''
+ #NOTE: You should probably run a topology check after this
+
+ link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+ description = "Turn off a link to ensure that Link Discovery is working properly"
+ main.log.report(description)
+ main.case(description)
+
+
+ main.step("Kill Link between s3 and s28")
+ Link_Down = main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
+ main.log.info("Waiting " + str(link_sleep) + " seconds for link down to be discovered")
+ time.sleep(link_sleep)
+ utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
+ onpass="Link down succesful",
+ onfail="Failed to bring link down")
+ #TODO do some sort of check here
+
+ def CASE10 (self,main):
+ '''
+ Link s3-s28 up
+ '''
+ #NOTE: You should probably run a topology check after this
+
+ link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+ description = "Restore a link to ensure that Link Discovery is working properly"
+ main.log.report(description)
+ main.case(description)
+
+ main.step("Bring link between s3 and s28 back up")
+ Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
+ main.log.info("Waiting " + str(link_sleep) + " seconds for link up to be discovered")
+ time.sleep(link_sleep)
+ utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
+ onpass="Link up succesful",
+ onfail="Failed to bring link up")
+ #TODO do some sort of check here
+
+
+ def CASE11 (self, main) :
+ '''
+ Switch Down
+ '''
+ #NOTE: You should probably run a topology check after this
+ import time
+
+ switch_sleep = int(main.params['timers']['SwitchDiscovery'])
+
+ description = "Killing a switch to ensure it is discovered correctly"
+ main.log.report(description)
+ main.case(description)
+
+ #TODO: Make this switch parameterizable
+ main.step("Kill s28 ")
+ main.log.report("Deleting s28")
+ #FIXME: use new dynamic topo functions
+ main.Mininet1.del_switch("s28")
+ main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered")
+ time.sleep(switch_sleep)
+ #Peek at the deleted switch
+ main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+ #TODO do some sort of check here
+
+ def CASE12 (self, main) :
+ '''
+ Switch Up
+ '''
+ #NOTE: You should probably run a topology check after this
+ import time
+ #FIXME: use new dynamic topo functions
+ description = "Adding a switch to ensure it is discovered correctly"
+ main.log.report(description)
+ main.case(description)
+
+ main.step("Add back s28")
+ main.log.report("Adding back s28")
+ main.Mininet1.add_switch("s28", dpid = '0000000000002800')
+ #TODO: New dpid or same? Ask Thomas?
+ main.Mininet1.add_link('s28', 's3')
+ main.Mininet1.add_link('s28', 's6')
+ main.Mininet1.add_link('s28', 'h28')
+ main.Mininet1.assign_sw_controller(sw="28",count=7,
+ ip1=ONOS1_ip,port1=ONOS1_port,
+ ip2=ONOS2_ip,port2=ONOS2_port,
+ ip3=ONOS3_ip,port3=ONOS3_port,
+ ip4=ONOS4_ip,port4=ONOS4_port,
+ ip5=ONOS5_ip,port5=ONOS5_port,
+ ip6=ONOS6_ip,port6=ONOS6_port,
+ ip7=ONOS7_ip,port7=ONOS7_port)
+ main.log.info("Waiting " + str(switch_sleep) + " seconds for switch up to be discovered")
+ time.sleep(switch_sleep)
+ #Peek at the added switch
+ main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+ #TODO do some sort of check here
+
+ def CASE13 (self, main) :
+ '''
+ Clean up
+ '''
+ import os
+ import time
+ description = "Test Cleanup"
+ main.log.report(description)
+ main.case(description)
+ main.step("Killing tcpdumps")
+ main.Mininet2.stop_tcpdump()
+
+ main.step("Copying MN pcap and ONOS log files to test station")
+ testname = main.TEST
+ #NOTE: MN Pcap file is being saved to ~/packet_captures
+ # scp this file as MN and TestON aren't necessarily the same vm
+ #FIXME: scp
+ #####mn files
+ #TODO: Load these from params
+ #NOTE: must end in /
+ log_folder = "/opt/onos/log/"
+ log_files = ["karaf.log", "karaf.log.1"]
+ #NOTE: must end in /
+ dst_dir = "~/packet_captures/"
+ for f in log_files:
+ main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS1-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS2_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS2-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS3_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS3-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS4_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS4-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS5_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS5-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS6_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS6-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS7_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS7-"+f )
+
+ #std*.log's
+ #NOTE: must end in /
+ log_folder = "/opt/onos/var/"
+ log_files = ["stderr.log", "stdout.log"]
+ #NOTE: must end in /
+ dst_dir = "~/packet_captures/"
+ for f in log_files:
+ main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS1-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS2_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS2-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS3_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS3-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS4_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS4-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS5_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS5-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS6_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS6-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS7_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS7-"+f )
+
+
+
+
+ #sleep so scp can finish
+ time.sleep(10)
+ main.step("Packing and rotating pcap archives")
+ os.system("~/TestON/dependencies/rotate.sh "+ str(testname))
+
+
+ #TODO: actually check something here
+ utilities.assert_equals(expect=main.TRUE, actual=main.TRUE,
+ onpass="Test cleanup successful",
+ onfail="Test cleanup NOT successful")
diff --git a/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.topo b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.topo
new file mode 100644
index 0000000..4d4156c
--- /dev/null
+++ b/TestON/tests/HATestMinorityRestart/HATestMinorityRestart.topo
@@ -0,0 +1,173 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli1>
+
+ <ONOScli2>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli2>
+
+ <ONOScli3>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli3>
+
+
+ <ONOScli4>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli4>
+
+
+ <ONOScli5>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli5>
+
+
+ <ONOScli6>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli6>
+
+
+ <ONOScli7>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli7>
+
+ <ONOS1>
+ <host>10.128.30.11</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.30.12</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>10</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.30.13</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>11</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <ONOS4>
+ <host>10.128.30.14</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>12</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4>
+
+ <ONOS5>
+ <host>10.128.30.15</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>13</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5>
+
+ <ONOS6>
+ <host>10.128.30.16</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>14</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6>
+
+ <ONOS7>
+ <host>10.128.30.17</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>15</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7>
+
+ <Mininet1>
+ <host>10.128.30.9</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>16</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ <Mininet2>
+ <host>10.128.30.9</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>17</connect_order>
+ <COMPONENTS>
+ # Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo --arp</arg2>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet2>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/HATestMinorityRestart/__init__.py b/TestON/tests/HATestMinorityRestart/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/HATestMinorityRestart/__init__.py
diff --git a/TestON/tests/HATestSanity/HATestSanity.params b/TestON/tests/HATestSanity/HATestSanity.params
new file mode 100644
index 0000000..e1e75f9
--- /dev/null
+++ b/TestON/tests/HATestSanity/HATestSanity.params
@@ -0,0 +1,63 @@
+<PARAMS>
+ <testcases>1,2,8,3,4,5,[6],7,8,4,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+ <ENV>
+ <cellName>HA</cellName>
+ </ENV>
+ <Git>True</Git>
+
+ <CTRL>
+ <ip1>10.128.30.11</ip1>
+ <port1>6633</port1>
+
+ <ip2>10.128.30.12</ip2>
+ <port2>6633</port2>
+
+ <ip3>10.128.30.13</ip3>
+ <port3>6633</port3>
+
+ <ip4>10.128.30.14</ip4>
+ <port4>6633</port4>
+
+ <ip5>10.128.30.15</ip5>
+ <port5>6633</port5>
+
+ <ip6>10.128.30.16</ip6>
+ <port6>6633</port6>
+
+ <ip7>10.128.30.17</ip7>
+ <port7>6633</port7>
+ </CTRL>
+ <TESTONUSER>admin</TESTONUSER>
+ <TESTONIP>10.128.30.10</TESTONIP>
+ <PING>
+ <source1>h8</source1>
+ <source2>h9</source2>
+ <source3>h10</source3>
+ <source4>h11</source4>
+ <source5>h12</source5>
+ <source6>h13</source6>
+ <source7>h14</source7>
+ <source8>h15</source8>
+ <source9>h16</source9>
+ <source10>h17</source10>
+ <target1>10.0.0.18</target1>
+ <target2>10.0.0.19</target2>
+ <target3>10.0.0.20</target3>
+ <target4>10.0.0.21</target4>
+ <target5>10.0.0.22</target5>
+ <target6>10.0.0.23</target6>
+ <target7>10.0.0.24</target7>
+ <target8>10.0.0.25</target8>
+ <target9>10.0.0.26</target9>
+ <target10>10.0.0.27</target10>
+ </PING>
+ <timers>
+ <LinkDiscovery>2</LinkDiscovery>
+ <SwitchDiscovery>2</SwitchDiscovery>
+ </timers>
+ <MNtcpdump>
+ <intf>eth0</intf>
+ <port> </port>
+ <folder>~/packet_captures/</folder>
+ </MNtcpdump>
+</PARAMS>
diff --git a/TestON/tests/HATestSanity/HATestSanity.py b/TestON/tests/HATestSanity/HATestSanity.py
new file mode 100644
index 0000000..614d514
--- /dev/null
+++ b/TestON/tests/HATestSanity/HATestSanity.py
@@ -0,0 +1,1171 @@
+'''
+Description: This test is to determine if the HA test setup is
+ working correctly. There are no failures so this test should
+ have a 100% pass rate
+
+List of test cases:
+CASE1: Compile ONOS and push it to the test machines
+CASE2: Assign mastership to controllers
+CASE3: Assign intents
+CASE4: Ping across added host intents
+CASE5: Reading state of ONOS
+CASE6: The Failure case. Since this is the Sanity test, we do nothing.
+CASE7: Check state after control plane failure
+CASE8: Compare topo
+CASE9: Link s3-s28 down
+CASE10: Link s3-s28 up
+CASE11: Switch down
+CASE12: Switch up
+CASE13: Clean up
+'''
+class HATestSanity:
+
+ def __init__(self) :
+ self.default = ''
+
+ def CASE1(self,main) :
+ '''
+ CASE1 is to compile ONOS and push it to the test machines
+
+ Startup sequence:
+ git pull
+ mvn clean install
+ onos-package
+ cell <name>
+ onos-verify-cell
+ NOTE: temporary - onos-remove-raft-logs
+ onos-install -f
+ onos-wait-for-start
+ '''
+ import time
+ main.log.report("ONOS HA Sanity test - initialization")
+ main.case("Setting up test environment")
+ #TODO: save all the timers and output them for plotting
+
+ # load some vairables from the params file
+ PULL_CODE = False
+ if main.params['Git'] == 'True':
+ PULL_CODE = True
+ cell_name = main.params['ENV']['cellName']
+
+ #set global variables
+ global ONOS1_ip
+ global ONOS1_port
+ global ONOS2_ip
+ global ONOS2_port
+ global ONOS3_ip
+ global ONOS3_port
+ global ONOS4_ip
+ global ONOS4_port
+ global ONOS5_ip
+ global ONOS5_port
+ global ONOS6_ip
+ global ONOS6_port
+ global ONOS7_ip
+ global ONOS7_port
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS1_port = main.params['CTRL']['port1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS2_port = main.params['CTRL']['port2']
+ ONOS3_ip = main.params['CTRL']['ip3']
+ ONOS3_port = main.params['CTRL']['port3']
+ ONOS4_ip = main.params['CTRL']['ip4']
+ ONOS4_port = main.params['CTRL']['port4']
+ ONOS5_ip = main.params['CTRL']['ip5']
+ ONOS5_port = main.params['CTRL']['port5']
+ ONOS6_ip = main.params['CTRL']['ip6']
+ ONOS6_port = main.params['CTRL']['port6']
+ ONOS7_ip = main.params['CTRL']['ip7']
+ ONOS7_port = main.params['CTRL']['port7']
+
+
+ main.step("Applying cell variable to environment")
+ cell_result = main.ONOSbench.set_cell(cell_name)
+ verify_result = main.ONOSbench.verify_cell()
+
+ #FIXME:this is short term fix
+ main.log.report("Removing raft logs")
+ main.ONOSbench.onos_remove_raft_logs()
+ main.log.report("Uninstalling ONOS")
+ main.ONOSbench.onos_uninstall(ONOS1_ip)
+ main.ONOSbench.onos_uninstall(ONOS2_ip)
+ main.ONOSbench.onos_uninstall(ONOS3_ip)
+ main.ONOSbench.onos_uninstall(ONOS4_ip)
+ main.ONOSbench.onos_uninstall(ONOS5_ip)
+ main.ONOSbench.onos_uninstall(ONOS6_ip)
+ main.ONOSbench.onos_uninstall(ONOS7_ip)
+
+ clean_install_result = main.TRUE
+ git_pull_result = main.TRUE
+
+ main.step("Compiling the latest version of ONOS")
+ if PULL_CODE:
+ main.step("Git checkout and pull master")
+ main.ONOSbench.git_checkout("master")
+ git_pull_result = main.ONOSbench.git_pull()
+
+ main.step("Using mvn clean & install")
+ clean_install_result = main.TRUE
+ if git_pull_result == main.TRUE:
+ clean_install_result = main.ONOSbench.clean_install()
+ else:
+ main.log.warn("Did not pull new code so skipping mvn "+ \
+ "clean install")
+ main.ONOSbench.get_version(report=True)
+
+ main.step("Creating ONOS package")
+ package_result = main.ONOSbench.onos_package()
+
+ main.step("Installing ONOS package")
+ onos1_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS1_ip)
+ onos2_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS2_ip)
+ onos3_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS3_ip)
+ onos4_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS4_ip)
+ onos5_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS5_ip)
+ onos6_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS6_ip)
+ onos7_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS7_ip)
+ onos_install_result = onos1_install_result and onos2_install_result\
+ and onos3_install_result and onos4_install_result\
+ and onos5_install_result and onos6_install_result\
+ and onos7_install_result
+ '''
+ #FIXME: work around until onos is less fragile
+ main.ONOSbench.handle.sendline("onos-cluster-install")
+ print main.ONOSbench.handle.expect("\$")
+ onos_install_result = main.TRUE
+ '''
+
+
+ main.step("Checking if ONOS is up yet")
+ #TODO: Refactor
+ # check bundle:list?
+ for i in range(2):
+ onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+ if not onos1_isup:
+ main.log.report("ONOS1 didn't start!")
+ onos2_isup = main.ONOSbench.isup(ONOS2_ip)
+ if not onos2_isup:
+ main.log.report("ONOS2 didn't start!")
+ onos3_isup = main.ONOSbench.isup(ONOS3_ip)
+ if not onos3_isup:
+ main.log.report("ONOS3 didn't start!")
+ onos4_isup = main.ONOSbench.isup(ONOS4_ip)
+ if not onos4_isup:
+ main.log.report("ONOS4 didn't start!")
+ onos5_isup = main.ONOSbench.isup(ONOS5_ip)
+ if not onos5_isup:
+ main.log.report("ONOS5 didn't start!")
+ onos6_isup = main.ONOSbench.isup(ONOS6_ip)
+ if not onos6_isup:
+ main.log.report("ONOS6 didn't start!")
+ onos7_isup = main.ONOSbench.isup(ONOS7_ip)
+ if not onos7_isup:
+ main.log.report("ONOS7 didn't start!")
+ onos_isup_result = onos1_isup and onos2_isup and onos3_isup\
+ and onos4_isup and onos5_isup and onos6_isup and onos7_isup
+ if onos_isup_result == main.TRUE:
+ break
+ # TODO: if it becomes an issue, we can retry this step a few times
+
+
+ cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip)
+ cli_result2 = main.ONOScli2.start_onos_cli(ONOS2_ip)
+ cli_result3 = main.ONOScli3.start_onos_cli(ONOS3_ip)
+ cli_result4 = main.ONOScli4.start_onos_cli(ONOS4_ip)
+ cli_result5 = main.ONOScli5.start_onos_cli(ONOS5_ip)
+ cli_result6 = main.ONOScli6.start_onos_cli(ONOS6_ip)
+ cli_result7 = main.ONOScli7.start_onos_cli(ONOS7_ip)
+ cli_results = cli_result1 and cli_result2 and cli_result3 and\
+ cli_result4 and cli_result5 and cli_result6 and cli_result7
+
+ main.step("Start Packet Capture MN")
+ main.Mininet2.start_tcpdump(
+ str(main.params['MNtcpdump']['folder'])+str(main.TEST)+"-MN.pcap",
+ intf = main.params['MNtcpdump']['intf'],
+ port = main.params['MNtcpdump']['port'])
+
+
+ case1_result = (clean_install_result and package_result and
+ cell_result and verify_result and onos_install_result and
+ onos_isup_result and cli_results)
+
+ utilities.assert_equals(expect=main.TRUE, actual=case1_result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful")
+
+
+ if case1_result==main.FALSE:
+ main.cleanup()
+ main.exit()
+
+ def CASE2(self,main) :
+ '''
+ Assign mastership to controllers
+ '''
+ import time
+ import json
+ import re
+
+
+ '''
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS1_port = main.params['CTRL']['port1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS2_port = main.params['CTRL']['port2']
+ ONOS3_ip = main.params['CTRL']['ip3']
+ ONOS3_port = main.params['CTRL']['port3']
+ ONOS4_ip = main.params['CTRL']['ip4']
+ ONOS4_port = main.params['CTRL']['port4']
+ ONOS5_ip = main.params['CTRL']['ip5']
+ ONOS5_port = main.params['CTRL']['port5']
+ ONOS6_ip = main.params['CTRL']['ip6']
+ ONOS6_port = main.params['CTRL']['port6']
+ ONOS7_ip = main.params['CTRL']['ip7']
+ ONOS7_port = main.params['CTRL']['port7']
+ '''
+
+
+ main.log.report("Assigning switches to controllers")
+ main.case("Assigning Controllers")
+ main.step("Assign switches to controllers")
+
+ for i in range (1,29):
+ main.Mininet1.assign_sw_controller(sw=str(i),count=7,
+ ip1=ONOS1_ip,port1=ONOS1_port,
+ ip2=ONOS2_ip,port2=ONOS2_port,
+ ip3=ONOS3_ip,port3=ONOS3_port,
+ ip4=ONOS4_ip,port4=ONOS4_port,
+ ip5=ONOS5_ip,port5=ONOS5_port,
+ ip6=ONOS6_ip,port6=ONOS6_port,
+ ip7=ONOS7_ip,port7=ONOS7_port)
+
+ mastership_check = main.TRUE
+ for i in range (1,29):
+ response = main.Mininet1.get_sw_controller("s"+str(i))
+ try:
+ main.log.info(str(response))
+ except:
+ main.log.info(repr(response))
+ if re.search("tcp:"+ONOS1_ip,response)\
+ and re.search("tcp:"+ONOS2_ip,response)\
+ and re.search("tcp:"+ONOS3_ip,response)\
+ and re.search("tcp:"+ONOS4_ip,response)\
+ and re.search("tcp:"+ONOS5_ip,response)\
+ and re.search("tcp:"+ONOS6_ip,response)\
+ and re.search("tcp:"+ONOS7_ip,response):
+ mastership_check = mastership_check and main.TRUE
+ else:
+ mastership_check = main.FALSE
+ if mastership_check == main.TRUE:
+ main.log.report("Switch mastership assigned correctly")
+ utilities.assert_equals(expect = main.TRUE,actual=mastership_check,
+ onpass="Switch mastership assigned correctly",
+ onfail="Switches not assigned correctly to controllers")
+
+ #TODO: If assign roles is working reliably then manually
+ # assign mastership to the controller we want
+
+
+ def CASE3(self,main) :
+ """
+ Assign intents
+
+ """
+ import time
+ import json
+ import re
+ main.log.report("Adding host intents")
+ main.case("Adding host Intents")
+
+ main.step("Discovering Hosts( Via pingall for now)")
+ #FIXME: Once we have a host discovery mechanism, use that instead
+
+ #REACTIVE FWD test
+ ping_result = main.FALSE
+ time1 = time.time()
+ ping_result = main.Mininet1.pingall()
+ time2 = time.time()
+ main.log.info("Time for pingall: %2f seconds" % (time2 - time1))
+
+ #uninstall onos-app-fwd
+ main.log.info("Uninstall reactive forwarding app")
+ main.ONOScli1.feature_uninstall("onos-app-fwd")
+ main.ONOScli2.feature_uninstall("onos-app-fwd")
+ main.ONOScli3.feature_uninstall("onos-app-fwd")
+ main.ONOScli4.feature_uninstall("onos-app-fwd")
+ main.ONOScli5.feature_uninstall("onos-app-fwd")
+ main.ONOScli6.feature_uninstall("onos-app-fwd")
+ main.ONOScli7.feature_uninstall("onos-app-fwd")
+
+ main.step("Add host intents")
+ #TODO: move the host numbers to params
+ import json
+ intents_json= json.loads(main.ONOScli1.hosts())
+ intent_add_result = main.FALSE
+ for i in range(8,18):
+ main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+ host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+ host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+ #NOTE: get host can return None
+ #TODO: handle this
+ host1_id = main.ONOScli1.get_host(host1)['id']
+ host2_id = main.ONOScli1.get_host(host2)['id']
+ tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
+ intent_add_result = intent_add_result and tmp_result
+ #TODO Check if intents all exist in datastore
+ #NOTE: Do we need to print this once the test is working?
+ #main.log.info(json.dumps(json.loads(main.ONOScli1.intents(json_format=True)),
+ # sort_keys=True, indent=4, separators=(',', ': ') ) )
+
+ def CASE4(self,main) :
+ """
+ Ping across added host intents
+ """
+ description = " Ping across added host intents"
+ main.log.report(description)
+ main.case(description)
+ Ping_Result = main.TRUE
+ for i in range(8,18):
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+ Ping_Result = Ping_Result and ping
+ if ping==main.FALSE:
+ main.log.warn("Ping failed between h"+str(i)+" and h" + str(i+10))
+ elif ping==main.TRUE:
+ main.log.info("Ping test passed!")
+ Ping_Result = main.TRUE
+ if Ping_Result==main.FALSE:
+ main.log.report("Intents have not been installed correctly, pings failed.")
+ if Ping_Result==main.TRUE:
+ main.log.report("Intents have been installed correctly and verified by pings")
+ utilities.assert_equals(expect = main.TRUE,actual=Ping_Result,
+ onpass="Intents have been installed correctly and pings work",
+ onfail ="Intents have not been installed correctly, pings failed." )
+
+ def CASE5(self,main) :
+ '''
+ Reading state of ONOS
+ '''
+ import time
+ import json
+ from subprocess import Popen, PIPE
+ from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+
+ main.log.report("Setting up and gathering data for current state")
+ main.case("Setting up and gathering data for current state")
+ #The general idea for this test case is to pull the state of (intents,flows, topology,...) from each ONOS node
+ #We can then compare them with eachother and also with past states
+
+ main.step("Get the Mastership of each switch from each controller")
+ global mastership_state
+ ONOS1_mastership = main.ONOScli1.roles()
+ ONOS2_mastership = main.ONOScli2.roles()
+ ONOS3_mastership = main.ONOScli3.roles()
+ ONOS4_mastership = main.ONOScli4.roles()
+ ONOS5_mastership = main.ONOScli5.roles()
+ ONOS6_mastership = main.ONOScli6.roles()
+ ONOS7_mastership = main.ONOScli7.roles()
+ #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+ if "Error" in ONOS1_mastership or not ONOS1_mastership\
+ or "Error" in ONOS2_mastership or not ONOS2_mastership\
+ or "Error" in ONOS3_mastership or not ONOS3_mastership\
+ or "Error" in ONOS4_mastership or not ONOS4_mastership\
+ or "Error" in ONOS5_mastership or not ONOS5_mastership\
+ or "Error" in ONOS6_mastership or not ONOS6_mastership\
+ or "Error" in ONOS7_mastership or not ONOS7_mastership:
+ main.log.report("Error in getting ONOS roles")
+ main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+ main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership))
+ main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership))
+ main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership))
+ main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership))
+ main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership))
+ main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership))
+ consistent_mastership = main.FALSE
+ elif ONOS1_mastership == ONOS2_mastership\
+ and ONOS1_mastership == ONOS3_mastership\
+ and ONOS1_mastership == ONOS4_mastership\
+ and ONOS1_mastership == ONOS5_mastership\
+ and ONOS1_mastership == ONOS6_mastership\
+ and ONOS1_mastership == ONOS7_mastership:
+ mastership_state = ONOS1_mastership
+ consistent_mastership = main.TRUE
+ main.log.report("Switch roles are consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ consistent_mastership = main.FALSE
+ utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+ onpass="Switch roles are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of switch roles")
+
+
+ main.step("Get the intents from each controller")
+ global intent_state
+ ONOS1_intents = main.ONOScli1.intents( json_format=True )
+ ONOS2_intents = main.ONOScli2.intents( json_format=True )
+ ONOS3_intents = main.ONOScli3.intents( json_format=True )
+ ONOS4_intents = main.ONOScli4.intents( json_format=True )
+ ONOS5_intents = main.ONOScli5.intents( json_format=True )
+ ONOS6_intents = main.ONOScli6.intents( json_format=True )
+ ONOS7_intents = main.ONOScli7.intents( json_format=True )
+ intent_check = main.FALSE
+ if "Error" in ONOS1_intents or not ONOS1_intents\
+ or "Error" in ONOS2_intents or not ONOS2_intents\
+ or "Error" in ONOS3_intents or not ONOS3_intents\
+ or "Error" in ONOS4_intents or not ONOS4_intents\
+ or "Error" in ONOS5_intents or not ONOS5_intents\
+ or "Error" in ONOS6_intents or not ONOS6_intents\
+ or "Error" in ONOS7_intents or not ONOS7_intents:
+ main.log.report("Error in getting ONOS intents")
+ main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+ main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents))
+ main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents))
+ main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents))
+ main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents))
+ main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents))
+ main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents))
+ elif ONOS1_intents == ONOS2_intents\
+ and ONOS1_intents == ONOS3_intents\
+ and ONOS1_intents == ONOS4_intents\
+ and ONOS1_intents == ONOS5_intents\
+ and ONOS1_intents == ONOS6_intents\
+ and ONOS1_intents == ONOS7_intents:
+ intent_state = ONOS1_intents
+ intent_check = main.TRUE
+ main.log.report("Intents are consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+ onpass="Intents are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of intents")
+
+
+ main.step("Get the flows from each controller")
+ global flow_state
+ ONOS1_flows = main.ONOScli1.flows( json_format=True )
+ ONOS2_flows = main.ONOScli2.flows( json_format=True )
+ ONOS3_flows = main.ONOScli3.flows( json_format=True )
+ ONOS4_flows = main.ONOScli4.flows( json_format=True )
+ ONOS5_flows = main.ONOScli5.flows( json_format=True )
+ ONOS6_flows = main.ONOScli6.flows( json_format=True )
+ ONOS7_flows = main.ONOScli7.flows( json_format=True )
+ flow_check = main.FALSE
+ if "Error" in ONOS1_flows or not ONOS1_flows\
+ or "Error" in ONOS2_flows or not ONOS2_flows\
+ or "Error" in ONOS3_flows or not ONOS3_flows\
+ or "Error" in ONOS4_flows or not ONOS4_flows\
+ or "Error" in ONOS5_flows or not ONOS5_flows\
+ or "Error" in ONOS6_flows or not ONOS6_flows\
+ or "Error" in ONOS7_flows or not ONOS7_flows:
+ main.log.report("Error in getting ONOS intents")
+ main.log.warn("ONOS1 flows repsponse: "+ ONOS1_flows)
+ main.log.warn("ONOS2 flows repsponse: "+ ONOS2_flows)
+ main.log.warn("ONOS3 flows repsponse: "+ ONOS3_flows)
+ main.log.warn("ONOS4 flows repsponse: "+ ONOS4_flows)
+ main.log.warn("ONOS5 flows repsponse: "+ ONOS5_flows)
+ main.log.warn("ONOS6 flows repsponse: "+ ONOS6_flows)
+ main.log.warn("ONOS7 flows repsponse: "+ ONOS7_flows)
+ elif len(json.loads(ONOS1_flows)) == len(json.loads(ONOS2_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS3_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS4_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS5_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS6_flows))\
+ and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS7_flows)):
+ #TODO: Do a better check, maybe compare flows on switches?
+ flow_state = ONOS1_flows
+ flow_check = main.TRUE
+ main.log.report("Flow count is consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 flows: "+ json.dumps(json.loads(ONOS1_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 flows: "+ json.dumps(json.loads(ONOS2_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 flows: "+ json.dumps(json.loads(ONOS3_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 flows: "+ json.dumps(json.loads(ONOS4_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 flows: "+ json.dumps(json.loads(ONOS5_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 flows: "+ json.dumps(json.loads(ONOS6_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 flows: "+ json.dumps(json.loads(ONOS7_flows),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ utilities.assert_equals(expect = main.TRUE,actual=flow_check,
+ onpass="The flow count is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different flow counts")
+
+
+ main.step("Get the OF Table entries")
+ global flows
+ flows=[]
+ for i in range(1,29):
+ flows.append(main.Mininet2.get_flowTable("s"+str(i),1.0))
+
+ #TODO: Compare switch flow tables with ONOS flow tables
+
+ main.step("Start continuous pings")
+ main.Mininet2.pingLong(src=main.params['PING']['source1'],
+ target=main.params['PING']['target1'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source2'],
+ target=main.params['PING']['target2'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source3'],
+ target=main.params['PING']['target3'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source4'],
+ target=main.params['PING']['target4'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source5'],
+ target=main.params['PING']['target5'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source6'],
+ target=main.params['PING']['target6'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source7'],
+ target=main.params['PING']['target7'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source8'],
+ target=main.params['PING']['target8'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source9'],
+ target=main.params['PING']['target9'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source10'],
+ target=main.params['PING']['target10'],pingTime=500)
+
+ main.step("Create TestONTopology object")
+ ctrls = []
+ count = 1
+ while True:
+ temp = ()
+ if ('ip' + str(count)) in main.params['CTRL']:
+ temp = temp + (getattr(main,('ONOS' + str(count))),)
+ temp = temp + ("ONOS"+str(count),)
+ temp = temp + (main.params['CTRL']['ip'+str(count)],)
+ temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+ ctrls.append(temp)
+ count = count + 1
+ else:
+ break
+ MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+ main.step("Collecting topology information from ONOS")
+ devices = []
+ devices.append( main.ONOScli1.devices() )
+ devices.append( main.ONOScli2.devices() )
+ devices.append( main.ONOScli3.devices() )
+ devices.append( main.ONOScli4.devices() )
+ devices.append( main.ONOScli5.devices() )
+ devices.append( main.ONOScli6.devices() )
+ devices.append( main.ONOScli7.devices() )
+ '''
+ hosts = []
+ hosts.append( main.ONOScli1.hosts() )
+ hosts.append( main.ONOScli2.hosts() )
+ hosts.append( main.ONOScli3.hosts() )
+ hosts.append( main.ONOScli4.hosts() )
+ hosts.append( main.ONOScli5.hosts() )
+ hosts.append( main.ONOScli6.hosts() )
+ hosts.append( main.ONOScli7.hosts() )
+ '''
+ ports = []
+ ports.append( main.ONOScli1.ports() )
+ ports.append( main.ONOScli2.ports() )
+ ports.append( main.ONOScli3.ports() )
+ ports.append( main.ONOScli4.ports() )
+ ports.append( main.ONOScli5.ports() )
+ ports.append( main.ONOScli6.ports() )
+ ports.append( main.ONOScli7.ports() )
+ links = []
+ links.append( main.ONOScli1.links() )
+ links.append( main.ONOScli2.links() )
+ links.append( main.ONOScli3.links() )
+ links.append( main.ONOScli4.links() )
+ links.append( main.ONOScli5.links() )
+ links.append( main.ONOScli6.links() )
+ links.append( main.ONOScli7.links() )
+
+
+ main.step("Comparing ONOS topology to MN")
+ devices_results = main.TRUE
+ ports_results = main.TRUE
+ links_results = main.TRUE
+ for controller in range(7): #TODO parameterize the number of controllers
+ if devices[controller] or not "Error" in devices[controller]:
+ current_devices_result = main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+ else:
+ current_devices_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+ onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+ onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+ if ports[controller] or not "Error" in ports[controller]:
+ current_ports_result = main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+ else:
+ current_ports_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+ onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+ onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+ if links[controller] or not "Error" in links[controller]:
+ current_links_result = main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+ else:
+ current_links_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+ onpass="ONOS"+str(int(controller+1))+" links view is correct",
+ onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+
+ devices_results = devices_results and current_devices_result
+ ports_results = ports_results and current_ports_result
+ links_results = links_results and current_links_result
+
+ topo_result = devices_results and ports_results and links_results
+ utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful")
+
+ final_assert = main.TRUE
+ final_assert = final_assert and topo_result and flow_check \
+ and intent_check and consistent_mastership
+ utilities.assert_equals(expect=main.TRUE, actual=final_assert,
+ onpass="State check successful",
+ onfail="State check NOT successful")
+
+
+ def CASE6(self,main) :
+ '''
+ The Failure case. Since this is the Sanity test, we do nothing.
+ '''
+ import time
+ main.log.report("Wait 60 seconds instead of inducing a failure")
+ time.sleep(60)
+ utilities.assert_equals(expect=main.TRUE, actual=main.TRUE,
+ onpass="Sleeping 60 seconds",
+ onfail="Something is terribly wrong with my math")
+
+ def CASE7(self,main) :
+ '''
+ Check state after ONOS failure
+ '''
+ import os
+ import json
+ main.case("Running ONOS Constant State Tests")
+
+ main.step("Check if switch roles are consistent across all nodes")
+ ONOS1_mastership = main.ONOScli1.roles()
+ ONOS2_mastership = main.ONOScli2.roles()
+ ONOS3_mastership = main.ONOScli3.roles()
+ ONOS4_mastership = main.ONOScli4.roles()
+ ONOS5_mastership = main.ONOScli5.roles()
+ ONOS6_mastership = main.ONOScli6.roles()
+ ONOS7_mastership = main.ONOScli7.roles()
+ #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+ if "Error" in ONOS1_mastership or not ONOS1_mastership\
+ or "Error" in ONOS2_mastership or not ONOS2_mastership\
+ or "Error" in ONOS3_mastership or not ONOS3_mastership\
+ or "Error" in ONOS4_mastership or not ONOS4_mastership\
+ or "Error" in ONOS5_mastership or not ONOS5_mastership\
+ or "Error" in ONOS6_mastership or not ONOS6_mastership\
+ or "Error" in ONOS7_mastership or not ONOS7_mastership:
+ main.log.error("Error in getting ONOS mastership")
+ main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+ main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership))
+ main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership))
+ main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership))
+ main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership))
+ main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership))
+ main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership))
+ consistent_mastership = main.FALSE
+ elif ONOS1_mastership == ONOS2_mastership\
+ and ONOS1_mastership == ONOS3_mastership\
+ and ONOS1_mastership == ONOS4_mastership\
+ and ONOS1_mastership == ONOS5_mastership\
+ and ONOS1_mastership == ONOS6_mastership\
+ and ONOS1_mastership == ONOS7_mastership:
+ #mastership_state = ONOS1_mastership
+ consistent_mastership = main.TRUE
+ main.log.report("Switch roles are consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ consistent_mastership = main.FALSE
+ utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+ onpass="Switch roles are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of switch roles")
+
+
+ description2 = "Compare switch roles from before failure"
+ main.step(description2)
+
+ current_json = json.loads(ONOS1_mastership)
+ old_json = json.loads(mastership_state)
+ mastership_check = main.TRUE
+ for i in range(1,29):
+ switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i)))
+
+ current = [switch['master'] for switch in current_json if switchDPID in switch['id']]
+ old = [switch['master'] for switch in old_json if switchDPID in switch['id']]
+ if current == old:
+ mastership_check = mastership_check and main.TRUE
+ else:
+ main.log.warn("Mastership of switch %s changed" % switchDPID)
+ mastership_check = main.FALSE
+ if mastership_check == main.TRUE:
+ main.log.report("Mastership of Switches was not changed")
+ utilities.assert_equals(expect=main.TRUE,actual=mastership_check,
+ onpass="Mastership of Switches was not changed",
+ onfail="Mastership of some switches changed")
+ mastership_check = mastership_check and consistent_mastership
+
+
+
+ main.step("Get the intents and compare across all nodes")
+ ONOS1_intents = main.ONOScli1.intents( json_format=True )
+ ONOS2_intents = main.ONOScli2.intents( json_format=True )
+ ONOS3_intents = main.ONOScli3.intents( json_format=True )
+ ONOS4_intents = main.ONOScli4.intents( json_format=True )
+ ONOS5_intents = main.ONOScli5.intents( json_format=True )
+ ONOS6_intents = main.ONOScli6.intents( json_format=True )
+ ONOS7_intents = main.ONOScli7.intents( json_format=True )
+ intent_check = main.FALSE
+ if "Error" in ONOS1_intents or not ONOS1_intents\
+ or "Error" in ONOS2_intents or not ONOS2_intents\
+ or "Error" in ONOS3_intents or not ONOS3_intents\
+ or "Error" in ONOS4_intents or not ONOS4_intents\
+ or "Error" in ONOS5_intents or not ONOS5_intents\
+ or "Error" in ONOS6_intents or not ONOS6_intents\
+ or "Error" in ONOS7_intents or not ONOS7_intents:
+ main.log.report("Error in getting ONOS intents")
+ main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+ main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents))
+ main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents))
+ main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents))
+ main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents))
+ main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents))
+ main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents))
+ elif ONOS1_intents == ONOS2_intents\
+ and ONOS1_intents == ONOS3_intents\
+ and ONOS1_intents == ONOS4_intents\
+ and ONOS1_intents == ONOS5_intents\
+ and ONOS1_intents == ONOS6_intents\
+ and ONOS1_intents == ONOS7_intents:
+ intent_check = main.TRUE
+ main.log.report("Intents are consistent across all ONOS nodes")
+ else:
+ main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents),
+ sort_keys=True, indent=4, separators=(',', ': ')))
+ utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+ onpass="Intents are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of intents")
+
+ main.step("Compare current intents with intents before the failure")
+ if intent_state == ONOS1_intents:
+ same_intents = main.TRUE
+ main.log.report("Intents are consistent with before failure")
+ #TODO: possibly the states have changed? we may need to figure out what the aceptable states are
+ else:
+ same_intents = main.FALSE
+ utilities.assert_equals(expect = main.TRUE,actual=same_intents,
+ onpass="Intents are consistent with before failure",
+ onfail="The Intents changed during failure")
+ intent_check = intent_check and same_intents
+
+
+
+ main.step("Get the OF Table entries and compare to before component failure")
+ Flow_Tables = main.TRUE
+ flows2=[]
+ for i in range(28):
+ main.log.info("Checking flow table on s" + str(i+1))
+ tmp_flows = main.Mininet2.get_flowTable("s"+str(i+1),1.0)
+ flows2.append(tmp_flows)
+ Flow_Tables = Flow_Tables and main.Mininet2.flow_comp(flow1=flows[i],flow2=tmp_flows)
+ if Flow_Tables == main.FALSE:
+ main.log.info("Differences in flow table for switch: "+str(i+1))
+ break
+ if Flow_Tables == main.TRUE:
+ main.log.report("No changes were found in the flow tables")
+ utilities.assert_equals(expect=main.TRUE,actual=Flow_Tables,
+ onpass="No changes were found in the flow tables",
+ onfail="Changes were found in the flow tables")
+
+ main.step("Check the continuous pings to ensure that no packets were dropped during component failure")
+ #FIXME: This check is always failing. Investigate cause
+ #NOTE: this may be something to do with file permsissions
+ # or slight change in format
+ main.Mininet2.pingKill(main.params['TESTONUSER'], main.params['TESTONIP'])
+ Loss_In_Pings = main.FALSE
+ #NOTE: checkForLoss returns main.FALSE with 0% packet loss
+ for i in range(8,18):
+ main.log.info("Checking for a loss in pings along flow from s" + str(i))
+ Loss_In_Pings = Loss_In_Pings or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i))
+ if Loss_In_Pings == main.TRUE:
+ main.log.info("Loss in ping detected")
+ elif Loss_In_Pings == main.ERROR:
+ main.log.info("There are multiple mininet process running")
+ elif Loss_In_Pings == main.FALSE:
+ main.log.info("No Loss in the pings")
+ main.log.report("No loss of dataplane connectivity")
+ utilities.assert_equals(expect=main.FALSE,actual=Loss_In_Pings,
+ onpass="No Loss of connectivity",
+ onfail="Loss of dataplane connectivity detected")
+
+
+ #TODO:add topology to this or leave as a seperate case?
+ result = mastership_check and intent_check and Flow_Tables and (not Loss_In_Pings)
+ result = int(result)
+ if result == main.TRUE:
+ main.log.report("Constant State Tests Passed")
+ utilities.assert_equals(expect=main.TRUE,actual=result,
+ onpass="Constant State Tests Passed",
+ onfail="Constant state tests failed")
+
+ def CASE8 (self,main):
+ '''
+ Compare topo
+ '''
+ import sys
+ sys.path.append("/home/admin/sts") # Trying to remove some dependancies, #FIXME add this path to params
+ from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+ import json
+ import time
+
+ description ="Compare ONOS Topology view to Mininet topology"
+ main.case(description)
+ main.log.report(description)
+ main.step("Create TestONTopology object")
+ ctrls = []
+ count = 1
+ while True:
+ temp = ()
+ if ('ip' + str(count)) in main.params['CTRL']:
+ temp = temp + (getattr(main,('ONOS' + str(count))),)
+ temp = temp + ("ONOS"+str(count),)
+ temp = temp + (main.params['CTRL']['ip'+str(count)],)
+ temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+ ctrls.append(temp)
+ count = count + 1
+ else:
+ break
+ MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+ main.step("Comparing ONOS topology to MN")
+ devices_results = main.TRUE
+ ports_results = main.TRUE
+ links_results = main.TRUE
+ topo_result = main.FALSE
+ start_time = time.time()
+ elapsed = 0
+ count = 0
+ while topo_result == main.FALSE and elapsed < 120:
+ print "cond 1:" + str(topo_result == main.FALSE)
+ print "cond 2:" + str(elapsed < 120)
+ count = count + 1
+ try:
+ main.step("Collecting topology information from ONOS")
+ devices = []
+ devices.append( main.ONOScli1.devices() )
+ devices.append( main.ONOScli2.devices() )
+ devices.append( main.ONOScli3.devices() )
+ devices.append( main.ONOScli4.devices() )
+ devices.append( main.ONOScli5.devices() )
+ devices.append( main.ONOScli6.devices() )
+ devices.append( main.ONOScli7.devices() )
+ '''
+ hosts = []
+ hosts.append( main.ONOScli1.hosts() )
+ hosts.append( main.ONOScli2.hosts() )
+ hosts.append( main.ONOScli3.hosts() )
+ hosts.append( main.ONOScli4.hosts() )
+ hosts.append( main.ONOScli5.hosts() )
+ hosts.append( main.ONOScli6.hosts() )
+ hosts.append( main.ONOScli7.hosts() )
+ '''
+ ports = []
+ ports.append( main.ONOScli1.ports() )
+ ports.append( main.ONOScli2.ports() )
+ ports.append( main.ONOScli3.ports() )
+ ports.append( main.ONOScli4.ports() )
+ ports.append( main.ONOScli5.ports() )
+ ports.append( main.ONOScli6.ports() )
+ ports.append( main.ONOScli7.ports() )
+ links = []
+ links.append( main.ONOScli1.links() )
+ links.append( main.ONOScli2.links() )
+ links.append( main.ONOScli3.links() )
+ links.append( main.ONOScli4.links() )
+ links.append( main.ONOScli5.links() )
+ links.append( main.ONOScli6.links() )
+ links.append( main.ONOScli7.links() )
+
+ for controller in range(7): #TODO parameterize the number of controllers
+ if devices[controller] or not "Error" in devices[controller]:
+ current_devices_result = main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+ else:
+ current_devices_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+ onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+ onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+ if ports[controller] or not "Error" in ports[controller]:
+ current_ports_result = main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+ else:
+ current_ports_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+ onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+ onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+ if links[controller] or not "Error" in links[controller]:
+ current_links_result = main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+ else:
+ current_links_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+ onpass="ONOS"+str(int(controller+1))+" links view is correct",
+ onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+ except:
+ main.log.error("something went wrong in topo comparison")
+ main.log.warn( repr( devices ) )
+ main.log.warn( repr( ports ) )
+ main.log.warn( repr( links ) )
+
+ devices_results = devices_results and current_devices_result
+ ports_results = ports_results and current_ports_result
+ links_results = links_results and current_links_result
+ topo_result = devices_results and ports_results and links_results
+ elapsed = time.time() - start_time
+ time_threshold = elapsed < 1
+ topo_result = topo_result and time_threshold
+ #TODO make sure this step is non-blocking. IE add a timeout
+ main.log.report("Very crass estimate for topology discovery/convergence: " +\
+ str(elapsed) + " seconds, " + str(count) +" tries" )
+ utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful")
+ if topo_result == main.TRUE:
+ main.log.report("ONOS topology view matches Mininet topology")
+
+
+ def CASE9 (self,main):
+ '''
+ Link s3-s28 down
+ '''
+ #NOTE: You should probably run a topology check after this
+
+ link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+ description = "Turn off a link to ensure that Link Discovery is working properly"
+ main.log.report(description)
+ main.case(description)
+
+
+ main.step("Kill Link between s3 and s28")
+ Link_Down = main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
+ main.log.info("Waiting " + str(link_sleep) + " seconds for link down to be discovered")
+ time.sleep(link_sleep)
+ utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
+ onpass="Link down succesful",
+ onfail="Failed to bring link down")
+ #TODO do some sort of check here
+
+ def CASE10 (self,main):
+ '''
+ Link s3-s28 up
+ '''
+ #NOTE: You should probably run a topology check after this
+
+ link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+ description = "Restore a link to ensure that Link Discovery is working properly"
+ main.log.report(description)
+ main.case(description)
+
+ main.step("Bring link between s3 and s28 back up")
+ Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
+ main.log.info("Waiting " + str(link_sleep) + " seconds for link up to be discovered")
+ time.sleep(link_sleep)
+ utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
+ onpass="Link up succesful",
+ onfail="Failed to bring link up")
+ #TODO do some sort of check here
+
+
+ def CASE11 (self, main) :
+ '''
+ Switch Down
+ '''
+ #NOTE: You should probably run a topology check after this
+ import time
+
+ switch_sleep = int(main.params['timers']['SwitchDiscovery'])
+
+ description = "Killing a switch to ensure it is discovered correctly"
+ main.log.report(description)
+ main.case(description)
+
+ #TODO: Make this switch parameterizable
+ main.step("Kill s28 ")
+ main.log.report("Deleting s28")
+ #FIXME: use new dynamic topo functions
+ main.Mininet1.del_switch("s28")
+ main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered")
+ time.sleep(switch_sleep)
+ #Peek at the deleted switch
+ main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+ #TODO do some sort of check here
+
+ def CASE12 (self, main) :
+ '''
+ Switch Up
+ '''
+ #NOTE: You should probably run a topology check after this
+ import time
+ #FIXME: use new dynamic topo functions
+ description = "Adding a switch to ensure it is discovered correctly"
+ main.log.report(description)
+ main.case(description)
+
+ main.step("Add back s28")
+ main.log.report("Adding back s28")
+ main.Mininet1.add_switch("s28", dpid = '0000000000002800')
+ #TODO: New dpid or same? Ask Thomas?
+ main.Mininet1.add_link('s28', 's3')
+ main.Mininet1.add_link('s28', 's6')
+ main.Mininet1.add_link('s28', 'h28')
+ main.Mininet1.assign_sw_controller(sw="28",count=7,
+ ip1=ONOS1_ip,port1=ONOS1_port,
+ ip2=ONOS2_ip,port2=ONOS2_port,
+ ip3=ONOS3_ip,port3=ONOS3_port,
+ ip4=ONOS4_ip,port4=ONOS4_port,
+ ip5=ONOS5_ip,port5=ONOS5_port,
+ ip6=ONOS6_ip,port6=ONOS6_port,
+ ip7=ONOS7_ip,port7=ONOS7_port)
+ main.log.info("Waiting " + str(switch_sleep) + " seconds for switch up to be discovered")
+ time.sleep(switch_sleep)
+ #Peek at the added switch
+ main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+ #TODO do some sort of check here
+
+ def CASE13 (self, main) :
+ '''
+ Clean up
+ '''
+ import os
+ import time
+ description = "Test Cleanup"
+ main.log.report(description)
+ main.case(description)
+ main.step("Killing tcpdumps")
+ main.Mininet2.stop_tcpdump()
+
+ main.step("Copying MN pcap and ONOS log files to test station")
+ testname = main.TEST
+ #NOTE: MN Pcap file is being saved to ~/packet_captures
+ # scp this file as MN and TestON aren't necessarily the same vm
+ #FIXME: scp
+ #####mn files
+ #TODO: Load these from params
+ #NOTE: must end in /
+ log_folder = "/opt/onos/log/"
+ log_files = ["karaf.log", "karaf.log.1"]
+ #NOTE: must end in /
+ dst_dir = "~/packet_captures/"
+ for f in log_files:
+ main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS1-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS2_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS2-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS3_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS3-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS4_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS4-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS5_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS5-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS6_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS6-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS7_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS7-"+f )
+
+ #std*.log's
+ #NOTE: must end in /
+ log_folder = "/opt/onos/var/"
+ log_files = ["stderr.log", "stdout.log"]
+ #NOTE: must end in /
+ dst_dir = "~/packet_captures/"
+ for f in log_files:
+ main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS1-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS2_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS2-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS3_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS3-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS4_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS4-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS5_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS5-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS6_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS6-"+f )
+ main.ONOSbench.secureCopy( "sdn", ONOS7_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS7-"+f )
+
+
+
+
+ #sleep so scp can finish
+ time.sleep(10)
+ main.step("Packing and rotating pcap archives")
+ os.system("~/TestON/dependencies/rotate.sh "+ str(testname))
+
+
+ #TODO: actually check something here
+ utilities.assert_equals(expect=main.TRUE, actual=main.TRUE,
+ onpass="Test cleanup successful",
+ onfail="Test cleanup NOT successful")
diff --git a/TestON/tests/HATestSanity/HATestSanity.topo b/TestON/tests/HATestSanity/HATestSanity.topo
new file mode 100644
index 0000000..4d4156c
--- /dev/null
+++ b/TestON/tests/HATestSanity/HATestSanity.topo
@@ -0,0 +1,173 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli1>
+
+ <ONOScli2>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli2>
+
+ <ONOScli3>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli3>
+
+
+ <ONOScli4>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli4>
+
+
+ <ONOScli5>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli5>
+
+
+ <ONOScli6>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli6>
+
+
+ <ONOScli7>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli7>
+
+ <ONOS1>
+ <host>10.128.30.11</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.30.12</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>10</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.30.13</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>11</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <ONOS4>
+ <host>10.128.30.14</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>12</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4>
+
+ <ONOS5>
+ <host>10.128.30.15</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>13</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5>
+
+ <ONOS6>
+ <host>10.128.30.16</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>14</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6>
+
+ <ONOS7>
+ <host>10.128.30.17</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>15</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7>
+
+ <Mininet1>
+ <host>10.128.30.9</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>16</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ <Mininet2>
+ <host>10.128.30.9</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>17</connect_order>
+ <COMPONENTS>
+ # Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo --arp</arg2>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet2>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/HATestSanity/__init__.py b/TestON/tests/HATestSanity/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/HATestSanity/__init__.py
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.py b/TestON/tests/IntentPerfNext/IntentPerfNext.py
index 493f1f2..73aa304 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.py
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.py
@@ -495,6 +495,7 @@
time.sleep(120 / int(cluster_count))
for node in range(1, cluster_count+1):
with open(save_dir) as f_onos:
+ line_count = 0
for line in f_onos:
line = line[1:]
line = line.split(": ")
diff --git a/TestON/tests/MultiProd/MultiProd.params b/TestON/tests/MultiProd/MultiProd.params
index 2f99555..3007fb2 100755
--- a/TestON/tests/MultiProd/MultiProd.params
+++ b/TestON/tests/MultiProd/MultiProd.params
@@ -1,6 +1,6 @@
<PARAMS>
- <testcases>1,4,5,6,7,8,9</testcases>
+ <testcases>1,4,10,5,6,7,8,6,8,9</testcases>
#Environment variables
<ENV>
diff --git a/TestON/tests/MultiProd/MultiProd.py b/TestON/tests/MultiProd/MultiProd.py
index 33d86b4..7545f3e 100755
--- a/TestON/tests/MultiProd/MultiProd.py
+++ b/TestON/tests/MultiProd/MultiProd.py
@@ -17,11 +17,12 @@
def CASE1(self, main):
'''
Startup sequence:
+ cell <name>
+ onos-verify-cell
+ onos-remove-raft-logs
git pull
mvn clean install
onos-package
- cell <name>
- onos-verify-cell
onos-install -f
onos-wait-for-start
'''
@@ -32,11 +33,23 @@
ONOS3_ip = main.params['CTRL']['ip3']
ONOS1_port = main.params['CTRL']['port1']
ONOS2_port = main.params['CTRL']['port2']
- ONOS3_port = main.params['CTRL']['port3']
-
+ ONOS3_port = main.params['CTRL']['port3']
+
main.case("Setting up test environment")
main.log.report("This testcase is testing setting up test environment")
main.log.report("__________________________________")
+
+ main.step("Applying cell variable to environment")
+ cell_result1 = main.ONOSbench.set_cell(cell_name)
+ #cell_result2 = main.ONOScli1.set_cell(cell_name)
+ #cell_result3 = main.ONOScli2.set_cell(cell_name)
+ #cell_result4 = main.ONOScli3.set_cell(cell_name)
+ verify_result = main.ONOSbench.verify_cell()
+ cell_result = cell_result1
+
+ main.step("Removing raft logs before a clen installation of ONOS")
+ remove_log_Result = main.ONOSbench.onos_remove_raft_logs()
+
main.step("Git checkout and pull master and get version")
main.ONOSbench.git_checkout("master")
git_pull_result = main.ONOSbench.git_pull()
@@ -48,14 +61,6 @@
clean_install_result = main.ONOSbench.clean_install()
#clean_install_result = main.TRUE
- main.step("Applying cell variable to environment")
- cell_result1 = main.ONOSbench.set_cell(cell_name)
- #cell_result2 = main.ONOScli1.set_cell(cell_name)
- #cell_result3 = main.ONOScli2.set_cell(cell_name)
- #cell_result4 = main.ONOScli3.set_cell(cell_name)
- verify_result = main.ONOSbench.verify_cell()
- cell_result = cell_result1
-
main.step("Creating ONOS package")
package_result = main.ONOSbench.onos_package()
@@ -223,9 +228,9 @@
devices1 = main.ONOScli1.devices()
devices2 = main.ONOScli2.devices()
devices3 = main.ONOScli3.devices()
- print "devices1 = ", devices1
- print "devices2 = ", devices2
- print "devices3 = ", devices3
+ #print "devices1 = ", devices1
+ #print "devices2 = ", devices2
+ #print "devices3 = ", devices3
hosts1 = main.ONOScli1.hosts()
hosts2 = main.ONOScli2.hosts()
hosts3 = main.ONOScli3.hosts()
@@ -355,14 +360,36 @@
onpass="Topology Check Test successful",
onfail="Topology Check Test NOT successful")
+
+
+
+ def CASE10(self):
+ main.log.report("This testcase uninstalls the reactive forwarding app")
+ main.log.report("__________________________________")
+ main.case("Uninstalling reactive forwarding app")
+ #Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstall_result1 = main.ONOScli1.feature_uninstall("onos-app-fwd")
+ appUninstall_result2 = main.ONOScli2.feature_uninstall("onos-app-fwd")
+ appUninstall_result3 = main.ONOScli3.feature_uninstall("onos-app-fwd")
+ main.log.info("onos-app-fwd uninstalled")
+
+ #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+ #So sleep for 15s
+ time.sleep(15)
+
+ hosts = main.ONOScli1.hosts()
+ main.log.info(hosts)
+
+ case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3
+ utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
+
+
def CASE6(self):
main.log.report("This testcase is testing the addition of host intents and then doing pingall")
main.log.report("__________________________________")
- main.case("Uninstalling reactive forwarding app and addhost intents")
+ main.case("Obtaining hostsfor adding host intents")
main.step("Get hosts")
- main.ONOScli1.handle.sendline("hosts")
- main.ONOScli1.handle.expect("onos>")
- hosts = main.ONOScli1.handle.before
+ hosts = main.ONOScli1.hosts()
main.log.info(hosts)
main.step("Get all devices id")
@@ -371,7 +398,8 @@
#ONOS displays the hosts in hex format unlike mininet which does in decimal format
#So take care while adding intents
-
+
+ '''
main.step("Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
@@ -383,16 +411,17 @@
hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
hth_intent_result = main.ONOScli1.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
+ '''
-
- #Unistall onos-app-fwd app to disable reactive forwarding
- main.step("Unistall onos-app-fwd app to disable reactive forwarding")
- appUninstall_result = main.ONOScli1.feature_uninstall("onos-app-fwd")
- main.log.info("onos-app-fwd uninstalled")
-
- #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
- #So sleep for 15s
- time.sleep(15)
+ for i in range(8,18):
+ main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+ host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+ host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+ #NOTE: get host can return None
+ #TODO: handle this
+ host1_id = main.ONOScli1.get_host(host1)['id']
+ host2_id = main.ONOScli1.get_host(host2)['id']
+ tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
flowHandle = main.ONOScli1.flows()
#print "flowHandle = ", flowHandle
@@ -634,7 +663,7 @@
def CASE8(self):
'''
- Host intents removal
+ Intent removal
'''
main.log.report("This testcase removes host intents before adding the point intents")
main.log.report("__________________________________")
@@ -643,31 +672,37 @@
main.step("Obtain the intent id's")
intent_result = main.ONOScli1.intents()
#print "intent_result = ",intent_result
+
intent_linewise = intent_result.split("\n")
- intent_linewise = intent_linewise[1:-1] #ignore the first and last item of the list obtained from split
- #for line in intent_linewise:
- #print "line = ", line
- intentids = []
+ intentList = []
for line in intent_linewise:
+ if line.startswith("id="):
+ intentList.append(line)
+
+ intentids = []
+ for line in intentList:
intentids.append(line.split(",")[0].split("=")[1])
for id in intentids:
print "id = ", id
-
+
main.step("Iterate through the intentids list and remove each intent")
for id in intentids:
main.ONOScli1.remove_intent(intent_id = id)
-
+
intent_result = main.ONOScli1.intents()
intent_linewise = intent_result.split("\n")
- intent_linewise = intent_linewise[1:-1] #ignore the first and last item of the list obtained from split
-
+ list_afterRemoval = []
+ for line in intent_linewise:
+ if line.startswith("id="):
+ list_afterRemoval.append(line)
+
intentState = {}
- for id, line in zip(intentids, intent_linewise):
+ for id, line in zip(intentids, list_afterRemoval):
#print "line after removing intent = ", line
x = line.split(",")
state = x[1].split("=")[1]
intentState[id] = state
-
+
case8_result = main.TRUE
for key,value in intentState.iteritems():
print "key,value = ", key, value
@@ -676,14 +711,39 @@
else:
case8_result = case8_result and main.FALSE
- if case8_result == main.TRUE:
+ i = 8
+ Ping_Result = main.TRUE
+ while i <18 :
+ main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+ if ping==main.TRUE:
+ i = 19
+ Ping_Result = main.TRUE
+ elif ping==main.FALSE:
+ i+=1
+ Ping_Result = main.FALSE
+ else:
+ main.log.info("Unknown error")
+ Ping_Result = main.ERROR
+
+ #Note: If the ping result failed, that means the intents have been withdrawn correctly.
+ if Ping_Result==main.TRUE:
+ main.log.report("Host intents have not been withdrawn correctly")
+ #main.cleanup()
+ #main.exit()
+ if Ping_Result==main.FALSE:
+ main.log.report("Host intents have been withdrawn correctly")
+
+ case8_result = case8_result and Ping_Result
+
+ if case8_result == main.FALSE:
main.log.report("Intent removal successful")
else:
main.log.report("Intent removal failed")
- utilities.assert_equals(expect=main.TRUE, actual=case8_result,
- onpass="Intent removal test successful",
- onfail="Intent removal test failed")
+ utilities.assert_equals(expect=main.FALSE, actual=case8_result,
+ onpass="Intent removal test failed",
+ onfail="Intent removal test successful")
def CASE9(self):
@@ -696,117 +756,117 @@
main.log.info("Adding point intents")
main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008", 1, "of:0000000000006018", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018", 1, "of:0000000000003008", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009", 1, "of:0000000000006019", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019", 1, "of:0000000000003009", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010", 1, "of:0000000000006020", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020", 1, "of:0000000000003010", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011", 1, "of:0000000000006021", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021", 1, "of:0000000000003011", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012", 1, "of:0000000000006022", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022", 1, "of:0000000000003012", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013", 1, "of:0000000000006023", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023", 1, "of:0000000000003013", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014", 1, "of:0000000000006024", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024", 1, "of:0000000000003014", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015", 1, "of:0000000000006025", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025", 1, "of:0000000000003015", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016", 1, "of:0000000000006026", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026", 1, "of:0000000000003016", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
@@ -814,13 +874,13 @@
main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017", 1, "of:0000000000006027", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027", 1, "of:0000000000003017", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
@@ -867,3 +927,163 @@
onpass="Ping all test after Point intents addition successful",
onfail="Ping all test after Point intents addition failed")
+ def CASE31(self):
+ '''
+ This test case adds point intent related to SDN-IP matching on ICMP (ethertype=IPV4, ipProto=1)
+ '''
+ import json
+
+ main.log.report("This test case adds point intent related to SDN-IP matching on ICMP")
+ main.case("Adding bidirectional point intent related to SDN-IP matching on ICMP")
+ main.step("Adding bidirectional point intent")
+ #add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=1 of:0000000000003008/1 of:0000000000006018/1
+
+ hosts_json = json.loads(main.ONOScli1.hosts())
+ for i in range(8,11):
+ main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
+ host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+ host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+ host1_id = main.ONOScli1.get_host(host1)['id']
+ host2_id = main.ONOScli1.get_host(host2)['id']
+ for host in hosts_json:
+ if host['id'] == host1_id:
+ ip1 = host['ips'][0]
+ ip1 = str(ip1+"/32")
+ print "ip1 = ", ip1
+ device1 = host['location']['device']
+ device1 = str(device1+"/1")
+ print "device1 = ", device1
+ elif host['id'] == host2_id:
+ ip2 = str(host['ips'][0])+"/32"
+ print "ip2 = ", ip2
+ device2 = host['location']["device"]
+ device2 = str(device2+"/1")
+ print "device2 = ", device2
+
+ p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
+ ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
+
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info(get_intent_result)
+
+ p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
+ ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
+
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info(get_intent_result)
+ if (p_intent_result1 and p_intent_result2) == main.TRUE:
+ #get_intent_result = main.ONOScli1.intents()
+ #main.log.info(get_intent_result)
+ main.log.info("Point intent related to SDN-IP matching on ICMP install successful")
+
+ time.sleep(15)
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info("intents = "+ get_intent_result)
+ get_flows_result = main.ONOScli1.flows()
+ main.log.info("flows = " + get_flows_result)
+
+ count = 1
+ i = 8
+ Ping_Result = main.TRUE
+ while i <11 :
+ main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+ if ping == main.FALSE and count <3:
+ count+=1
+ #i = 8
+ Ping_Result = main.FALSE
+ main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
+ time.sleep(2)
+ elif ping==main.FALSE:
+ main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
+ i=19
+ Ping_Result = main.FALSE
+ elif ping==main.TRUE:
+ main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
+ i+=1
+ Ping_Result = main.TRUE
+ else:
+ main.log.info("Unknown error")
+ Ping_Result = main.ERROR
+ if Ping_Result==main.FALSE:
+ main.log.report("Ping test after Point intents related to SDN-IP matching on ICMP failed.")
+ #main.cleanup()
+ #main.exit()
+ if Ping_Result==main.TRUE:
+ main.log.report("Ping all test after Point intents related to SDN-IP matching on ICMP successful")
+
+ case31_result = Ping_Result and p_intent_result1 and p_intent_result2
+ utilities.assert_equals(expect=main.TRUE, actual=case31_result,
+ onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
+ onfail="Point intent related to SDN-IP matching on ICMP and ping test failed")
+
+ def CASE32(self):
+ '''
+ This test case adds point intent related to SDN-IP matching on TCP (ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001)
+ Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
+ '''
+ import json
+
+ main.log.report("This test case adds point intent related to SDN-IP matching on TCP")
+ main.case("Adding bidirectional point intent related to SDN-IP matching on TCP")
+ main.step("Adding bidirectional point intent")
+ """
+ add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1 of:0000000000006018/1
+
+ add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1 of:0000000000003008/1
+
+ add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1 of:0000000000006018/1
+
+ add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1 of:0000000000003008/1
+
+ """
+
+ hosts_json = json.loads(main.ONOScli1.hosts())
+ for i in range(8,9):
+ main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
+ host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+ host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+ host1_id = main.ONOScli1.get_host(host1)['id']
+ host2_id = main.ONOScli1.get_host(host2)['id']
+ for host in hosts_json:
+ if host['id'] == host1_id:
+ ip1 = host['ips'][0]
+ ip1 = str(ip1+"/32")
+ print "ip1 = ", ip1
+ device1 = host['location']['device']
+ device1 = str(device1+"/1")
+ print "device1 = ", device1
+ elif host['id'] == host2_id:
+ ip2 = str(host['ips'][0])+"/32"
+ print "ip2 = ", ip2
+ device2 = host['location']["device"]
+ device2 = str(device2+"/1")
+ print "device2 = ", device2
+
+ p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
+ ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
+ p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
+ ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
+
+ p_intent_result3 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
+ ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
+ p_intent_result4 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
+ ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
+
+ p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4
+ if p_intent_result ==main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info(get_intent_result)
+ main.log.info("Point intent related to SDN-IP matching on TCP install successful")
+
+ iperf_result = main.Mininet1.iperf('h8', 'h18')
+ if iperf_result == main.TRUE:
+ main.log.report("iperf test successful")
+ else:
+ main.log.report("iperf test failed")
+
+
+ case32_result = p_intent_result and iperf_result
+ utilities.assert_equals(expect=main.TRUE, actual=case32_result,
+ onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
+ onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed")
diff --git a/TestON/tests/MultiProd13/MultiProd13.params b/TestON/tests/MultiProd13/MultiProd13.params
index b60f5cf..f41abe2 100755
--- a/TestON/tests/MultiProd13/MultiProd13.params
+++ b/TestON/tests/MultiProd13/MultiProd13.params
@@ -1,6 +1,6 @@
<PARAMS>
- <testcases>1,4,10,31</testcases>
+ <testcases>1,4,10,31,32</testcases>
#Environment variables
<ENV>
@@ -16,6 +16,14 @@
<port3>6633</port3>
</CTRL>
+ <SDNIP>
+ <ethType>IPV4</ethType>
+ <tcpProto>6</tcpProto>
+ <icmpProto>1</icmpProto>
+ <srcPort>5001</srcPort>
+ <dstPort>5001</dstPort>
+ </SDNIP>
+
<PING>
<source1>h8</source1>
<source2>h9</source2>
diff --git a/TestON/tests/MultiProd13/MultiProd13.py b/TestON/tests/MultiProd13/MultiProd13.py
index d825c62..40f41b6 100755
--- a/TestON/tests/MultiProd13/MultiProd13.py
+++ b/TestON/tests/MultiProd13/MultiProd13.py
@@ -17,11 +17,12 @@
def CASE1(self, main):
'''
Startup sequence:
+ cell <name>
+ onos-verify-cell
+ onos-remove-raft-logs
git pull
mvn clean install
onos-package
- cell <name>
- onos-verify-cell
onos-install -f
onos-wait-for-start
'''
@@ -32,11 +33,23 @@
ONOS3_ip = main.params['CTRL']['ip3']
ONOS1_port = main.params['CTRL']['port1']
ONOS2_port = main.params['CTRL']['port2']
- ONOS3_port = main.params['CTRL']['port3']
-
+ ONOS3_port = main.params['CTRL']['port3']
+
main.case("Setting up test environment")
main.log.report("This testcase is testing setting up test environment")
main.log.report("__________________________________")
+
+ main.step("Applying cell variable to environment")
+ cell_result1 = main.ONOSbench.set_cell(cell_name)
+ #cell_result2 = main.ONOScli1.set_cell(cell_name)
+ #cell_result3 = main.ONOScli2.set_cell(cell_name)
+ #cell_result4 = main.ONOScli3.set_cell(cell_name)
+ verify_result = main.ONOSbench.verify_cell()
+ cell_result = cell_result1
+
+ main.step("Removing raft logs before a clen installation of ONOS")
+ remove_log_Result = main.ONOSbench.onos_remove_raft_logs()
+
main.step("Git checkout and pull master and get version")
main.ONOSbench.git_checkout("master")
git_pull_result = main.ONOSbench.git_pull()
@@ -48,14 +61,6 @@
clean_install_result = main.ONOSbench.clean_install()
#clean_install_result = main.TRUE
- main.step("Applying cell variable to environment")
- cell_result1 = main.ONOSbench.set_cell(cell_name)
- #cell_result2 = main.ONOScli1.set_cell(cell_name)
- #cell_result3 = main.ONOScli2.set_cell(cell_name)
- #cell_result4 = main.ONOScli3.set_cell(cell_name)
- verify_result = main.ONOSbench.verify_cell()
- cell_result = cell_result1
-
main.step("Creating ONOS package")
package_result = main.ONOSbench.onos_package()
@@ -371,7 +376,10 @@
#After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
#So sleep for 15s
time.sleep(15)
-
+
+ hosts = main.ONOScli1.hosts()
+ main.log.info(hosts)
+
case10_result = appUninstall_result1 and appUninstall_result2 and appUninstall_result3
utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
@@ -709,6 +717,7 @@
main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
if ping==main.TRUE:
+ i = 19
Ping_Result = main.TRUE
elif ping==main.FALSE:
i+=1
@@ -733,8 +742,8 @@
main.log.report("Intent removal failed")
utilities.assert_equals(expect=main.FALSE, actual=case8_result,
- onpass="Intent removal test successful",
- onfail="Intent removal test failed")
+ onpass="Intent removal test failed",
+ onfail="Intent removal test successful")
def CASE9(self):
@@ -747,117 +756,117 @@
main.log.info("Adding point intents")
main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008", 1, "of:0000000000006018", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018", 1, "of:0000000000003008", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009", 1, "of:0000000000006019", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019", 1, "of:0000000000003009", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010", 1, "of:0000000000006020", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020", 1, "of:0000000000003010", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011", 1, "of:0000000000006021", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021", 1, "of:0000000000003011", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012", 1, "of:0000000000006022", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022", 1, "of:0000000000003012", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013", 1, "of:0000000000006023", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023", 1, "of:0000000000003013", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014", 1, "of:0000000000006024", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024", 1, "of:0000000000003014", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015", 1, "of:0000000000006025", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025", 1, "of:0000000000003015", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016", 1, "of:0000000000006026", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026", 1, "of:0000000000003016", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
@@ -865,13 +874,13 @@
main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017", 1, "of:0000000000006027", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
#main.log.info(get_intent_result)
- ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027", 1, "of:0000000000003017", 1)
+ ptp_intent_result = main.ONOScli1.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOScli1.intents()
main.log.info("Point to point intent install successful")
@@ -925,6 +934,7 @@
import json
main.log.report("This test case adds point intent related to SDN-IP matching on ICMP")
+ main.case("Adding bidirectional point intent related to SDN-IP matching on ICMP")
main.step("Adding bidirectional point intent")
#add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=1 of:0000000000003008/1 of:0000000000006018/1
@@ -937,15 +947,143 @@
host2_id = main.ONOScli1.get_host(host2)['id']
for host in hosts_json:
if host['id'] == host1_id:
- ip1 = host['ips']+"/"+"32"
- device1 = str(host['location']['device'])
- port1 = 1
+ ip1 = host['ips'][0]
+ ip1 = str(ip1+"/32")
print "ip1 = ", ip1
+ device1 = host['location']['device']
+ device1 = str(device1+"/1")
print "device1 = ", device1
elif host['id'] == host2_id:
- ip2 = str(host['ips'])+"/"+"32"
- device2 = str(host['location']["device"])
- port2 = 1
+ ip2 = str(host['ips'][0])+"/32"
print "ip2 = ", ip2
+ device2 = host['location']["device"]
+ device2 = str(device2+"/1")
print "device2 = ", device2
-
+
+ p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
+ ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
+
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info(get_intent_result)
+
+ p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
+ ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['icmpProto'])
+
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info(get_intent_result)
+ if (p_intent_result1 and p_intent_result2) == main.TRUE:
+ #get_intent_result = main.ONOScli1.intents()
+ #main.log.info(get_intent_result)
+ main.log.info("Point intent related to SDN-IP matching on ICMP install successful")
+
+ time.sleep(15)
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info("intents = "+ get_intent_result)
+ get_flows_result = main.ONOScli1.flows()
+ main.log.info("flows = " + get_flows_result)
+
+ count = 1
+ i = 8
+ Ping_Result = main.TRUE
+ while i <11 :
+ main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+ if ping == main.FALSE and count <3:
+ count+=1
+ #i = 8
+ Ping_Result = main.FALSE
+ main.log.report("Ping between h" + str(i) + " and h" + str(i+10) + " failed. Making attempt number "+str(count) + " in 2 seconds")
+ time.sleep(2)
+ elif ping==main.FALSE:
+ main.log.report("All ping attempts between h" + str(i) + " and h" + str(i+10) +"have failed")
+ i=19
+ Ping_Result = main.FALSE
+ elif ping==main.TRUE:
+ main.log.info("Ping test between h" + str(i) + " and h" + str(i+10) + "passed!")
+ i+=1
+ Ping_Result = main.TRUE
+ else:
+ main.log.info("Unknown error")
+ Ping_Result = main.ERROR
+ if Ping_Result==main.FALSE:
+ main.log.report("Ping test after Point intents related to SDN-IP matching on ICMP failed.")
+ #main.cleanup()
+ #main.exit()
+ if Ping_Result==main.TRUE:
+ main.log.report("Ping all test after Point intents related to SDN-IP matching on ICMP successful")
+
+ case31_result = Ping_Result and p_intent_result1 and p_intent_result2
+ utilities.assert_equals(expect=main.TRUE, actual=case31_result,
+ onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
+ onfail="Point intent related to SDN-IP matching on ICMP and ping test failed")
+
+ def CASE32(self):
+ '''
+ This test case adds point intent related to SDN-IP matching on TCP (ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001)
+ Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
+ '''
+ import json
+
+ main.log.report("This test case adds point intent related to SDN-IP matching on TCP")
+ main.case("Adding bidirectional point intent related to SDN-IP matching on TCP")
+ main.step("Adding bidirectional point intent")
+ """
+ add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1 of:0000000000006018/1
+
+ add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1 of:0000000000003008/1
+
+ add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1 of:0000000000006018/1
+
+ add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1 of:0000000000003008/1
+
+ """
+
+ hosts_json = json.loads(main.ONOScli1.hosts())
+ for i in range(8,9):
+ main.log.info("Adding point intent between h"+str(i)+" and h"+str(i+10))
+ host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+ host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+ host1_id = main.ONOScli1.get_host(host1)['id']
+ host2_id = main.ONOScli1.get_host(host2)['id']
+ for host in hosts_json:
+ if host['id'] == host1_id:
+ ip1 = host['ips'][0]
+ ip1 = str(ip1+"/32")
+ print "ip1 = ", ip1
+ device1 = host['location']['device']
+ device1 = str(device1+"/1")
+ print "device1 = ", device1
+ elif host['id'] == host2_id:
+ ip2 = str(host['ips'][0])+"/32"
+ print "ip2 = ", ip2
+ device2 = host['location']["device"]
+ device2 = str(device2+"/1")
+ print "device2 = ", device2
+
+ p_intent_result1 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
+ ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
+ p_intent_result2 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
+ ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpDst=main.params['SDNIP']['dstPort'])
+
+ p_intent_result3 = main.ONOScli1.add_point_intent(ingress_device=device1, egress_device=device2, ipSrc=ip1, ipDst=ip2,
+ ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
+ p_intent_result4 = main.ONOScli1.add_point_intent(ingress_device=device2, egress_device=device1, ipSrc=ip2, ipDst=ip1,
+ ethType=main.params['SDNIP']['ethType'], ipProto=main.params['SDNIP']['tcpProto'], tcpSrc=main.params['SDNIP']['srcPort'])
+
+ p_intent_result = p_intent_result1 and p_intent_result2 and p_intent_result3 and p_intent_result4
+ if p_intent_result ==main.TRUE:
+ get_intent_result = main.ONOScli1.intents()
+ main.log.info(get_intent_result)
+ main.log.info("Point intent related to SDN-IP matching on TCP install successful")
+
+ iperf_result = main.Mininet1.iperf('h8', 'h18')
+ if iperf_result == main.TRUE:
+ main.log.report("iperf test successful")
+ else:
+ main.log.report("iperf test failed")
+
+
+ case32_result = p_intent_result and iperf_result
+ utilities.assert_equals(expect=main.TRUE, actual=case32_result,
+ onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
+ onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed")
diff --git a/TestON/tests/ProdFunc/ProdFunc.params b/TestON/tests/ProdFunc/ProdFunc.params
index 9b44a53..6879c37 100755
--- a/TestON/tests/ProdFunc/ProdFunc.params
+++ b/TestON/tests/ProdFunc/ProdFunc.params
@@ -1,6 +1,6 @@
<PARAMS>
- <testcases>1,4,5,6,7,8,9</testcases>
+ <testcases>1,4,10,5,6,7,8,6,8,9</testcases>
#Environment variables
<ENV>
diff --git a/TestON/tests/ProdFunc/ProdFunc.py b/TestON/tests/ProdFunc/ProdFunc.py
index 67a2981..7464739 100755
--- a/TestON/tests/ProdFunc/ProdFunc.py
+++ b/TestON/tests/ProdFunc/ProdFunc.py
@@ -6,7 +6,6 @@
import sys
import os
import re
-import time
import json
time.sleep(1)
@@ -17,11 +16,12 @@
def CASE1(self, main):
'''
Startup sequence:
+ cell <name>
+ onos-verify-cell
+ onos-remove-raft-log
git pull
mvn clean install
onos-package
- cell <name>
- onos-verify-cell
onos-install -f
onos-wait-for-start
'''
@@ -33,6 +33,17 @@
main.case("Setting up test environment")
main.log.report("This testcase is testing setting up test environment")
main.log.report("__________________________________")
+
+ main.step("Applying cell variable to environment")
+ cell_result1 = main.ONOSbench.set_cell(cell_name)
+ verify_result = main.ONOSbench.verify_cell()
+ cell_result2 = main.ONOS2.set_cell(cell_name)
+ verify_result = main.ONOS2.verify_cell()
+ cell_result = cell_result1 and cell_result2
+
+ main.step("Removing raft logs before a clen installation of ONOS")
+ main.ONOSbench.onos_remove_raft_logs()
+
main.step("Git checkout and pull master and get version")
main.ONOSbench.git_checkout("master")
git_pull_result = main.ONOSbench.git_pull()
@@ -43,21 +54,10 @@
main.step("Using mvn clean & install")
clean_install_result = main.ONOSbench.clean_install()
#clean_install_result = main.TRUE
-
- main.step("Applying cell variable to environment")
- cell_result1 = main.ONOSbench.set_cell(cell_name)
- verify_result = main.ONOSbench.verify_cell()
- cell_result2 = main.ONOS2.set_cell(cell_name)
- #verify_result = main.ONOS2.verify_cell()
- main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
-
- cell_result = cell_result1 and cell_result2
-
+
main.step("Creating ONOS package")
package_result = main.ONOSbench.onos_package()
- #main.step("Creating a cell")
- #cell_create_result = main.ONOSbench.create_cell_file(**************)
main.step("Installing ONOS package")
onos_install_result = main.ONOSbench.onos_install()
@@ -74,6 +74,8 @@
main.step("Starting ONOS service")
start_result = main.ONOSbench.onos_start(ONOS1_ip)
+
+ main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
case1_result = (package_result and\
cell_result and verify_result and onos_install_result and\
@@ -125,6 +127,218 @@
main.log.info("onos command returned: "+cmd_result2)
+ def CASE20(self):
+ '''
+ Exit from mininet cli
+ reinstall ONOS
+ '''
+ main.log.report("This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology")
+ main.log.report("_____________________________________________")
+ main.step("Disconnecting mininet and restarting ONOS")
+ main.step("Disconnecting mininet and restarting ONOS")
+ mininet_disconnect = main.Mininet1.disconnect()
+
+ main.step("Applying cell variable to environment")
+ cell_result1 = main.ONOSbench.set_cell(cell_name)
+ verify_result = main.ONOSbench.verify_cell()
+ cell_result2 = main.ONOS2.set_cell(cell_name)
+ verify_result = main.ONOS2.verify_cell()
+ cell_result = cell_result1 and cell_result2
+
+ onos_install_result = main.ONOSbench.onos_install()
+ if onos_install_result == main.TRUE:
+ main.log.report("Installing ONOS package successful")
+ else:
+ main.log.report("Installing ONOS package failed")
+
+ onos1_isup = main.ONOSbench.isup()
+ if onos1_isup == main.TRUE:
+ main.log.report("ONOS instance is up and ready")
+ else:
+ main.log.report("ONOS instance may not be up")
+
+ main.step("Starting ONOS service")
+ start_result = main.ONOSbench.onos_start(ONOS1_ip)
+
+ print "mininet_disconnect =", mininet_disconnect
+ print "onos_install_result =", onos_install_result
+ print "onos1_isup =", onos1_isup
+ print "start_result =", start_result
+
+ case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
+ utilities.assert_equals(expect=main.TRUE, actual=case20_result,
+ onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
+ onfail="Exiting functionality mininet topology and reinstalling ONOS failed")
+
+ def CASE21(self, main):
+ import time
+ '''
+ On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
+ which starts the rest and copies the links json file to the onos instance
+ Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
+ from the json config file
+ '''
+ main.log.report("This testcase starts the packet layer topology and REST")
+ main.log.report("_____________________________________________")
+ main.case("Starting LINC-OE and other components")
+ main.step("Starting LINC-OE and other components")
+ start_console_result = main.LincOE1.start_console()
+ optical_mn_script = main.LincOE2.run_optical_mn_script()
+ onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(instance_name = main.params['CTRL']['ip1'], json_file = main.params['OPTICAL']['jsonfile'])
+
+ print "start_console_result =",start_console_result
+ print "optical_mn_script = ",optical_mn_script
+ print "onos_topo_cfg_result =",onos_topo_cfg_result
+
+ case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
+ utilities.assert_equals(expect=main.TRUE, actual=case21_result,
+ onpass="Packet optical topology spawned successsfully",
+ onfail="Packet optical topology spawning failed")
+
+
+ def CASE22(self, main):
+ '''
+ Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
+ and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
+ '''
+
+ main.log.report("This testcase compares the optical+packet topology against what is expected")
+ main.case("Topology comparision")
+ main.step("Topology comparision")
+ main.ONOS3.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+ devices_result = main.ONOS3.devices(json_format = False)
+
+ print "devices_result = ", devices_result
+ devices_linewise = devices_result.split("\n")
+ devices_linewise = devices_linewise[1:-1]
+ roadmCount = 0
+ packetLayerSWCount = 0
+ for line in devices_linewise:
+ components = line.split(",")
+ availability = components[1].split("=")[1]
+ type = components[3].split("=")[1]
+ if availability == 'true' and type == 'ROADM':
+ roadmCount += 1
+ elif availability == 'true' and type =='SWITCH':
+ packetLayerSWCount += 1
+ if roadmCount == 4:
+ print "Number of Optical Switches = %d and is correctly detected" %roadmCount
+ main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is correctly detected")
+ opticalSW_result = main.TRUE
+ else:
+ print "Number of Optical Switches = %d and is wrong" %roadCount
+ main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is wrong")
+ opticalSW_result = main.FALSE
+
+ if packetLayerSWCount == 2:
+ print "Number of Packet layer or mininet Switches = %d and is correctly detected" %packetLayerSWCount
+ main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is correctly detected")
+ packetSW_result = main.TRUE
+ else:
+ print "Number of Packet layer or mininet Switches = %d and is wrong" %packetLayerSWCount
+ main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is wrong")
+ packetSW_result = main.FALSE
+ print "_________________________________"
+
+ links_result = main.ONOS3.links(json_format = False)
+ print "links_result = ", links_result
+ print "_________________________________"
+
+
+
+ #Discover hosts using pingall
+ pingall_result = main.LincOE2.pingall()
+
+ hosts_result = main.ONOS3.hosts(json_format = False)
+ main.log.info("hosts_result = "+hosts_result)
+ main.log.info("_________________________________")
+ hosts_linewise = hosts_result.split("\n")
+ hosts_linewise = hosts_linewise[1:-1]
+ hostCount = 0
+ for line in hosts_linewise:
+ hostid = line.split(",")[0].split("=")[1]
+ hostCount +=1
+ if hostCount ==2:
+ print "Number of hosts = %d and is correctly detected" %hostCount
+ main.log.info("Number of hosts = " + str(hostCount) +" and is correctly detected")
+ hostDiscovery = main.TRUE
+ else:
+ print "Number of hosts = %d and is wrong" %hostCount
+ main.log.info("Number of hosts = " + str(hostCount) +" and is wrong")
+ hostDiscovery = main.FALSE
+
+ case22_result = opticalSW_result and packetSW_result and hostDiscovery
+ utilities.assert_equals(expect=main.TRUE, actual=case22_result,
+ onpass="Packet optical topology discovery successful",
+ onfail="Packet optical topology discovery failed")
+
+ def CASE23(self, main):
+ import time
+ '''
+ Add bidirectional point intents between 2 packet layer(mininet) devices and
+ ping mininet hosts
+ '''
+ main.log.report("This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts")
+ main.case("Topology comparision")
+ main.step("Adding point intents")
+ ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0001/1", "of:0000ffffffff0002/1")
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS3.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0002/1", "of:0000ffffffff0001/1")
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS3.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ time.sleep(10)
+ flowHandle = main.ONOS3.flows()
+ #print "flowHandle = ", flowHandle
+ main.log.info("flows :" + flowHandle)
+
+ # Sleep for 30 seconds to provide time for the intent state to change
+ time.sleep(30)
+ intentHandle = main.ONOS3.intents()
+ main.log.info("intents :" + intentHandle)
+
+ Ping_Result = main.TRUE
+ count = 1
+ main.log.info("\n\nh1 is Pinging h2")
+ ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+ #ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count<5:
+ count+=1
+ Ping_Result = main.FALSE
+ main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
+ time.sleep(2)
+ ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+ #ping = main.LincOE2.pinghost()
+ elif ping==main.FALSE:
+ main.log.info("All ping attempts between h1 and h2 have failed")
+ Ping_Result = main.FALSE
+ elif ping==main.TRUE:
+ main.log.info("Ping test between h1 and h2 passed!")
+ Ping_Result = main.TRUE
+ else:
+ main.log.info("Unknown error")
+ Ping_Result = main.ERROR
+
+ if Ping_Result==main.FALSE:
+ main.log.report("Point intents for packet optical have not ben installed correctly. Cleaning up")
+ if Ping_Result==main.TRUE:
+ main.log.report("Point Intents for packet optical have been installed correctly")
+
+ case23_result = Ping_Result
+ utilities.assert_equals(expect=main.TRUE, actual=case23_result,
+ onpass="Point intents addition for packet optical and Pingall Test successful",
+ onfail="Point intents addition for packet optical and Pingall Test NOT successful")
+
+
+
+
def CASE4(self, main):
import re
@@ -235,17 +449,33 @@
else:
main.log.report("Pingall Test in reactive mode to discover the hosts failed")
- utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall T est successful",onfail="Controller assignment and Pingall Test NOT successful")
+ utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
+
+ def CASE10(self):
+ main.log.report("This testcase uninstalls the reactive forwarding app")
+ main.log.report("__________________________________")
+ main.case("Uninstalling reactive forwarding app")
+ #Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
+ main.log.info("onos-app-fwd uninstalled")
+
+ #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+ #So sleep for 15s
+ time.sleep(15)
+
+ flows = main.ONOS2.flows()
+ main.log.info(flows)
+
+ case10_result = appUninstall_result
+ utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
def CASE6(self):
- main.log.report("This testcase is testing the addition of host intents and then doing pingall")
+ main.log.report("This testcase is testing the addition of host intents and then does pingall")
main.log.report("__________________________________")
- main.case("Uninstalling reactive forwarding app and addhost intents")
+ main.case("Obtaining host id's")
main.step("Get hosts")
- main.ONOS2.handle.sendline("hosts")
- main.ONOS2.handle.expect("onos>")
- hosts = main.ONOS2.handle.before
+ hosts = main.ONOS2.hosts()
main.log.info(hosts)
main.step("Get all devices id")
@@ -254,7 +484,7 @@
#ONOS displays the hosts in hex format unlike mininet which does in decimal format
#So take care while adding intents
-
+ '''
main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
@@ -266,22 +496,24 @@
hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
-
-
-
print "_____________________________________________________________________________________"
+ '''
- #Unistall onos-app-fwd app to disable reactive forwarding
- appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
- main.log.info("onos-app-fwd uninstalled")
+ for i in range(8,18):
+ main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+ host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+ host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+ #NOTE: get host can return None
+ #TODO: handle this
+ host1_id = main.ONOS2.get_host(host1)['id']
+ host2_id = main.ONOS2.get_host(host2)['id']
+ tmp_result = main.ONOS2.add_host_intent(host1_id, host2_id )
- #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
- #So sleep for 15s
- time.sleep(15)
-
+ time.sleep(10)
+ h_intents = main.ONOS2.intents()
+ main.log.info("intents:" +h_intents)
flowHandle = main.ONOS2.flows()
- #print "flowHandle = ", flowHandle
- main.log.info("flow:" +flowHandle)
+ #main.log.info("flow:" +flowHandle)
count = 1
i = 8
@@ -315,7 +547,7 @@
main.log.report("Ping all test after Host intent addition successful")
case6_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case4_result,
+ utilities.assert_equals(expect=main.TRUE, actual=case6_result,
onpass="Pingall Test after Host intents addition successful",
onfail="Pingall Test after Host intents addition failed")
@@ -413,6 +645,7 @@
main.log.report("__________________________________")
main.log.report("Killing a link to ensure that link discovery is consistent")
main.case("Killing a link to Ensure that Link Discovery is Working Properly")
+ '''
main.step("Start continuous pings")
main.Mininet2.pingLong(src=main.params['PING']['source1'],
@@ -435,7 +668,7 @@
target=main.params['PING']['target9'],pingTime=500)
main.Mininet2.pingLong(src=main.params['PING']['source10'],
target=main.params['PING']['target10'],pingTime=500)
-
+ '''
main.step("Determine the current number of switches and links")
topology_output = main.ONOS2.topology()
@@ -470,30 +703,9 @@
onpass="Link up discovered properly",
onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
- #Check ping result here..add code for it
- main.step("Start continuous pings")
-
- main.Mininet2.pingLong(src=main.params['PING']['source1'],
- target=main.params['PING']['target1'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source2'],
- target=main.params['PING']['target2'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source3'],
- target=main.params['PING']['target3'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source4'],
- target=main.params['PING']['target4'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source5'],
- target=main.params['PING']['target5'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source6'],
- target=main.params['PING']['target6'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source7'],
- target=main.params['PING']['target7'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source8'],
- target=main.params['PING']['target8'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source9'],
- target=main.params['PING']['target9'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source10'],
- target=main.params['PING']['target10'],pingTime=500)
-
+ #NOTE Check ping result here..add code for it
+
+
main.step("Compare ONOS Topology to MN Topology")
Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
MNTopo = Topo
@@ -532,19 +744,22 @@
'''
Host intents removal
'''
- main.log.report("This testcase removes host intents before adding the point intents")
+ main.log.report("This testcase removes host intents before adding the same intents or point intents")
main.log.report("__________________________________")
main.log.info("Host intents removal")
main.case("Removing host intents")
main.step("Obtain the intent id's")
intent_result = main.ONOS2.intents()
#print "intent_result = ",intent_result
+
intent_linewise = intent_result.split("\n")
- intent_linewise = intent_linewise[1:-1] #ignore the first and last item of the list obtained from split
- #for line in intent_linewise:
- #print "line = ", line
- intentids = []
+ intentList = []
for line in intent_linewise:
+ if line.startswith("id="):
+ intentList.append(line)
+
+ intentids = []
+ for line in intentList:
intentids.append(line.split(",")[0].split("=")[1])
for id in intentids:
print "id = ", id
@@ -555,10 +770,13 @@
intent_result = main.ONOS2.intents()
intent_linewise = intent_result.split("\n")
- intent_linewise = intent_linewise[1:-1] #ignore the first and last item of the list obtained from split
-
+ list_afterRemoval = []
+ for line in intent_linewise:
+ if line.startswith("id="):
+ list_afterRemoval.append(line)
+
intentState = {}
- for id, line in zip(intentids, intent_linewise):
+ for id, line in zip(intentids, list_afterRemoval):
#print "line after removing intent = ", line
x = line.split(",")
state = x[1].split("=")[1]
@@ -576,13 +794,41 @@
main.log.report("Intent removal successful")
else:
main.log.report("Intent removal failed")
-
- utilities.assert_equals(expect=main.TRUE, actual=case8_result,
- onpass="Intent removal test successful",
- onfail="Intent removal test failed")
+
+ Ping_Result = main.TRUE
+ if case8_result == main.TRUE:
+ i = 8
+ while i <18 :
+ main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+ if ping==main.TRUE:
+ i = 19
+ Ping_Result = Ping_Result and main.TRUE
+ elif ping==main.FALSE:
+ i+=1
+ Ping_Result = Ping_Result and main.FALSE
+ else:
+ main.log.info("Unknown error")
+ Ping_Result = main.ERROR
+ #Note: If the ping result failed, that means the intents have been withdrawn correctly.
+ if Ping_Result==main.TRUE:
+ main.log.report("Host intents have not been withdrawn correctly")
+ #main.cleanup()
+ #main.exit()
+ if Ping_Result==main.FALSE:
+ main.log.report("Host intents have been withdrawn correctly")
-
+ case8_result = case8_result and Ping_Result
+
+ if case8_result == main.FALSE:
+ main.log.report("Intent removal successful")
+ else:
+ main.log.report("Intent removal failed")
+
+ utilities.assert_equals(expect=main.FALSE, actual=case8_result,
+ onpass="Intent removal test failed",
+ onfail="Intent removal test passed")
def CASE9(self):
@@ -591,135 +837,135 @@
main.log.info("Adding point intents")
main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008", 1, "of:0000000000006018", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018", 1, "of:0000000000003008", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009", 1, "of:0000000000006019", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019", 1, "of:0000000000003009", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010", 1, "of:0000000000006020", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020", 1, "of:0000000000003010", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011", 1, "of:0000000000006021", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021", 1, "of:0000000000003011", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012", 1, "of:0000000000006022", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022", 1, "of:0000000000003012", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013", 1, "of:0000000000006023", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023", 1, "of:0000000000003013", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014", 1, "of:0000000000006024", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024", 1, "of:0000000000003014", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015", 1, "of:0000000000006025", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025", 1, "of:0000000000003015", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016", 1, "of:0000000000006026", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026", 1, "of:0000000000003016", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017", 1, "of:0000000000006027", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027", 1, "of:0000000000003017", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
print("_______________________________________________________________________________________")
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.params b/TestON/tests/ProdFunc13/ProdFunc13.params
index 9b44a53..a77dd02 100755
--- a/TestON/tests/ProdFunc13/ProdFunc13.params
+++ b/TestON/tests/ProdFunc13/ProdFunc13.params
@@ -1,6 +1,6 @@
<PARAMS>
- <testcases>1,4,5,6,7,8,9</testcases>
+ <testcases>1,4,10,5,6,7,8,6,8,9,20,21,22,10,23,24</testcases>
#Environment variables
<ENV>
@@ -40,4 +40,10 @@
<SwitchDiscovery>31</SwitchDiscovery>
</timers>
+ <OPTICAL>
+ <jsonfile> /home/admin/ONOS/tools/test/topos/oe-nonlinear-4.json </jsonfile>
+ </OPTICAL>
+
+
+
</PARAMS>
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.py b/TestON/tests/ProdFunc13/ProdFunc13.py
index 63a15cc..205bfb8 100755
--- a/TestON/tests/ProdFunc13/ProdFunc13.py
+++ b/TestON/tests/ProdFunc13/ProdFunc13.py
@@ -6,7 +6,6 @@
import sys
import os
import re
-import time
import json
time.sleep(1)
@@ -17,11 +16,12 @@
def CASE1(self, main):
'''
Startup sequence:
+ cell <name>
+ onos-verify-cell
+ onos-remove-raft-log
git pull
mvn clean install
onos-package
- cell <name>
- onos-verify-cell
onos-install -f
onos-wait-for-start
'''
@@ -33,6 +33,17 @@
main.case("Setting up test environment")
main.log.report("This testcase is testing setting up test environment")
main.log.report("__________________________________")
+
+ main.step("Applying cell variable to environment")
+ cell_result1 = main.ONOSbench.set_cell(cell_name)
+ verify_result = main.ONOSbench.verify_cell()
+ cell_result2 = main.ONOS2.set_cell(cell_name)
+ verify_result = main.ONOS2.verify_cell()
+ cell_result = cell_result1 and cell_result2
+
+ main.step("Removing raft logs before a clen installation of ONOS")
+ main.ONOSbench.onos_remove_raft_logs()
+
main.step("Git checkout and pull master and get version")
main.ONOSbench.git_checkout("master")
git_pull_result = main.ONOSbench.git_pull()
@@ -43,21 +54,10 @@
main.step("Using mvn clean & install")
clean_install_result = main.ONOSbench.clean_install()
#clean_install_result = main.TRUE
-
- main.step("Applying cell variable to environment")
- cell_result1 = main.ONOSbench.set_cell(cell_name)
- verify_result = main.ONOSbench.verify_cell()
- cell_result2 = main.ONOS2.set_cell(cell_name)
- #verify_result = main.ONOS2.verify_cell()
- main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
-
- cell_result = cell_result1 and cell_result2
-
+
main.step("Creating ONOS package")
package_result = main.ONOSbench.onos_package()
- #main.step("Creating a cell")
- #cell_create_result = main.ONOSbench.create_cell_file(**************)
main.step("Installing ONOS package")
onos_install_result = main.ONOSbench.onos_install()
@@ -74,6 +74,8 @@
main.step("Starting ONOS service")
start_result = main.ONOSbench.onos_start(ONOS1_ip)
+
+ main.ONOS2.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
case1_result = (package_result and\
cell_result and verify_result and onos_install_result and\
@@ -125,6 +127,273 @@
main.log.info("onos command returned: "+cmd_result2)
+ def CASE20(self):
+ '''
+ Exit from mininet cli
+ reinstall ONOS
+ '''
+ main.log.report("This testcase exits the mininet cli and reinstalls ONOS to switch over to Packet Optical topology")
+ main.log.report("_____________________________________________")
+ main.step("Disconnecting mininet and restarting ONOS")
+ main.step("Disconnecting mininet and restarting ONOS")
+ mininet_disconnect = main.Mininet1.disconnect()
+
+ main.step("Applying cell variable to environment")
+ cell_result1 = main.ONOSbench.set_cell(cell_name)
+ verify_result = main.ONOSbench.verify_cell()
+ cell_result2 = main.ONOS2.set_cell(cell_name)
+ verify_result = main.ONOS2.verify_cell()
+ cell_result = cell_result1 and cell_result2
+
+ onos_install_result = main.ONOSbench.onos_install()
+ if onos_install_result == main.TRUE:
+ main.log.report("Installing ONOS package successful")
+ else:
+ main.log.report("Installing ONOS package failed")
+
+ onos1_isup = main.ONOSbench.isup()
+ if onos1_isup == main.TRUE:
+ main.log.report("ONOS instance is up and ready")
+ else:
+ main.log.report("ONOS instance may not be up")
+
+ main.step("Starting ONOS service")
+ start_result = main.ONOSbench.onos_start(ONOS1_ip)
+
+ print "mininet_disconnect =", mininet_disconnect
+ print "onos_install_result =", onos_install_result
+ print "onos1_isup =", onos1_isup
+ print "start_result =", start_result
+
+ case20_result = mininet_disconnect and cell_result and onos_install_result and onos1_isup and start_result
+ utilities.assert_equals(expect=main.TRUE, actual=case20_result,
+ onpass="Exiting functionality mininet topology and reinstalling ONOS successful",
+ onfail="Exiting functionality mininet topology and reinstalling ONOS failed")
+
+ def CASE21(self, main):
+ import time
+ '''
+ On ONOS bench, run this command: ./~/ONOS/tools/test/bin/onos-topo-cfg
+ which starts the rest and copies the links json file to the onos instance
+ Note that in case of Packet Optical, the links are not learnt from the topology, instead the links are learnt
+ from the json config file
+ '''
+ main.log.report("This testcase starts the packet layer topology and REST")
+ main.log.report("_____________________________________________")
+ main.case("Starting LINC-OE and other components")
+ main.step("Starting LINC-OE and other components")
+ start_console_result = main.LincOE1.start_console()
+ optical_mn_script = main.LincOE2.run_optical_mn_script()
+ onos_topo_cfg_result = main.ONOSbench.run_onos_topo_cfg(instance_name = main.params['CTRL']['ip1'], json_file = main.params['OPTICAL']['jsonfile'])
+
+ print "start_console_result =",start_console_result
+ print "optical_mn_script = ",optical_mn_script
+ print "onos_topo_cfg_result =",onos_topo_cfg_result
+
+ case21_result = start_console_result and optical_mn_script and onos_topo_cfg_result
+ utilities.assert_equals(expect=main.TRUE, actual=case21_result,
+ onpass="Packet optical topology spawned successsfully",
+ onfail="Packet optical topology spawning failed")
+
+
+ def CASE22(self, main):
+ '''
+ Curretly we use, 4 linear switch optical topology and 2 packet layer mininet switches each with one host.
+ Therefore, the roadmCount variable = 4, packetLayerSWCount variable = 2, hostCount =2
+ and this is hardcoded in the testcase. If the topology changes, these hardcoded values need to be changed
+ '''
+
+ main.log.report("This testcase compares the optical+packet topology against what is expected")
+ main.case("Topology comparision")
+ main.step("Topology comparision")
+ main.ONOS3.start_onos_cli(ONOS_ip=main.params['CTRL']['ip1'])
+ devices_result = main.ONOS3.devices(json_format = False)
+
+ print "devices_result = ", devices_result
+ devices_linewise = devices_result.split("\n")
+ devices_linewise = devices_linewise[1:-1]
+ roadmCount = 0
+ packetLayerSWCount = 0
+ for line in devices_linewise:
+ components = line.split(",")
+ availability = components[1].split("=")[1]
+ type = components[3].split("=")[1]
+ if availability == 'true' and type == 'ROADM':
+ roadmCount += 1
+ elif availability == 'true' and type =='SWITCH':
+ packetLayerSWCount += 1
+ if roadmCount == 4:
+ print "Number of Optical Switches = %d and is correctly detected" %roadmCount
+ main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is correctly detected")
+ opticalSW_result = main.TRUE
+ else:
+ print "Number of Optical Switches = %d and is wrong" %roadCount
+ main.log.info ("Number of Optical Switches = " +str(roadmCount) +" and is wrong")
+ opticalSW_result = main.FALSE
+
+ if packetLayerSWCount == 2:
+ print "Number of Packet layer or mininet Switches = %d and is correctly detected" %packetLayerSWCount
+ main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is correctly detected")
+ packetSW_result = main.TRUE
+ else:
+ print "Number of Packet layer or mininet Switches = %d and is wrong" %packetLayerSWCount
+ main.log.info("Number of Packet layer or mininet Switches = " +str(packetLayerSWCount) + " and is wrong")
+ packetSW_result = main.FALSE
+ print "_________________________________"
+
+ links_result = main.ONOS3.links(json_format = False)
+ print "links_result = ", links_result
+ print "_________________________________"
+
+
+
+ #Discover hosts using pingall
+ pingall_result = main.LincOE2.pingall()
+
+ hosts_result = main.ONOS3.hosts(json_format = False)
+ main.log.info("hosts_result = "+hosts_result)
+ main.log.info("_________________________________")
+ hosts_linewise = hosts_result.split("\n")
+ hosts_linewise = hosts_linewise[1:-1]
+ hostCount = 0
+ for line in hosts_linewise:
+ hostid = line.split(",")[0].split("=")[1]
+ hostCount +=1
+ if hostCount ==2:
+ print "Number of hosts = %d and is correctly detected" %hostCount
+ main.log.info("Number of hosts = " + str(hostCount) +" and is correctly detected")
+ hostDiscovery = main.TRUE
+ else:
+ print "Number of hosts = %d and is wrong" %hostCount
+ main.log.info("Number of hosts = " + str(hostCount) +" and is wrong")
+ hostDiscovery = main.FALSE
+
+ case22_result = opticalSW_result and packetSW_result and hostDiscovery
+ utilities.assert_equals(expect=main.TRUE, actual=case22_result,
+ onpass="Packet optical topology discovery successful",
+ onfail="Packet optical topology discovery failed")
+
+ def CASE23(self, main):
+ import time
+ '''
+ Add bidirectional point intents between 2 packet layer(mininet) devices and
+ ping mininet hosts
+ '''
+ main.log.report("This testcase adds bidirectional point intents between 2 packet layer(mininet) devices and ping mininet hosts")
+ main.case("Topology comparision")
+ main.step("Adding point intents")
+ ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0001/1", "of:0000ffffffff0002/1")
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS3.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ ptp_intent_result = main.ONOS3.add_point_intent("of:0000ffffffff0002/1", "of:0000ffffffff0001/1")
+ if ptp_intent_result == main.TRUE:
+ get_intent_result = main.ONOS3.intents()
+ main.log.info("Point to point intent install successful")
+ main.log.info(get_intent_result)
+
+ time.sleep(10)
+ flowHandle = main.ONOS3.flows()
+ main.log.info("flows :" + flowHandle)
+
+ # Sleep for 30 seconds to provide time for the intent state to change
+ time.sleep(30)
+ intentHandle = main.ONOS3.intents()
+ main.log.info("intents :" + intentHandle)
+
+ Ping_Result = main.TRUE
+ count = 1
+ main.log.info("\n\nh1 is Pinging h2")
+ ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+ #ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count<5:
+ count+=1
+ Ping_Result = main.FALSE
+ main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
+ time.sleep(2)
+ ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+ #ping = main.LincOE2.pinghost()
+ elif ping==main.FALSE:
+ main.log.info("All ping attempts between h1 and h2 have failed")
+ Ping_Result = main.FALSE
+ elif ping==main.TRUE:
+ main.log.info("Ping test between h1 and h2 passed!")
+ Ping_Result = main.TRUE
+ else:
+ main.log.info("Unknown error")
+ Ping_Result = main.ERROR
+
+ if Ping_Result==main.FALSE:
+ main.log.report("Point intents for packet optical have not ben installed correctly. Cleaning up")
+ if Ping_Result==main.TRUE:
+ main.log.report("Point Intents for packet optical have been installed correctly")
+
+ case23_result = Ping_Result
+ utilities.assert_equals(expect=main.TRUE, actual=case23_result,
+ onpass="Point intents addition for packet optical and Pingall Test successful",
+ onfail="Point intents addition for packet optical and Pingall Test NOT successful")
+
+
+
+ def CASE24(self, main):
+ import time
+ '''
+ Test Rerouting of Packet Optical by bringing a port down (port 22) of a switch(switchID=1), so that link (between switch1 port22 - switch4-port30) is inactive
+ and do a ping test. If rerouting is successful, ping should pass. also check the flows
+ '''
+ main.log.report("This testcase tests rerouting and pings mininet hosts")
+ main.step("Test rerouting and pings mininet hosts")
+ main.case("Bring a port down and verify the link state")
+ main.LincOE1.port_down(sw_id=1, pt_id=22)
+ links_result = main.ONOS3.links()
+ links_state_result = main.FALSE
+ for item in links_result:
+ if item('src') == "of:0000ffffffffff01/22" and item('dst') == "of:0000ffffffffff04/30":
+ links_state = item('state')
+ if links_state == "INACTIVE":
+ main.log.info("Links state is inactive as expected due to one of the ports being down")
+ main.log.report("Links state is inactive as expected due to one of the ports being down")
+ links_state_result = main.TRUE
+ break
+ else:
+ main.log.info("Links state is not inactive as expected")
+ main.log.report("Links state is not inactive as expected")
+ links_state_result = main.FALSE
+
+ main.case("Verify Rerouting by a ping test")
+ Ping_Result = main.TRUE
+ count = 1
+ main.log.info("\n\nh1 is Pinging h2")
+ ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+ #ping = main.LincOE2.pinghost()
+ if ping == main.FALSE and count<5:
+ count+=1
+ Ping_Result = main.FALSE
+ main.log.info("Ping between h1 and h2 failed. Making attempt number "+str(count) + " in 2 seconds")
+ time.sleep(2)
+ ping = main.LincOE2.pingHostOptical(src="h1", target="h2")
+ #ping = main.LincOE2.pinghost()
+ elif ping==main.FALSE:
+ main.log.info("All ping attempts between h1 and h2 have failed")
+ Ping_Result = main.FALSE
+ elif ping==main.TRUE:
+ main.log.info("Ping test between h1 and h2 passed!")
+ Ping_Result = main.TRUE
+ else:
+ main.log.info("Unknown error")
+ Ping_Result = main.ERROR
+
+ if Ping_Result==main.FALSE:
+ main.log.report("Ping test successful ")
+ if Ping_Result==main.TRUE:
+ main.log.report("Ping test failed")
+
+ case24_result = Ping_Result and links_state_result
+ utilities.assert_equals(expect=main.TRUE, actual=case24_result,
+ onpass="Packet optical rerouting successful",
+ onfail="Packet optical rerouting failed")
def CASE4(self, main):
import re
@@ -235,17 +504,33 @@
else:
main.log.report("Pingall Test in reactive mode to discover the hosts failed")
- utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall T est successful",onfail="Controller assignment and Pingall Test NOT successful")
+ utilities.assert_equals(expect=main.TRUE, actual=case4_result,onpass="Controller assignment and Pingall Test successful",onfail="Controller assignment and Pingall Test NOT successful")
+
+ def CASE10(self):
+ main.log.report("This testcase uninstalls the reactive forwarding app")
+ main.log.report("__________________________________")
+ main.case("Uninstalling reactive forwarding app")
+ #Unistall onos-app-fwd app to disable reactive forwarding
+ appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
+ main.log.info("onos-app-fwd uninstalled")
+
+ #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
+ #So sleep for 15s
+ time.sleep(15)
+
+ flows = main.ONOS2.flows()
+ main.log.info(flows)
+
+ case10_result = appUninstall_result
+ utilities.assert_equals(expect=main.TRUE, actual=case10_result,onpass="Reactive forwarding app uninstallation successful",onfail="Reactive forwarding app uninstallation failed")
def CASE6(self):
- main.log.report("This testcase is testing the addition of host intents and then doing pingall")
+ main.log.report("This testcase is testing the addition of host intents and then does pingall")
main.log.report("__________________________________")
- main.case("Uninstalling reactive forwarding app and addhost intents")
+ main.case("Obtaining host id's")
main.step("Get hosts")
- main.ONOS2.handle.sendline("hosts")
- main.ONOS2.handle.expect("onos>")
- hosts = main.ONOS2.handle.before
+ hosts = main.ONOS2.hosts()
main.log.info(hosts)
main.step("Get all devices id")
@@ -254,7 +539,7 @@
#ONOS displays the hosts in hex format unlike mininet which does in decimal format
#So take care while adding intents
-
+ '''
main.step("Add host-to-host intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1")
hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1")
@@ -266,22 +551,24 @@
hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1")
hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1")
hth_intent_result = main.ONOS2.add_host_intent("00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1")
-
-
-
print "_____________________________________________________________________________________"
+ '''
- #Unistall onos-app-fwd app to disable reactive forwarding
- appUninstall_result = main.ONOS2.feature_uninstall("onos-app-fwd")
- main.log.info("onos-app-fwd uninstalled")
+ for i in range(8,18):
+ main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+ host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+ host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+ #NOTE: get host can return None
+ #TODO: handle this
+ host1_id = main.ONOS2.get_host(host1)['id']
+ host2_id = main.ONOS2.get_host(host2)['id']
+ tmp_result = main.ONOS2.add_host_intent(host1_id, host2_id )
- #After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
- #So sleep for 15s
- time.sleep(15)
-
+ time.sleep(10)
+ h_intents = main.ONOS2.intents()
+ main.log.info("intents:" +h_intents)
flowHandle = main.ONOS2.flows()
- #print "flowHandle = ", flowHandle
- main.log.info("flow:" +flowHandle)
+ #main.log.info("flow:" +flowHandle)
count = 1
i = 8
@@ -315,7 +602,7 @@
main.log.report("Ping all test after Host intent addition successful")
case6_result = Ping_Result
- utilities.assert_equals(expect=main.TRUE, actual=case4_result,
+ utilities.assert_equals(expect=main.TRUE, actual=case6_result,
onpass="Pingall Test after Host intents addition successful",
onfail="Pingall Test after Host intents addition failed")
@@ -413,6 +700,7 @@
main.log.report("__________________________________")
main.log.report("Killing a link to ensure that link discovery is consistent")
main.case("Killing a link to Ensure that Link Discovery is Working Properly")
+ '''
main.step("Start continuous pings")
main.Mininet2.pingLong(src=main.params['PING']['source1'],
@@ -435,7 +723,7 @@
target=main.params['PING']['target9'],pingTime=500)
main.Mininet2.pingLong(src=main.params['PING']['source10'],
target=main.params['PING']['target10'],pingTime=500)
-
+ '''
main.step("Determine the current number of switches and links")
topology_output = main.ONOS2.topology()
@@ -470,30 +758,9 @@
onpass="Link up discovered properly",
onfail="Link up was not discovered in "+ str(link_sleep) + " seconds")
- #Check ping result here..add code for it
- main.step("Start continuous pings")
-
- main.Mininet2.pingLong(src=main.params['PING']['source1'],
- target=main.params['PING']['target1'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source2'],
- target=main.params['PING']['target2'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source3'],
- target=main.params['PING']['target3'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source4'],
- target=main.params['PING']['target4'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source5'],
- target=main.params['PING']['target5'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source6'],
- target=main.params['PING']['target6'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source7'],
- target=main.params['PING']['target7'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source8'],
- target=main.params['PING']['target8'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source9'],
- target=main.params['PING']['target9'],pingTime=500)
- main.Mininet2.pingLong(src=main.params['PING']['source10'],
- target=main.params['PING']['target10'],pingTime=500)
-
+ #NOTE Check ping result here..add code for it
+
+
main.step("Compare ONOS Topology to MN Topology")
Topo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
MNTopo = Topo
@@ -532,19 +799,22 @@
'''
Host intents removal
'''
- main.log.report("This testcase removes host intents before adding the point intents")
+ main.log.report("This testcase removes host intents before adding the same intents or point intents")
main.log.report("__________________________________")
main.log.info("Host intents removal")
main.case("Removing host intents")
main.step("Obtain the intent id's")
intent_result = main.ONOS2.intents()
#print "intent_result = ",intent_result
+
intent_linewise = intent_result.split("\n")
- intent_linewise = intent_linewise[1:-1] #ignore the first and last item of the list obtained from split
- #for line in intent_linewise:
- #print "line = ", line
- intentids = []
+ intentList = []
for line in intent_linewise:
+ if line.startswith("id="):
+ intentList.append(line)
+
+ intentids = []
+ for line in intentList:
intentids.append(line.split(",")[0].split("=")[1])
for id in intentids:
print "id = ", id
@@ -555,10 +825,13 @@
intent_result = main.ONOS2.intents()
intent_linewise = intent_result.split("\n")
- intent_linewise = intent_linewise[1:-1] #ignore the first and last item of the list obtained from split
-
+ list_afterRemoval = []
+ for line in intent_linewise:
+ if line.startswith("id="):
+ list_afterRemoval.append(line)
+
intentState = {}
- for id, line in zip(intentids, intent_linewise):
+ for id, line in zip(intentids, list_afterRemoval):
#print "line after removing intent = ", line
x = line.split(",")
state = x[1].split("=")[1]
@@ -576,13 +849,41 @@
main.log.report("Intent removal successful")
else:
main.log.report("Intent removal failed")
-
- utilities.assert_equals(expect=main.TRUE, actual=case8_result,
- onpass="Intent removal test successful",
- onfail="Intent removal test failed")
+
+ Ping_Result = main.TRUE
+ if case8_result == main.TRUE:
+ i = 8
+ while i <18 :
+ main.log.info("\n\nh"+str(i)+" is Pinging h" + str(i+10))
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+ if ping==main.TRUE:
+ i = 19
+ Ping_Result = Ping_Result and main.TRUE
+ elif ping==main.FALSE:
+ i+=1
+ Ping_Result = Ping_Result and main.FALSE
+ else:
+ main.log.info("Unknown error")
+ Ping_Result = main.ERROR
+ #Note: If the ping result failed, that means the intents have been withdrawn correctly.
+ if Ping_Result==main.TRUE:
+ main.log.report("Host intents have not been withdrawn correctly")
+ #main.cleanup()
+ #main.exit()
+ if Ping_Result==main.FALSE:
+ main.log.report("Host intents have been withdrawn correctly")
-
+ case8_result = case8_result and Ping_Result
+
+ if case8_result == main.FALSE:
+ main.log.report("Intent removal successful")
+ else:
+ main.log.report("Intent removal failed")
+
+ utilities.assert_equals(expect=main.FALSE, actual=case8_result,
+ onpass="Intent removal test failed",
+ onfail="Intent removal test passed")
def CASE9(self):
@@ -591,135 +892,135 @@
main.log.info("Adding point intents")
main.case("Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)")
main.step("Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008", 1, "of:0000000000006018", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003008/1", "of:0000000000006018/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018", 1, "of:0000000000003008", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006018/1", "of:0000000000003008/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009", 1, "of:0000000000006019", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003009/1", "of:0000000000006019/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019", 1, "of:0000000000003009", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006019/1", "of:0000000000003009/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010", 1, "of:0000000000006020", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003010/1", "of:0000000000006020/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020", 1, "of:0000000000003010", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006020/1", "of:0000000000003010/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011", 1, "of:0000000000006021", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003011/1", "of:0000000000006021/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021", 1, "of:0000000000003011", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006021/1", "of:0000000000003011/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012", 1, "of:0000000000006022", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003012/1", "of:0000000000006022/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022", 1, "of:0000000000003012", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006022/1", "of:0000000000003012/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013", 1, "of:0000000000006023", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003013/1", "of:0000000000006023/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023", 1, "of:0000000000003013", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006023/1", "of:0000000000003013/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014", 1, "of:0000000000006024", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003014/1", "of:0000000000006024/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024", 1, "of:0000000000003014", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006024/1", "of:0000000000003014/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015", 1, "of:0000000000006025", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003015/1", "of:0000000000006025/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025", 1, "of:0000000000003015", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006025/1", "of:0000000000003015/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016", 1, "of:0000000000006026", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003016/1", "of:0000000000006026/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026", 1, "of:0000000000003016", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006026/1", "of:0000000000003016/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
main.step("Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B")
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017", 1, "of:0000000000006027", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000003017/1", "of:0000000000006027/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
- ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027", 1, "of:0000000000003017", 1)
+ ptp_intent_result = main.ONOS2.add_point_intent("of:0000000000006027/1", "of:0000000000003017/1")
if ptp_intent_result == main.TRUE:
get_intent_result = main.ONOS2.intents()
main.log.info("Point to point intent install successful")
- main.log.info(get_intent_result)
+ #main.log.info(get_intent_result)
print("_______________________________________________________________________________________")
diff --git a/TestON/tests/ProdFunc13/ProdFunc13.topo b/TestON/tests/ProdFunc13/ProdFunc13.topo
index cf6ffac..c592e18 100755
--- a/TestON/tests/ProdFunc13/ProdFunc13.topo
+++ b/TestON/tests/ProdFunc13/ProdFunc13.topo
@@ -28,12 +28,22 @@
<COMPONENTS> </COMPONENTS>
</ONOS2>
+ <ONOS3>
+ <host>10.128.10.11</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+
<Mininet1>
<host>10.128.10.11</host>
<user>admin</user>
<password>onos_test</password>
<type>MininetCliDriver</type>
- <connect_order>4</connect_order>
+ <connect_order>5</connect_order>
<COMPONENTS>
#Specify the Option for mininet
<arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
@@ -48,7 +58,7 @@
<user>admin</user>
<password>onos_test</password>
<type>RemoteMininetDriver</type>
- <connect_order>5</connect_order>
+ <connect_order>6</connect_order>
<COMPONENTS>
#Specify the Option for mininet
<arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
@@ -57,5 +67,37 @@
<controller> remote </controller>
</COMPONENTS>
</Mininet2>
+
+ <LincOE1>
+ <host>10.128.20.30</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>LincOEDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS>
+ <arg1> </arg1>
+ </COMPONENTS>
+ </LincOE1>
+
+ <LincOE2>
+ <host>10.128.20.30</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS>
+ <arg1> sudo python /home/admin/optical.py </arg1>
+ <arg2> </arg2>
+ </COMPONENTS>
+ </LincOE2>
+
+ <LincOE3>
+ <host>10.128.20.30</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>LincOEDriver</type>
+ <connect_order>9</connect_order>
+ </LincOE3>
+
</COMPONENT>
</TOPOLOGY>
diff --git a/TestON/tests/SdnIpTest/SdnIpTest.py b/TestON/tests/SdnIpTest/SdnIpTest.py
index dd73766..543bea2 100755
--- a/TestON/tests/SdnIpTest/SdnIpTest.py
+++ b/TestON/tests/SdnIpTest/SdnIpTest.py
@@ -1,3 +1,4 @@
+from cupshelpers.config import prefix
#Testing the basic functionality of SDN-IP
@@ -24,38 +25,51 @@
SDNIP_JSON_FILE_PATH = "../tests/SdnIpTest/sdnip.json"
# all expected routes for all BGP peers
allRoutes_expected = []
- main.step("Start to generate routes for BGP peer on host1")
- prefixes = main.Quaggacli.generate_prefixes(1, 3)
- main.log.info(prefixes)
+ main.step("Start to generate routes for all BGP peers")
+ #bgpPeerHosts = []
+ #for i in range(3, 5):
+ # bgpPeerHosts.append("host" + str(i))
+ #main.log.info("BGP Peer Hosts are:" + bgpPeerHosts)
- # TODO: delete the static prefix below after integration with Demo Mininet script
- prefixes = []
- prefixes.append("172.16.30.0/24")
- prefixes.append("1.0.0.0/24")
- prefixes.append("2.0.0.0/24")
- prefixes.append("3.0.0.0/24")
+ #for i in range(3, 5):
+ # QuaggaCliHost = "QuaggaCliHost" + str(i)
+ # prefixes = main.QuaggaCliHost.generate_prefixes(3, 10)
+ # main.log.info(prefixes)
+ #allRoutes_expected.append(prefixes)
+ main.log.info("Generate prefixes for host3")
+ prefixes_host3 = main.QuaggaCliHost3.generate_prefixes(3, 10)
+ main.log.info(prefixes_host3)
+ # generate route with next hop
+ for prefix in prefixes_host3:
+ allRoutes_expected.append(prefix + "/" + "192.168.20.1")
+ routeIntents_expected_host3 = main.QuaggaCliHost3.generate_expected_onePeerRouteIntents(prefixes_host3, "192.168.20.1", "00:00:00:00:02:02", SDNIP_JSON_FILE_PATH)
- for prefix in prefixes:
- # generate route with next hop
- allRoutes_expected.append(prefix + "/" + "1.1.1.1")
+ main.log.info("Generate prefixes for host4")
+ prefixes_host4 = main.QuaggaCliHost4.generate_prefixes(4, 10)
+ main.log.info(prefixes_host4)
+ # generate route with next hop
+ for prefix in prefixes_host4:
+ allRoutes_expected.append(prefix + "/" + "192.168.30.1")
+ routeIntents_expected_host4 = main.QuaggaCliHost4.generate_expected_onePeerRouteIntents(prefixes_host4, "192.168.30.1", "00:00:00:00:03:01", SDNIP_JSON_FILE_PATH)
- routeIntents_expected = main.Quaggacli.generate_expected_onePeerRouteIntents(prefixes, "192.168.30.1", "00:00:00:00:03:01", SDNIP_JSON_FILE_PATH)
+ routeIntents_expected = routeIntents_expected_host3 + routeIntents_expected_host4
- # start to insert routes into the bgp peer
- main.step("Start Quagga-cli on host1")
- main.Quaggacli.loginQuagga("1.1.1.1")
+ main.step("Login all BGP peers and add routes into peers")
+ main.log.info("Login Quagga CLI on host3")
+ main.QuaggaCliHost3.loginQuagga("1.168.30.2")
+ main.log.info("Enter configuration model of Quagga CLI on host3")
+ main.QuaggaCliHost3.enter_config(64514)
+ main.log.info("Add routes to Quagga on host3")
+ main.QuaggaCliHost3.add_routes(prefixes_host3, 1)
- main.step("Start to configure Quagga on host1")
- main.Quaggacli.enter_config(64513)
-
- main.step("Start to generate and add routes for BGP peer on host1")
- routes = main.Quaggacli.generate_prefixes(8, 3)
- main.Quaggacli.add_routes(routes, 1)
-
- # add generates routes to allRoutes
- for route in routes:
- allRoutes_expected.append(route + "/" + "1.1.1.1")
+ main.log.info("Login Quagga CLI on host4")
+ main.QuaggaCliHost4.loginQuagga("1.168.30.3")
+ main.log.info("Enter configuration model of Quagga CLI on host4")
+ main.QuaggaCliHost4.enter_config(64516)
+ main.log.info("Add routes to Quagga on host4")
+ main.QuaggaCliHost4.add_routes(prefixes_host4, 1)
+
cell_name = main.params['ENV']['cellName']
ONOS1_ip = main.params['CTRL']['ip1']
@@ -77,42 +91,46 @@
main.log.info(list_result)
#get all routes inside SDN-IP
- get_routes_result = main.ONOScli.routes(json_format=True)
+ get_routes_result = main.ONOScli.routes(json_format=True)
# parse routes from ONOS CLI
- allRoutes_actual = main.Quaggacli.extract_actual_routes(get_routes_result)
+ allRoutes_actual = main.QuaggaCliHost3.extract_actual_routes(get_routes_result)
+ allRoutes_str_expected = str(sorted(allRoutes_expected))
+ allRoutes_str_actual = str(allRoutes_actual).replace('u',"")
main.step("Check routes installed")
main.log.info("Routes expected:")
- main.log.info(sorted(allRoutes_expected))
+ main.log.info(allRoutes_str_expected)
main.log.info("Routes get from ONOS CLI:")
- main.log.info(allRoutes_actual)
- utilities.assert_equals(expect=sorted(allRoutes_expected), actual=allRoutes_actual,
+ main.log.info(allRoutes_str_actual)
+ utilities.assert_equals(expect=allRoutes_str_expected, actual=allRoutes_str_actual,
onpass="***Routes in SDN-IP are correct!***",
onfail="***Routes in SDN-IP are wrong!***")
- time.sleep(2)
+ time.sleep(20)
get_intents_result = main.ONOScli.intents(json_format=True)
main.step("Check MultiPointToSinglePointIntent intents installed")
# route_intents_expected are generated when generating routes
# get rpoute intents from ONOS CLI
- routeIntents_actual = main.Quaggacli.extract_actual_routeIntents(get_intents_result)
+ routeIntents_actual = main.QuaggaCliHost3.extract_actual_routeIntents(get_intents_result)
+ routeIntents_str_expected = str(sorted(routeIntents_expected))
+ routeIntents_str_actual = str(routeIntents_actual).replace('u',"")
main.log.info("MultiPointToSinglePoint intents expected:")
- main.log.info(routeIntents_expected)
+ main.log.info(routeIntents_str_expected)
main.log.info("MultiPointToSinglePoint intents get from ONOS CLI:")
- main.log.info(routeIntents_actual)
- utilities.assert_equals(expect=True, actual=eq(routeIntents_expected, routeIntents_actual),
+ main.log.info(routeIntents_str_actual)
+ utilities.assert_equals(expect=True, actual=eq(routeIntents_str_expected, routeIntents_str_actual),
onpass="***MultiPointToSinglePoint Intents in SDN-IP are correct!***",
onfail="***MultiPointToSinglePoint Intents in SDN-IP are wrong!***")
main.step("Check BGP PointToPointIntent intents installed")
# bgp intents expected
- bgpIntents_expected = main.Quaggacli.generate_expected_bgpIntents(SDNIP_JSON_FILE_PATH)
+ bgpIntents_expected = main.QuaggaCliHost3.generate_expected_bgpIntents(SDNIP_JSON_FILE_PATH)
# get BGP intents from ONOS CLI
- bgpIntents_actual = main.Quaggacli.extract_actual_bgpIntents(get_intents_result)
+ bgpIntents_actual = main.QuaggaCliHost3.extract_actual_bgpIntents(get_intents_result)
bgpIntents_str_expected = str(bgpIntents_expected).replace('u',"")
bgpIntents_str_actual = str(bgpIntents_actual)
diff --git a/TestON/tests/SdnIpTest/SdnIpTest.topo b/TestON/tests/SdnIpTest/SdnIpTest.topo
index 1d23878..a2d9616 100755
--- a/TestON/tests/SdnIpTest/SdnIpTest.topo
+++ b/TestON/tests/SdnIpTest/SdnIpTest.topo
@@ -28,14 +28,30 @@
<COMPONENTS> </COMPONENTS>
</ONOS1>
- <Quaggacli>
+ <QuaggaCliHost3>
<host>127.0.0.1</host>
<user>username</user>
<password>password</password>
<type>QuaggaCliDriver</type>
<connect_order>5</connect_order>
<COMPONENTS> </COMPONENTS>
- </Quaggacli>
+ </QuaggaCliHost3>
+ <QuaggaCliHost4>
+ <host>127.0.0.1</host>
+ <user>username</user>
+ <password>password</password>
+ <type>QuaggaCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </QuaggaCliHost4>
+ <QuaggaCliHost5>
+ <host>127.0.0.1</host>
+ <user>username</user>
+ <password>password</password>
+ <type>QuaggaCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </QuaggaCliHost5>
</COMPONENT>
</TOPOLOGY>
diff --git a/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.params b/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.params
new file mode 100644
index 0000000..e1e75f9
--- /dev/null
+++ b/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.params
@@ -0,0 +1,63 @@
+<PARAMS>
+ <testcases>1,2,8,3,4,5,[6],7,8,4,9,8,4,10,8,4,11,8,4,12,8,4,13</testcases>
+ <ENV>
+ <cellName>HA</cellName>
+ </ENV>
+ <Git>True</Git>
+
+ <CTRL>
+ <ip1>10.128.30.11</ip1>
+ <port1>6633</port1>
+
+ <ip2>10.128.30.12</ip2>
+ <port2>6633</port2>
+
+ <ip3>10.128.30.13</ip3>
+ <port3>6633</port3>
+
+ <ip4>10.128.30.14</ip4>
+ <port4>6633</port4>
+
+ <ip5>10.128.30.15</ip5>
+ <port5>6633</port5>
+
+ <ip6>10.128.30.16</ip6>
+ <port6>6633</port6>
+
+ <ip7>10.128.30.17</ip7>
+ <port7>6633</port7>
+ </CTRL>
+ <TESTONUSER>admin</TESTONUSER>
+ <TESTONIP>10.128.30.10</TESTONIP>
+ <PING>
+ <source1>h8</source1>
+ <source2>h9</source2>
+ <source3>h10</source3>
+ <source4>h11</source4>
+ <source5>h12</source5>
+ <source6>h13</source6>
+ <source7>h14</source7>
+ <source8>h15</source8>
+ <source9>h16</source9>
+ <source10>h17</source10>
+ <target1>10.0.0.18</target1>
+ <target2>10.0.0.19</target2>
+ <target3>10.0.0.20</target3>
+ <target4>10.0.0.21</target4>
+ <target5>10.0.0.22</target5>
+ <target6>10.0.0.23</target6>
+ <target7>10.0.0.24</target7>
+ <target8>10.0.0.25</target8>
+ <target9>10.0.0.26</target9>
+ <target10>10.0.0.27</target10>
+ </PING>
+ <timers>
+ <LinkDiscovery>2</LinkDiscovery>
+ <SwitchDiscovery>2</SwitchDiscovery>
+ </timers>
+ <MNtcpdump>
+ <intf>eth0</intf>
+ <port> </port>
+ <folder>~/packet_captures/</folder>
+ </MNtcpdump>
+</PARAMS>
diff --git a/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.py b/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.py
new file mode 100644
index 0000000..e6f2fde
--- /dev/null
+++ b/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.py
@@ -0,0 +1,814 @@
+'''
+Description: This test is to determine if a single
+ instance ONOS 'cluster' can handle a restart
+
+List of test cases:
+CASE1: Compile ONOS and push it to the test machines
+CASE2: Assign mastership to controllers
+CASE3: Assign intents
+CASE4: Ping across added host intents
+CASE5: Reading state of ONOS
+CASE6: The Failure case. Since this is the Sanity test, we do nothing.
+CASE7: Check state after control plane failure
+CASE8: Compare topo
+CASE9: Link s3-s28 down
+CASE10: Link s3-s28 up
+CASE11: Switch down
+CASE12: Switch up
+CASE13: Clean up
+'''
+class SingleInstanceHATestRestart:
+
+ def __init__(self) :
+ self.default = ''
+
+ def CASE1(self,main) :
+ '''
+ CASE1 is to compile ONOS and push it to the test machines
+
+ Startup sequence:
+ git pull
+ mvn clean install
+ onos-package
+ cell <name>
+ onos-verify-cell
+ NOTE: temporary - onos-remove-raft-logs
+ onos-install -f
+ onos-wait-for-start
+ '''
+ import time
+ main.log.report("ONOS Single node cluster restart HA test - initialization")
+ main.case("Setting up test environment")
+
+ # load some vairables from the params file
+ PULL_CODE = False
+ if main.params['Git'] == 'True':
+ PULL_CODE = True
+ cell_name = main.params['ENV']['cellName']
+
+ #set global variables
+ global ONOS1_ip
+ global ONOS1_port
+ global ONOS2_ip
+ global ONOS2_port
+ global ONOS3_ip
+ global ONOS3_port
+ global ONOS4_ip
+ global ONOS4_port
+ global ONOS5_ip
+ global ONOS5_port
+ global ONOS6_ip
+ global ONOS6_port
+ global ONOS7_ip
+ global ONOS7_port
+
+ ONOS1_ip = main.params['CTRL']['ip1']
+ ONOS1_port = main.params['CTRL']['port1']
+ ONOS2_ip = main.params['CTRL']['ip2']
+ ONOS2_port = main.params['CTRL']['port2']
+ ONOS3_ip = main.params['CTRL']['ip3']
+ ONOS3_port = main.params['CTRL']['port3']
+ ONOS4_ip = main.params['CTRL']['ip4']
+ ONOS4_port = main.params['CTRL']['port4']
+ ONOS5_ip = main.params['CTRL']['ip5']
+ ONOS5_port = main.params['CTRL']['port5']
+ ONOS6_ip = main.params['CTRL']['ip6']
+ ONOS6_port = main.params['CTRL']['port6']
+ ONOS7_ip = main.params['CTRL']['ip7']
+ ONOS7_port = main.params['CTRL']['port7']
+
+
+ main.step("Applying cell variable to environment")
+ cell_result = main.ONOSbench.set_cell(cell_name)
+ verify_result = main.ONOSbench.verify_cell()
+
+ #FIXME:this is short term fix
+ main.log.report("Removing raft logs")
+ main.ONOSbench.onos_remove_raft_logs()
+ main.log.report("Uninstalling ONOS")
+ main.ONOSbench.onos_uninstall(ONOS1_ip)
+ main.ONOSbench.onos_uninstall(ONOS2_ip)
+ main.ONOSbench.onos_uninstall(ONOS3_ip)
+ main.ONOSbench.onos_uninstall(ONOS4_ip)
+ main.ONOSbench.onos_uninstall(ONOS5_ip)
+ main.ONOSbench.onos_uninstall(ONOS6_ip)
+ main.ONOSbench.onos_uninstall(ONOS7_ip)
+
+ clean_install_result = main.TRUE
+ git_pull_result = main.TRUE
+
+ main.step("Compiling the latest version of ONOS")
+ if PULL_CODE:
+ main.step("Git checkout and pull master")
+ main.ONOSbench.git_checkout("master")
+ git_pull_result = main.ONOSbench.git_pull()
+
+ main.step("Using mvn clean & install")
+ clean_install_result = main.TRUE
+ if git_pull_result == main.TRUE:
+ clean_install_result = main.ONOSbench.clean_install()
+ else:
+ main.log.warn("Did not pull new code so skipping mvn "+ \
+ "clean install")
+ main.ONOSbench.get_version(report=True)
+
+ main.step("Creating ONOS package")
+ package_result = main.ONOSbench.onos_package()
+
+ main.step("Installing ONOS package")
+ onos1_install_result = main.ONOSbench.onos_install(options="-f",
+ node=ONOS1_ip)
+
+
+ main.step("Checking if ONOS is up yet")
+ #TODO: Refactor
+ # check bundle:list?
+ #this should be enough for ONOS to start
+ time.sleep(60)
+ onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+ if not onos1_isup:
+ main.log.report("ONOS1 didn't start!")
+ # TODO: if it becomes an issue, we can retry this step a few times
+
+
+ cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip)
+
+ main.step("Start Packet Capture MN")
+ main.Mininet2.start_tcpdump(
+ str(main.params['MNtcpdump']['folder'])+str(main.TEST)+"-MN.pcap",
+ intf = main.params['MNtcpdump']['intf'],
+ port = main.params['MNtcpdump']['port'])
+
+
+ case1_result = (clean_install_result and package_result and
+ cell_result and verify_result and onos1_install_result and
+ onos1_isup and cli1_results)
+
+ utilities.assert_equals(expect=main.TRUE, actual=case1_result,
+ onpass="Test startup successful",
+ onfail="Test startup NOT successful")
+
+
+ if case1_result==main.FALSE:
+ main.cleanup()
+ main.exit()
+
+ def CASE2(self,main) :
+ '''
+ Assign mastership to controllers
+ '''
+ import time
+ import json
+ import re
+
+ main.log.report("Assigning switches to controllers")
+ main.case("Assigning Controllers")
+ main.step("Assign switches to controllers")
+
+ for i in range (1,29):
+ main.Mininet1.assign_sw_controller(sw=str(i),
+ ip1=ONOS1_ip,port1=ONOS1_port)
+
+ mastership_check = main.TRUE
+ for i in range (1,29):
+ response = main.Mininet1.get_sw_controller("s"+str(i))
+ try:
+ main.log.info(str(response))
+ except:
+ main.log.info(repr(response))
+ if re.search("tcp:"+ONOS1_ip,response):
+ mastership_check = mastership_check and main.TRUE
+ else:
+ mastership_check = main.FALSE
+ if mastership_check == main.TRUE:
+ main.log.report("Switch mastership assigned correctly")
+ utilities.assert_equals(expect = main.TRUE,actual=mastership_check,
+ onpass="Switch mastership assigned correctly",
+ onfail="Switches not assigned correctly to controllers")
+
+ #TODO: If assign roles is working reliably then manually
+ # assign mastership to the controller we want
+
+
+ def CASE3(self,main) :
+ """
+ Assign intents
+
+ """
+ import time
+ import json
+ import re
+ main.log.report("Adding host intents")
+ main.case("Adding host Intents")
+
+ main.step("Discovering Hosts( Via pingall for now)")
+ #FIXME: Once we have a host discovery mechanism, use that instead
+
+ #REACTIVE FWD test
+ ping_result = main.FALSE
+ time1 = time.time()
+ ping_result = main.Mininet1.pingall()
+ time2 = time.time()
+ main.log.info("Time for pingall: %2f seconds" % (time2 - time1))
+
+ #uninstall onos-app-fwd
+ main.log.info("Uninstall reactive forwarding app")
+ main.ONOScli1.feature_uninstall("onos-app-fwd")
+
+ main.step("Add host intents")
+ #TODO: move the host numbers to params
+ import json
+ intents_json= json.loads(main.ONOScli1.hosts())
+ intent_add_result = main.FALSE
+ for i in range(8,18):
+ main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10))
+ host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper()
+ host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper()
+ #NOTE: get host can return None
+ #TODO: handle this
+ host1_id = main.ONOScli1.get_host(host1)['id']
+ host2_id = main.ONOScli1.get_host(host2)['id']
+ tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id )
+ intent_add_result = intent_add_result and tmp_result
+ #TODO Check if intents all exist in datastore
+ #NOTE: Do we need to print this once the test is working?
+ #main.log.info(json.dumps(json.loads(main.ONOScli1.intents(json_format=True)),
+ # sort_keys=True, indent=4, separators=(',', ': ') ) )
+
+ def CASE4(self,main) :
+ """
+ Ping across added host intents
+ """
+ description = " Ping across added host intents"
+ main.log.report(description)
+ main.case(description)
+ Ping_Result = main.TRUE
+ for i in range(8,18):
+ ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10))
+ Ping_Result = Ping_Result and ping
+ if ping==main.FALSE:
+ main.log.warn("Ping failed between h"+str(i)+" and h" + str(i+10))
+ elif ping==main.TRUE:
+ main.log.info("Ping test passed!")
+ Ping_Result = main.TRUE
+ if Ping_Result==main.FALSE:
+ main.log.report("Intents have not been installed correctly, pings failed.")
+ if Ping_Result==main.TRUE:
+ main.log.report("Intents have been installed correctly and verified by pings")
+ utilities.assert_equals(expect = main.TRUE,actual=Ping_Result,
+ onpass="Intents have been installed correctly and pings work",
+ onfail ="Intents have not been installed correctly, pings failed." )
+
+ def CASE5(self,main) :
+ '''
+ Reading state of ONOS
+ '''
+ import time
+ import json
+ from subprocess import Popen, PIPE
+ from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+
+ main.log.report("Setting up and gathering data for current state")
+ main.case("Setting up and gathering data for current state")
+ #The general idea for this test case is to pull the state of (intents,flows, topology,...) from each ONOS node
+ #We can then compare them with eachother and also with past states
+
+ main.step("Get the Mastership of each switch from each controller")
+ global mastership_state
+ ONOS1_mastership = main.ONOScli1.roles()
+ #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+ #TODO: Make this a meaningful check
+ if "Error" in ONOS1_mastership or not ONOS1_mastership:
+ main.log.report("Error in getting ONOS roles")
+ main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+ consistent_mastership = main.FALSE
+ else:
+ mastership_state = ONOS1_mastership
+ consistent_mastership = main.TRUE
+ main.log.report("Switch roles are consistent across all ONOS nodes")
+ utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+ onpass="Switch roles are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of switch roles")
+
+
+ main.step("Get the intents from each controller")
+ global intent_state
+ ONOS1_intents = main.ONOScli1.intents( json_format=True )
+ intent_check = main.FALSE
+ if "Error" in ONOS1_intents or not ONOS1_intents:
+ main.log.report("Error in getting ONOS intents")
+ main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+ else:
+ intent_check = main.TRUE
+ main.log.report("Intents are consistent across all ONOS nodes")
+ utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+ onpass="Intents are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of intents")
+
+
+ main.step("Get the flows from each controller")
+ global flow_state
+ ONOS1_flows = main.ONOScli1.flows( json_format=True )
+ flow_check = main.FALSE
+ if "Error" in ONOS1_flows or not ONOS1_flows:
+ main.log.report("Error in getting ONOS intents")
+ main.log.warn("ONOS1 flows repsponse: "+ ONOS1_flows)
+ else:
+ #TODO: Do a better check, maybe compare flows on switches?
+ flow_state = ONOS1_flows
+ flow_check = main.TRUE
+ main.log.report("Flow count is consistent across all ONOS nodes")
+ utilities.assert_equals(expect = main.TRUE,actual=flow_check,
+ onpass="The flow count is consistent across all ONOS nodes",
+ onfail="ONOS nodes have different flow counts")
+
+
+ main.step("Get the OF Table entries")
+ global flows
+ flows=[]
+ for i in range(1,29):
+ flows.append(main.Mininet2.get_flowTable("s"+str(i),1.0))
+
+ #TODO: Compare switch flow tables with ONOS flow tables
+
+ main.step("Start continuous pings")
+ main.Mininet2.pingLong(src=main.params['PING']['source1'],
+ target=main.params['PING']['target1'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source2'],
+ target=main.params['PING']['target2'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source3'],
+ target=main.params['PING']['target3'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source4'],
+ target=main.params['PING']['target4'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source5'],
+ target=main.params['PING']['target5'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source6'],
+ target=main.params['PING']['target6'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source7'],
+ target=main.params['PING']['target7'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source8'],
+ target=main.params['PING']['target8'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source9'],
+ target=main.params['PING']['target9'],pingTime=500)
+ main.Mininet2.pingLong(src=main.params['PING']['source10'],
+ target=main.params['PING']['target10'],pingTime=500)
+
+ main.step("Create TestONTopology object")
+ ctrls = []
+ count = 1
+ temp = ()
+ temp = temp + (getattr(main,('ONOS' + str(count))),)
+ temp = temp + ("ONOS"+str(count),)
+ temp = temp + (main.params['CTRL']['ip'+str(count)],)
+ temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+ ctrls.append(temp)
+ MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+ main.step("Collecting topology information from ONOS")
+ devices = []
+ devices.append( main.ONOScli1.devices() )
+ '''
+ hosts = []
+ hosts.append( main.ONOScli1.hosts() )
+ '''
+ ports = []
+ ports.append( main.ONOScli1.ports() )
+ links = []
+ links.append( main.ONOScli1.links() )
+
+
+ main.step("Comparing ONOS topology to MN")
+ devices_results = main.TRUE
+ ports_results = main.TRUE
+ links_results = main.TRUE
+ for controller in range(1): #TODO parameterize the number of controllers
+ if devices[controller] or not "Error" in devices[controller]:
+ current_devices_result = main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+ else:
+ current_devices_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+ onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+ onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+ if ports[controller] or not "Error" in ports[controller]:
+ current_ports_result = main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+ else:
+ current_ports_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+ onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+ onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+ if links[controller] or not "Error" in links[controller]:
+ current_links_result = main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+ else:
+ current_links_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+ onpass="ONOS"+str(int(controller+1))+" links view is correct",
+ onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+
+ devices_results = devices_results and current_devices_result
+ ports_results = ports_results and current_ports_result
+ links_results = links_results and current_links_result
+
+ topo_result = devices_results and ports_results and links_results
+ utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful")
+
+ final_assert = main.TRUE
+ final_assert = final_assert and topo_result and flow_check \
+ and intent_check and consistent_mastership
+ utilities.assert_equals(expect=main.TRUE, actual=final_assert,
+ onpass="State check successful",
+ onfail="State check NOT successful")
+
+
+ def CASE6(self,main) :
+ '''
+ The Failure case.
+ '''
+ import time
+
+ main.log.report("Restart ONOS node")
+ main.log.case("Restart ONOS node")
+ main.ONOSbench.onos_kill(ONOS1_ip)
+ start = time.time()
+
+ main.step("Checking if ONOS is up yet")
+ count = 0
+ while count < 10
+ onos1_isup = main.ONOSbench.isup(ONOS1_ip)
+ if onos1_isup == main.TRUE:
+ elapsed = time.time() - start
+ break
+ else:
+ count = count + 1
+
+ cli_result = main.ONOScli1.start_onos_cli(ONOS1_ip)
+
+ case_results = main.TRUE and onosi1_isup and cli_result
+ utilities.assert_equals(expect=main.TRUE, actual=case_results,
+ onpass="ONOS restart successful",
+ onfail="ONOS restart NOT successful")
+ main.log.info("ONOS took %s seconds to restart" % str(elapsed) )
+
+ def CASE7(self,main) :
+ '''
+ Check state after ONOS failure
+ '''
+ import os
+ import json
+ main.case("Running ONOS Constant State Tests")
+
+ main.step("Check if switch roles are consistent across all nodes")
+ ONOS1_mastership = main.ONOScli1.roles()
+ #FIXME: Refactor this whole case for single instance
+ #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': '))
+ if "Error" in ONOS1_mastership or not ONOS1_mastership:
+ main.log.report("Error in getting ONOS mastership")
+ main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership))
+ consistent_mastership = main.FALSE
+ else:
+ consistent_mastership = main.TRUE
+ main.log.report("Switch roles are consistent across all ONOS nodes")
+ utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership,
+ onpass="Switch roles are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of switch roles")
+
+
+ description2 = "Compare switch roles from before failure"
+ main.step(description2)
+
+ current_json = json.loads(ONOS1_mastership)
+ old_json = json.loads(mastership_state)
+ mastership_check = main.TRUE
+ for i in range(1,29):
+ switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i)))
+
+ current = [switch['master'] for switch in current_json if switchDPID in switch['id']]
+ old = [switch['master'] for switch in old_json if switchDPID in switch['id']]
+ if current == old:
+ mastership_check = mastership_check and main.TRUE
+ else:
+ main.log.warn("Mastership of switch %s changed" % switchDPID)
+ mastership_check = main.FALSE
+ if mastership_check == main.TRUE:
+ main.log.report("Mastership of Switches was not changed")
+ utilities.assert_equals(expect=main.TRUE,actual=mastership_check,
+ onpass="Mastership of Switches was not changed",
+ onfail="Mastership of some switches changed")
+ mastership_check = mastership_check and consistent_mastership
+
+
+
+ main.step("Get the intents and compare across all nodes")
+ ONOS1_intents = main.ONOScli1.intents( json_format=True )
+ intent_check = main.FALSE
+ if "Error" in ONOS1_intents or not ONOS1_intents:
+ main.log.report("Error in getting ONOS intents")
+ main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents))
+ else:
+ intent_state = ONOS1_intents
+ intent_check = main.TRUE
+ main.log.report("Intents are consistent across all ONOS nodes")
+ utilities.assert_equals(expect = main.TRUE,actual=intent_check,
+ onpass="Intents are consistent across all ONOS nodes",
+ onfail="ONOS nodes have different views of intents")
+
+ main.step("Compare current intents with intents before the failure")
+ if intent_state == ONOS1_intents:
+ same_intents = main.TRUE
+ main.log.report("Intents are consistent with before failure")
+ #TODO: possibly the states have changed? we may need to figure out what the aceptable states are
+ else:
+ same_intents = main.FALSE
+ utilities.assert_equals(expect = main.TRUE,actual=same_intents,
+ onpass="Intents are consistent with before failure",
+ onfail="The Intents changed during failure")
+ intent_check = intent_check and same_intents
+
+
+
+ main.step("Get the OF Table entries and compare to before component failure")
+ Flow_Tables = main.TRUE
+ flows2=[]
+ for i in range(28):
+ main.log.info("Checking flow table on s" + str(i+1))
+ tmp_flows = main.Mininet2.get_flowTable("s"+str(i+1),1.0)
+ flows2.append(tmp_flows)
+ Flow_Tables = Flow_Tables and main.Mininet2.flow_comp(flow1=flows[i],flow2=tmp_flows)
+ if Flow_Tables == main.FALSE:
+ main.log.info("Differences in flow table for switch: "+str(i+1))
+ break
+ if Flow_Tables == main.TRUE:
+ main.log.report("No changes were found in the flow tables")
+ utilities.assert_equals(expect=main.TRUE,actual=Flow_Tables,
+ onpass="No changes were found in the flow tables",
+ onfail="Changes were found in the flow tables")
+
+ main.step("Check the continuous pings to ensure that no packets were dropped during component failure")
+ #FIXME: This check is always failing. Investigate cause
+ #NOTE: this may be something to do with file permsissions
+ # or slight change in format
+ main.Mininet2.pingKill(main.params['TESTONUSER'], main.params['TESTONIP'])
+ Loss_In_Pings = main.FALSE
+ #NOTE: checkForLoss returns main.FALSE with 0% packet loss
+ for i in range(8,18):
+ main.log.info("Checking for a loss in pings along flow from s" + str(i))
+ Loss_In_Pings = Loss_In_Pings or main.Mininet2.checkForLoss("/tmp/ping.h"+str(i))
+ if Loss_In_Pings == main.TRUE:
+ main.log.info("Loss in ping detected")
+ elif Loss_In_Pings == main.ERROR:
+ main.log.info("There are multiple mininet process running")
+ elif Loss_In_Pings == main.FALSE:
+ main.log.info("No Loss in the pings")
+ main.log.report("No loss of dataplane connectivity")
+ utilities.assert_equals(expect=main.FALSE,actual=Loss_In_Pings,
+ onpass="No Loss of connectivity",
+ onfail="Loss of dataplane connectivity detected")
+
+
+ #TODO:add topology to this or leave as a seperate case?
+ result = mastership_check and intent_check and Flow_Tables and (not Loss_In_Pings)
+ result = int(result)
+ if result == main.TRUE:
+ main.log.report("Constant State Tests Passed")
+ utilities.assert_equals(expect=main.TRUE,actual=result,
+ onpass="Constant State Tests Passed",
+ onfail="Constant state tests failed")
+
+ def CASE8 (self,main):
+ '''
+ Compare topo
+ '''
+ import sys
+ sys.path.append("/home/admin/sts") # Trying to remove some dependancies, #FIXME add this path to params
+ from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH
+ import json
+ import time
+
+ description ="Compare ONOS Topology view to Mininet topology"
+ main.case(description)
+ main.log.report(description)
+ main.step("Create TestONTopology object")
+ ctrls = []
+ count = 1
+ temp = ()
+ temp = temp + (getattr(main,('ONOS' + str(count))),)
+ temp = temp + ("ONOS"+str(count),)
+ temp = temp + (main.params['CTRL']['ip'+str(count)],)
+ temp = temp + (eval(main.params['CTRL']['port'+str(count)]),)
+ ctrls.append(temp)
+ MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations
+
+ main.step("Comparing ONOS topology to MN")
+ devices_results = main.TRUE
+ ports_results = main.TRUE
+ links_results = main.TRUE
+ topo_result = main.FALSE
+ start_time = time.time()
+ elapsed = 0
+ count = 0
+ while topo_result == main.FALSE and elapsed < 120:
+ count = count + 1
+ try:
+ main.step("Collecting topology information from ONOS")
+ devices = []
+ devices.append( main.ONOScli1.devices() )
+ '''
+ hosts = []
+ hosts.append( main.ONOScli1.hosts() )
+ '''
+ ports = []
+ ports.append( main.ONOScli1.ports() )
+ links = []
+ links.append( main.ONOScli1.links() )
+ for controller in range(1): #TODO parameterize the number of controllers
+ if devices[controller] or not "Error" in devices[controller]:
+ current_devices_result = main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller]))
+ else:
+ current_devices_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_devices_result,
+ onpass="ONOS"+str(int(controller+1))+" Switches view is correct",
+ onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect")
+
+ if ports[controller] or not "Error" in ports[controller]:
+ current_ports_result = main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller]))
+ else:
+ current_ports_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_ports_result,
+ onpass="ONOS"+str(int(controller+1))+" ports view is correct",
+ onfail="ONOS"+str(int(controller+1))+" ports view is incorrect")
+
+ if links[controller] or not "Error" in links[controller]:
+ current_links_result = main.Mininet1.compare_links(MNTopo, json.loads(links[controller]))
+ else:
+ current_links_result = main.FALSE
+ utilities.assert_equals(expect=main.TRUE, actual=current_links_result,
+ onpass="ONOS"+str(int(controller+1))+" links view is correct",
+ onfail="ONOS"+str(int(controller+1))+" links view is incorrect")
+ except:
+ main.log.error("something went wrong in topo comparison")
+ main.log.warn( repr( devices ) )
+ main.log.warn( repr( ports ) )
+ main.log.warn( repr( links ) )
+
+ devices_results = devices_results and current_devices_result
+ ports_results = ports_results and current_ports_result
+ links_results = links_results and current_links_result
+ elapsed = time.time() - start_time
+ time_threshold = elapsed < 1
+ topo_result = devices_results and ports_results and links_results and time_threshold
+ #TODO make sure this step is non-blocking. IE add a timeout
+ main.log.report("Very crass estimate for topology discovery/convergence: " +\
+ str(elapsed) + " seconds, " + str(count) +" tries" )
+ utilities.assert_equals(expect=main.TRUE, actual=topo_result,
+ onpass="Topology Check Test successful",
+ onfail="Topology Check Test NOT successful")
+ if topo_result == main.TRUE:
+ main.log.report("ONOS topology view matches Mininet topology")
+
+
+ def CASE9 (self,main):
+ '''
+ Link s3-s28 down
+ '''
+ #NOTE: You should probably run a topology check after this
+
+ link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+ description = "Turn off a link to ensure that Link Discovery is working properly"
+ main.log.report(description)
+ main.case(description)
+
+
+ main.step("Kill Link between s3 and s28")
+ Link_Down = main.Mininet1.link(END1="s3",END2="s28",OPTION="down")
+ main.log.info("Waiting " + str(link_sleep) + " seconds for link down to be discovered")
+ time.sleep(link_sleep)
+ utilities.assert_equals(expect=main.TRUE,actual=Link_Down,
+ onpass="Link down succesful",
+ onfail="Failed to bring link down")
+ #TODO do some sort of check here
+
+ def CASE10 (self,main):
+ '''
+ Link s3-s28 up
+ '''
+ #NOTE: You should probably run a topology check after this
+
+ link_sleep = int(main.params['timers']['LinkDiscovery'])
+
+ description = "Restore a link to ensure that Link Discovery is working properly"
+ main.log.report(description)
+ main.case(description)
+
+ main.step("Bring link between s3 and s28 back up")
+ Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up")
+ main.log.info("Waiting " + str(link_sleep) + " seconds for link up to be discovered")
+ time.sleep(link_sleep)
+ utilities.assert_equals(expect=main.TRUE,actual=Link_Up,
+ onpass="Link up succesful",
+ onfail="Failed to bring link up")
+ #TODO do some sort of check here
+
+
+ def CASE11 (self, main) :
+ '''
+ Switch Down
+ '''
+ #NOTE: You should probably run a topology check after this
+ import time
+
+ switch_sleep = int(main.params['timers']['SwitchDiscovery'])
+
+ description = "Killing a switch to ensure it is discovered correctly"
+ main.log.report(description)
+ main.case(description)
+
+ #TODO: Make this switch parameterizable
+ main.step("Kill s28 ")
+ main.log.report("Deleting s28")
+ #FIXME: use new dynamic topo functions
+ main.Mininet1.del_switch("s28")
+ main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered")
+ time.sleep(switch_sleep)
+ #Peek at the deleted switch
+ main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+ #TODO do some sort of check here
+
+ def CASE12 (self, main) :
+ '''
+ Switch Up
+ '''
+ #NOTE: You should probably run a topology check after this
+ import time
+ #FIXME: use new dynamic topo functions
+ description = "Adding a switch to ensure it is discovered correctly"
+ main.log.report(description)
+ main.case(description)
+
+ main.step("Add back s28")
+ main.log.report("Adding back s28")
+ main.Mininet1.add_switch("s28", dpid = '0000000000002800')
+ #TODO: New dpid or same? Ask Thomas?
+ main.Mininet1.add_link('s28', 's3')
+ main.Mininet1.add_link('s28', 's6')
+ main.Mininet1.add_link('s28', 'h28')
+ main.Mininet1.assign_sw_controller(sw="28",
+ ip1=ONOS1_ip,port1=ONOS1_port)
+ main.log.info("Waiting " + str(switch_sleep) + " seconds for switch up to be discovered")
+ time.sleep(switch_sleep)
+ #Peek at the added switch
+ main.log.warn(main.ONOScli1.get_device(dpid="0028"))
+ #TODO do some sort of check here
+
+ def CASE13 (self, main) :
+ '''
+ Clean up
+ '''
+ import os
+ import time
+ description = "Test Cleanup"
+ main.log.report(description)
+ main.case(description)
+ main.step("Killing tcpdumps")
+ main.Mininet2.stop_tcpdump()
+
+ main.step("Copying MN pcap and ONOS log files to test station")
+ testname = main.TEST
+ #NOTE: MN Pcap file is being saved to ~/packet_captures
+ # scp this file as MN and TestON aren't necessarily the same vm
+ #FIXME: scp
+ #####mn files
+ #TODO: Load these from params
+ #NOTE: must end in /
+ log_folder = "/opt/onos/log/"
+ log_files = ["karaf.log", "karaf.log.1"]
+ #NOTE: must end in /
+ dst_dir = "~/packet_captures/"
+ for f in log_files:
+ main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS1-"+f )
+
+ #std*.log's
+ #NOTE: must end in /
+ log_folder = "/opt/onos/var/"
+ log_files = ["stderr.log", "stdout.log"]
+ #NOTE: must end in /
+ dst_dir = "~/packet_captures/"
+ for f in log_files:
+ main.ONOSbench.secureCopy( "sdn", ONOS1_ip,log_folder+f,"rocks",\
+ dst_dir + str(testname) + "-ONOS1-"+f )
+
+
+ #sleep so scp can finish
+ time.sleep(10)
+ main.step("Packing and rotating pcap archives")
+ os.system("~/TestON/dependencies/rotate.sh "+ str(testname))
+
+
+ #TODO: actually check something here
+ utilities.assert_equals(expect=main.TRUE, actual=main.TRUE,
+ onpass="Test cleanup successful",
+ onfail="Test cleanup NOT successful")
diff --git a/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.topo b/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.topo
new file mode 100644
index 0000000..4d4156c
--- /dev/null
+++ b/TestON/tests/SingleInstanceHATestRestart/SingleInstanceHATestRestart.topo
@@ -0,0 +1,173 @@
+<TOPOLOGY>
+ <COMPONENT>
+
+ <ONOSbench>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosDriver</type>
+ <connect_order>1</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOSbench>
+
+ <ONOScli1>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>2</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli1>
+
+ <ONOScli2>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>3</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli2>
+
+ <ONOScli3>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>4</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli3>
+
+
+ <ONOScli4>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>5</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli4>
+
+
+ <ONOScli5>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>6</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli5>
+
+
+ <ONOScli6>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>7</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli6>
+
+
+ <ONOScli7>
+ <host>10.128.30.10</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>OnosCliDriver</type>
+ <connect_order>8</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOScli7>
+
+ <ONOS1>
+ <host>10.128.30.11</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>9</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS1>
+
+ <ONOS2>
+ <host>10.128.30.12</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>10</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS2>
+
+ <ONOS3>
+ <host>10.128.30.13</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>11</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS3>
+
+ <ONOS4>
+ <host>10.128.30.14</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>12</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS4>
+
+ <ONOS5>
+ <host>10.128.30.15</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>13</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS5>
+
+ <ONOS6>
+ <host>10.128.30.16</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>14</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS6>
+
+ <ONOS7>
+ <host>10.128.30.17</host>
+ <user>sdn</user>
+ <password>rocks</password>
+ <type>OnosDriver</type>
+ <connect_order>15</connect_order>
+ <COMPONENTS> </COMPONENTS>
+ </ONOS7>
+
+ <Mininet1>
+ <host>10.128.30.9</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>MininetCliDriver</type>
+ <connect_order>16</connect_order>
+ <COMPONENTS>
+ #Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo </arg2>
+ <arg3> </arg3>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet1>
+
+ <Mininet2>
+ <host>10.128.30.9</host>
+ <user>admin</user>
+ <password>onos_test</password>
+ <type>RemoteMininetDriver</type>
+ <connect_order>17</connect_order>
+ <COMPONENTS>
+ # Specify the Option for mininet
+ <arg1> --custom ~/mininet/custom/topo-HA.py </arg1>
+ <arg2> --topo mytopo --arp</arg2>
+ <controller> remote </controller>
+ </COMPONENTS>
+ </Mininet2>
+
+ </COMPONENT>
+</TOPOLOGY>
diff --git a/TestON/tests/SingleInstanceHATestRestart/__init__.py b/TestON/tests/SingleInstanceHATestRestart/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/TestON/tests/SingleInstanceHATestRestart/__init__.py
diff --git a/TestON/tests/TopoConvNext/TopoConvNext.params b/TestON/tests/TopoConvNext/TopoConvNext.params
index 96cb9ad..198befb 100644
--- a/TestON/tests/TopoConvNext/TopoConvNext.params
+++ b/TestON/tests/TopoConvNext/TopoConvNext.params
@@ -1,5 +1,5 @@
<PARAMS>
- <testcases>1,2,3,2,3,2,3,4,2,3,2,3,2,4,2,3,2,3,2</testcases>
+ <testcases>1,2,3,2,3,2,3,2,4,2,3,2,3,2,3,2</testcases>
<ENV>
<cellName>topo_conv_test</cellName>
@@ -42,10 +42,11 @@
<onosLogFile>/opt/onos/log/karaf*</onosLogFile>
#Number of times to iterate each case
- <numIter>5</numIter>
- <numSwitch1>200</numSwitch1>
+ <numIter>3</numIter>
+ <numSwitch1>500</numSwitch1>
<numSwitch2>400</numSwitch2>
- <numSwitch3>500</numSwitch3>
+ <numSwitch3>200</numSwitch3>
+ <numSwitch4>300</numSwitch4>
#Number of iterations to ignore initially
<iterIgnore>1</iterIgnore>
diff --git a/TestON/tests/TopoConvNext/TopoConvNext.py b/TestON/tests/TopoConvNext/TopoConvNext.py
index 52a951c..68d7b5d 100644
--- a/TestON/tests/TopoConvNext/TopoConvNext.py
+++ b/TestON/tests/TopoConvNext/TopoConvNext.py
@@ -185,6 +185,8 @@
num_sw = main.params['TEST']['numSwitch2']
elif topo_iteration == 3:
num_sw = main.params['TEST']['numSwitch3']
+ elif topo_iteration == 4:
+ num_sw = main.params['TEST']['numSwitch4']
#***********
#Timestamp 'keys' for json metrics output.
@@ -323,7 +325,7 @@
#NOTE:
# Delay before checking devices to
# help prevent timing out from CLI
- # due to multiple command drop
+ # due to multiple command issuing
time.sleep(20)
loop = True
@@ -338,6 +340,9 @@
device_json1 = json.loads(device_str1)
json_len = len(device_json1)
+ #NOTE: May want to check the rest of
+ # the ONOS instances for device down as well
+
for device1 in device_json1:
temp_len = temp_len + 1
if device1['available'] == True:
@@ -361,73 +366,10 @@
loop = False
break
-
- #if cluster_count == 1:
- # device_str1 = main.ONOS1cli.devices(
- # node_ip=ONOS_ip_list[1])
- # device_json1 = json.loads(device_str1)
- # for device1 in device_json1:
- # if device1['available'] == False:
- # device_count += 1
- # else:
- # device_count = 0
- #if cluster_count == 2:
- # device_str2 = main.ONOS2cli.devices(
- # node_ip=ONOS_ip_list[2])
- # device_json2 = json.loads(device_str2)
- # for device2 in device_json2:
- # if device2['available'] == False:
- # device_count += 1
- # else:
- # device_count = 0
- #if cluster_count == 3:
- # device_str3 = main.ONOS3cli.devices(
- # node_ip=ONOS_ip_list[3])
- # device_json3 = json.loads(device_str3)
- # for device3 in device_json3:
- # if device3['available'] == False:
- # device_count += 1
- # else:
- # device_count = 0
- #if cluster_count == 4:
- # device_str4 = main.ONOS4cli.devices(
- # node_ip=ONOS_ip_list[4])
- # device_json4 = json.loads(device_str4)
- # for device4 in device_json4:
- # if device4['available'] == False:
- # device_count += 1
- # else:
- # device_count = 0
- #if cluster_count == 5:
- # device_str5 = main.ONOS5cli.devices(
- # node_ip=ONOS_ip_list[5])
- # device_json5 = json.loads(device_str5)
- # for device5 in device_json5:
- # if device5['available'] == False:
- # device_count += 1
- # else:
- # device_count = 0
- #if cluster_count == 7:
- # device_str7 = main.ONOS7cli.devices(
- # node_ip=ONOS_ip_list[7])
- # device_json7 = json.loads(device_str7)
- # for device7 in device_json7:
- # if device7['available'] == False:
- # device_count += 1
- # else:
- # device_count = 0
-
- #If device count is greater than the
- #number of switches discovered by all nodes
- #then remove iptables and measure t0 system time
-
loop_count += 1
time.sleep(1)
- if device_count < int(num_sw):
- main.log.info("Devices down did not ")
-
main.log.info("System time t0: "+str(t0_system))
counter_loop = 0
@@ -590,7 +532,7 @@
else:
main.log.info("Switch discovery latency "+
"exceeded the threshold.")
- main.log.info(graph_lat_1)
+ main.log.info(str(graph_lat_1)+" ms")
#Break while loop
break
if cluster_count == 2:
@@ -635,7 +577,7 @@
else:
main.log.info("Switch discovery latency "+
"exceeded the threshold.")
- main.log.info(max_graph_lat)
+ main.log.info(str(max_graph_lat)+" ms")
break
if cluster_count == 3:
if onos1_dev and onos2_dev and onos3_dev:
@@ -693,7 +635,7 @@
else:
main.log.info("Switch discovery latency "+
"exceeded the threshold.")
- main.log.info(max_graph_lat)
+ main.log.info(str(max_graph_lat)+" ms")
break
if cluster_count == 4:
@@ -756,7 +698,7 @@
else:
main.log.info("Switch discovery latency "+
"exceeded the threshold.")
- main.log.info(max_graph_lat)
+ main.log.info(str(max_graph_lat)+" ms")
break
if cluster_count == 5:
@@ -835,7 +777,7 @@
else:
main.log.info("Switch discovery latency "+
"exceeded the threshold.")
- main.log.info(max_graph_lat)
+ main.log.info(str(max_graph_lat)+" ms")
break
if cluster_count == 6:
@@ -918,7 +860,7 @@
else:
main.log.info("Switch discovery latency "+
"exceeded the threshold.")
- main.log.info(max_graph_lat)
+ main.log.info(str(max_graph_lat)+" ms")
break
if cluster_count == 7:
@@ -1018,7 +960,7 @@
else:
main.log.info("Switch discovery latency "+
"exceeded the threshold.")
- main.log.info(max_graph_lat)
+ main.log.info(str(max_graph_lat)+" ms")
break
@@ -1153,7 +1095,9 @@
sw_lat_avg = sum(sw_discovery_lat_list) / \
len(sw_discovery_lat_list)
sw_lat_dev = numpy.std(sw_discovery_lat_list)
- else:
+ else:
+ sw_lat_avg = 0
+ sw_lat_dev = 0
assertion = main.FALSE
main.log.report("Switch connection attempt time avg "+
@@ -1329,3 +1273,6 @@
utilities.assert_equals(expect=main.TRUE, actual=assertion,
onpass="Topology size increased successfully",
onfail="Topology size was not increased")
+
+
+
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.params b/TestON/tests/TopoPerfNext/TopoPerfNext.params
index 42512e8..851522c 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.params
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.params
@@ -57,7 +57,9 @@
<linkUpThreshold>0,10000</linkUpThreshold>
<linkDownThreshold>0,10000</linkDownThreshold>
<swDisc100Threshold>0,10000</swDisc100Threshold>
- </TEST>
+
+ <tabletFile>tablets_3node.json</tabletFile>
+ </TEST>
<JSON>
<deviceTimestamp>topologyDeviceEventTimestamp</deviceTimestamp>
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.py b/TestON/tests/TopoPerfNext/TopoPerfNext.py
index 49089bf..65bc7a9 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.py
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.py
@@ -47,10 +47,10 @@
main.case("Setting up test environment")
main.log.info("Copying topology event accumulator config"+\
- " to ONOS /ppackage/etc")
+ " to ONOS /package/etc")
main.ONOSbench.handle.sendline("cp ~/"+\
topo_cfg_file+\
- "~/ONOS/tools/package/etc/"+\
+ " ~/ONOS/tools/package/etc/"+\
topo_cfg_name)
main.ONOSbench.handle.expect("\$")
@@ -64,7 +64,7 @@
main.step("Creating cell file")
cell_file_result = main.ONOSbench.create_cell_file(
- BENCH_ip, cell_name, MN1_ip, "onos-core",
+ BENCH_ip, cell_name, MN1_ip, "onos-core,onos-app-metrics",
ONOS1_ip, ONOS2_ip, ONOS3_ip)
main.step("Applying cell file to environment")
@@ -75,7 +75,8 @@
# copy cat log functionality
main.step("Removing raft/copy-cat logs from ONOS nodes")
main.ONOSbench.onos_remove_raft_logs()
-
+ time.sleep(30)
+
main.step("Git checkout and pull "+checkout_branch)
if git_pull == 'on':
checkout_result = \
@@ -114,11 +115,6 @@
cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
- main.step("Enable metrics feature")
- main.ONOS1cli.feature_install("onos-app-metrics")
- main.ONOS2cli.feature_install("onos-app-metrics")
- main.ONOS3cli.feature_install("onos-app-metrics")
-
utilities.assert_equals(expect=main.TRUE,
actual= cell_file_result and cell_apply_result and\
verify_cell_result and checkout_result and\