aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/client.py
diff options
context:
space:
mode:
authorMorgan Richomme <morgan.richomme@orange.com>2016-11-08 14:18:12 +0100
committerMorgan Richomme <morgan.richomme@orange.com>2016-11-09 16:55:45 +0100
commit107e61635c2ab1feb5263380ea63e21cf2e6e65b (patch)
tree4966b77605bd34a40f452b1d268868691e84d008 /functest/opnfv_tests/Controllers/ONOS/Teston/adapters/client.py
parente74c9b347f2623eb1a3c477921a84da4c31b364f (diff)
Repo structure modification
- create functest subdirectory - rename unit tests - adapt path in exec and config files JIRA: FUNCTEST-525 Change-Id: Ifd5c6edfb5bda1b09f82848e2269ad5fbeb84d0a Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
Diffstat (limited to 'functest/opnfv_tests/Controllers/ONOS/Teston/adapters/client.py')
-rw-r--r--functest/opnfv_tests/Controllers/ONOS/Teston/adapters/client.py92
1 files changed, 92 insertions, 0 deletions
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/client.py b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/client.py
new file mode 100644
index 00000000..6b3285e5
--- /dev/null
+++ b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/client.py
@@ -0,0 +1,92 @@
+"""
+Description:
+ This file is used to run testcase
+ lanqinglong@huawei.com
+
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+"""
+import json
+import pexpect
+import requests
+import time
+
+from environment import environment
+import functest.utils.functest_logger as ft_logger
+
+
+class client(environment):
+
+ logger = ft_logger.Logger("client").getLogger()
+
+ def __init__(self):
+ environment.__init__(self)
+ self.loginfo = environment()
+ self.testcase = ''
+
+ def RunScript(self, handle, testname, timeout=300):
+ """
+ Run ONOS Test Script
+ Parameters:
+ testname: ONOS Testcase Name
+ masterusername: The server username of running ONOS
+ masterpassword: The server password of running ONOS
+ """
+ self.testcase = testname
+ self.ChangeTestCasePara(testname, self.masterusername,
+ self.masterpassword)
+ runhandle = handle
+ runtest = (self.home + "/OnosSystemTest/TestON/bin/cli.py run " +
+ testname)
+ runhandle.sendline(runtest)
+ circletime = 0
+ lastshowscreeninfo = ''
+ while True:
+ Result = runhandle.expect(["PEXPECT]#", pexpect.EOF,
+ pexpect.TIMEOUT])
+ curshowscreeninfo = runhandle.before
+ if(len(lastshowscreeninfo) != len(curshowscreeninfo)):
+ self.loginfo.log(str(curshowscreeninfo)
+ [len(lastshowscreeninfo)::])
+ lastshowscreeninfo = curshowscreeninfo
+ if Result == 0:
+ self.logger.info("Done!")
+ return
+ time.sleep(1)
+ circletime += 1
+ if circletime > timeout:
+ break
+ self.loginfo.log("Timeout when running the test, please check!")
+
+ def onosstart(self):
+ # This is the compass run machine user&pass,you need to modify
+
+ self.logger.info("Test Begin.....")
+ self.OnosConnectionSet()
+ masterhandle = self.SSHlogin(self.localhost, self.masterusername,
+ self.masterpassword)
+ self.OnosEnvSetup(masterhandle)
+ return masterhandle
+
+ def onosclean(self, handle):
+ self.SSHRelease(handle)
+ self.loginfo.log('Release onos handle Successful')
+
+ def push_results_to_db(self, payload, pushornot=1):
+ if pushornot != 1:
+ return 1
+ url = self.Result_DB + "/results"
+ params = {"project_name": "functest", "case_name": "ONOS-" +
+ self.testcase, "pod_name": 'huawei-build-2',
+ "details": payload}
+
+ headers = {'Content-Type': 'application/json'}
+ try:
+ r = requests.post(url, data=json.dumps(params), headers=headers)
+ self.loginfo.log(r)
+ except:
+ self.loginfo.log('Error pushing results into Database')