1 """Script to Test the SFC scenarios in ONOS."""
4 # Copyright (c) CREATED5 All rights reserved
5 # This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # ###########################################################################
13 # **** Scripted by Antony Silvester - antony.silvester@huawei.com ******
14 # ###########################################################################
16 # Testcase 1 : Prerequisites configuration for SFC
17 # Testcase 2 : Creation of 3 VNF Nodes and Attaching Ports
18 # Testcase 3 : Configure SFC [Port pair,Port Group ,Flow classifer
19 # Testcase 4 : Configure Port Chain and verify the flows are added.
20 # Testcase 5 : Verify traffic with VNF node.
21 # Testcase 6 : Remove the Port Chain and Verify the traffic.
22 # Testcase 7 : Cleanup
23 # ###########################################################################
27 import functest.utils.functest_logger as ft_logger
28 import functest.utils.functest_utils as functest_utils
29 from Sfc_fun import Sfc_fun
31 logger = ft_logger.Logger("sfc").getLogger()
41 logger.info("Testcase 1 : Prerequisites configuration for SFC")
42 logger.info("1.1 Creation of Auth-Token")
43 if (Sfc_obj.getToken() == OK):
44 logger.info("Creation of Token is successfull")
46 logger.error(" : Creation of Token is NOT successfull")
48 logger.info("1.2 Creation of Network")
49 if (Sfc_obj.createNetworks() == CREATED):
50 logger.info("Creation of network is successfull")
52 logger.error(" : Creation of network is NOT successfull")
54 logger.info("1.3 Creation of Subnetwork")
56 if (Sfc_obj.createSubnets() == CREATED):
57 logger.info("Creation of Subnetwork is successfull")
59 logger.error(" : Creation of Subnetwork is NOT successfull")
64 logger.info("Testcase 2 : Creation of 3 VNF Nodes and Attaching Ports")
65 logger.info("2.1 Creation of Ports")
66 if (Sfc_obj.createPorts() == CREATED):
67 logger.info("Creation of Port is successfull")
69 logger.error(" : Creation of Port is NOT successfull")
71 logger.info("2.2 Creation of VM-Compute-Node")
72 if (Sfc_obj.createVm() == ACCEPTED):
73 logger.info("Creation of VM is successfull")
75 logger.error(" : Creation of VM is NOT successfull")
77 logger.info("2.3 Check VM Status")
78 if (Sfc_obj.checkVmState() == OK):
79 logger.info("VM are in active state")
81 logger.error(" : VM is NOT Active")
83 logger.info("2.4 Router Creation")
84 if (Sfc_obj.createRouter() == CREATED):
85 logger.info("Creation of Router is Successful")
87 logger.error(" : Router Creation is NOT Successful")
89 logger.info("2.5 Attachement of Interface to VM")
90 if (Sfc_obj.attachInterface() == OK):
91 logger.info("Interface attached to VM")
93 logger.error(" : Interface NOT attached to VM")
95 logger.info("2.6 Attachement of FLoating Ip to VM")
96 if (Sfc_obj.addFloatingIp() == ACCEPTED):
97 logger.info("Floating Ip attached to VM SUccessful")
99 logger.error(" : Floating Ip NOT attached to VM ")
105 "Testcase 3 : Configure SFC [Portair,PortGroup,Flow classifer]")
106 logger.info("3.1 Creation of Port Pair")
107 if (Sfc_obj.createPortPair() == CREATED):
108 logger.info("Creation of Port pair is successful")
110 logger.error(" : Creation of Port pair is NOT successful")
112 logger.info("3.2 Getting the Port Pair ID")
113 if (Sfc_obj.getPortPair() == OK):
114 logger.info("Port Pair ID is successfully got")
116 logger.error(" : UnSuccessfully got Port Pair ID")
118 logger.info("3.3 Creation of Port Pair Group")
119 if (Sfc_obj.createPortGroup() == CREATED):
120 logger.info("Creation of Port Pair Group is successful")
122 logger.error(" : Creation of Port Pair Group is NOT successful")
124 logger.info("3.4 Getting Port Pair Group ID ")
125 if (Sfc_obj.getPortGroup() == OK):
126 logger.info("Port Pair Group ID is successfully received")
128 logger.error(" : Port Pair Group ID is NOT successfully got")
130 logger.info("3.5 Creation of Flow Classifier")
131 if (Sfc_obj.createFlowClassifier() == CREATED):
132 logger.info("Creation of Flow Classifier is successful")
134 logger.error(" : Creation of Flow Classifier is NOT successful")
137 "Testcase 4 : Configure Port Chain and verify flows are added")
138 logger.info("4.1 Creation of Port Chain")
139 if (Sfc_obj.createPortChain() == CREATED):
140 logger.info("Creation of Port Chain is successful")
142 logger.error("Creation of Port Chain is NOT successful")
145 def VerifySfcTraffic():
147 logger.info("Testcase 5 : Verify traffic with VNF node.")
148 if (Sfc_obj.loginToVM() == "1"):
149 logger.info("SFC function Working")
151 logger.error(" : SFC function not working")
154 logger.info("Testcase 6 : Remove the Port Chain and Verify the traffic")
155 if (Sfc_obj.deletePortChain() == NO_CONTENT):
156 if (Sfc_obj.loginToVM() == "0"):
157 logger.info("SFC function is removed Successfully")
159 logger.error(":SFC function not Removed. Have some problem")
161 if (Sfc_obj.deleteFlowClassifier() == NO_CONTENT):
162 if (Sfc_obj.deletePortGroup() == NO_CONTENT):
163 if (Sfc_obj.deletePortPair() == NO_CONTENT):
165 "SFC configuration is deleted successfully")
167 logger.error(" : Port pair configuration is NOT\
168 deleted successfully")
171 logger.error(" : Port Group configuration is NOT \
172 deleted successfully")
175 logger.error(" : Flow classifier configuration is NOT \
176 deleted successfully")
179 logger.error(":PortChain configuration is NOT deleted \
182 if (status == "FAIL"):
187 logger.info("Testcase 7 : Cleanup")
188 if (Sfc_obj.cleanup() == NO_CONTENT):
189 logger.info("CleanUp is successfull")
191 logger.error(" : CleanUp is NOT successfull")
200 """Script to Test the SFC scenarios in ONOS."""
201 start_time = time.time()
208 logger.info("Summary :")
210 logger.debug("Push ONOS SFC results into DB")
211 stop_time = time.time()
213 # ONOS SFC success criteria = all tests OK
214 duration = round(stop_time - start_time, 1)
215 logger.info("Result is " + status)
216 functest_utils.push_results_to_db("functest",
221 details={'timestart': start_time,
222 'duration': duration,
225 logger.error("Error pushing results into Database")
227 if __name__ == '__main__':