Merge "Remove OVNO test for Colorado"
[functest.git] / testcases / Controllers / ONOS / Sfc / Sfc.py
1 """Script to Test the SFC scenarios in ONOS."""
2 # !/usr/bin/python
3 #
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
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # ###########################################################################
12 #                          OPNFV SFC Script
13 # **** Scripted by Antony Silvester  - antony.silvester@huawei.com ******
14 # ###########################################################################
15
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 # ###########################################################################
25 #
26 import functest.utils.functest_logger as ft_logger
27 from Sfc_fun import Sfc_fun
28
29
30 class Sfc:
31     """Script to Test the SFC scenarios in ONOS."""
32     logger = ft_logger.Logger("sfc").getLogger()
33     Sfc_obj = Sfc_fun()
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")
42     else:
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")
48     else:
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")
54     else:
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")
63     else:
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")
69     else:
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")
75     else:
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")
81     else:
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")
87     else:
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")
93     else:
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,\
98                  Flow classifer")
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")
103     else:
104         logger.error("\t\t  :  Creation of Port pair is NOT successful")
105
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")
110     else:
111         logger.error("\t\t  :  UnSuccessfully got Port Pair ID")
112
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")
117     else:
118         logger.error("\t\t  :  Port Pair Group NOT successfully Created")
119
120     #########################################################################
121     logger.info("\t3.4 Getting Port Pair Group ID ")
122
123     if (Sfc_obj.getPortGroup() == 200):
124         logger.info("\t\tPort Pair Group ID successfully received")
125     else:
126         logger.error("\t\t  :  Port Pair Group ID NOT successfully received")
127
128     #########################################################################
129     logger.info("\t3.5 Creation of Flow Classifier")
130     if (Sfc_obj.createFlowClassifier() == 201):
131         logger.info("\t\tFlow Classifier successfully Created")
132     else:
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\
137                  added.")
138     #########################################################################
139     logger.info("\t4.1 Creation of PortChain")
140     if (Sfc_obj.createPortChain() == 201):
141         logger.info("\t\tPortChain successfully Created")
142     else:
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 ")
148     else:
149         logger.error("\t\t  :  Flows NOT Installed successfully")
150
151     if (Sfc_obj.portChainDeviceMap() == 200):
152         logger.info("\t\t portChainDeviceMap successfully ")
153     else:
154         logger.error("\t\t:portChainDeviceMap NOT Installed successfully")
155
156     if (Sfc_obj.portChainSfMap() == 200):
157         logger.info("\t\tportChainSfMap successfully ")
158     else:
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")
165     else:
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 ")
171     else:
172         logger.error("\t\t:portChainDeviceMap NOT Installed successfully")
173
174     if (Sfc_obj.portChainSfMap() == 200):
175         logger.info("\t\tportChainSfMap successfully ")
176     else:
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")
183         else:
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 \
189                                 successfully")
190                 else:
191                     logger.error("\t\t  :  Port pair configuration is NOT\
192                                   deleted successfully")
193             else:
194                 logger.error("\t\t  :  Port Group configuration is NOT \
195                              deleted successfully")
196         else:
197                 logger.error("\t\t  :  Flow classifier configuration is NOT \
198                              deleted successfully")
199     else:
200         logger.error("\t\t:PortChain configuration is NOT deleted \
201                      successfully")
202     print ("\n###########################################################n")
203     #######################################################################
204     logger.info("Testcase 8 : Cleanup")
205     if (Sfc_obj.cleanup() == 204):
206         logger.info("\t\tCleanUp is successfull")
207     else:
208         logger.error("\t\t  :  CleanUp is NOT successfull")
209     print ("###############################################################")
210     print("############################END OF SCRIPT ######################")