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
13 from environment import environment
20 class client(environment):
23 environment.__init__(self)
24 self.loginfo = environment()
27 def RunScript(self, handle, testname, timeout=300):
31 testname: ONOS Testcase Name
32 masterusername: The server username of running ONOS
33 masterpassword: The server password of running ONOS
35 self.testcase = testname
36 self.ChangeTestCasePara(testname, self.masterusername,
39 runtest = (self.home + "/OnosSystemTest/TestON/bin/cli.py run " +
41 runhandle.sendline(runtest)
43 lastshowscreeninfo = ''
45 Result = runhandle.expect(["PEXPECT]#", pexpect.EOF,
47 curshowscreeninfo = runhandle.before
48 if(len(lastshowscreeninfo) != len(curshowscreeninfo)):
49 self.loginfo.log(str(curshowscreeninfo)
50 [len(lastshowscreeninfo)::])
51 lastshowscreeninfo = curshowscreeninfo
57 if circletime > timeout:
59 self.loginfo.log("Timeout when running the test, please check!")
62 # This is the compass run machine user&pass,you need to modify
64 print "Test Begin....."
65 self.OnosConnectionSet()
66 masterhandle = self.SSHlogin(self.localhost, self.masterusername,
68 self.OnosEnvSetup(masterhandle)
71 def onosclean(self, handle):
72 self.SSHRelease(handle)
73 self.loginfo.log('Release onos handle Successful')
75 def push_results_to_db(self, payload, pushornot=1):
78 url = self.Result_DB + "/results"
79 params = {"project_name": "functest", "case_name": "ONOS-" +
80 self.testcase, "pod_name": 'huawei-build-2',
83 headers = {'Content-Type': 'application/json'}
85 r = requests.post(url, data=json.dumps(params), headers=headers)
88 self.loginfo.log('Error pushing results into Database')