aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/Controllers/ONOS/Teston
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests/Controllers/ONOS/Teston')
-rw-r--r--functest/opnfv_tests/Controllers/ONOS/Teston/Readme.txt5
-rw-r--r--functest/opnfv_tests/Controllers/ONOS/Teston/__init__.py0
-rw-r--r--functest/opnfv_tests/Controllers/ONOS/Teston/adapters/__init__.py0
-rw-r--r--functest/opnfv_tests/Controllers/ONOS/Teston/adapters/client.py92
-rw-r--r--functest/opnfv_tests/Controllers/ONOS/Teston/adapters/connection.py200
-rw-r--r--functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py286
-rw-r--r--functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py93
-rw-r--r--functest/opnfv_tests/Controllers/ONOS/Teston/dependencies/onos29
-rw-r--r--functest/opnfv_tests/Controllers/ONOS/Teston/log/gitignore0
-rwxr-xr-xfunctest/opnfv_tests/Controllers/ONOS/Teston/onosfunctest.py261
10 files changed, 0 insertions, 966 deletions
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/Readme.txt b/functest/opnfv_tests/Controllers/ONOS/Teston/Readme.txt
deleted file mode 100644
index 7393f59a..00000000
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/Readme.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-1.This is a basic test run about onos,we will make them better and better
-2.This test include two suites:
-(1)Test northbound(network/subnet/ports create/update/delete)
-(2)Ovsdb test,default configuration,openflow connection,vm go onlines.
-3.Later we will make a framework to do this test \ No newline at end of file
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/__init__.py b/functest/opnfv_tests/Controllers/ONOS/Teston/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/__init__.py
+++ /dev/null
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/__init__.py b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/__init__.py
+++ /dev/null
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/client.py b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/client.py
deleted file mode 100644
index 6b3285e5..00000000
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/client.py
+++ /dev/null
@@ -1,92 +0,0 @@
-"""
-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')
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/connection.py b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/connection.py
deleted file mode 100644
index b2a2e3d8..00000000
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/connection.py
+++ /dev/null
@@ -1,200 +0,0 @@
-"""
-Description:
- This file is used to make connections
- Include ssh & exchange public-key to each other so that
- it can run without password
-
- 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 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()
-
- def AddKnownHost(self, handle, ipaddr, username, password):
- """
- Add an user to known host,so that onos can login in with onos $ipaddr.
- parameters:
- ipaddr: ip address
- username: login user name
- password: login password
- """
- 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
- while index != 2:
- index = login.expect(['assword:', 'yes/no', pexpect.EOF,
- pexpect.TIMEOUT])
- if index == 0:
- login.sendline(password)
- login.sendline("logout")
- index = login.expect(["closed", pexpect.EOF])
- if index == 0:
- self.loginfo.log("Add SSH Known Host Success!")
- break
- else:
- self.loginfo.log("Add SSH Known Host Failed! "
- "Please Check!")
- break
- login.prompt()
-
- if index == 1:
- login.sendline('yes')
-
- def GetEnvValue(self, handle, envname):
- """
- os.getenv only returns current user value
- GetEnvValue returns a environment value of
- current handle
- eg: GetEnvValue(handle,'HOME')
- """
- envhandle = handle
- envhandle.sendline('echo $' + envname)
- envhandle.prompt()
- reg = envname + '\r\n(.*)\r'
- envaluereg = re.compile(reg)
- envalue = envaluereg.search(envhandle.before)
- if envalue:
- return envalue.groups()[0]
- else:
- return None
-
- def Gensshkey(self, handle):
- """
- Generate ssh keys, used for some server have no sshkey.
- """
- 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
- filepath = self.GetEnvValue(keysub, 'HOME') + '/.ssh'
- filelist = os.listdir(filepath)
- for item in filelist:
- if 'id' in item:
- self.loginfo.log("SSH keys are exsit in ssh directory.")
- return True
- keysub.sendline("ssh-keygen -t rsa")
- Result = 0
- while Result != 2:
- Result = keysub.expect(["Overwrite", "Enter", pexpect.EOF,
- 'PEXPECT]#', pexpect.TIMEOUT])
- if Result == 0:
- keysub.sendline("y")
- if Result == 1 or Result == 2:
- keysub.sendline("\n")
- if Result == 3:
- self.loginfo.log("Generate SSH key success.")
- keysub.prompt()
- break
- if Result == 4:
- self.loginfo.log("Generate SSH key failed.")
- keysub.prompt()
- break
-
- def GetRootAuth(self, password):
- """
- Get root user
- parameters:
- password: root login password
- """
- self.logger.info("Now changing to user root")
- login = pexpect.spawn("su - root")
- index = 0
- while index != 2:
- index = login.expect(['assword:', "failure",
- pexpect.EOF, pexpect.TIMEOUT])
- if index == 0:
- login.sendline(password)
- if index == 1:
- self.loginfo.log("Change user to root failed.")
-
- login.interact()
-
- def ReleaseRootAuth(self):
- """
- Exit root user.
- """
- self.logger.info("Now Release user root")
- login = pexpect.spawn("exit")
- index = login.expect(['logout', pexpect.EOF, pexpect.TIMEOUT])
- if index == 0:
- self.loginfo.log("Release root user success.")
- if index == 1:
- self.loginfo.log("Release root user failed.")
-
- login.interact()
-
- def AddEnvIntoBashrc(self, envalue):
- """
- Add Env var into /etc/profile.
- parameters:
- envalue: environment value to add
- """
- self.logger.info("Now Adding bash environment")
- fileopen = open("/etc/profile", 'r')
- findContext = 1
- while findContext:
- findContext = fileopen.readline()
- result = findContext.find(envalue)
- if result != -1:
- break
- fileopen.close
- if result == -1:
- envAdd = open("/etc/profile", 'a+')
- envAdd.writelines("\n" + envalue)
- envAdd.close()
- self.loginfo.log("Add env to bashrc success!")
-
- def OnosRootPathChange(self, onospath):
- """
- Change ONOS root path in file:bash_profile
- onospath: path of onos root
- """
- self.logger.info("Now Changing ONOS Root Path")
- filepath = onospath + 'onos/tools/dev/bash_profile'
- line = open(filepath, 'r').readlines()
- lenall = len(line) - 1
- for i in range(lenall):
- if "export ONOS_ROOT" in line[i]:
- line[i] = 'export ONOS_ROOT=' + onospath + 'onos\n'
- NewFile = open(filepath, 'w')
- NewFile.writelines(line)
- NewFile.close
- self.logger.info("Done!")
-
- def OnosConnectionSet(self):
- """
- Intergrate for ONOS connection setup
- """
- if self.masterusername == 'root':
- filepath = '/root/'
- else:
- filepath = '/home/' + self.masterusername + '/'
- filepath = os.path.join(filepath, "onos/tools/dev/bash_profile")
- self.AddEnvIntoBashrc("source " + filepath + "\n")
- self.AddEnvIntoBashrc("export OCT=" + self.OCT)
- self.AddEnvIntoBashrc("export OC1=" + self.OC1)
- self.AddEnvIntoBashrc("export OC2=" + self.OC2)
- self.AddEnvIntoBashrc("export OC3=" + self.OC3)
- self.AddEnvIntoBashrc("export OCN=" + self.OCN)
- self.AddEnvIntoBashrc("export OCN2=" + self.OCN2)
- self.AddEnvIntoBashrc("export localhost=" + self.localhost)
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py
deleted file mode 100644
index 01f70b85..00000000
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/environment.py
+++ /dev/null
@@ -1,286 +0,0 @@
-"""
-Description:
- This file is used to setup the running environment
- Include Download code,setup environment variable
- Set onos running config
- Set user name/password
- Onos-push-keys and so on
- 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 pexpect
-import pxssh
-import re
-import os
-import sys
-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()
- self.masterhandle = ''
- self.home = ''
-
- def DownLoadCode(self, handle, codeurl):
- """
- Download Code use 'git clone'
- parameters:
- handle: current working handle
- codeurl: clone code url
- """
- self.logger.info("Now loading test codes! Please wait in patient...")
- originalfolder = sys.path[0]
- self.logger.info(originalfolder)
- gitclone = handle
- gitclone.sendline("git clone " + codeurl)
- index = 0
- # increment = 0
- while index != 1 or index != 4:
- index = gitclone.expect(['already exists',
- 'esolving deltas: 100%',
- 'eceiving objects',
- 'Already up-to-date',
- 'npacking objects: 100%', pexpect.EOF])
-
- filefolder = self.home + '/' + codeurl.split('/')[-1].split('.')[0]
- if index == 0:
- os.chdir(filefolder)
- os.system('git pull')
- os.chdir(originalfolder)
- self.loginfo.log('Download code success!')
- break
- elif index == 1 or index == 4:
- self.loginfo.log('Download code success!')
- gitclone.sendline("mkdir onos")
- gitclone.prompt()
- gitclone.sendline("cp -rf " + filefolder + "/tools onos/")
- gitclone.prompt()
- break
- elif index == 2:
- os.write(1, gitclone.before)
- sys.stdout.flush()
- else:
- self.loginfo.log('Download code failed!')
- self.loginfo.log('Information before' + gitclone.before)
- break
- gitclone.prompt()
-
- def InstallDefaultSoftware(self, handle):
- """
- Install default software
- parameters:
- handle(input): current working handle
- """
- self.logger.info("Now Cleaning test environment")
- handle.sendline("sudo apt-get install -y mininet")
- handle.prompt()
- handle.sendline("sudo pip install configobj")
- handle.prompt()
- handle.sendline("sudo apt-get install -y sshpass")
- handle.prompt()
- handle.sendline("OnosSystemTest/TestON/bin/cleanup.sh")
- handle.prompt()
- time.sleep(5)
- self.loginfo.log('Clean environment success!')
-
- def OnosPushKeys(self, handle, cmd, password):
- """
- Using onos-push-keys to make ssh device without password
- parameters:
- handle(input): working handle
- cmd(input): onos-push-keys xxx(xxx is device)
- password(input): login in password
- """
- self.logger.info("Now Pushing Onos Keys:" + cmd)
- Pushkeys = handle
- Pushkeys.sendline(cmd)
- Result = 0
- while Result != 2:
- Result = Pushkeys.expect(["(yes/no)", "assword:", "PEXPECT]#",
- pexpect.EOF, pexpect.TIMEOUT])
- if(Result == 0):
- Pushkeys.sendline("yes")
- if(Result == 1):
- Pushkeys.sendline(password)
- if(Result == 2):
- self.loginfo.log("ONOS Push keys Success!")
- break
- if(Result == 3):
- self.loginfo.log("ONOS Push keys Error!")
- break
- time.sleep(2)
- Pushkeys.prompt()
- self.logger.info("Done!")
-
- def SetOnosEnvVar(self, handle, masterpass, agentpass):
- """
- Setup onos pushkeys to all devices(3+2)
- parameters:
- handle(input): current working handle
- masterpass: scripts running server's password
- agentpass: onos cluster&compute node password
- """
- self.logger.info("Now Setting test environment")
- for host in self.hosts:
- self.logger.info("try to connect " + str(host))
- result = self.CheckSshNoPasswd(host)
- if not result:
- 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)
- self.OnosPushKeys(handle, "onos-push-keys " + self.OC2, agentpass)
- self.OnosPushKeys(handle, "onos-push-keys " + self.OC3, agentpass)
- self.OnosPushKeys(handle, "onos-push-keys " + self.OCN, agentpass)
- self.OnosPushKeys(handle, "onos-push-keys " + self.OCN2, agentpass)
-
- def CheckSshNoPasswd(self, host):
- """
- Check master can connect agent with no password
- """
- login = pexpect.spawn("ssh " + str(host))
- index = 4
- while index == 4:
- index = login.expect(['(yes/no)', '>|#|\$',
- pexpect.EOF, pexpect.TIMEOUT])
- if index == 0:
- login.sendline("yes")
- index = 4
- if index == 1:
- self.loginfo.log("ssh connect to " + str(host) +
- " success,no need to copy ssh public key")
- return True
- login.interact()
- return False
-
- def ChangeOnosName(self, user, password):
- """
- Change onos name in envDefault file
- Because some command depend on this
- parameters:
- user: onos&compute node user
- password: onos&compute node 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
- for i in range(lenall):
- if "ONOS_USER=" in line[i]:
- line[i] = line[i].replace("sdn", user)
- if "ONOS_GROUP" in line[i]:
- line[i] = line[i].replace("sdn", user)
- if "ONOS_PWD" in line[i]:
- line[i] = line[i].replace("rocks", password)
- NewFile = open(filepath, 'w')
- NewFile.writelines(line)
- NewFile.close
- self.logger.info("Done!")
-
- def ChangeTestCasePara(self, testcase, user, password):
- """
- When running test script, there's something need \
- to change in every test folder's *.param & *.topo files
- user: onos&compute node user
- password: onos&compute node password
- """
- self.logger.info("Now Changing " + testcase + " name&password")
- if self.masterusername == 'root':
- filepath = '/root/'
- else:
- filepath = '/home/' + self.masterusername + '/'
- filepath = (filepath + "OnosSystemTest/TestON/tests/" +
- testcase + "/" + testcase + ".topo")
- line = open(filepath, 'r').readlines()
- lenall = len(line) - 1
- for i in range(lenall - 2):
- if("localhost" in line[i]) or ("OCT" in line[i]):
- line[i + 1] = re.sub(">\w+", ">" + user, line[i + 1])
- line[i + 2] = re.sub(">\w+", ">" + password, line[i + 2])
- if ("OC1" in line[i] or "OC2" in line[i] or "OC3" in line[i] or
- "OCN" in line[i] or "OCN2" in line[i]):
- line[i + 1] = re.sub(">\w+", ">root", line[i + 1])
- line[i + 2] = re.sub(">\w+", ">root", line[i + 2])
- NewFile = open(filepath, 'w')
- NewFile.writelines(line)
- NewFile.close
-
- def SSHlogin(self, ipaddr, username, password):
- """
- SSH login provide a connection to destination.
- parameters:
- ipaddr: ip address
- username: login user name
- password: login password
- return: handle
- """
- login = pxssh.pxssh()
- login.login(ipaddr, username, password, original_prompt='[$#>]')
- # send command ls -l
- login.sendline('ls -l')
- # match prompt
- login.prompt()
- self.logger.info("SSH login " + ipaddr + " success!")
- return login
-
- def SSHRelease(self, handle):
- # Release ssh
- handle.logout()
-
- def CopyOnostoTestbin(self):
- sourcefile = self.cipath + '/dependencies/onos'
- destifile = self.home + '/onos/tools/test/bin/'
- os.system('pwd')
- runcommand = 'cp ' + sourcefile + ' ' + destifile
- os.system(runcommand)
-
- def CopyPublicKey(self, host):
- output = os.popen('cat /root/.ssh/id_rsa.pub')
- publickey = output.read().strip('\n')
- tmphandle = self.SSHlogin(self.installer_master,
- self.installer_master_username,
- self.installer_master_password)
- tmphandle.sendline("ssh " + host + " -T \'echo " +
- str(publickey) + ">>/root/.ssh/authorized_keys\'")
- tmphandle.prompt()
- self.SSHRelease(tmphandle)
- self.logger.info("Add OCT PublicKey to " + host + " success")
-
- def OnosEnvSetup(self, handle):
- """
- Onos Environment Setup function
- """
- self.Gensshkey(handle)
- self.home = self.GetEnvValue(handle, 'HOME')
- self.AddKnownHost(handle, self.OC1, "karaf", "karaf")
- self.AddKnownHost(handle, self.OC2, "karaf", "karaf")
- self.AddKnownHost(handle, self.OC3, "karaf", "karaf")
- self.DownLoadCode(handle,
- 'https://github.com/wuwenbin2/OnosSystemTest.git')
- # self.DownLoadCode(handle, 'https://gerrit.onosproject.org/onos')
- if self.masterusername == 'root':
- filepath = '/root/'
- else:
- filepath = '/home/' + self.masterusername + '/'
- self.OnosRootPathChange(filepath)
- self.CopyOnostoTestbin()
- self.ChangeOnosName(self.agentusername, self.agentpassword)
- self.InstallDefaultSoftware(handle)
- self.SetOnosEnvVar(handle, self.masterpassword, self.agentpassword)
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py b/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py
deleted file mode 100644
index 6f7a40ff..00000000
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/adapters/foundation.py
+++ /dev/null
@@ -1,93 +0,0 @@
-"""
-Description:
- This file include basis functions
- 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 datetime
-import logging
-import os
-import re
-import time
-
-import functest.utils.functest_constants as ft_constants
-import functest.utils.functest_utils as ft_utils
-
-
-class foundation:
-
- def __init__(self):
-
- # currentpath = os.getcwd()
- currentpath = \
- ft_constants.FUNCTEST_TEST_DIR + '/Controllers/ONOS/Teston/CI'
- self.cipath = currentpath
- self.logdir = os.path.join(currentpath, 'log')
- self.workhome = currentpath[0: currentpath.rfind('opnfv_tests') - 1]
- self.Result_DB = ''
- filename = time.strftime('%Y-%m-%d-%H-%M-%S') + '.log'
- self.logfilepath = os.path.join(self.logdir, filename)
- self.starttime = datetime.datetime.now()
-
- def log(self, loginfo):
- """
- Record log in log directory for deploying test environment
- parameters:
- loginfo(input): record info
- """
- logging.basicConfig(level=logging.INFO,
- format='%(asctime)s %(filename)s:%(message)s',
- datefmt='%d %b %Y %H:%M:%S',
- filename=self.logfilepath,
- filemode='w')
- filelog = logging.FileHandler(self.logfilepath)
- logging.getLogger('Functest').addHandler(filelog)
- logging.info(loginfo)
-
- def getdefaultpara(self):
- """
- Get Default Parameters value
- """
- self.Result_DB = str(ft_utils.get_db_url())
- self.masterusername = str(ft_constants.ONOSBENCH_USERNAME)
- self.masterpassword = str(ft_constants.ONOSBENCH_PASSWORD)
- self.agentusername = str(ft_constants.ONOSCLI_USERNAME)
- self.agentpassword = str(ft_constants.ONOSCLI_PASSWORD)
- self.runtimeout = ft_constants.ONOS_RUNTIMEOUT
- self.OCT = str(ft_constants.ONOS_OCT)
- self.OC1 = str(ft_constants.ONOS_OC1)
- self.OC2 = str(ft_constants.ONOS_OC2)
- self.OC3 = str(ft_constants.ONOS_OC3)
- self.OCN = str(ft_constants.ONOS_OCN)
- self.OCN2 = str(ft_constants.ONOS_OCN2)
- self.installer_master = str(ft_constants.ONOS_INSTALLER_MASTER)
- self.installer_master_username = \
- str(ft_constants.ONOS_INSTALLER_MASTER_USERNAME)
- self.installer_master_password = \
- ft_constants.ONOS_INSTALLER_MASTER_PASSWORD
- self.hosts = [self.OC1, self.OCN, self.OCN2]
- self.localhost = self.OCT
-
- def GetResult(self):
- cmd = "cat " + self.logfilepath + " | grep Fail"
- Resultbuffer = os.popen(cmd).read()
- duration = datetime.datetime.now() - self.starttime
- time.sleep(2)
-
- if re.search("[1-9]+", Resultbuffer):
- self.log("Testcase Fails\n" + Resultbuffer)
- Result = "POK"
- else:
- self.log("Testcases Pass")
- Result = "OK"
- payload = {'timestart': str(self.starttime),
- 'duration': str(duration), 'status': Result}
-
- return payload
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/dependencies/onos b/functest/opnfv_tests/Controllers/ONOS/Teston/dependencies/onos
deleted file mode 100644
index bb02fa89..00000000
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/dependencies/onos
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# ONOS remote command-line client.
-# -----------------------------------------------------------------------------
-#
-# 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
-#
-
-[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
-. /root/.bashrc
-. $ONOS_ROOT/tools/build/envDefaults
-. $ONOS_ROOT/tools/test/bin/find-node.sh
-
-[ "$1" = "-w" ] && shift && onos-wait-for-start $1
-
-[ -n "$1" ] && OCI=$(find_node $1) && shift
-
-if which client 1>/dev/null 2>&1 && [ -z "$ONOS_USE_SSH" ]; then
- # Use Karaf client only if we can and are allowed to
- unset KARAF_HOME
- client -h $OCI -u karaf "$@" 2>/dev/null
-else
- # Otherwise use raw ssh; strict checking is off for dev environments only
- #ssh -p 8101 -o StrictHostKeyChecking=no $OCI "$@"
- sshpass -p karaf ssh -l karaf -p 8101 $OCI "$@"
-fi
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/log/gitignore b/functest/opnfv_tests/Controllers/ONOS/Teston/log/gitignore
deleted file mode 100644
index e69de29b..00000000
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/log/gitignore
+++ /dev/null
diff --git a/functest/opnfv_tests/Controllers/ONOS/Teston/onosfunctest.py b/functest/opnfv_tests/Controllers/ONOS/Teston/onosfunctest.py
deleted file mode 100755
index 300f56d1..00000000
--- a/functest/opnfv_tests/Controllers/ONOS/Teston/onosfunctest.py
+++ /dev/null
@@ -1,261 +0,0 @@
-"""
-Description: This test is to run onos Teston VTN scripts
-
-List of test cases:
-CASE1 - Northbound NBI test network/subnet/ports
-CASE2 - Ovsdb test&Default configuration&Vm go online
-
-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 datetime
-import os
-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 ft_utils
-import functest.utils.openstack_utils as openstack_utils
-import functest.utils.functest_constants as ft_constants
-
-
-parser = argparse.ArgumentParser()
-parser.add_argument("-t", "--testcase", help="Testcase name")
-args = parser.parse_args()
-
-
-""" logging configuration """
-logger = ft_logger.Logger("onos").getLogger()
-
-# onos parameters
-ONOSCI_PATH = ft_constants.REPOS_DIR + "/"
-starttime = datetime.datetime.now()
-
-INSTALLER_TYPE = ft_constants.CI_INSTALLER_TYPE
-ONOS_SFC_IMAGE_NAME = ft_constants.ONOS_SFC_IMAGE_NAME
-ONOS_SFC_IMAGE_PATH = os.path.join(ft_constants.FUNCTEST_DATA_DIR,
- ft_constants.ONOS_SFC_IMAGE_FILENAME)
-ONOS_SFC_PATH = os.path.join(ft_constants.FUNCTEST_REPO_DIR,
- ft_constants.ONOS_SFC_RELATIVE_PATH)
-
-
-def RunScript(testname):
- """
- Run ONOS Test Script
- Parameters:
- testname: ONOS Testcase Name
- """
- runtest = ONOSCI_PATH + "onos/TestON/bin/cli.py run " + testname
- logger.debug("Run script " + testname)
- os.system(runtest)
-
-
-def DownloadCodes(url="https://github.com/wuwenbin2/OnosSystemTest.git"):
- """
- Download Onos Teston codes
- Parameters:
- url: github url
- """
- downloadcode = "git clone " + url + " " + ONOSCI_PATH + "OnosSystemTest"
- logger.debug("Download Onos Teston codes " + url)
- os.system(downloadcode)
-
-
-def GetResult():
- LOGPATH = ONOSCI_PATH + "onos/TestON/logs"
- cmd = "grep -rnh " + "Fail" + " " + LOGPATH
- Resultbuffer = os.popen(cmd).read()
- # duration = datetime.datetime.now() - starttime
- time.sleep(2)
-
- if re.search("\s+[1-9]+\s+", Resultbuffer):
- logger.debug("Testcase Fails\n" + Resultbuffer)
- # Result = "Failed"
- else:
- logger.debug("Testcases Success")
- # Result = "Success"
- # payload={'timestart': str(starttime),
- # 'duration': str(duration),
- # 'status': Result}
- cmd = "grep -rnh 'Execution Time' " + LOGPATH
- Resultbuffer = os.popen(cmd).read()
- time1 = Resultbuffer[114:128]
- time2 = Resultbuffer[28:42]
- cmd = "grep -rnh 'Success Percentage' " + LOGPATH + "/FUNCvirNetNB_*"
- Resultbuffer = os.popen(cmd).read()
- if Resultbuffer.find('100%') >= 0:
- result1 = 'Success'
- else:
- result1 = 'Failed'
- cmd = "grep -rnh 'Success Percentage' " + LOGPATH + "/FUNCvirNetNBL3*"
- Resultbuffer = os.popen(cmd).read()
- if Resultbuffer.find('100%') >= 0:
- result2 = 'Success'
- else:
- result2 = 'Failed'
- status1 = []
- status2 = []
- cmd = "grep -rnh 'h3' " + LOGPATH + "/FUNCvirNetNB_*"
- Resultbuffer = os.popen(cmd).read()
- pattern = re.compile("<h3>([^-]+) - ([^-]+) - (\S*)</h3>")
- # res = pattern.search(Resultbuffer).groups()
- res = pattern.findall(Resultbuffer)
- i = 0
- for index in range(len(res)):
- status1.append({'Case name:': res[i][0] + res[i][1],
- 'Case result': res[i][2]})
- i = i + 1
- cmd = "grep -rnh 'h3' " + LOGPATH + "/FUNCvirNetNBL3*"
- Resultbuffer = os.popen(cmd).read()
- pattern = re.compile("<h3>([^-]+) - ([^-]+) - (\S*)</h3>")
- # res = pattern.search(Resultbuffer).groups()
- res = pattern.findall(Resultbuffer)
- i = 0
- for index in range(len(res)):
- status2.append({'Case name:': res[i][0] + res[i][1],
- 'Case result': res[i][2]})
- i = i + 1
- payload = {'timestart': str(starttime),
- 'FUNCvirNet': {'duration': time1,
- 'result': result1,
- 'status': status1},
- 'FUNCvirNetL3': {'duration': time2,
- 'result': result2,
- 'status': status2}}
- return payload
-
-
-def SetOnosIp():
- cmd = "openstack catalog show network | grep publicURL"
- cmd_output = os.popen(cmd).read()
- OC1 = re.search(r"\d+\.\d+\.\d+\.\d+", cmd_output).group()
- os.environ['OC1'] = OC1
- time.sleep(2)
- logger.debug("ONOS IP is " + OC1)
-
-
-def SetOnosIpForJoid():
- cmd = "env | grep SDN_CONTROLLER"
- cmd_output = os.popen(cmd).read()
- OC1 = re.search(r"\d+\.\d+\.\d+\.\d+", cmd_output).group()
- os.environ['OC1'] = OC1
- time.sleep(2)
- logger.debug("ONOS IP is " + OC1)
-
-
-def CleanOnosTest():
- TESTONPATH = ONOSCI_PATH + "onos/"
- cmd = "rm -rf " + TESTONPATH
- os.system(cmd)
- time.sleep(2)
- logger.debug("Clean ONOS Teston")
-
-
-def CreateImage():
- glance_client = openstack_utils.get_glance_client()
- image_id = openstack_utils.create_glance_image(glance_client,
- ONOS_SFC_IMAGE_NAME,
- ONOS_SFC_IMAGE_PATH)
- EXIT_CODE = -1
- if not image_id:
- logger.error("Failed to create a Glance image...")
- return(EXIT_CODE)
- logger.debug("Image '%s' with ID=%s created successfully."
- % (ONOS_SFC_IMAGE_NAME, image_id))
-
-
-def SfcTest():
- cmd = "python " + ONOS_SFC_PATH + "/Sfc.py"
- logger.debug("Run sfc tests")
- os.system(cmd)
-
-
-def GetIp(type):
- cmd = "openstack catalog show " + type + " | grep publicURL"
- cmd_output = os.popen(cmd).read()
- ip = re.search(r"\d+\.\d+\.\d+\.\d+", cmd_output).group()
- return ip
-
-
-def Replace(before, after):
- file = "/Sfc_fun.py"
- cmd = "sed -i 's/" + before + "/" + after + "/g' " + ONOS_SFC_PATH + file
- os.system(cmd)
-
-
-def SetSfcConf():
- Replace("keystone_ip", GetIp("keystone"))
- Replace("neutron_ip", GetIp("neutron"))
- Replace("nova_ip", GetIp("nova"))
- Replace("glance_ip", GetIp("glance"))
- pwd = ft_constants.OS_PASSWORD
- Replace("console", pwd)
- creds_neutron = openstack_utils.get_credentials("neutron")
- neutron_client = neutronclient.Client(**creds_neutron)
- ext_net = openstack_utils.get_external_net(neutron_client)
- Replace("admin_floating_net", ext_net)
- logger.info("Modify configuration for SFC")
-
-
-def OnosTest():
- start_time = time.time()
- stop_time = start_time
- if INSTALLER_TYPE == "joid":
- logger.debug("Installer is Joid")
- SetOnosIpForJoid()
- else:
- SetOnosIp()
- RunScript("FUNCvirNetNB")
- RunScript("FUNCvirNetNBL3")
- try:
- logger.debug("Push ONOS results into DB")
- # TODO check path result for the file
- result = GetResult()
- stop_time = time.time()
-
- # ONOS success criteria = all tests OK
- # i.e. FUNCvirNet & FUNCvirNetL3
- status = "FAIL"
- try:
- if (result['FUNCvirNet']['result'] == "Success" and
- result['FUNCvirNetL3']['result'] == "Success"):
- status = "PASS"
- except:
- logger.error("Unable to set ONOS criteria")
-
- ft_utils.push_results_to_db("functest",
- "onos",
- start_time,
- stop_time,
- status,
- result)
-
- except:
- logger.error("Error pushing results into Database")
-
- if status == "FAIL":
- EXIT_CODE = -1
- exit(EXIT_CODE)
-
-
-def main():
-
- if args.testcase == "sfc":
- CreateImage()
- SetSfcConf()
- SfcTest()
- else:
- OnosTest()
-
-
-if __name__ == '__main__':
- main()