3 This file include basis functions
7 # All rights reserved. This program and the accompanying materials
8 # are made available under the terms of the Apache License, Version 2.0
9 # which accompanies this distribution, and is available at
10 # http://www.apache.org/licenses/LICENSE-2.0
20 import functest.utils.functest_constants as ft_constants
21 import functest.utils.functest_utils as ft_utils
28 # currentpath = os.getcwd()
30 ft_constants.FUNCTEST_TEST_DIR + '/sdn/onos/teston/ci'
31 self.cipath = currentpath
32 self.logdir = os.path.join(currentpath, 'log')
33 self.workhome = currentpath[0: currentpath.rfind('opnfv_tests') - 1]
35 filename = time.strftime('%Y-%m-%d-%H-%M-%S') + '.log'
36 self.logfilepath = os.path.join(self.logdir, filename)
37 self.starttime = datetime.datetime.now()
39 def log(self, loginfo):
41 Record log in log directory for deploying test environment
43 loginfo(input): record info
45 logging.basicConfig(level=logging.INFO,
46 format='%(asctime)s %(filename)s:%(message)s',
47 datefmt='%d %b %Y %H:%M:%S',
48 filename=self.logfilepath,
50 filelog = logging.FileHandler(self.logfilepath)
51 logging.getLogger('Functest').addHandler(filelog)
54 def getdefaultpara(self):
56 Get Default Parameters value
58 self.Result_DB = str(ft_utils.get_db_url())
59 self.masterusername = str(ft_constants.ONOSBENCH_USERNAME)
60 self.masterpassword = str(ft_constants.ONOSBENCH_PASSWORD)
61 self.agentusername = str(ft_constants.ONOSCLI_USERNAME)
62 self.agentpassword = str(ft_constants.ONOSCLI_PASSWORD)
63 self.runtimeout = ft_constants.ONOS_RUNTIMEOUT
64 self.OCT = str(ft_constants.ONOS_OCT)
65 self.OC1 = str(ft_constants.ONOS_OC1)
66 self.OC2 = str(ft_constants.ONOS_OC2)
67 self.OC3 = str(ft_constants.ONOS_OC3)
68 self.OCN = str(ft_constants.ONOS_OCN)
69 self.OCN2 = str(ft_constants.ONOS_OCN2)
70 self.installer_master = str(ft_constants.ONOS_INSTALLER_MASTER)
71 self.installer_master_username = \
72 str(ft_constants.ONOS_INSTALLER_MASTER_USERNAME)
73 self.installer_master_password = \
74 ft_constants.ONOS_INSTALLER_MASTER_PASSWORD
75 self.hosts = [self.OC1, self.OCN, self.OCN2]
76 self.localhost = self.OCT
79 cmd = "cat " + self.logfilepath + " | grep Fail"
80 Resultbuffer = os.popen(cmd).read()
81 duration = datetime.datetime.now() - self.starttime
84 if re.search("[1-9]+", Resultbuffer):
85 self.log("Testcase Fails\n" + Resultbuffer)
88 self.log("Testcases Pass")
90 payload = {'timestart': str(self.starttime),
91 'duration': str(duration), 'status': Result}