From 9ed71c32036e2f52a09f1a62ada9cce99c729a15 Mon Sep 17 00:00:00 2001 From: Darshan Thaker Date: Thu, 25 Jul 2013 12:16:33 -0700 Subject: [PATCH 1/5] Added sampleTest-AddFlowSpace/UpdateSlice --- tests/tests-Sample.py | 111 +++++++++++++++++++++++++++++++++++++++++ tests/tests-Sample.pyc | Bin 0 -> 4745 bytes 2 files changed, 111 insertions(+) create mode 100755 tests/tests-Sample.py create mode 100644 tests/tests-Sample.pyc diff --git a/tests/tests-Sample.py b/tests/tests-Sample.py new file mode 100755 index 0000000..d7b7cd4 --- /dev/null +++ b/tests/tests-Sample.py @@ -0,0 +1,111 @@ +import sys +import logging +import templatetest +import testutils +import oftest.cstruct as ofp +import oftest.message as message +import oftest.action as action +import re + +# ------ Start: Mandatory portion on each test case file ------ + +#@var basic_port_map Local copy of the configuration map from OF port +# numbers to OS interfaces +basic_port_map = None +#@var basic_logger Local logger object +basic_logger = None +#@var basic_timeout Local copy of global timeout value +basic_timeout = None +#@var basic_config Local copy of global configuration data +basic_config = None + +test_prio = {} + +def test_set_init(config): + """ + Set up function for basic test classes + @param config The configuration dictionary; see fvt + """ + global basic_port_map + global basic_fv_cmd + global basic_logger + global basic_timeout + global basic_config + + basic_fv_cmd = config["fv_cmd"] + basic_logger = logging.getLogger("api") + basic_logger.info("Initializing test set") + basic_timeout = config["timeout"] + basic_port_map = config["port_map"] + basic_config = config + +# ------ End: Mandatory portion on each test case file ------ +NUM_SW = 2 +NUM_CTL = 2 + +class Ping(templatetest.TemplateTest): + """ + Ping and pong + Check if FlowVisor receives ping from API client and sends back pong to it + """ + def setUp(self): + templatetest.TemplateTest.setUp(self) + self.logger = basic_logger + # Set up the test environment + # -- Note: setting: config_file = test-base.xml, num of SW = 2, num of CTL = 2 + # no additional rules + (self.fv, self.sv, sv_ret, ctl_ret, sw_ret) = testutils.setUpTestEnv(self, fv_cmd=basic_fv_cmd, num_of_switches=NUM_SW, num_of_controllers=NUM_CTL) + self.chkSetUpCondition(self.fv, sv_ret, ctl_ret, sw_ret) + + def runTest(self): + rule = ["list-version"] + exp_data_fv = "flowvisor-version" + exp_data_db = "db-version" + # send the command and expect to receive pong + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertTrue(success, "%s: Not success" %(self.__class__.__name__)) + self.logger.info("Ping: Received: %s" % data) + self.assertTrue(data.has_key(exp_data_fv), "%s: Received unexpected message" %(self.__class__.__name__)) + self.assertTrue(data.has_key(exp_data_db), "%s: Received unexpected message" %(self.__class__.__name__)) + +class addFlowSpace(Ping): + def runTest(self): + #Add flowspace + flowspace_name = "dummyFlowName" + flowspace_dpid = "1" + flowspace_priority = 100 + flowspace_match = {"in_port" : 1, "dl_src" : "00:00:00:00:00:02"} + flowspace_slice = [{"slice-name" : "controller0", "permission" : 7}] + + rule = ["add-flowspace" , flowspace_name, flowspace_dpid, flowspace_priority, flowspace_match, flowspace_slice, {}] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertTrue(success, "%s: AddFlowSpace: Not success" %(self.__class__.__name__)) + self.logger.info("Raw received " + str(data)) + + #Check if flowspace added. + rule = ["list-flowspace", {}] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertTrue(success, "%s: Not success" %(self.__class__.__name__)) + num_flow = len(data) + self.logger.info("ListFlowSpace: Expected: %s" %(testutils.NUM_FLOWSPACE_IN_CONF_FILE + 1)) + self.logger.info("ListFlowSpace: Received: %s" % num_flow) + self.logger.debug("ListFlowSpace: Raw received: %s" % data) + self.assertEqual(num_flow, testutils.NUM_FLOWSPACE_IN_CONF_FILE + 1, "%s: Received wrong number of flow space" %(self.__class__.__name__)) + + #Send packet across flowspace. + pkt = testutils.simplePacket(dl_src="00:00:00:00:00:02") + in_port = 1 + msg = testutils.genPacketIn(in_port=in_port, pkt=pkt) + + snd_list = ["switch", 0, msg] + exp_list = [["controller", 0, msg]] + res = testutils.ofmsgSndCmp(self, snd_list, exp_list, xid_ignore=True) + self.assertTrue(res, "%s: Received unexpected message" %(self.__class__.__name__)) + +class updateSlicePasswd(Ping): + def runTest(self): + new_passwd = "hello123" + slice_user = "controller0" + rule = ["update-slice-password", slice_user, new_passwd] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertTrue(success, "%s: UpdateSlicePasswd: Not success" %(self.__class__.__name__)) diff --git a/tests/tests-Sample.pyc b/tests/tests-Sample.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e341fe78b7ab483ae194c0159440f76f1ab0618d GIT binary patch literal 4745 zcmcInYf~G^744CPKmrWL7>u3A?86l$DHgAH%OA+2)=TVKDnv_0IId7zH8sq%#0Y6- zGTnkDg+8(WCci76@+p-ckeqWzFIZ>G<=qubtNYIF+qe6kd-|&UpXGY}^51_B)#y{k z_h)#_KhZ?^cT`WQ<4NC9$Ie(@QpcrnzpReS<9MR5?n%3@qKeWb)xEFU@Mn$+*Gm2Mctb^1 zr8h)6Kap;#Xkjd^O{5RFN~=-FPUHXL(+nMS`IPYN;W2+eb0w#+6)0sL)y0lW>Kgu* zl`X4oh3;VJP^+T0f;rKjL$AtSFi(eCjd@x-MN@b2X=&>YGPgZQLK~-v+fH-$BrtL4 zT5YTw_5x$H5!KJKAP@R(m?rJG;~t&rQFo9BGBt|DM37(p#x+{I?Q<*hY!!>O&;76; z!B04n#pXV~_mkMhK`;J$oOFuSjJB5U*|@LMfwc?hXK8NzevmaA9N8r_;-5dVNc~>g z>A;Asq2JN=07IS6sPa7o6}*my5f@bG5 z?dzTB#GVFcI^Svc(u?!hr1>__afgj5+U-`*&wBc!>{9&T8y_3@V;sj8t#ONLvF@xm z%T67CF)<*{A7Yas-||CuKF4ERG#aRsY+xQZ#1)gEKx;*Ltp*R?w9!aNXvhtc$j#EE zBa*#S9iF*y+kFYg|3b&zT!%V7*T&7L-Okg#`}}Ypkcf3+Wwy~tWB?b;q#@U)Zd}A% z@XPaN&;-B8U1gQ(3UC2OA{B5z&#x#ur@8`C_zncXal{^QMntcj@>hanzb?v)YUrq8 zNeyLgcZouz@s*>lO6m$3P*F~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mn+d|4!tgqBtP0Sc&FX#9b|bcQ8`h?PKT z1@QSXVe&^T*X5E0Od9;XC<$aPjmIE(6H1bNPTTw`@=*xh8HB}e>v5k+mA124wNX7P zx6-)J+hAlRke~NLqoXdpz>kayzM5&GJqAF25P3EB$V*bP(g~mR;mPH)$(Ik Date: Thu, 25 Jul 2013 14:27:00 -0700 Subject: [PATCH 2/5] Added tests-Sample --- tests/tests-Sample.py | 17 +++++++++++++++++ tests/tests-Sample.pyc | Bin 4745 -> 5102 bytes 2 files changed, 17 insertions(+) diff --git a/tests/tests-Sample.py b/tests/tests-Sample.py index d7b7cd4..528c733 100755 --- a/tests/tests-Sample.py +++ b/tests/tests-Sample.py @@ -81,7 +81,24 @@ def runTest(self): (success, data) = testutils.setRule(self, self.sv, rule) self.assertTrue(success, "%s: AddFlowSpace: Not success" %(self.__class__.__name__)) self.logger.info("Raw received " + str(data)) + + #Attempt to add corrupt flowspace. Should return MissingRequiredField Exception. + rule = ["add-flowspace", flowspace_name, flowspace_dpid, flowspace_priority, flowspace_match, {}] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertFalse(success, "%s: AddFlowSpace: Was success, but shouldn't be" %(self.__class__.__name__)) + self.logger.info("Raw received " + str(data)) + #Attempt to add corrupt flowspace. Should return SliceNotFound Exception. + flowspace_slice = [{"slice-name" : "FAKESLICE", "permission" : 7}] + rule = ["add-flowspace", flowspace_name, flowspace_dpid, flowspace_priority, flowspace_match, flowspace_slice, {}] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertFalse(success, "%s: AddFlowSpace: Was success, but shouldn't be" %(self.__class__.__name__)) + self.logger.info("Raw received: " + str(data)) + + #Attempt to add corrupt flowspace. Should return UnknownMatchField Exception. +# flowspace_match.append("FAKEFIELD" : 1) + + #Check if flowspace added. rule = ["list-flowspace", {}] (success, data) = testutils.setRule(self, self.sv, rule) diff --git a/tests/tests-Sample.pyc b/tests/tests-Sample.pyc index e341fe78b7ab483ae194c0159440f76f1ab0618d..669c34e3afd4da3267e41f3822f56dcd73bba3cd 100644 GIT binary patch delta 612 zcmZ8dON-M`6#h=qrb(KnZ8|o!)gdm%@rB9^vng&ynffdPcHwFkZEvV8Wh!%12lWPp zg5bi{MZ}H&z=dStuTXF!=*F!J5y2lY-c+%JiwpOB&%=4P@?+J|e--S57jKONjcSRZ zztm_wd7W)*bV+{CNjfi|m^<2MO@1}sR2&F`&>(b(42HnKkQ>&?oCT2sE6SdAIy=3M624$GxfsT62Kw$yGL`;a(pcn%|9=wcD%@%kLjk+RfLRBCN zN;<)8@M`Muk2&eaM9*tek#gNOM@4XzVIT%YSw>`M`!2W+q5NhbEXA_O0k4BMARP2H zL`pcDcKUnvRcSX9dTD|vLMR6xVF|HDQ3eJYga_W7st^~{w>faQ+LF)qYx3^+L}e+; zi_&+iN!K-qI&#Mw&hG&jwABS>PB Zda`ZqyP>Io?)fFZIy>HG@};^)OTSu}R5Jho From 6b2e78e5cb24ca8e57d43f78be284778eb7a5838 Mon Sep 17 00:00:00 2001 From: Darshan Thaker Date: Thu, 8 Aug 2013 13:56:06 -0700 Subject: [PATCH 3/5] Added api/config tests --- tests/tests-api.py | 109 +++++++++++++++++++++++++++++++++-- tests/tests-config.py | 129 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 232 insertions(+), 6 deletions(-) create mode 100644 tests/tests-config.py diff --git a/tests/tests-api.py b/tests/tests-api.py index 517eecf..3a04114 100755 --- a/tests/tests-api.py +++ b/tests/tests-api.py @@ -11,7 +11,6 @@ import oftest.message as message import oftest.action as action import re - # ------ Start: Mandatory portion on each test case file ------ #@var basic_port_map Local copy of the configuration map from OF port @@ -73,9 +72,7 @@ def runTest(self): self.assertTrue(success, "%s: Not success" %(self.__class__.__name__)) self.logger.info("Ping: Received: %s" % data) self.assertTrue(data.has_key(exp_data_fv), "%s: Received unexpected message" %(self.__class__.__name__)) - self.assertTrue(data.has_key(exp_data_db), "%s: Received unexpected message" %(self.__class__.__name__)) - - + self.assertTrue(data.has_key(exp_data_db), "%s: Received unexpected message" %(self.__class__.__name__)) class ListFlowSpace(Ping): """ @@ -138,6 +135,11 @@ def runTest(self): (success, data) = testutils.setRule(self, self.sv, rule) self.assertTrue(success, "%s: Not success" %(self.__class__.__name__)) + #Attempt to remove a dummy flowspace. Should return FlowEntryNotFound Exception. + rule = ["remove-flowspace", "DummyFlowName"] + (success, data) = testutils.setRule(self, self.sv,rule) + self.assertFalse(success, "%s: Was success but should not be" %(self.__class__.__name__)) + class CreateSlice(Ping): """ @@ -171,7 +173,7 @@ def runTest(self): # Try to create a slice with a same name and different configuration. # Should be failed slice_random_email = "ctl2@bar.com" - rule = ["add-lice", slice_name, slice_pswd, slice_port, slice_random_email, {}] + rule = ["add-slice", slice_name, slice_pswd, slice_port, slice_random_email, {}] (success, data) = testutils.setRule(self, self.sv, rule) self.assertFalse(success, "%s: Shouldn't be created" %(self.__class__.__name__)) @@ -186,7 +188,6 @@ def runTest(self): self.assertTrue(success, "%s: The slice should be created" %(self.__class__.__name__)) - class DeleteSlice(Ping): """ Delete_slice @@ -198,6 +199,11 @@ def runTest(self): rule = ["remove-slice", testutils.EXIST_SLICE0_IN_CONF_FILE] (success, data) = testutils.setRule(self, self.sv, rule) self.assertTrue(success, "%s: DeleteSlice: Not success" %(self.__class__.__name__)) + + #Attempt to delete a dummy slice name. Should return InvalidSliceName Exception + rule = ["remove-slice", "DummySliceName"] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertFalse(success, "%s: DeleteSlice: Success but should not be" %(self.__class__.__name__)) remaining_fs = testutils.NUM_FLOWSPACE_IN_CONF_FILE-testutils.NUM_FLOWSPACE_EXIST_SLICE0 # Check number of flow space @@ -274,3 +280,94 @@ def runTest(self): self.logger.debug("GetSliceInfo: Raw received: " + str(data)) self.assertEqual(data['admin-contact'], new_email, "%s: Received unexpected contact_email" %(self.__class__.__name__)) self.assertTrue(re.search(str(new_port), data['controller-url']), "%s: Received unexpected controller_port" %(self.__class__.__name__)) + +class addFlowSpace(Ping): + def runTest(self): + #Add flowspace + flowspace_name = "dummyFlowName" + flowspace_dpid = "1" + flowspace_priority = 100 + flowspace_match = {"in_port" : 1, "dl_src" : "00:00:00:00:00:02"} + flowspace_slice = [{"slice-name" : "controller0", "permission" : 7}] + + rule = ["add-flowspace" , flowspace_name, flowspace_dpid, flowspace_priority, flowspace_match, flowspace_slice, {}] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertTrue(success, "%s: AddFlowSpace: Not success" %(self.__class__.__name__)) + self.logger.info("Raw received " + str(data)) + + #Attempt to add corrupt flowspace. Should return MissingRequiredField Exception. + rule = ["add-flowspace", flowspace_name, flowspace_dpid, flowspace_priority, flowspace_match, {}] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertFalse(success, "%s: AddFlowSpace: Was success, but shouldn't be" %(self.__class__.__name__)) + self.logger.info("Raw received " + str(data)) + + #Attempt to add corrupt flowspace. Should return SliceNotFound Exception. + flowspace_slice = [{"slice-name" : "FAKESLICE", "permission" : 7}] + rule = ["add-flowspace", flowspace_name, flowspace_dpid, flowspace_priority, flowspace_match, flowspace_slice, {}] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertFalse(success, "%s: AddFlowSpace: Was success, but shouldn't be" %(self.__class__.__name__)) + self.logger.info("Raw received: " + str(data)) + + #Check if flowspace added. + rule = ["list-flowspace", {}] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertTrue(success, "%s: Not success" %(self.__class__.__name__)) + num_flow = len(data) + self.logger.info("ListFlowSpace: Expected: %s" %(testutils.NUM_FLOWSPACE_IN_CONF_FILE + 1)) + self.logger.info("ListFlowSpace: Received: %s" % num_flow) + self.logger.debug("ListFlowSpace: Raw received: %s" % data) + self.assertEqual(num_flow, testutils.NUM_FLOWSPACE_IN_CONF_FILE + 1, "%s: Received wrong number of flow space" %(self.__class__.__name__)) + + #Send packet across flowspace. + pkt = testutils.simplePacket(dl_src="00:00:00:00:00:02") + in_port = 1 + msg = testutils.genPacketIn(in_port=in_port, pkt=pkt) + + snd_list = ["switch", 0, msg] + exp_list = [["controller", 0, msg]] + res = testutils.ofmsgSndCmp(self, snd_list, exp_list, xid_ignore=True) + self.assertTrue(res, "%s: Received unexpected message" %(self.__class__.__name__)) + +class listFVHealth(Ping): + def runTest(self): + rule = ["list-fv-health"] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertTrue(success, "%s: Not success." %(self.__class__.__name__)) + +class listDatapathStats(Ping): + def runTest(self): + rule = ["list-datapath-stats", testutils.SRC_MAC_FOR_CTL1_0] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertTrue(success, "%s: Not success." %(self.__class__.__name__)) + + #Test whether any packets dropped from this dpid. Should be {} or no packets dropped. + self.assertEqual(data['drop']['Total'], {}, "%s: Dropped some packets" %(self.__class__.__name__)) + self.logger.debug("Received: " + str(data)) + + #Attempt to list stats for random DPID. Should return DPIDNotFound Exception. + randomDPID = "12:34:56:78:90" + rule = ["list-datapath-stats", randomDPID] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertFalse(success, "%s: Was success but should not be" %(self.__class__.__name__)) + +class listSliceStats(Ping): + def runTest(self): + rule = ["list-slice-stats", testutils.EXIST_SLICE0_IN_CONF_FILE] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertTrue(success, "%s: Not success." %(self.__class__.__name__)) + +class listSliceHealth(Ping): + def runTest(self): + rule = ["list-slice-health", testutils.EXIST_SLICE0_IN_CONF_FILE] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertTrue(success, "%s: Not success." %(self.__class__.__name__)) + self.assertEqual(data['is-connected'], True, "%s: Slice not connected" %(self.__class__.__name__)) + self.logger.debug("Received: " + str(data)) + +class updateSlicePasswd(Ping): + def runTest(self): + new_passwd = "hello123" + slice_user = "controller0" + rule = ["update-slice-password", slice_user, new_passwd] + (success, data) = testutils.setRule(self, self.sv, rule) + self.assertTrue(success, "%s: UpdateSlicePasswd: Not success" %(self.__class__.__name__)) diff --git a/tests/tests-config.py b/tests/tests-config.py new file mode 100644 index 0000000..95f18e2 --- /dev/null +++ b/tests/tests-config.py @@ -0,0 +1,129 @@ +""" +Tests for the configuration commands using fvconfig. +""" +import sys +import logging +import templatetest +import testutils +import oftest.cstruct as ofp +import oftest.message as message +import oftest.parse as parse +import oftest.action as action +import oftest.error as error +import socket +import time +import json +import subprocess +import threading +from pprint import pprint + + +# ------ Start: Mandatory portion on each test case file ------ + +#@var basic_port_map Local copy of the configuration map from OF port +# numbers to OS interfaces +basic_port_map = None +#@var basic_logger Local logger object +basic_logger = None +#@var basic_timeout Local copy of global timeout value +basic_timeout = None +#@var basic_config Local copy of global configuration data +basic_config = None + +test_prio = {} + +def test_set_init(config): + """ + Set up function for basic test classes + @param config The configuration dictionary; see fvt + """ + global basic_port_map + global basic_fv_cmd + global basic_logger + global basic_timeout + global basic_config + + basic_fv_cmd = config["fv_cmd"] + basic_logger = logging.getLogger("actions") + basic_logger.info("Initializing test set") + basic_timeout = config["timeout"] + basic_port_map = config["port_map"] + basic_config = config + +# ------ End: Mandatory portion on each test case file ------ + +#Command class for calling the command.run which takes in a timeout period. +#After the timeout period(usually reached when exceptions thrown), +#the thread is stopped so that the test can continue on +class Command(object): + def __init__(self, cmd): + self.cmd = cmd + self.process = None + + def run(self, timeout): + def target(): + self.process = subprocess.Popen(self.cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + (out, err) = self.process.communicate() + basic_logger.debug("Received output: " + out) + + #Start thread with target as the command to be run. + thread = threading.Thread(target=target) + thread.start() + + #Wait for however long timeout is. + thread.join(timeout) + if (thread.is_alive()): + basic_logger.debug("Terminating thread.") + self.process.terminate() + thread._Thread__stop() + #Takes too long, so return success value = False + return False + #Command finished successfully, so success value = True + else: + return True + +class generateConfig(templatetest.TemplateTest): + def setUp(self): + templatetest.TemplateTest.setUp(self) + self.logger = basic_logger + return + + def runTest(self): + cmd = " generate " + config_file = "newconfig.json" + host_name = " host" + host_passwd = " openflow" + of_port = " 16633" + api_port = " 6633" + output = "" + params = host_name +host_passwd + of_port + api_port + + #Generating newconfig.json + self.logger.info("Running fvconfig" + cmd + config_file + params) + command = Command("fvconfig" + cmd + config_file + params) + success = command.run(timeout=10) + self.assertTrue(success, "%s: Generate timeout" %(self.__class__.__name__)) + + with open('newconfig.json') as data_file: + data = json.load(data_file) + self.logger.debug("Data received: " + str(data)) + + #Loading newconfig.json + cmd = " load " + self.logger.info("Running fvconfig" + cmd + config_file) + command = Command("fvconfig" + cmd + config_file) + success = command.run(timeout=10) + self.assertTrue(success, "%s: Load timeout" %(self.__class__.__name__)) + + #Loading DUMMYCONFIG.json. Should return error. + config_file = "DUMMYCONFIG.json" + self.logger.info("Running fvconfig" + cmd + config_file) + command = Command("fvconfig" + cmd + config_file) + success = command.run(timeout=10) + self.assertFalse(success, "%s: Load error not caught." %(self.__class__.__name__)) + + #Delete newconfig.json generated from this test. + config_file = "newconfig.json" + command = Command("rm -f " + config_file) + success = command.run(timeout=10) + self.assertTrue(success, "%s: rm Timeout." %(self.__class__.__name__)) From 0f4974d79e9b0e49fdc0d059f45b10f1fa389573 Mon Sep 17 00:00:00 2001 From: Darshan Thaker Date: Thu, 8 Aug 2013 14:15:42 -0700 Subject: [PATCH 4/5] Removed Sample Tests --- tests/tests-Sample.py | 128 ----------------------------------------- tests/tests-Sample.pyc | Bin 5102 -> 0 bytes 2 files changed, 128 deletions(-) delete mode 100755 tests/tests-Sample.py delete mode 100644 tests/tests-Sample.pyc diff --git a/tests/tests-Sample.py b/tests/tests-Sample.py deleted file mode 100755 index 528c733..0000000 --- a/tests/tests-Sample.py +++ /dev/null @@ -1,128 +0,0 @@ -import sys -import logging -import templatetest -import testutils -import oftest.cstruct as ofp -import oftest.message as message -import oftest.action as action -import re - -# ------ Start: Mandatory portion on each test case file ------ - -#@var basic_port_map Local copy of the configuration map from OF port -# numbers to OS interfaces -basic_port_map = None -#@var basic_logger Local logger object -basic_logger = None -#@var basic_timeout Local copy of global timeout value -basic_timeout = None -#@var basic_config Local copy of global configuration data -basic_config = None - -test_prio = {} - -def test_set_init(config): - """ - Set up function for basic test classes - @param config The configuration dictionary; see fvt - """ - global basic_port_map - global basic_fv_cmd - global basic_logger - global basic_timeout - global basic_config - - basic_fv_cmd = config["fv_cmd"] - basic_logger = logging.getLogger("api") - basic_logger.info("Initializing test set") - basic_timeout = config["timeout"] - basic_port_map = config["port_map"] - basic_config = config - -# ------ End: Mandatory portion on each test case file ------ -NUM_SW = 2 -NUM_CTL = 2 - -class Ping(templatetest.TemplateTest): - """ - Ping and pong - Check if FlowVisor receives ping from API client and sends back pong to it - """ - def setUp(self): - templatetest.TemplateTest.setUp(self) - self.logger = basic_logger - # Set up the test environment - # -- Note: setting: config_file = test-base.xml, num of SW = 2, num of CTL = 2 - # no additional rules - (self.fv, self.sv, sv_ret, ctl_ret, sw_ret) = testutils.setUpTestEnv(self, fv_cmd=basic_fv_cmd, num_of_switches=NUM_SW, num_of_controllers=NUM_CTL) - self.chkSetUpCondition(self.fv, sv_ret, ctl_ret, sw_ret) - - def runTest(self): - rule = ["list-version"] - exp_data_fv = "flowvisor-version" - exp_data_db = "db-version" - # send the command and expect to receive pong - (success, data) = testutils.setRule(self, self.sv, rule) - self.assertTrue(success, "%s: Not success" %(self.__class__.__name__)) - self.logger.info("Ping: Received: %s" % data) - self.assertTrue(data.has_key(exp_data_fv), "%s: Received unexpected message" %(self.__class__.__name__)) - self.assertTrue(data.has_key(exp_data_db), "%s: Received unexpected message" %(self.__class__.__name__)) - -class addFlowSpace(Ping): - def runTest(self): - #Add flowspace - flowspace_name = "dummyFlowName" - flowspace_dpid = "1" - flowspace_priority = 100 - flowspace_match = {"in_port" : 1, "dl_src" : "00:00:00:00:00:02"} - flowspace_slice = [{"slice-name" : "controller0", "permission" : 7}] - - rule = ["add-flowspace" , flowspace_name, flowspace_dpid, flowspace_priority, flowspace_match, flowspace_slice, {}] - (success, data) = testutils.setRule(self, self.sv, rule) - self.assertTrue(success, "%s: AddFlowSpace: Not success" %(self.__class__.__name__)) - self.logger.info("Raw received " + str(data)) - - #Attempt to add corrupt flowspace. Should return MissingRequiredField Exception. - rule = ["add-flowspace", flowspace_name, flowspace_dpid, flowspace_priority, flowspace_match, {}] - (success, data) = testutils.setRule(self, self.sv, rule) - self.assertFalse(success, "%s: AddFlowSpace: Was success, but shouldn't be" %(self.__class__.__name__)) - self.logger.info("Raw received " + str(data)) - - #Attempt to add corrupt flowspace. Should return SliceNotFound Exception. - flowspace_slice = [{"slice-name" : "FAKESLICE", "permission" : 7}] - rule = ["add-flowspace", flowspace_name, flowspace_dpid, flowspace_priority, flowspace_match, flowspace_slice, {}] - (success, data) = testutils.setRule(self, self.sv, rule) - self.assertFalse(success, "%s: AddFlowSpace: Was success, but shouldn't be" %(self.__class__.__name__)) - self.logger.info("Raw received: " + str(data)) - - #Attempt to add corrupt flowspace. Should return UnknownMatchField Exception. -# flowspace_match.append("FAKEFIELD" : 1) - - - #Check if flowspace added. - rule = ["list-flowspace", {}] - (success, data) = testutils.setRule(self, self.sv, rule) - self.assertTrue(success, "%s: Not success" %(self.__class__.__name__)) - num_flow = len(data) - self.logger.info("ListFlowSpace: Expected: %s" %(testutils.NUM_FLOWSPACE_IN_CONF_FILE + 1)) - self.logger.info("ListFlowSpace: Received: %s" % num_flow) - self.logger.debug("ListFlowSpace: Raw received: %s" % data) - self.assertEqual(num_flow, testutils.NUM_FLOWSPACE_IN_CONF_FILE + 1, "%s: Received wrong number of flow space" %(self.__class__.__name__)) - - #Send packet across flowspace. - pkt = testutils.simplePacket(dl_src="00:00:00:00:00:02") - in_port = 1 - msg = testutils.genPacketIn(in_port=in_port, pkt=pkt) - - snd_list = ["switch", 0, msg] - exp_list = [["controller", 0, msg]] - res = testutils.ofmsgSndCmp(self, snd_list, exp_list, xid_ignore=True) - self.assertTrue(res, "%s: Received unexpected message" %(self.__class__.__name__)) - -class updateSlicePasswd(Ping): - def runTest(self): - new_passwd = "hello123" - slice_user = "controller0" - rule = ["update-slice-password", slice_user, new_passwd] - (success, data) = testutils.setRule(self, self.sv, rule) - self.assertTrue(success, "%s: UpdateSlicePasswd: Not success" %(self.__class__.__name__)) diff --git a/tests/tests-Sample.pyc b/tests/tests-Sample.pyc deleted file mode 100644 index 669c34e3afd4da3267e41f3822f56dcd73bba3cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5102 zcmcIo>vG%16<&}OB}%g8i>!-tDcZyn_9Dx%r~aX4I&oAf)l^|z(5|PN%wQm3Nr46d z7Q2+9RQjd7LZ6~f)CcGTbov14_Z<)9gO>qI&eyPMIBViepMY*%YIGuX4FBw9L}oVoI02*hYi)6 zR|oUua6ug`P)l%4+UwFTNqa-ZP<>NH74fKQt*fYZk7fSv4 zU`0iBrB_5cJC?4hXs(nt#?m!vX*cI_()c^PTA_n3KNWno@iD(cb0)X29w=oU)x(J^ z>H_vwm945?jpktJa8^yN2QxB%2E96a!7L4GH)pxq5t?}yueP@CaNu@^X=vjtbvs$^ z9tI{3U8{|C!z3_98=3m)AjpHh8)j)I?z+#8^r$<`16dlyvPF=e{>C+0yPabz>uep$ zI>&z4k6sHr}MvbbTx-^-V1=PTZtBx@QIIu`!TL#jl1!P zYGK}4a;`b^c*n$m82=Q94EdBVn)4Yx#zmunN{I%>fkRv|2nw{;l-F+Z;!OvQxP%+I zK^nP(EbWS9`$&f`-MHiK!tg)Qa5vYXj*qo*2b|r>v%dS}=^h{v>(t6>qtnO$E?CKp zT${OZ;d8++@0(5&{33RhRjMbz1ssV~zyUqKrtFOB2}of(5CFsBd%zhUy>O~u36lMJ znY^IR9d%w&=d!l9NFl=b%u#0*b%qG2DJN3EIkmSuG|DcaNr!zu>-gp*w&4-({MJMU zf7(1t5}lhSp&_of8eR&lrhi26Y$SL_!3?IsY0n3q;FSm;fs7dBnxTyoBMW67SM8+7 z9<34(wVr?Bw_ga{+1-A&Z|P?Q4ZqB>y@{{z=w+K)wzD)suw<#6O0Zyb(vgkKv7e9P zCbWt4X^uHzSMd3xK7~Ny z@Dd#b7d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-Krj3ezNrq*gNoe#q zkpH0w(T=*b0>9*H_-bXT_UHil)#)|ZBU8!m0vh3yP&~cC0Uc!GcmYl_Uy;8m#w^{A4udh7%4_EhIGXMYp From 63f2fd6b0fb8846fbf34ede2a48ec267f38d6b44 Mon Sep 17 00:00:00 2001 From: Darshan Thaker Date: Thu, 8 Aug 2013 14:17:37 -0700 Subject: [PATCH 5/5] Added config test --- tests/tests-config.pyc | Bin 0 -> 4216 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/tests-config.pyc diff --git a/tests/tests-config.pyc b/tests/tests-config.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e5cce10ab7d6026736512084b44f4e1f85ecf20c GIT binary patch literal 4216 zcmb_f;cgsB5w6*_*Y?_u9Vd>HT<(|yAyxw09FZcFLlEI`QKUOx7;iXkK^l!`dhOZU zomoxyItuds3IhJ|9J~|%c>o>&zOQ=5b^-zsv*T`8_jFfRRabpg)BgK<_b-2IN2%1m zHvT_Bv)>CuGLZrLK(dyM0~vtubV~-UhHlHC-Ovj%SZL@)8Fgf^)C`wpv?7C*X4sX{ zsti_};hK!rWw721Z^&pv1{=+AQwEz2eNzTE8+uCyTMd0n2DcjewhV47-InpTOtxjP zEdg{$cBn~mSNnU~-FOTWiiZ8W>wlhPk2HcvwbZNhY%SZk~DDipG$-A-m}$^&2`w-p!X*n_b*|9rKzA@GQa9qAR%WYZhQnP(_*7v*h?N48;9DEZ) z@i>P$zC&(QQC7RbMz9`q@u*1-ybq;(#~=OU=V#&#wQ#Y!5JO(=tC*H zrl~{S!Nhq$&xqkL>Rd7Q30#DX4|{F&a4hV_#Vv5EEQ|^=t;*C`tBm!HHREBli6v@_ z>luVs9IGYb_*2l9M@z60s0tiVCN}HP{ZTY51Nno1t9+d<)Hfh0Y5=CVB}R z0wKL%8lpJtP0+@IxFcNF;c<}Tw=J1Ng+So)Kud%$u4ab;tw%0`_o0T8br}PLU;)xp z6*z)CHRG|p2`VzF$*WBsVVf{^cG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