1 """Script to Test the SFC scenarios in ONOS."""
4 # Copyright (c) 2015 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 : Verify the Service Chain Statistics
22 # TestCase 7 : Remove the Port Chain and Verify the traffic.
23 # Testcase 8 : Cleanup
24 # ###########################################################################
26 import functest.utils.functest_logger as ft_logger
27 from Sfc_fun import Sfc_fun
31 """Script to Test the SFC scenarios in ONOS."""
32 logger = ft_logger.Logger("sfc").getLogger()
34 print("################################################################")
35 print(" OPNFV SFC Script ")
36 print("################################################################")
37 logger.info("Testcase 1 : Prerequisites configuration for SFC")
38 #########################################################################
39 logger.info("\t1.1 Creation of Auth-Token")
40 if (Sfc_obj.getToken() == 200):
41 logger.info("\t\tCreation of Token is successfull")
43 logger.error("\t\t : Creation of Token is NOT successfull")
44 #########################################################################
45 logger.info("\t1.2 Creation of Network")
46 if (Sfc_obj.createNetworks() == 201):
47 logger.info("\t\tCreation of network is successfull")
49 logger.error("\t\t : Creation of network is NOT successfull")
50 #########################################################################
51 logger.info("\t1.3 Creation of Subnetwork")
52 if (Sfc_obj.createSubnets() == 201):
53 logger.info("\t\tCreation of Subnetwork is successfull")
55 logger.error("\t\t : Creation of Subnetwork is NOT successfull")
56 print ("\n###########################################################\n")
57 ########################################################################
58 logger.info("Testcase 2 : Creation of 3 VNF Nodes and Attaching Ports")
59 #########################################################################
60 logger.info("\t2.1 Creation of Ports")
61 if (Sfc_obj.createPorts() == 201):
62 logger.info("\t\tCreation of Port is successfull")
64 logger.error("\t\t : Creation of Port is NOT successfull")
65 #########################################################################
66 logger.info("\t2.2 Creation of VM-Compute-Node")
67 if (Sfc_obj.createVm() == 202):
68 logger.info("\t\tCreation of VM is successfull")
70 logger.error("\t\t : Creation of VM is NOT successfull")
71 #########################################################################
72 logger.info("\t2.3 Check VM Status")
73 if (Sfc_obj.checkVmState() == 200):
74 logger.info("\t\tVM are in active state")
76 logger.error("\t\t : VM is NOT Active")
77 #########################################################################
78 logger.info("\t\t2.4 Router Creation")
79 if (Sfc_obj.createRouter() == 201):
80 logger.info("\t\t Router Creation is Successful")
82 logger.error("\t\t : Router Creation is NOT Successful")
83 #########################################################################
84 logger.info("\t\t2.5 Attachement of Interface to VM")
85 if (Sfc_obj.attachInterface() == 200):
86 logger.info("\t\t Interface attached to VM")
88 logger.error("\t\t : Interface NOT attached to VM")
89 #########################################################################
90 logger.info("\t\t2.6 Attachement of FLoating Ip to VM")
91 if (Sfc_obj.addFloatingIp() == 202):
92 logger.info("\t\t Floating Ip attached to VM SUccessful")
94 logger.error("\t\t : Floating Ip NOT attached to VM ")
95 print ("\n###########################################################\n")
96 ########################################################################
97 logger.info("TestCase 3 : Configure SFC [Portair,PortGroup,\
99 #########################################################################
100 logger.info("\t3.1 Creation of Port Pair")
101 if (Sfc_obj.createPortPair() == 201):
102 logger.info("\t\tCreation of Port pair is successful")
104 logger.error("\t\t : Creation of Port pair is NOT successful")
106 #########################################################################
107 logger.info("\t3.2 Getting the Port Pair ID")
108 if (Sfc_obj.getPortPair() == 200):
109 logger.info("\t\tSuccessfully got Port Pair ID")
111 logger.error("\t\t : UnSuccessfully got Port Pair ID")
113 #########################################################################
114 logger.info("\t3.3 Creation of Port Pair Group")
115 if (Sfc_obj.createPortGroup() == 201):
116 logger.info("\t\tPort Pair Group successfully Created")
118 logger.error("\t\t : Port Pair Group NOT successfully Created")
120 #########################################################################
121 logger.info("\t3.4 Getting Port Pair Group ID ")
123 if (Sfc_obj.getPortGroup() == 200):
124 logger.info("\t\tPort Pair Group ID successfully received")
126 logger.error("\t\t : Port Pair Group ID NOT successfully received")
128 #########################################################################
129 logger.info("\t3.5 Creation of Flow Classifier")
130 if (Sfc_obj.createFlowClassifier() == 201):
131 logger.info("\t\tFlow Classifier successfully Created")
133 logger.error("\t\t : Flow Classifier NOT successfully Created")
134 print ("\n###########################################################\n")
135 ########################################################################
136 logger.info("TestCase 4 : Configure Port Chain and verify the flows are\
138 #########################################################################
139 logger.info("\t4.1 Creation of PortChain")
140 if (Sfc_obj.createPortChain() == 201):
141 logger.info("\t\tPortChain successfully Created")
143 logger.error("\t\tPortChain NOT successfully Created")
144 #########################################################################
145 logger.info("\t4.2 Verification of Flows Installed in OVS")
146 if (Sfc_obj.checkFlowAdded() == 200):
147 logger.info("\t\tFlows Installed successfully ")
149 logger.error("\t\t : Flows NOT Installed successfully")
151 if (Sfc_obj.portChainDeviceMap() == 200):
152 logger.info("\t\t portChainDeviceMap successfully ")
154 logger.error("\t\t:portChainDeviceMap NOT Installed successfully")
156 if (Sfc_obj.portChainSfMap() == 200):
157 logger.info("\t\tportChainSfMap successfully ")
159 logger.error("\t\t : portChainSfMap NOT Installed successfully")
160 print ("\n############################################################n")
161 ########################################################################
162 logger.info("\tTestCase 5 : Verify traffic with VNF node.")
163 if (Sfc_obj.loginToVM() == "1"):
164 logger.info("\t\tSFC function Working")
166 logger.error("\t\t : SFC function not working")
167 print ("\n###########################################################\n")
168 logger.info("TestCase 6 : Verify the Service Chain Statistics")
169 if (Sfc_obj.portChainDeviceMap() == 200):
170 logger.info("\t\tportChainDeviceMap successfully ")
172 logger.error("\t\t:portChainDeviceMap NOT Installed successfully")
174 if (Sfc_obj.portChainSfMap() == 200):
175 logger.info("\t\tportChainSfMap successfully ")
177 logger.error("\t\t : portChainSfMap NOT Installed successfully")
178 print ("\n##########################################################\n")
179 logger.info("TestCase 7 : Remove the Port Chain and Verify the traffic")
180 if (Sfc_obj.deletePortChain() == 204):
181 if (Sfc_obj.loginToVM() == "0"):
182 logger.info("\t\tSFC function is removed Successfully")
184 logger.error("\t\t:SFC function not Removed.Have some problem")
185 if (Sfc_obj.deleteFlowClassifier() == 204):
186 if (Sfc_obj.deletePortGroup() == 204):
187 if (Sfc_obj.deletePortPair() == 204):
188 logger.info("\t\tSFC configuration is deleted \
191 logger.error("\t\t : Port pair configuration is NOT\
192 deleted successfully")
194 logger.error("\t\t : Port Group configuration is NOT \
195 deleted successfully")
197 logger.error("\t\t : Flow classifier configuration is NOT \
198 deleted successfully")
200 logger.error("\t\t:PortChain configuration is NOT deleted \
202 print ("\n###########################################################n")
203 #######################################################################
204 logger.info("Testcase 8 : Cleanup")
205 if (Sfc_obj.cleanup() == 204):
206 logger.info("\t\tCleanUp is successfull")
208 logger.error("\t\t : CleanUp is NOT successfull")
209 print ("###############################################################")
210 print("############################END OF SCRIPT ######################")