3 This file is used to run testcase
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
18 from environment import environment
19 import functest.utils.functest_logger as ft_logger
22 class client(environment):
24 logger = ft_logger.Logger("client").getLogger()
27 environment.__init__(self)
28 self.loginfo = environment()
31 def RunScript(self, handle, testname, timeout=300):
35 testname: ONOS Testcase Name
36 masterusername: The server username of running ONOS
37 masterpassword: The server password of running ONOS
39 self.testcase = testname
40 self.ChangeTestCasePara(testname, self.masterusername,
43 runtest = (self.home + "/OnosSystemTest/TestON/bin/cli.py run " +
45 runhandle.sendline(runtest)
47 lastshowscreeninfo = ''
49 Result = runhandle.expect(["PEXPECT]#", pexpect.EOF,
51 curshowscreeninfo = runhandle.before
52 if(len(lastshowscreeninfo) != len(curshowscreeninfo)):
53 self.loginfo.log(str(curshowscreeninfo)
54 [len(lastshowscreeninfo)::])
55 lastshowscreeninfo = curshowscreeninfo
57 self.logger.info("Done!")
61 if circletime > timeout:
63 self.loginfo.log("Timeout when running the test, please check!")
66 # This is the compass run machine user&pass,you need to modify
68 self.logger.info("Test Begin.....")
69 self.OnosConnectionSet()
70 masterhandle = self.SSHlogin(self.localhost, self.masterusername,
72 self.OnosEnvSetup(masterhandle)
75 def onosclean(self, handle):
76 self.SSHRelease(handle)
77 self.loginfo.log('Release onos handle Successful')
79 def push_results_to_db(self, payload, pushornot=1):
82 url = self.Result_DB + "/results"
83 params = {"project_name": "functest", "case_name": "ONOS-" +
84 self.testcase, "pod_name": 'huawei-build-2',
87 headers = {'Content-Type': 'application/json'}
89 r = requests.post(url, data=json.dumps(params), headers=headers)
92 self.loginfo.log('Error pushing results into Database')