admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | ''' |
| 3 | Created on 22-Oct-2012 |
Jon Hall | 65844a3 | 2015-03-09 19:09:37 -0700 | [diff] [blame] | 4 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 5 | @author: Anil Kumar (anilkumar.s@paxterrasolutions.com) |
| 6 | |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
Jon Hall | 65844a3 | 2015-03-09 19:09:37 -0700 | [diff] [blame] | 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 20 | |
| 21 | |
| 22 | |
| 23 | teston is the main module. |
| 24 | |
| 25 | ''' |
| 26 | |
| 27 | import sys |
| 28 | import getpass |
| 29 | import os |
| 30 | import re |
| 31 | import __builtin__ |
| 32 | import new |
| 33 | import xmldict |
Jon Hall | 30b82fa | 2015-03-04 17:15:43 -0800 | [diff] [blame] | 34 | import importlib |
Jon Hall | 5b58673 | 2015-06-11 11:39:39 -0700 | [diff] [blame] | 35 | import threading |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 36 | module = new.module("test") |
| 37 | import openspeak |
Hari Krishna | be4b97b | 2015-07-15 12:19:43 -0700 | [diff] [blame] | 38 | import subprocess |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 39 | global path, drivers_path, core_path, tests_path,logs_path |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 40 | location = os.path.abspath( os.path.dirname( __file__ ) ) |
| 41 | path = re.sub( "(core|bin)$", "", location ) |
Jon Hall | 2a5002c | 2015-08-21 16:49:11 -0700 | [diff] [blame] | 42 | drivers_path = path+"drivers" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 43 | core_path = path+"core" |
| 44 | tests_path = path+"tests" |
| 45 | logs_path = path+"logs/" |
| 46 | config_path = path + "config/" |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 47 | sys.path.append( path ) |
| 48 | sys.path.append( drivers_path ) |
| 49 | sys.path.append( core_path ) |
| 50 | sys.path.append( tests_path ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 51 | |
| 52 | from core.utilities import Utilities |
kelvin-onlab | fb52166 | 2015-02-27 09:52:40 -0800 | [diff] [blame] | 53 | from core.Thread import Thread |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 54 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 55 | |
| 56 | class TestON: |
| 57 | ''' |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 58 | TestON will initiate the specified test. |
| 59 | The main tasks are : |
| 60 | * Initiate the required Component handles for the test. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 61 | * Create Log file Handles. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 62 | ''' |
| 63 | def __init__(self,options): |
| 64 | ''' |
| 65 | Initialise the component handles specified in the topology file of the specified test. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 66 | ''' |
| 67 | # Initialization of the variables. |
| 68 | __builtin__.main = self |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 69 | __builtin__.path = path |
| 70 | __builtin__.utilities = Utilities() |
| 71 | self.TRUE = 1 |
| 72 | self.FALSE = 0 |
| 73 | self.ERROR = -1 |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 74 | self.NORESULT = 2 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 75 | self.FAIL = False |
| 76 | self.PASS = True |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 77 | self.CASERESULT = self.ERROR |
| 78 | self.STEPRESULT = self.NORESULT |
| 79 | self.stepResults = [] |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 80 | self.init_result = self.TRUE |
| 81 | self.testResult = "Summary" |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 82 | self.stepName = "" |
| 83 | self.stepCache = "" |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 84 | self.EXPERIMENTAL_MODE = False |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 85 | self.test_target = None |
| 86 | self.lastcommand = None |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 87 | self.testDir = tests_path |
| 88 | self.configFile = config_path + "teston.cfg" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 89 | self.parsingClass = "xmlparser" |
| 90 | self.parserPath = core_path + "/xmlparser" |
| 91 | self.loggerPath = core_path + "/logger" |
| 92 | self.loggerClass = "Logger" |
| 93 | self.logs_path = logs_path |
| 94 | self.driver = '' |
kelvin-onlab | fb52166 | 2015-02-27 09:52:40 -0800 | [diff] [blame] | 95 | self.Thread = Thread |
Jon Hall | 5b58673 | 2015-06-11 11:39:39 -0700 | [diff] [blame] | 96 | self.cleanupFlag = False |
| 97 | self.cleanupLock = threading.Lock() |
Jon Hall | 0fc0d45 | 2015-07-14 09:49:58 -0700 | [diff] [blame] | 98 | self.initiated = False |
Jon Hall | 65844a3 | 2015-03-09 19:09:37 -0700 | [diff] [blame] | 99 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 100 | self.configparser() |
| 101 | verifyOptions(options) |
| 102 | load_logger() |
| 103 | self.componentDictionary = {} |
| 104 | self.componentDictionary = self.topology ['COMPONENT'] |
| 105 | self.driversList=[] |
| 106 | if type(self.componentDictionary) == str : |
| 107 | self.componentDictionary = dict(self.componentDictionary) |
Jon Hall | 65844a3 | 2015-03-09 19:09:37 -0700 | [diff] [blame] | 108 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 109 | for component in self.componentDictionary : |
| 110 | self.driversList.append(self.componentDictionary[component]['type']) |
Jon Hall | 65844a3 | 2015-03-09 19:09:37 -0700 | [diff] [blame] | 111 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 112 | self.driversList = list(set(self.driversList)) # Removing duplicates. |
| 113 | # Checking the test_target option set for the component or not |
| 114 | if type(self.componentDictionary) == dict: |
| 115 | for component in self.componentDictionary.keys(): |
| 116 | if 'test_target' in self.componentDictionary[component].keys(): |
| 117 | self.test_target = component |
Jon Hall | 65844a3 | 2015-03-09 19:09:37 -0700 | [diff] [blame] | 118 | |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 119 | # Checking for the openspeak file and test script |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 120 | self.logger.initlog(self) |
| 121 | |
| 122 | # Creating Drivers Handles |
| 123 | initString = "\n"+"*" * 30+"\n CASE INIT \n"+"*" * 30+"\n" |
| 124 | self.log.exact(initString) |
| 125 | self.driverObject = {} |
| 126 | self.random_order = 111 # Random order id to connect the components |
| 127 | components_connect_order = {} |
| 128 | #component_list.append() |
| 129 | if type(self.componentDictionary) == dict: |
| 130 | for component in self.componentDictionary.keys(): |
| 131 | self.componentDictionary[component]['connect_order'] = self.componentDictionary[component]['connect_order'] if ('connect_order' in self.componentDictionary[component].keys()) else str(self.get_random()) |
| 132 | components_connect_order[component] = eval(self.componentDictionary[component]['connect_order']) |
| 133 | #Ordering components based on the connect order. |
| 134 | ordered_component_list =sorted(components_connect_order, key=lambda key: components_connect_order[key]) |
| 135 | print ordered_component_list |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 136 | for component in ordered_component_list: |
| 137 | self.componentInit(component) |
| 138 | |
| 139 | def configparser(self): |
| 140 | ''' |
| 141 | It will parse the config file (teston.cfg) and return as dictionary |
| 142 | ''' |
| 143 | matchFileName = re.match(r'(.*)\.cfg', self.configFile, re.M | re.I) |
| 144 | if matchFileName: |
| 145 | xml = open(self.configFile).read() |
| 146 | try : |
| 147 | self.configDict = xmldict.xml_to_dict(xml) |
| 148 | return self.configDict |
Jon Hall | 1de6c19 | 2015-09-02 13:50:16 -0700 | [diff] [blame] | 149 | except IOError: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 150 | print "There is no such file to parse " + self.configFile |
Jon Hall | 1de6c19 | 2015-09-02 13:50:16 -0700 | [diff] [blame] | 151 | else: |
| 152 | print "There is no such file to parse " + self.configFile |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 153 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 154 | def componentInit(self,component): |
| 155 | ''' |
| 156 | This method will initialize specified component |
| 157 | ''' |
| 158 | global driver_options |
Jon Hall | 0fc0d45 | 2015-07-14 09:49:58 -0700 | [diff] [blame] | 159 | self.initiated = False |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 160 | self.log.info("Creating component Handle: "+component) |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 161 | driver_options = {} |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 162 | if 'COMPONENTS' in self.componentDictionary[component].keys(): |
| 163 | driver_options =dict(self.componentDictionary[component]['COMPONENTS']) |
| 164 | |
| 165 | driver_options['name']=component |
| 166 | driverName = self.componentDictionary[component]['type'] |
| 167 | driver_options ['type'] = driverName |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 168 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 169 | classPath = self.getDriverPath(driverName.lower()) |
Jon Hall | 30b82fa | 2015-03-04 17:15:43 -0800 | [diff] [blame] | 170 | driverModule = importlib.import_module(classPath) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 171 | driverClass = getattr(driverModule, driverName) |
| 172 | driverObject = driverClass() |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 173 | |
Hari Krishna | be4b97b | 2015-07-15 12:19:43 -0700 | [diff] [blame] | 174 | if ( "OCN" in self.componentDictionary[component]['host'] and main.onoscell ): |
| 175 | self.componentDictionary[component]['host'] = main.mnIP |
| 176 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 177 | connect_result = driverObject.connect(user_name = self.componentDictionary[component]['user'] if ('user' in self.componentDictionary[component].keys()) else getpass.getuser(), |
| 178 | ip_address= self.componentDictionary[component]['host'] if ('host' in self.componentDictionary[component].keys()) else 'localhost', |
| 179 | pwd = self.componentDictionary[component]['password'] if ('password' in self.componentDictionary[component].keys()) else 'changeme', |
| 180 | port = self.componentDictionary[component]['port'] if ('port' in self.componentDictionary[component].keys()) else None, |
| 181 | options = driver_options) |
cameron@onlab.us | 5cc6a37 | 2015-05-11 17:18:07 -0700 | [diff] [blame] | 182 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 183 | if not connect_result: |
Jon Hall | 166e4a4 | 2015-08-10 12:03:41 -0700 | [diff] [blame] | 184 | self.log.error("Exiting from the test execution because the connecting to the "+component+" component failed.") |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 185 | self.exit() |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 186 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 187 | vars(self)[component] = driverObject |
Jon Hall | 0fc0d45 | 2015-07-14 09:49:58 -0700 | [diff] [blame] | 188 | self.initiated = True |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 189 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 190 | def run(self): |
| 191 | ''' |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 192 | The Execution of the test script's cases listed in the Test params file will be done here. |
| 193 | And Update each test case result. |
| 194 | This method will return TRUE if it executed all the test cases successfully, |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 195 | else will retun FALSE |
| 196 | ''' |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 197 | self.testCaseResult = {} |
Jon Hall | a118598 | 2014-09-15 14:55:10 -0700 | [diff] [blame] | 198 | self.TOTAL_TC = 0 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 199 | self.TOTAL_TC_RUN = 0 |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 200 | self.TOTAL_TC_PLANNED = 0 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 201 | self.TOTAL_TC_NORESULT = 0 |
| 202 | self.TOTAL_TC_FAIL = 0 |
| 203 | self.TOTAL_TC_PASS = 0 |
Jon Hall | a118598 | 2014-09-15 14:55:10 -0700 | [diff] [blame] | 204 | self.TEST_ITERATION = 0 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 205 | self.stepCount = 0 |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 206 | self.CASERESULT = self.NORESULT |
| 207 | |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 208 | import testparser |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 209 | testFile = self.tests_path + "/"+self.TEST + "/"+self.TEST + ".py" |
| 210 | test = testparser.TestParser(testFile) |
| 211 | self.testscript = test.testscript |
| 212 | self.code = test.getStepCode() |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 213 | repeat= int(self.params['repeat']) if ('repeat' in self.params) else 1 |
| 214 | self.TOTAL_TC_PLANNED = len(self.testcases_list)*repeat |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 215 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 216 | result = self.TRUE |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 217 | while(repeat): |
Jon Hall | a118598 | 2014-09-15 14:55:10 -0700 | [diff] [blame] | 218 | for self.CurrentTestCaseNumber in self.testcases_list: |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 219 | result = self.runCase(self.CurrentTestCaseNumber) |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 220 | repeat-=1 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 221 | return result |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 222 | |
Jon Hall | e234cc4 | 2015-08-31 15:26:47 -0700 | [diff] [blame] | 223 | def runCase( self, testCaseNumber ): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 224 | self.CurrentTestCaseNumber = testCaseNumber |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 225 | self.CurrentTestCase = "" |
| 226 | self.stepResults = [] |
| 227 | self.stepName = "" |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 228 | self.caseExplanation = "" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 229 | result = self.TRUE |
| 230 | self.stepCount = 0 |
| 231 | self.EXPERIMENTAL_MODE = self.FALSE |
| 232 | self.addCaseHeader() |
Jon Hall | e234cc4 | 2015-08-31 15:26:47 -0700 | [diff] [blame] | 233 | self.testCaseNumber = str( testCaseNumber ) |
| 234 | self.CASERESULT = self.NORESULT |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 235 | stopped = False |
| 236 | try : |
| 237 | self.stepList = self.code[self.testCaseNumber].keys() |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 238 | except KeyError: |
Jon Hall | e234cc4 | 2015-08-31 15:26:47 -0700 | [diff] [blame] | 239 | self.log.error( "There is no Test-Case " + self.testCaseNumber ) |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 240 | return self.FALSE |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 241 | self.stepCount = 0 |
| 242 | while self.stepCount < len(self.code[self.testCaseNumber].keys()): |
| 243 | result = self.runStep(self.stepList,self.code,self.testCaseNumber) |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 244 | if result == self.FALSE: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 245 | break |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 246 | elif result == self.TRUE: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 247 | continue |
Jon Hall | e234cc4 | 2015-08-31 15:26:47 -0700 | [diff] [blame] | 248 | if not stopped: |
| 249 | if self.CASERESULT == self.TRUE or self.CASERESULT == self.FALSE: |
| 250 | # Result was already explitily set somewhere else like skipCase() |
| 251 | pass |
| 252 | elif all( self.TRUE == i for i in self.stepResults ): |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 253 | # ALL PASSED |
| 254 | self.CASERESULT = self.TRUE |
| 255 | elif self.FALSE in self.stepResults: |
| 256 | # AT LEAST ONE FAILED |
| 257 | self.CASERESULT = self.FALSE |
| 258 | elif self.TRUE in self.stepResults: |
| 259 | # AT LEAST ONE PASSED |
| 260 | self.CASERESULT = self.TRUE |
| 261 | else: |
| 262 | self.CASERESULT = self.NORESULT |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 263 | self.testCaseResult[str(self.CurrentTestCaseNumber)] = self.CASERESULT |
| 264 | self.logger.updateCaseResults(self) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 265 | self.log.wiki( "<p>" + self.caseExplanation + "</p>" ) |
| 266 | self.log.summary( self.caseExplanation ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 267 | self.log.wiki( "<ul>" ) |
| 268 | for line in self.stepCache.splitlines(): |
| 269 | if re.search( " - PASS$", line ): |
| 270 | self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"tick\" /></li>\n" ) |
| 271 | elif re.search( " - FAIL$", line ): |
| 272 | self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"cross\" /></li>\n" ) |
| 273 | elif re.search( " - No Result$", line ): |
| 274 | self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"warning\" /></li>\n" ) |
Jon Hall | 9062761 | 2015-06-09 14:57:02 -0700 | [diff] [blame] | 275 | else: # Should only be on fail message |
| 276 | self.log.wiki( "<ul><li>" + line + "</li></ul>\n" ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 277 | self.log.wiki( "</ul>" ) |
| 278 | self.log.summary( self.stepCache ) |
| 279 | self.stepCache = "" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 280 | return result |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 281 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 282 | def runStep(self,stepList,code,testCaseNumber): |
| 283 | if not cli.pause: |
| 284 | try : |
| 285 | step = stepList[self.stepCount] |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 286 | self.STEPRESULT = self.NORESULT |
Jon Hall | e234cc4 | 2015-08-31 15:26:47 -0700 | [diff] [blame] | 287 | self.onFailMsg = "No on fail message given" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 288 | exec code[testCaseNumber][step] in module.__dict__ |
| 289 | self.stepCount = self.stepCount + 1 |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 290 | if step > 0: |
| 291 | self.stepCache += "\t"+str(testCaseNumber)+"."+str(step)+" "+self.stepName+" - " |
| 292 | if self.STEPRESULT == self.TRUE: |
| 293 | self.stepCache += "PASS\n" |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 294 | elif self.STEPRESULT == self.FALSE: |
| 295 | self.stepCache += "FAIL\n" |
Jon Hall | 8ce34e8 | 2015-06-05 10:41:45 -0700 | [diff] [blame] | 296 | # TODO: Print the on-fail statement here |
Jon Hall | 9062761 | 2015-06-09 14:57:02 -0700 | [diff] [blame] | 297 | self.stepCache += "\t\t" + self.onFailMsg + "\n" |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 298 | else: |
| 299 | self.stepCache += "No Result\n" |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 300 | self.stepResults.append(self.STEPRESULT) |
Jon Hall | e234cc4 | 2015-08-31 15:26:47 -0700 | [diff] [blame] | 301 | except StopIteration: # Raised in self.skipCase() |
| 302 | self.log.warn( "Skipping the rest of CASE" + |
| 303 | str( testCaseNumber ) ) |
| 304 | self.stepResults.append(self.STEPRESULT) |
| 305 | self.stepCache += "\t\t" + self.onFailMsg + "\n" |
| 306 | self.stepCount = self.stepCount + 1 |
| 307 | return self.FALSE |
Jon Hall | 5b58673 | 2015-06-11 11:39:39 -0700 | [diff] [blame] | 308 | except StandardError: |
Jon Hall | 40d2cbd | 2015-06-03 16:24:29 -0700 | [diff] [blame] | 309 | self.log.exception( "\nException in the following section of" + |
Jon Hall | e234cc4 | 2015-08-31 15:26:47 -0700 | [diff] [blame] | 310 | " code: " + str( testCaseNumber ) + "." + |
| 311 | str( step ) + ": " + self.stepName ) |
Jon Hall | 6360493 | 2015-02-26 17:09:50 -0800 | [diff] [blame] | 312 | #print code[testCaseNumber][step] |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 313 | self.stepCount = self.stepCount + 1 |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 314 | self.logger.updateCaseResults(self) |
| 315 | #WIKI results |
| 316 | self.log.wiki( "<ul>" ) |
| 317 | for line in self.stepCache.splitlines(): |
| 318 | if re.search( " - PASS$", line ): |
| 319 | self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"tick\" /></li>\n" ) |
| 320 | elif re.search( " - FAIL$", line ): |
| 321 | self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"cross\" /></li>\n" ) |
| 322 | elif re.search( " - No Result$", line ): |
| 323 | self.log.wiki( "<li>" + line + " <ac:emoticon ac:name=\"warning\" /></li>\n" ) |
Jon Hall | 9062761 | 2015-06-09 14:57:02 -0700 | [diff] [blame] | 324 | else: # Should only be on fail message |
| 325 | self.log.wiki( "<ul><li>" + line + "</li></ul>\n" ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 326 | self.log.wiki( "</ul>" ) |
| 327 | #summary results |
| 328 | self.log.summary( self.stepCache ) |
| 329 | self.stepCache = "" |
shahshreya | 957feaa | 2015-03-23 16:08:29 -0700 | [diff] [blame] | 330 | self.cleanup() |
Jon Hall | 00539b1 | 2015-04-03 13:55:46 -0700 | [diff] [blame] | 331 | self.exit() |
Jon Hall | e234cc4 | 2015-08-31 15:26:47 -0700 | [diff] [blame] | 332 | return self.TRUE |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 333 | if cli.stop: |
| 334 | cli.stop = False |
| 335 | stopped = True |
| 336 | self.TOTAL_TC_NORESULT = self.TOTAL_TC_NORESULT + 1 |
| 337 | self.testCaseResult[str(self.CurrentTestCaseNumber)] = "Stopped" |
| 338 | self.logger.updateCaseResults(self) |
| 339 | result = self.cleanup() |
Jon Hall | e234cc4 | 2015-08-31 15:26:47 -0700 | [diff] [blame] | 340 | return self.FALSE |
| 341 | |
| 342 | def skipCase( self, result="DEFAULT", msg=None ): |
| 343 | """ |
| 344 | Will skip the rest of the code in a test case. The case results will be |
| 345 | determined as normal based on completed assertions unless the result |
| 346 | argument is given. |
| 347 | |
| 348 | Optional Arguments: |
| 349 | result: Case insensite string. Can be 'PASS' or 'FAIL' and will set |
| 350 | the case result accordingly. |
| 351 | msg: Message to be printed when the case is skipped in the reports. |
| 352 | """ |
| 353 | result = result.upper().strip() |
| 354 | if result == "PASS": |
| 355 | self.CASERESULT = self.TRUE |
| 356 | elif result == "FAIL": |
| 357 | self.CASERESULT = self.FALSE |
| 358 | self.onFailMsg = "Skipping the rest of this case. " |
| 359 | if msg: |
| 360 | self.onFailMsg += str( msg ) |
| 361 | raise StopIteration |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 362 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 363 | def addCaseHeader(self): |
| 364 | caseHeader = "\n"+"*" * 30+"\n Result summary for Testcase"+str(self.CurrentTestCaseNumber)+"\n"+"*" * 30+"\n" |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 365 | self.log.exact(caseHeader) |
| 366 | caseHeader = "\n"+"*" * 40 +"\nStart of Test Case"+str(self.CurrentTestCaseNumber)+" : " |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 367 | for driver in self.componentDictionary.keys(): |
| 368 | vars(self)[driver+'log'].info(caseHeader) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 369 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 370 | def addCaseFooter(self): |
| 371 | if self.stepCount-1 > 0 : |
| 372 | previousStep = " "+str(self.CurrentTestCaseNumber)+"."+str(self.stepCount-1)+": "+ str(self.stepName) + "" |
| 373 | stepHeader = "\n"+"*" * 40+"\nEnd of Step "+previousStep+"\n"+"*" * 40+"\n" |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 374 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 375 | caseFooter = "\n"+"*" * 40+"\nEnd of Test case "+str(self.CurrentTestCaseNumber)+"\n"+"*" * 40+"\n" |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 376 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 377 | for driver in self.driversList: |
| 378 | vars(self)[driver].write(stepHeader+"\n"+caseFooter) |
| 379 | |
| 380 | def cleanup(self): |
| 381 | ''' |
Jon Hall | 5b58673 | 2015-06-11 11:39:39 -0700 | [diff] [blame] | 382 | Print a summary of the current test's results then attempt to release |
| 383 | all the component handles and the close opened file handles. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 384 | |
Jon Hall | 5b58673 | 2015-06-11 11:39:39 -0700 | [diff] [blame] | 385 | This function shouldbe threadsafe such that cleanup will only be |
| 386 | executed once per test. |
| 387 | |
| 388 | This will return TRUE if all the component handles and log handles |
| 389 | closed properly, else return FALSE. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 390 | ''' |
| 391 | result = self.TRUE |
Jon Hall | 5b58673 | 2015-06-11 11:39:39 -0700 | [diff] [blame] | 392 | lock = self.cleanupLock |
| 393 | if lock.acquire( False ): |
| 394 | try: |
| 395 | if self.cleanupFlag is False: # First thread to run this |
| 396 | self.cleanupFlag = True |
Jon Hall | 0fc0d45 | 2015-07-14 09:49:58 -0700 | [diff] [blame] | 397 | if self.initiated: |
| 398 | self.logger.testSummary(self) |
Jon Hall | 5b58673 | 2015-06-11 11:39:39 -0700 | [diff] [blame] | 399 | for component in self.componentDictionary.keys(): |
| 400 | try : |
| 401 | tempObject = vars(self)[component] |
| 402 | print "Disconnecting from " + str(tempObject.name) + ": " + \ |
| 403 | str(tempObject) |
| 404 | tempObject.disconnect() |
Jon Hall | 1de6c19 | 2015-09-02 13:50:16 -0700 | [diff] [blame] | 405 | except KeyboardInterrupt: |
| 406 | pass |
| 407 | except KeyError: |
| 408 | # Component not created yet |
| 409 | self.log.warn( "Could not find the component " + |
| 410 | str( component ) ) |
| 411 | except StandardError: |
Jon Hall | 5b58673 | 2015-06-11 11:39:39 -0700 | [diff] [blame] | 412 | self.log.exception( "Exception while disconnecting from " + |
| 413 | str( component ) ) |
| 414 | result = self.FALSE |
| 415 | # Closing all the driver's session files |
| 416 | for driver in self.componentDictionary.keys(): |
| 417 | try: |
| 418 | vars(self)[driver].close_log_handles() |
Jon Hall | 1de6c19 | 2015-09-02 13:50:16 -0700 | [diff] [blame] | 419 | except KeyboardInterrupt: |
| 420 | pass |
| 421 | except KeyError: |
| 422 | # Component not created yet |
| 423 | self.log.warn( "Could not find the component " + |
| 424 | str( driver ) + " while trying to" + |
| 425 | " close log file" ) |
| 426 | except StandardError: |
Jon Hall | 5b58673 | 2015-06-11 11:39:39 -0700 | [diff] [blame] | 427 | self.log.exception( "Exception while closing log files for " + |
| 428 | str( driver ) ) |
| 429 | result = self.FALSE |
| 430 | else: |
| 431 | pass # Someone else already ran through this function |
| 432 | finally: |
| 433 | lock.release() |
| 434 | else: # Someone already has a lock |
| 435 | # NOTE: This could cause problems if we don't release the lock |
| 436 | # correctly |
| 437 | lock.acquire() # Wait for the other thread to finish |
| 438 | # NOTE: If we don't wait, exit could be called while the thread |
| 439 | # with the lock is still cleaning up |
| 440 | lock.release() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 441 | return result |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 442 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 443 | def pause(self): |
| 444 | ''' |
| 445 | This function will pause the test's execution, and will continue after user provide 'resume' command. |
| 446 | ''' |
| 447 | __builtin__.testthread.pause() |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 448 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 449 | def onfail(self,*components): |
| 450 | ''' |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 451 | When test step failed, calling all the components onfail. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 452 | ''' |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 453 | if not components: |
| 454 | try : |
| 455 | for component in self.componentDictionary.keys(): |
| 456 | tempObject = vars(self)[component] |
| 457 | result = tempObject.onfail() |
Jon Hall | 1de6c19 | 2015-09-02 13:50:16 -0700 | [diff] [blame] | 458 | except StandardError as e: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 459 | print str(e) |
| 460 | result = self.FALSE |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 461 | else: |
| 462 | try : |
| 463 | for component in components: |
| 464 | tempObject = vars(self)[component] |
| 465 | result = tempObject.onfail() |
Jon Hall | 1de6c19 | 2015-09-02 13:50:16 -0700 | [diff] [blame] | 466 | except StandardError as e: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 467 | print str(e) |
| 468 | result = self.FALSE |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 469 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 470 | def getDriverPath(self,driverName): |
| 471 | ''' |
| 472 | Based on the component 'type' specified in the params , this method will find the absolute path , |
| 473 | by recursively searching the name of the component. |
| 474 | ''' |
| 475 | import commands |
| 476 | |
| 477 | cmd = "find "+drivers_path+" -name "+driverName+".py" |
| 478 | result = commands.getoutput(cmd) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 479 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 480 | result_array = str(result).split('\n') |
| 481 | result_count = 0 |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 482 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 483 | for drivers_list in result_array: |
| 484 | result_count = result_count+1 |
| 485 | if result_count > 1 : |
| 486 | print "found "+driverName+" "+ str(result_count) + " times"+str(result_array) |
| 487 | self.exit() |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 488 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 489 | result = re.sub("(.*)drivers","",result) |
Jon Hall | 166e4a4 | 2015-08-10 12:03:41 -0700 | [diff] [blame] | 490 | result = re.sub("\/\/","/",result) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 491 | result = re.sub("\.py","",result) |
| 492 | result = re.sub("\.pyc","",result) |
| 493 | result = re.sub("\/",".",result) |
| 494 | result = "drivers"+result |
| 495 | return result |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 496 | |
| 497 | def step(self,stepDesc): |
| 498 | ''' |
| 499 | The step information of the test-case will append to the logs. |
| 500 | ''' |
| 501 | previousStep = " "+str(self.CurrentTestCaseNumber)+"."+str(self.stepCount-1)+": "+ str(self.stepName) + "" |
| 502 | self.stepName = stepDesc |
| 503 | |
| 504 | stepName = " "+str(self.CurrentTestCaseNumber)+"."+str(self.stepCount)+": "+ str(stepDesc) + "" |
| 505 | try : |
| 506 | if self.stepCount == 0: |
| 507 | stepName = " INIT : Initializing the test case :"+self.CurrentTestCase |
| 508 | except AttributeError: |
| 509 | stepName = " INIT : Initializing the test case :"+str(self.CurrentTestCaseNumber) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 510 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 511 | self.log.step(stepName) |
| 512 | stepHeader = "" |
| 513 | if self.stepCount > 1 : |
| 514 | stepHeader = "\n"+"-"*45+"\nEnd of Step "+previousStep+"\n"+"-"*45+"\n" |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 515 | |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 516 | stepHeader += "\n"+"-"*45+"\nStart of Step"+stepName+"\n"+"-"*45+"\n" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 517 | for driver in self.componentDictionary.keys(): |
| 518 | vars(self)[driver+'log'].info(stepHeader) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 519 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 520 | def case(self,testCaseName): |
| 521 | ''' |
| 522 | Test's each test-case information will append to the logs. |
| 523 | ''' |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 524 | self.CurrentTestCase = testCaseName |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 525 | testCaseName = " " + str(testCaseName) + "" |
| 526 | self.log.case(testCaseName) |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 527 | caseHeader = testCaseName+"\n"+"*" * 40+"\n" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 528 | for driver in self.componentDictionary.keys(): |
| 529 | vars(self)[driver+'log'].info(caseHeader) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 530 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 531 | def testDesc(self,description): |
| 532 | ''' |
| 533 | Test description will append to the logs. |
| 534 | ''' |
| 535 | description = "Test Description : " + str (description) + "" |
| 536 | self.log.info(description) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 537 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 538 | def _getTest(self): |
| 539 | ''' |
| 540 | This method will parse the test script to find required test information. |
| 541 | ''' |
| 542 | testFile = self.tests_path + "/"+self.TEST + "/"+self.TEST + ".py" |
| 543 | testFileHandler = open(testFile, 'r') |
| 544 | testFileList = testFileHandler.readlines() |
| 545 | testFileHandler.close() |
| 546 | #self.TOTAL_TC_PLANNED = 0 |
| 547 | counter = 0 |
| 548 | for index in range(len(testFileList)): |
| 549 | lineMatch = re.match('\s+def CASE(\d+)(.*):',testFileList[index],0) |
| 550 | if lineMatch: |
| 551 | counter = counter + 1 |
Jon Hall | a118598 | 2014-09-15 14:55:10 -0700 | [diff] [blame] | 552 | self.TC_PLANNED = len(self.testcases_list) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 553 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 554 | def response_parser(self,response, return_format): |
| 555 | ''' It will load the default response parser ''' |
| 556 | response_dict = {} |
| 557 | response_dict = self.response_to_dict(response, return_format) |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 558 | return_format_string = self.dict_to_return_format(response,return_format,response_dict) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 559 | return return_format_string |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 560 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 561 | def response_to_dict(self,response,return_format): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 562 | response_dict = {} |
| 563 | json_match = re.search('^\s*{', response) |
| 564 | xml_match = re.search('^\s*\<', response) |
| 565 | ini_match = re.search('^\s*\[', response) |
| 566 | if json_match : |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 567 | self.log.info(" Response is in 'JSON' format and Converting to '"+return_format+"' format") |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 568 | # Formatting the json string |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 569 | response = re.sub(r"{\s*'?(\w)", r'{"\1', response) |
| 570 | response = re.sub(r",\s*'?(\w)", r',"\1', response) |
| 571 | response = re.sub(r"(\w)'?\s*:", r'\1":', response) |
| 572 | response = re.sub(r":\s*'(\w)'\s*([,}])", r':"\1"\2', response) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 573 | try : |
| 574 | import json |
| 575 | response_dict = json.loads(response) |
Jon Hall | 1de6c19 | 2015-09-02 13:50:16 -0700 | [diff] [blame] | 576 | except StandardError: |
Jon Hall | 2a5002c | 2015-08-21 16:49:11 -0700 | [diff] [blame] | 577 | self.log.exception( "Json Parser is unable to parse the string" ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 578 | return response_dict |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 579 | elif ini_match : |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 580 | self.log.info(" Response is in 'INI' format and Converting to '"+return_format+"' format") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 581 | from configobj import ConfigObj |
| 582 | response_file = open("respnse_file.temp",'w') |
| 583 | response_file.write(response) |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 584 | response_file.close() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 585 | response_dict = ConfigObj("respnse_file.temp") |
| 586 | return response_dict |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 587 | elif xml_match : |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 588 | self.log.info(" Response is in 'XML' format and Converting to '"+return_format+"' format") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 589 | try : |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 590 | response_dict = xmldict.xml_to_dict("<response> "+str(response)+" </response>") |
Jon Hall | 1de6c19 | 2015-09-02 13:50:16 -0700 | [diff] [blame] | 591 | except StandardError: |
| 592 | self.log.exception() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 593 | return response_dict |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 594 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 595 | def dict_to_return_format(self,response,return_format,response_dict): |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 596 | if return_format =='table' : |
| 597 | ''' Will return in table format''' |
| 598 | to_do = "Call the table output formatter" |
| 599 | global response_table |
| 600 | response_table = '\n' |
| 601 | response_table = response_table +'\t'.join(response_dict)+"\n" |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 602 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 603 | def get_table(value_to_convert): |
| 604 | ''' This will parse the dictionary recusrsively and print as table format''' |
| 605 | table_data = "" |
| 606 | if type(value_to_convert) == dict : |
| 607 | table_data = table_data +'\t'.join(value_to_convert)+"\n" |
| 608 | for temp_val in value_to_convert.values() : |
| 609 | table_data = table_data + get_table(temp_val) |
| 610 | else : |
| 611 | table_data = table_data + str(value_to_convert) +"\t" |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 612 | return table_data |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 613 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 614 | for value in response_dict.values() : |
| 615 | response_table = response_table + get_table(value) |
Jon Hall | 88e498c | 2015-03-06 09:54:35 -0800 | [diff] [blame] | 616 | # response_table = response_table + '\t'.join(response_dict.values()) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 617 | return response_table |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 618 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 619 | elif return_format =='config': |
| 620 | ''' Will return in config format''' |
| 621 | to_do = 'Call dict to config coverter' |
| 622 | response_string = str(response_dict) |
| 623 | print response_string |
| 624 | response_config = re.sub(",", "\n\t", response_string) |
| 625 | response_config = re.sub("u\'", "\'", response_config) |
| 626 | response_config = re.sub("{", "", response_config) |
| 627 | response_config = re.sub("}", "\n", response_config) |
| 628 | response_config = re.sub(":", " =", response_config) |
| 629 | return "[response]\n\t "+response_config |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 630 | elif return_format == 'xml': |
| 631 | ''' Will return in xml format''' |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 632 | response_xml = xmldict.dict_to_xml(response_dict) |
| 633 | response_xml = re.sub(">\s*<", ">\n<", response_xml) |
| 634 | return "\n"+response_xml |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 635 | elif return_format == 'json': |
| 636 | ''' Will return in json format''' |
| 637 | to_do = 'Call dict to xml coverter' |
| 638 | import json |
| 639 | response_json = json.dumps(response_dict) |
| 640 | return response_json |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 641 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 642 | def get_random(self): |
| 643 | self.random_order = self.random_order + 1 |
| 644 | return self.random_order |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 645 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 646 | def exit(self): |
| 647 | __builtin__.testthread = None |
Jon Hall | 5b58673 | 2015-06-11 11:39:39 -0700 | [diff] [blame] | 648 | for thread in threading.enumerate(): |
| 649 | if thread.isAlive(): |
| 650 | try: |
| 651 | thread._Thread__stop() |
| 652 | except: |
Jon Hall | 1de6c19 | 2015-09-02 13:50:16 -0700 | [diff] [blame] | 653 | # NOTE: We should catch any exceptions while trying to |
| 654 | # close the thread so that we can try to close the other |
| 655 | # threads as well |
| 656 | print( str( thread.getName() ) + ' could not be terminated' ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 657 | sys.exit() |
| 658 | |
| 659 | def verifyOptions(options): |
| 660 | ''' |
| 661 | This will verify the command line options and set to default values, if any option not given in command line. |
| 662 | ''' |
| 663 | import pprint |
| 664 | pp = pprint.PrettyPrinter(indent=4) |
| 665 | |
Jon Hall | 88e498c | 2015-03-06 09:54:35 -0800 | [diff] [blame] | 666 | # pp.pprint(options) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 667 | verifyTest(options) |
| 668 | verifyExample(options) |
| 669 | verifyTestScript(options) |
| 670 | verifyParams() |
| 671 | verifyLogdir(options) |
| 672 | verifyMail(options) |
| 673 | verifyTestCases(options) |
Hari Krishna | 03f530e | 2015-07-10 17:28:27 -0700 | [diff] [blame] | 674 | verifyOnosCell(options) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 675 | |
| 676 | def verifyTest(options): |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 677 | try: |
| 678 | if options.testname: |
| 679 | main.TEST = options.testname |
| 680 | main.classPath = "tests."+main.TEST+"."+main.TEST |
| 681 | main.tests_path = tests_path |
| 682 | elif options.example: |
| 683 | main.TEST = options.example |
| 684 | main.tests_path = path+"/examples/" |
| 685 | main.classPath = "examples."+main.TEST+"."+main.TEST |
| 686 | except AttributeError: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 687 | print "Test or Example not specified please specify the --test <test name > or --example <example name>" |
Jon Hall | 5b58673 | 2015-06-11 11:39:39 -0700 | [diff] [blame] | 688 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 689 | |
| 690 | def verifyExample(options): |
| 691 | if options.example: |
| 692 | main.testDir = path+'/examples/' |
| 693 | main.tests_path = path+"/examples/" |
| 694 | main.classPath = "examples."+main.TEST+"."+main.TEST |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 695 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 696 | def verifyLogdir(options): |
Jon Hall | 88e498c | 2015-03-06 09:54:35 -0800 | [diff] [blame] | 697 | # Verifying Log directory option |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 698 | if options.logdir: |
| 699 | main.logdir = options.logdir |
| 700 | else : |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 701 | main.logdir = main.FALSE |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 702 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 703 | def verifyMail(options): |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 704 | # Checking the mailing list |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 705 | if options.mail: |
| 706 | main.mail = options.mail |
| 707 | elif main.params.has_key('mail'): |
| 708 | main.mail = main.params['mail'] |
| 709 | else : |
| 710 | main.mail = 'paxweb@paxterrasolutions.com' |
| 711 | |
| 712 | def verifyTestCases(options): |
Jon Hall | 88e498c | 2015-03-06 09:54:35 -0800 | [diff] [blame] | 713 | # Getting Test cases list |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 714 | if options.testcases: |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 715 | testcases_list = options.testcases |
Jon Hall | 88e498c | 2015-03-06 09:54:35 -0800 | [diff] [blame] | 716 | # sys.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 717 | testcases_list = re.sub("(\[|\])", "", options.testcases) |
| 718 | main.testcases_list = eval(testcases_list+",") |
| 719 | else : |
| 720 | if 'testcases' in main.params.keys(): |
Jon Hall | a118598 | 2014-09-15 14:55:10 -0700 | [diff] [blame] | 721 | temp = eval(main.params['testcases']+",") |
| 722 | list1=[] |
| 723 | if type(temp[0])==list: |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 724 | for test in temp: |
| 725 | for testcase in test: |
| 726 | if type(testcase)==int: |
| 727 | testcase=[testcase] |
| 728 | list1.extend(testcase) |
| 729 | else : |
| 730 | temp=list(temp) |
| 731 | for testcase in temp: |
| 732 | if type(testcase)==int: |
| 733 | testcase=[testcase] |
| 734 | list1.extend(testcase) |
| 735 | main.testcases_list=list1 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 736 | else : |
| 737 | print "testcases not specifed in params, please provide in params file or 'testcases' commandline argument" |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 738 | sys.exit() |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 739 | |
Hari Krishna | 03f530e | 2015-07-10 17:28:27 -0700 | [diff] [blame] | 740 | def verifyOnosCell(options): |
Hari Krishna | be4b97b | 2015-07-15 12:19:43 -0700 | [diff] [blame] | 741 | # Verifying onoscell option |
Hari Krishna | 03f530e | 2015-07-10 17:28:27 -0700 | [diff] [blame] | 742 | if options.onoscell: |
| 743 | main.onoscell = options.onoscell |
Hari Krishna | be4b97b | 2015-07-15 12:19:43 -0700 | [diff] [blame] | 744 | main.onosIPs = [] |
| 745 | main.mnIP = "" |
| 746 | cellCMD = ". ~/.profile; cell "+main.onoscell |
| 747 | output=subprocess.check_output( ["bash", '-c', cellCMD] ) |
| 748 | splitOutput = output.splitlines() |
| 749 | for i in range( len(splitOutput) ): |
| 750 | if( re.match( "OCN", splitOutput[i] ) ): |
| 751 | mnNode=splitOutput[i].split("=") |
| 752 | main.mnIP = mnNode[1] |
| 753 | # cell already sorts OC variables in bash, so no need to sort in TestON |
| 754 | if( re.match( "OC[1-9]", splitOutput[i] ) ): |
| 755 | onosNodes = splitOutput[i].split("=") |
| 756 | main.onosIPs.append( onosNodes[1] ) |
Hari Krishna | 03f530e | 2015-07-10 17:28:27 -0700 | [diff] [blame] | 757 | else : |
| 758 | main.onoscell = main.FALSE |
| 759 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 760 | def verifyTestScript(options): |
| 761 | ''' |
| 762 | Verifyies test script. |
| 763 | ''' |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 764 | main.openspeak = openspeak.OpenSpeak() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 765 | openspeakfile = main.testDir+"/" + main.TEST + "/" + main.TEST + ".ospk" |
| 766 | testfile = main.testDir+"/" + main.TEST + "/" + main.TEST + ".py" |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 767 | if os.path.exists(openspeakfile): |
| 768 | # Openspeak file found, compiling to python |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 769 | main.openspeak.compiler(openspeakfile=openspeakfile,writetofile=1) |
| 770 | elif os.path.exists(testfile): |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 771 | # No openspeak found, using python file instead |
| 772 | pass |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 773 | else: |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 774 | print "\nThere is no \""+main.TEST+"\" test script.\nPlease provide a " +\ |
| 775 | "Python or OpenSpeak test script in the tests folder: " +\ |
| 776 | main.testDir+"/" + main.TEST + "/" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 777 | __builtin__.testthread = None |
| 778 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 779 | try : |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 780 | testModule = __import__(main.classPath, globals(), locals(), [main.TEST], -1) |
Jon Hall | 1de6c19 | 2015-09-02 13:50:16 -0700 | [diff] [blame] | 781 | except ImportError: |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 782 | print "There was an import error, it might mean that there is no test named "+main.TEST |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 783 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 784 | |
| 785 | testClass = getattr(testModule, main.TEST) |
| 786 | main.testObject = testClass() |
| 787 | load_parser() |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 788 | main.params = main.parser.parseParams(main.classPath) |
| 789 | main.topology = main.parser.parseTopology(main.classPath) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 790 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 791 | def verifyParams(): |
| 792 | try : |
| 793 | main.params = main.params['PARAMS'] |
Jon Hall | 1de6c19 | 2015-09-02 13:50:16 -0700 | [diff] [blame] | 794 | except KeyError: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 795 | print "Error with the params file: Either the file not specified or the format is not correct" |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 796 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 797 | try : |
| 798 | main.topology = main.topology['TOPOLOGY'] |
Jon Hall | 1de6c19 | 2015-09-02 13:50:16 -0700 | [diff] [blame] | 799 | except KeyError: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 800 | print "Error with the Topology file: Either the file not specified or the format is not correct" |
| 801 | main.exit() |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 802 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 803 | def load_parser() : |
| 804 | ''' |
| 805 | It facilitates the loading customised parser for topology and params file. |
| 806 | It loads parser mentioned in tab named parser of teston.cfg file. |
| 807 | It also loads default xmlparser if no parser have specified in teston.cfg file. |
| 808 | |
| 809 | ''' |
| 810 | confighash = main.configDict |
| 811 | if 'file' in confighash['config']['parser'] and 'class' in confighash['config']['parser']: |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 812 | path = confighash['config']['parser']['file'] |
| 813 | if path != None or confighash['config']['parser']['class']!= None: |
| 814 | try: |
| 815 | module = re.sub( r".py\s*$", "", path ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 816 | moduleList = module.split("/") |
| 817 | newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]]) |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 818 | parsingClass = confighash['config']['parser']['class'] |
| 819 | parsingModule = __import__(newModule, globals(), locals(), [parsingClass], -1) |
| 820 | parsingClass = getattr(parsingModule, parsingClass) |
| 821 | main.parser = parsingClass() |
| 822 | #hashobj = main.parser.parseParams(main.classPath) |
| 823 | if hasattr(main.parser,"parseParams") and hasattr(main.parser,"parseTopology") and hasattr(main.parser,"parse"): |
| 824 | pass |
| 825 | else: |
| 826 | print "Invalid parser format" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 827 | main.exit() |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 828 | except ImportError: |
| 829 | print "Could not find the file " + path + " using default parser." |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 830 | load_defaultParser() |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 831 | elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None: |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 832 | load_defaultParser() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 833 | else: |
| 834 | load_defaultParser() |
| 835 | |
| 836 | def load_defaultParser(): |
| 837 | ''' |
| 838 | It will load the default parser which is xml parser to parse the params and topology file. |
| 839 | ''' |
| 840 | moduleList = main.parserPath.split("/") |
| 841 | newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]]) |
| 842 | try : |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 843 | parsingClass = main.parsingClass |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 844 | parsingModule = __import__(newModule, globals(), locals(), [parsingClass], -1) |
| 845 | parsingClass = getattr(parsingModule, parsingClass) |
| 846 | main.parser = parsingClass() |
| 847 | if hasattr(main.parser,"parseParams") and hasattr(main.parser,"parseTopology") and hasattr(main.parser,"parse") : |
| 848 | pass |
| 849 | else: |
| 850 | main.exit() |
| 851 | |
| 852 | except ImportError: |
| 853 | print sys.exc_info()[1] |
| 854 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 855 | def load_logger() : |
| 856 | ''' |
| 857 | It facilitates the loading customised parser for topology and params file. |
| 858 | It loads parser mentioned in tab named parser of teston.cfg file. |
| 859 | It also loads default xmlparser if no parser have specified in teston.cfg file. |
| 860 | |
| 861 | ''' |
| 862 | confighash = main.configDict |
| 863 | if 'file' in confighash['config']['logger'] and 'class' in confighash['config']['logger']: |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 864 | path = confighash['config']['logger']['file'] |
| 865 | if path != None or confighash['config']['logger']['class']!= None : |
| 866 | try: |
| 867 | module = re.sub( r".py\s*$", "", path ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 868 | moduleList = module.split("/") |
| 869 | newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]]) |
Jon Hall | 4450624 | 2015-07-29 17:40:26 -0700 | [diff] [blame] | 870 | loggerClass = confighash['config']['logger']['class'] |
| 871 | loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1) |
| 872 | loggerClass = getattr(loggerModule, loggerClass) |
| 873 | main.logger = loggerClass() |
| 874 | #hashobj = main.parser.parseParams(main.classPath) |
| 875 | except ImportError: |
| 876 | print "Could not find the file " + path + " using default logger." |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 877 | load_defaultlogger() |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 878 | elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None : |
| 879 | load_defaultlogger() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 880 | else: |
| 881 | load_defaultlogger() |
| 882 | |
| 883 | def load_defaultlogger(): |
| 884 | ''' |
| 885 | It will load the default parser which is xml parser to parse the params and topology file. |
| 886 | ''' |
| 887 | moduleList = main.loggerPath.split("/") |
| 888 | newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]]) |
| 889 | try : |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 890 | loggerClass = main.loggerClass |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 891 | loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1) |
| 892 | loggerClass = getattr(loggerModule, loggerClass) |
| 893 | main.logger = loggerClass() |
| 894 | |
| 895 | except ImportError: |
| 896 | print sys.exc_info()[1] |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 897 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 898 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 899 | def _echo(self): |
| 900 | print "THIS IS ECHO" |