summaryrefslogtreecommitdiffstats
path: root/testcases/Controllers
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2016-09-01 13:52:28 +0200
committerMorgan Richomme <morgan.richomme@orange.com>2016-09-05 12:30:20 +0000
commitbf64057ec2cc2dac2be15d0eb06b1c41ff27f293 (patch)
tree8764eba31eca2c04c69fc0db41338041a09473bb /testcases/Controllers
parent98a8439b6d7f8c176c668971ea0096c9cd1df118 (diff)
Switch print to logging.info
It follows the recommendations described in the next review [1]. [1] https://gerrit.opnfv.org/gerrit/#/c/19795/ Change-Id: Ie7ce28451122c554f135caad068844c0303deaeb Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com> (cherry picked from commit 0ae5f5fc64868e8c68eb330fa5aa219abdbdfee0)
Diffstat (limited to 'testcases/Controllers')
-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.py3
4 files changed, 43 insertions, 31 deletions
diff --git a/testcases/Controllers/ONOS/Teston/adapters/client.py b/testcases/Controllers/ONOS/Teston/adapters/client.py
index 77de092e4..6b3285e5e 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 16f2ef32c..b2a2e3d88 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 231677333..f2755b669 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 70c84ac02..3fae2a5d2 100644
--- a/testcases/Controllers/ONOS/Teston/adapters/foundation.py
+++ b/testcases/Controllers/ONOS/Teston/adapters/foundation.py
@@ -16,8 +16,8 @@ import logging
import os
import re
import time
-
import yaml
+
from functest.utils.functest_utils import FUNCTEST_REPO as FUNCTEST_REPO
@@ -49,7 +49,6 @@ class foundation:
filemode='w')
filelog = logging.FileHandler(self.logfilepath)
logging.getLogger('Functest').addHandler(filelog)
- print loginfo
logging.info(loginfo)
def getdefaultpara(self):