Fix regular expression in connect to look for the $ character instead of the end of line anchor
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index f2d1f69..cfa0ecc 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -155,7 +155,7 @@
'''
args = utilities.parse_args(["SRC","TARGET"],**pingParams)
#command = args["SRC"] + " ping -" + args["CONTROLLER"] + " " +args ["TARGET"]
- command = args["SRC"] + " ping "+args ["TARGET"]+" -c 1 -i .2 -W 8"
+ command = args["SRC"] + " ping "+args ["TARGET"]+" -c 1 -i 1 -w 8"
try:
main.log.warn("Sending: " + command)
#response = self.execute(cmd=command,prompt="mininet",timeout=10 )
@@ -433,7 +433,9 @@
option = args["OPTION"] if args["OPTION"] != None else ""
command = "link "+str(end1) + " " + str(end2)+ " " + str(option)
try:
- response = self.execute(cmd=command,prompt="mininet>",timeout=10)
+ #response = self.execute(cmd=command,prompt="mininet>",timeout=10)
+ self.handle.sendline(command)
+ self.handle.expect("mininet>")
except pexpect.EOF:
main.log.error(self.name + ": EOF exception found")
main.log.error(self.name + ": " + self.handle.before)
@@ -566,6 +568,7 @@
try:
response = self.execute(cmd="exit",prompt="(.*)",timeout=120)
response = self.execute(cmd="exit",prompt="(.*)",timeout=120)
+ self.handle.sendline("sudo mn -c")
except pexpect.EOF:
main.log.error(self.name + ": EOF exception found")
main.log.error(self.name + ": " + self.handle.before)
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 87df2fe..66c6733 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -122,7 +122,18 @@
main.log.info(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::")
main.cleanup()
main.exit()
-
+
+ def start_all(self):
+ '''
+ starts ZK, RC, and ONOS
+ '''
+ self.handle.sendline("cd "+self.home)
+ self.handle.sendline("./onos.sh start")
+ self.handle.expect("./onos.sh start")
+ self.handle.expect(["\$",pexpect.TIMEOUT])
+
+
+
def start_rest(self):
'''
Starts the rest server on ONOS.
@@ -196,23 +207,25 @@
self.execute(cmd="\n",prompt="\$",timeout=10)
tail2 = self.execute(cmd="tail " + self.home + "/onos-logs/onos.*.log",prompt="\$",timeout=10)
pattern = '(.*)1 instance(.*)'
+ patternUp = 'Sending LLDP out'
pattern2 = '(.*)Exception: Connection refused(.*)'
# if utilities.assert_matches(expect=pattern,actual=response,onpass="ONOS process is running...",onfail="ONOS process not running..."):
if re.search(pattern, response):
- main.log.info(self.name + ": ONOS process is running...")
- if tail1 == tail2:
- main.log.error(self.name + ": ONOS is frozen...")#logs aren't moving
- return main.FALSE
- elif re.search( pattern2,tail1 ):
- main.log.info(self.name + ": Connection Refused found in onos log")
- return main.FALSE
- elif re.search( pattern2,tail2 ):
- main.log.info(self.name + ": Connection Refused found in onos log")
- return main.FALSE
- else:
- main.log.info(self.name + ": Onos log is moving! It's looking good!")
- return main.TRUE
+ if re.search(patternUp,tail2):
+ main.log.info(self.name + ": ONOS process is running...")
+ if tail1 == tail2:
+ main.log.error(self.name + ": ONOS is frozen...")#logs aren't moving
+ return main.FALSE
+ elif re.search( pattern2,tail1 ):
+ main.log.info(self.name + ": Connection Refused found in onos log")
+ return main.FALSE
+ elif re.search( pattern2,tail2 ):
+ main.log.info(self.name + ": Connection Refused found in onos log")
+ return main.FALSE
+ else:
+ main.log.info(self.name + ": Onos log is moving! It's looking good!")
+ return main.TRUE
else:
main.log.error(self.name + ": ONOS process not running...")
return main.FALSE
@@ -805,8 +818,8 @@
'''
try:
- main.log.info(self.name + ": Stopping ONOS")
- self.stop()
+ # main.log.info(self.name + ": Stopping ONOS")
+ #self.stop()
self.handle.sendline("cd " + self.home)
self.handle.expect("ONOS\$")
if comp1=="":
diff --git a/TestON/drivers/common/cli/zookeeperclidriver.py b/TestON/drivers/common/cli/zookeeperclidriver.py
index 752df44..242e07b 100644
--- a/TestON/drivers/common/cli/zookeeperclidriver.py
+++ b/TestON/drivers/common/cli/zookeeperclidriver.py
@@ -135,7 +135,7 @@
Calls the zookeeper status and returns TRUE if it has an assigned Mode to it.
'''
self.execute(cmd="\n",prompt="\$",timeout=10)
- response = self.execute(cmd=self.home + "/bin/zkServer.sh status ",prompt="Mode",timeout=10)
+ response = self.execute(cmd=self.home + "/onos.sh zk status ",prompt="Mode",timeout=10)
pattern = '(.*)Mode(.*)'
if re.search(pattern, response):
main.log.info(self.name + ": Zookeeper is up.")
diff --git a/TestON/drivers/common/clidriver.py b/TestON/drivers/common/clidriver.py
index 0406e48..9db8f6f 100644
--- a/TestON/drivers/common/clidriver.py
+++ b/TestON/drivers/common/clidriver.py
@@ -53,7 +53,7 @@
self.handle =pexpect.spawn('ssh -X '+self.user_name+'@'+self.ip_address,maxread=50000)
self.handle.logfile = self.logfile_handler
- i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT,refused,'>|#|$'],120)
+ i=self.handle.expect([ssh_newkey,'password:',pexpect.EOF,pexpect.TIMEOUT,refused,'>|#|\$'],120)
if i==0:
main.log.info("ssh key confirmation received, send yes")
@@ -62,7 +62,7 @@
if i==1:
main.log.info("ssh connection asked for password, gave password")
self.handle.sendline(self.pwd)
- self.handle.expect('>|#|$')
+ self.handle.expect('>|#|\$')
elif i==2:
main.log.error("Connection timeout")
@@ -76,8 +76,8 @@
elif i==5:
main.log.info("Password not required logged in")
- self.handle.sendline("\r")
- self.handle.expect('>|#|$', 2)
+ self.handle.sendline("\n")
+ self.handle.expect('>|#|\$', 2)
return self.handle
@@ -99,7 +99,7 @@
'''
result = super(CLI, self).execute(self)
- defaultPrompt = '.*[$>\#]'
+ defaultPrompt = '.*[\$>\#]'
args = utilities.parse_args(["CMD", "TIMEOUT", "PROMPT", "MORE"], **execparams)
expectPrompt = args["PROMPT"] if args["PROMPT"] else defaultPrompt
self.LASTRSP = ""
@@ -163,7 +163,7 @@
i = handle.expect([".ssword:*",default, pexpect.EOF])
if i==0:
handle.sendline(pwd)
- handle.sendline("\r")
+ handle.sendline("\n")
if i==1:
handle.expect(default)
@@ -212,7 +212,7 @@
main.log.error("ssh: connect to host "+ip_address+" port 22: Connection refused")
return main.FALSE
- self.handle.sendline("\r")
+ self.handle.sendline("\n")
return self.handle