Move the configuration from test scripts to config_functest.yaml 85/2585/2
authorlanqinglong <lanqinglong@huawei.com>
Fri, 16 Oct 2015 08:49:08 +0000 (16:49 +0800)
committerlanqinglong <lanqinglong@huawei.com>
Fri, 16 Oct 2015 09:30:28 +0000 (17:30 +0800)
JIRA:FUNCTEST-77

The configuration is in onos test files
Get them out, put in config_functest.yaml

Change-Id: I3f7b868b61a7e66596f7c0cc232c5b045d77aecb
Signed-off-by: lanqinglong <lanqinglong@huawei.com>
testcases/Controllers/ONOS/Teston/CI/adapters/client.py
testcases/Controllers/ONOS/Teston/CI/adapters/connection.py
testcases/Controllers/ONOS/Teston/CI/adapters/environment.py
testcases/Controllers/ONOS/Teston/CI/adapters/foundation.py
testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
testcases/config_functest.yaml

index c84f187..32e3749 100644 (file)
@@ -14,6 +14,7 @@ class client( environment ):
     def __init__( self ):
         environment.__init__( self )
         self.loginfo = environment()
+        self.testcase = ''
 
     def RunScript( self, handle, testname, timeout=300 ):
         """
@@ -23,6 +24,7 @@ class client( environment ):
         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
@@ -56,3 +58,12 @@ class client( environment ):
 
     def onosclean( self, handle ):
         self.SSHRelease( handle )
+        self.loginfo.log('Release onos handle Successful')
+
+    def push_results_to_db( self, payload, pushornot = 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'}
+        r = requests.post(url, data=json.dumps(params), headers=headers)
+        self.loginfo.log('Pushing result via Northbound, info:' + r )
index 1d96a49..f7f283e 100644 (file)
@@ -175,7 +175,7 @@ class connection( foundation ):
         """
         Intergrate for ONOS connection setup
         """
-        if self.masterusername is 'root':
+        if self.masterusername == 'root':
             filepath = '/root/'
         else :
             filepath = '/home/' + self.masterusername + '/'
index ea1a836..bdd0e12 100644 (file)
@@ -158,7 +158,7 @@ class environment( connection ):
         password: onos&compute node password
         """
         print "Now Changing " + testcase +  " name&password"
-        if self.masterusername is 'root':
+        if self.masterusername == 'root':
             filepath = '/root/'
         else :
             filepath = '/home/' + self.masterusername + '/'
index 2d6b876..c909d36 100644 (file)
@@ -7,11 +7,16 @@ Description:
 import logging
 import os
 import time
+import yaml
 
 class foundation:
 
     def __init__(self):
-        self.dir = os.path.join( os.getcwd(), 'log' )
+
+        currentpath = os.getcwd()
+        self.logdir = os.path.join( currentpath, 'log' )
+        self.workhome = currentpath[0:currentpath.rfind('testcases')-1]
+        self.Result_DB = ''
 
     def log (self, loginfo):
         """
@@ -20,7 +25,7 @@ class foundation:
         loginfo(input): record info
         """
         filename = time.strftime( '%Y-%m-%d-%H-%M-%S' ) + '.log'
-        filepath = os.path.join( self.dir, filename )
+        filepath = os.path.join( self.logdir, filename )
         logging.basicConfig( level=logging.INFO,
                 format = '%(asctime)s %(filename)s:%(message)s',
                 datefmt = '%d %b %Y %H:%M:%S',
@@ -29,4 +34,31 @@ class foundation:
         filelog = logging.FileHandler( filepath )
         logging.getLogger( 'Functest' ).addHandler( filelog )
         print loginfo
-        logging.info(loginfo)
\ No newline at end of file
+        logging.info(loginfo)
+
+    def getdefaultpara( self ):
+        """
+        Get Default Parameters value
+        """
+        with open(self.workhome + "testcases/config_functest.yaml") as f:
+            functest_yaml = yaml.safe_load(f)
+        f.close()
+
+        self.Result_DB = str(functest_yaml.get("results").get("test_db_url"))
+        self.masterusername = str(functest_yaml.get("ONOS").get("general").\
+                                 get('onosbench_username'))
+        self.masterpassword = str(functest_yaml.get("ONOS").get("general").\
+                                 get("onosbench_password"))
+        self.agentusername = str(functest_yaml.get("ONOS").get("general").\
+                                 get("onoscli_username"))
+        self.agentpassword = str(functest_yaml.get("ONOS").get("general").\
+                                 get("onoscli_password"))
+        self.runtimeout = functest_yaml.get("ONOS").get("general").get("runtimeout")
+        self.OCT = str(functest_yaml.get("ONOS").get("environment").get("OCT"))
+        self.OC1 = str(functest_yaml.get("ONOS").get("environment").get("OC1"))
+        self.OC2 = str(functest_yaml.get("ONOS").get("environment").get("OC2"))
+        self.OC3 = str(functest_yaml.get("ONOS").get("environment").get("OC3"))
+        self.OCN = str(functest_yaml.get("ONOS").get("environment").get("OCN"))
+        self.OCN2 = str(functest_yaml.get("ONOS").get("environment").get("OCN2"))
+        self.localhost = self.OCT
+        return True
\ No newline at end of file
index fe6f9d7..e852443 100644 (file)
@@ -12,17 +12,7 @@ from adapters.client import client
 if __name__=="__main__":
 
     main = client()
-    main.masterusername = "root"
-    main.masterpassword = "root"
-    main.agentusername = "root"
-    main.agentpassword = "root"
-    main.OCT = '189.42.8.99'
-    main.OC1 = '189.42.8.101'
-    main.OC2 = '189.42.8.102'
-    main.OC3 = '189.42.8.103'
-    main.OCN = '189.42.8.104'
-    main.OCN2 = '189.42.8.105'
-    main.localhost = main.OCT
+    main.getdefaultpara()
 
     #scripts to run
     runhandle = main.onosstart()
index dcbac09..31d77df 100644 (file)
@@ -6,6 +6,7 @@ general:
         dir_rally:      testcases/VIM/OpenStack/CI/libraries/
         dir_rally_scn:  testcases/VIM/OpenStack/CI/suites/
         dir_vIMS:       testcases/vIMS/CI/
+        dir_onos:       testcases/Controllers/ONOS/Teston/CI/
 
         # Absolute path
         dir_repos:          /home/opnfv/repos
@@ -96,5 +97,19 @@ vIMS:
             agent_user: 'ubuntu'
             external_network_name: ''
             public_domain: clearwater.opnfv
+ONOS:
+    general:
+        onosbench_username: 'root'
+        onosbench_password: 'root'
+        onoscli_username: 'root'
+        onoscli_password: 'root'
+        runtimeout: 300
+    environment:
+        OCT: '189.42.8.99'
+        OC1: '189.42.8.101'
+        OC2: '189.42.8.102'
+        OC3: '189.42.8.103'
+        OCN: '189.42.8.104'
+        OCN2: '189.42.8.105'
 results:
     test_db_url: http://213.77.62.197