aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/Controllers/ONOS
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/Controllers/ONOS')
-rw-r--r--testcases/Controllers/ONOS/Teston/adapters/client.py14
-rw-r--r--testcases/Controllers/ONOS/Teston/adapters/connection.py18
-rw-r--r--testcases/Controllers/ONOS/Teston/adapters/environment.py39
-rw-r--r--testcases/Controllers/ONOS/Teston/adapters/foundation.py59
-rwxr-xr-xtestcases/Controllers/ONOS/Teston/onosfunctest.py45
5 files changed, 90 insertions, 85 deletions
diff --git a/testcases/Controllers/ONOS/Teston/adapters/client.py b/testcases/Controllers/ONOS/Teston/adapters/client.py
index 77de092e..6b3285e5 100644
--- a/testcases/Controllers/ONOS/Teston/adapters/client.py
+++ b/testcases/Controllers/ONOS/Teston/adapters/client.py
@@ -10,15 +10,19 @@ Description:
# http://www.apache.org/licenses/LICENSE-2.0
#
"""
-from environment import environment
-import time
+import json
import pexpect
import requests
-import json
+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()
@@ -50,7 +54,7 @@ class client(environment):
[len(lastshowscreeninfo)::])
lastshowscreeninfo = curshowscreeninfo
if Result == 0:
- print "Done!"
+ self.logger.info("Done!")
return
time.sleep(1)
circletime += 1
@@ -61,7 +65,7 @@ class client(environment):
def onosstart(self):
# This is the compass run machine user&pass,you need to modify
- print "Test Begin....."
+ self.logger.info("Test Begin.....")
self.OnosConnectionSet()
masterhandle = self.SSHlogin(self.localhost, self.masterusername,
self.masterpassword)
diff --git a/testcases/Controllers/ONOS/Teston/adapters/connection.py b/testcases/Controllers/ONOS/Teston/adapters/connection.py
index 16f2ef32..b2a2e3d8 100644
--- a/testcases/Controllers/ONOS/Teston/adapters/connection.py
+++ b/testcases/Controllers/ONOS/Teston/adapters/connection.py
@@ -16,11 +16,15 @@ Description:
import os
import pexpect
import re
+
from foundation import foundation
+import functest.utils.functest_logger as ft_logger
class connection(foundation):
+ logger = ft_logger.Logger("connection").getLogger()
+
def __init__(self):
foundation.__init__(self)
self.loginfo = foundation()
@@ -33,7 +37,7 @@ class connection(foundation):
username: login user name
password: login password
"""
- print("Now Adding an user to known hosts " + ipaddr)
+ self.logger.info("Now Adding an user to known hosts " + ipaddr)
login = handle
login.sendline("ssh -l %s -p 8101 %s" % (username, ipaddr))
index = 0
@@ -78,7 +82,7 @@ class connection(foundation):
"""
Generate ssh keys, used for some server have no sshkey.
"""
- print "Now Generating SSH keys..."
+ self.logger.info("Now Generating SSH keys...")
# Here file name may be id_rsa or id_ecdsa or others
# So here will have a judgement
keysub = handle
@@ -112,7 +116,7 @@ class connection(foundation):
parameters:
password: root login password
"""
- print("Now changing to user root")
+ self.logger.info("Now changing to user root")
login = pexpect.spawn("su - root")
index = 0
while index != 2:
@@ -129,7 +133,7 @@ class connection(foundation):
"""
Exit root user.
"""
- print("Now Release user root")
+ self.logger.info("Now Release user root")
login = pexpect.spawn("exit")
index = login.expect(['logout', pexpect.EOF, pexpect.TIMEOUT])
if index == 0:
@@ -145,7 +149,7 @@ class connection(foundation):
parameters:
envalue: environment value to add
"""
- print "Now Adding bash environment"
+ self.logger.info("Now Adding bash environment")
fileopen = open("/etc/profile", 'r')
findContext = 1
while findContext:
@@ -165,7 +169,7 @@ class connection(foundation):
Change ONOS root path in file:bash_profile
onospath: path of onos root
"""
- print "Now Changing ONOS Root Path"
+ self.logger.info("Now Changing ONOS Root Path")
filepath = onospath + 'onos/tools/dev/bash_profile'
line = open(filepath, 'r').readlines()
lenall = len(line) - 1
@@ -175,7 +179,7 @@ class connection(foundation):
NewFile = open(filepath, 'w')
NewFile.writelines(line)
NewFile.close
- print "Done!"
+ self.logger.info("Done!")
def OnosConnectionSet(self):
"""
diff --git a/testcases/Controllers/ONOS/Teston/adapters/environment.py b/testcases/Controllers/ONOS/Teston/adapters/environment.py
index 23167733..f2755b66 100644
--- a/testcases/Controllers/ONOS/Teston/adapters/environment.py
+++ b/testcases/Controllers/ONOS/Teston/adapters/environment.py
@@ -15,17 +15,21 @@ Description:
#
"""
-import os
-import time
import pexpect
+import pxssh
import re
+import os
import sys
-import pxssh
+import time
+
from connection import connection
+import functest.utils.functest_logger as ft_logger
class environment(connection):
+ logger = ft_logger.Logger("environment").getLogger()
+
def __init__(self):
connection.__init__(self)
self.loginfo = connection()
@@ -39,9 +43,9 @@ class environment(connection):
handle: current working handle
codeurl: clone code url
"""
- print "Now loading test codes! Please wait in patient..."
+ self.logger.info("Now loading test codes! Please wait in patient...")
originalfolder = sys.path[0]
- print originalfolder
+ self.logger.info(originalfolder)
gitclone = handle
gitclone.sendline("git clone " + codeurl)
index = 0
@@ -82,7 +86,7 @@ class environment(connection):
parameters:
handle(input): current working handle
"""
- print "Now Cleaning test environment"
+ self.logger.info("Now Cleaning test environment")
handle.sendline("sudo apt-get install -y mininet")
handle.prompt()
handle.sendline("sudo pip install configobj")
@@ -102,7 +106,7 @@ class environment(connection):
cmd(input): onos-push-keys xxx(xxx is device)
password(input): login in password
"""
- print "Now Pushing Onos Keys:" + cmd
+ self.logger.info("Now Pushing Onos Keys:" + cmd)
Pushkeys = handle
Pushkeys.sendline(cmd)
Result = 0
@@ -121,7 +125,7 @@ class environment(connection):
break
time.sleep(2)
Pushkeys.prompt()
- print "Done!"
+ self.logger.info("Done!")
def SetOnosEnvVar(self, handle, masterpass, agentpass):
"""
@@ -131,13 +135,14 @@ class environment(connection):
masterpass: scripts running server's password
agentpass: onos cluster&compute node password
"""
- print "Now Setting test environment"
+ self.logger.info("Now Setting test environment")
for host in self.hosts:
- print "try to connect " + str(host)
+ self.logger.info("try to connect " + str(host))
result = self.CheckSshNoPasswd(host)
if not result:
- print ("ssh login failed,try to copy master publickey" +
- "to agent " + str(host))
+ self.logger.info(
+ "ssh login failed,try to copy master publickey" +
+ "to agent " + str(host))
self.CopyPublicKey(host)
self.OnosPushKeys(handle, "onos-push-keys " + self.OCT, masterpass)
self.OnosPushKeys(handle, "onos-push-keys " + self.OC1, agentpass)
@@ -173,7 +178,7 @@ class environment(connection):
user: onos&compute node user
password: onos&compute node password
"""
- print "Now Changing ONOS name&password"
+ self.logger.info("Now Changing ONOS name&password")
filepath = self.home + '/onos/tools/build/envDefaults'
line = open(filepath, 'r').readlines()
lenall = len(line) - 1
@@ -187,7 +192,7 @@ class environment(connection):
NewFile = open(filepath, 'w')
NewFile.writelines(line)
NewFile.close
- print "Done!"
+ self.logger.info("Done!")
def ChangeTestCasePara(self, testcase, user, password):
"""
@@ -196,7 +201,7 @@ class environment(connection):
user: onos&compute node user
password: onos&compute node password
"""
- print "Now Changing " + testcase + " name&password"
+ self.logger.info("Now Changing " + testcase + " name&password")
if self.masterusername == 'root':
filepath = '/root/'
else:
@@ -232,7 +237,7 @@ class environment(connection):
login.sendline('ls -l')
# match prompt
login.prompt()
- print("SSH login " + ipaddr + " success!")
+ self.logger.info("SSH login " + ipaddr + " success!")
return login
def SSHRelease(self, handle):
@@ -256,7 +261,7 @@ class environment(connection):
str(publickey) + ">>/root/.ssh/authorized_keys\'")
tmphandle.prompt()
self.SSHRelease(tmphandle)
- print "Add OCT PublicKey to " + host + " success"
+ self.logger.info("Add OCT PublicKey to " + host + " success")
def OnosEnvSetup(self, handle):
"""
diff --git a/testcases/Controllers/ONOS/Teston/adapters/foundation.py b/testcases/Controllers/ONOS/Teston/adapters/foundation.py
index 70c84ac0..5c42c35e 100644
--- a/testcases/Controllers/ONOS/Teston/adapters/foundation.py
+++ b/testcases/Controllers/ONOS/Teston/adapters/foundation.py
@@ -17,8 +17,7 @@ import os
import re
import time
-import yaml
-from functest.utils.functest_utils import FUNCTEST_REPO as FUNCTEST_REPO
+import functest.utils.functest_utils as ft_utils
class foundation:
@@ -26,7 +25,7 @@ class foundation:
def __init__(self):
# currentpath = os.getcwd()
- REPO_PATH = FUNCTEST_REPO + '/'
+ REPO_PATH = ft_utils.FUNCTEST_REPO + '/'
currentpath = REPO_PATH + 'testcases/Controllers/ONOS/Teston/CI'
self.cipath = currentpath
self.logdir = os.path.join(currentpath, 'log')
@@ -49,42 +48,36 @@ class foundation:
filemode='w')
filelog = logging.FileHandler(self.logfilepath)
logging.getLogger('Functest').addHandler(filelog)
- print loginfo
logging.info(loginfo)
def getdefaultpara(self):
"""
Get Default Parameters value
"""
- with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
- functest_yaml = yaml.safe_load(f)
-
- 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.installer_master = str(functest_yaml.get("ONOS").
- get("environment").get("installer_master"))
- self.installer_master_username = str(functest_yaml.get("ONOS").
- get("environment").
- get("installer_master_username"))
- self.installer_master_password = str(functest_yaml.get("ONOS").
- get("environment").
- get("installer_master_password"))
+ self.Result_DB = str(
+ ft_utils.get_functest_config('results.test_db_url'))
+ self.masterusername = str(
+ ft_utils.get_functest_config('ONOS.general.onosbench_username'))
+ self.masterpassword = str(
+ ft_utils.get_functest_config('ONOS.general.onosbench_password'))
+ self.agentusername = str(
+ ft_utils.get_functest_config('ONOS.general.onoscli_username'))
+ self.agentpassword = str(
+ ft_utils.get_functest_config('ONOS.general.onoscli_password'))
+ self.runtimeout = \
+ ft_utils.get_functest_config('ONOS.general.runtimeout')
+ self.OCT = str(ft_utils.get_functest_config('ONOS.environment.OCT'))
+ self.OC1 = str(ft_utils.get_functest_config('ONOS.environment.OC1'))
+ self.OC2 = str(ft_utils.get_functest_config('ONOS.environment.OC2'))
+ self.OC3 = str(ft_utils.get_functest_config('ONOS.environment.OC3'))
+ self.OCN = str(ft_utils.get_functest_config('ONOS.environment.OCN'))
+ self.OCN2 = str(ft_utils.get_functest_config('ONOS.environment.OCN2'))
+ self.installer_master = str(
+ ft_utils.get_functest_config('ONOS.environment.installer_master'))
+ self.installer_master_username = str(ft_utils.get_functest_config(
+ 'ONOS.environment.installer_master_username'))
+ self.installer_master_password = str(ft_utils.get_functest_config(
+ 'ONOS.environment.installer_master_password'))
self.hosts = [self.OC1, self.OCN, self.OCN2]
self.localhost = self.OCT
diff --git a/testcases/Controllers/ONOS/Teston/onosfunctest.py b/testcases/Controllers/ONOS/Teston/onosfunctest.py
index 01537b99..c8045fd1 100755
--- a/testcases/Controllers/ONOS/Teston/onosfunctest.py
+++ b/testcases/Controllers/ONOS/Teston/onosfunctest.py
@@ -20,11 +20,11 @@ import re
import time
import argparse
+from neutronclient.v2_0 import client as neutronclient
+
import functest.utils.functest_logger as ft_logger
-import functest.utils.functest_utils as functest_utils
+import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as openstack_utils
-from functest.utils.functest_utils import FUNCTEST_REPO as REPO_PATH
-from neutronclient.v2_0 import client as neutronclient
parser = argparse.ArgumentParser()
parser.add_argument("-t", "--testcase", help="Testcase name")
@@ -35,12 +35,11 @@ args = parser.parse_args()
logger = ft_logger.Logger("onos").getLogger()
# onos parameters
-TEST_DB = functest_utils.get_parameter_from_yaml(
- "results.test_db_url")
-ONOS_REPO_PATH = functest_utils.get_parameter_from_yaml(
- "general.directories.dir_repos")
-ONOS_CONF_DIR = functest_utils.get_parameter_from_yaml(
- "general.directories.dir_functest_conf")
+TEST_DB = ft_utils.get_functest_config("results.test_db_url")
+ONOS_REPO_PATH = \
+ ft_utils.get_functest_config("general.directories.dir_repos")
+ONOS_CONF_DIR = \
+ ft_utils.get_functest_config("general.directories.dir_functest_conf")
ONOSCI_PATH = ONOS_REPO_PATH + "/"
starttime = datetime.datetime.now()
@@ -49,14 +48,14 @@ HOME = os.environ['HOME'] + "/"
INSTALLER_TYPE = os.environ['INSTALLER_TYPE']
DEPLOY_SCENARIO = os.environ['DEPLOY_SCENARIO']
ONOSCI_PATH = ONOS_REPO_PATH + "/"
-GLANCE_IMAGE_NAME = functest_utils.get_parameter_from_yaml(
- "onos_sfc.image_name")
-GLANCE_IMAGE_FILENAME = functest_utils.get_parameter_from_yaml(
- "onos_sfc.image_file_name")
-GLANCE_IMAGE_PATH = functest_utils.get_parameter_from_yaml(
- "general.directories.dir_functest_data") + "/" + GLANCE_IMAGE_FILENAME
-SFC_PATH = REPO_PATH + "/" + functest_utils.get_parameter_from_yaml(
- "general.directories.dir_onos_sfc")
+GLANCE_IMAGE_NAME = ft_utils.get_functest_config("onos_sfc.image_name")
+GLANCE_IMAGE_FILENAME = \
+ ft_utils.get_functest_config("onos_sfc.image_file_name")
+GLANCE_IMAGE_PATH = \
+ ft_utils.get_functest_config("general.directories.dir_functest_data") + \
+ "/" + GLANCE_IMAGE_FILENAME
+SFC_PATH = ft_utils.FUNCTEST_REPO + "/" + \
+ ft_utils.get_functest_config("general.directories.dir_onos_sfc")
def RunScript(testname):
@@ -243,12 +242,12 @@ def OnosTest():
except:
logger.error("Unable to set ONOS criteria")
- functest_utils.push_results_to_db("functest",
- "onos",
- start_time,
- stop_time,
- status,
- result)
+ ft_utils.push_results_to_db("functest",
+ "onos",
+ start_time,
+ stop_time,
+ status,
+ result)
except:
logger.error("Error pushing results into Database")