feat(ci): adding push / pull images operations to/from a local registry
Signed-off-by: Raphael Defosseux <raphael.defosseux@eurecom.fr>
This commit is contained in:
@@ -208,6 +208,7 @@ class Containerize():
|
||||
self.imageToCopy = ''
|
||||
self.registrySvrId = ''
|
||||
self.testSvrId = ''
|
||||
self.imageToPull = []
|
||||
|
||||
#checkers from xml
|
||||
self.ran_checkers={}
|
||||
@@ -616,6 +617,148 @@ class Containerize():
|
||||
HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
|
||||
return True
|
||||
|
||||
def ImageTagToUse(self, imageName):
|
||||
shortCommit = self.ranCommitID[0:8]
|
||||
if self.ranAllowMerge:
|
||||
tagToUse = f'{self.ranBranch}-{shortCommit}'
|
||||
else:
|
||||
tagToUse = f'develop-{shortCommit}'
|
||||
fullTag = f'porcepix.sboai.cs.eurecom.fr/{imageName}:{tagToUse}'
|
||||
return fullTag
|
||||
|
||||
def Push_Image_to_Local_Registry(self, HTML):
|
||||
if self.registrySvrId == '0':
|
||||
lIpAddr = self.eNBIPAddress
|
||||
lUserName = self.eNBUserName
|
||||
lPassWord = self.eNBPassword
|
||||
lSourcePath = self.eNBSourceCodePath
|
||||
elif self.registrySvrId == '1':
|
||||
lIpAddr = self.eNB1IPAddress
|
||||
lUserName = self.eNB1UserName
|
||||
lPassWord = self.eNB1Password
|
||||
lSourcePath = self.eNB1SourceCodePath
|
||||
elif self.registrySvrId == '2':
|
||||
lIpAddr = self.eNB2IPAddress
|
||||
lUserName = self.eNB2UserName
|
||||
lPassWord = self.eNB2Password
|
||||
lSourcePath = self.eNB2SourceCodePath
|
||||
if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '':
|
||||
HELP.GenericHelp(CONST.Version)
|
||||
sys.exit('Insufficient Parameter')
|
||||
logging.debug('Pushing images from server: ' + lIpAddr)
|
||||
mySSH = SSH.SSHConnection()
|
||||
mySSH.open(lIpAddr, lUserName, lPassWord)
|
||||
|
||||
mySSH.command('echo oaicicd | docker login --password-stdin -u oaicicd porcepix.sboai.cs.eurecom.fr', '\$', 5)
|
||||
if re.search('Login Succeeded', mySSH.getBefore()) is None:
|
||||
logging.error('Could not log into local registry')
|
||||
return False
|
||||
|
||||
orgTag = 'develop'
|
||||
if self.ranAllowMerge:
|
||||
orgTag = 'ci-temp'
|
||||
imageNames = ['oai-enb', 'oai-gnb', 'oai-lte-ue', 'oai-nr-ue', 'oai-lte-ru']
|
||||
for image in imageNames:
|
||||
tagToUse = self.ImageTagToUse(image)
|
||||
mySSH.command(f'docker image tag {image}:{orgTag} {tagToUse}', '\$', 5)
|
||||
mySSH.command(f'docker push {tagToUse}', '\$', 120)
|
||||
if re.search(': digest:', mySSH.getBefore()) is None:
|
||||
logging.debug(mySSH.getBefore())
|
||||
logging.error(f'Could not push {image} to local registry : {tagToUse}')
|
||||
return False
|
||||
mySSH.command(f'docker rmi {tagToUse}', '\$', 5)
|
||||
|
||||
mySSH.command('docker logout porcepix.sboai.cs.eurecom.fr', '\$', 5)
|
||||
if re.search('Removing login credentials', mySSH.getBefore()) is None:
|
||||
logging.error('Could not log off from local registry')
|
||||
return False
|
||||
|
||||
mySSH.close()
|
||||
return True
|
||||
|
||||
def Pull_Image_from_Local_Registry(self, HTML):
|
||||
if self.testSvrId == '0':
|
||||
lIpAddr = self.eNBIPAddress
|
||||
lUserName = self.eNBUserName
|
||||
lPassWord = self.eNBPassword
|
||||
lSourcePath = self.eNBSourceCodePath
|
||||
elif self.testSvrId == '1':
|
||||
lIpAddr = self.eNB1IPAddress
|
||||
lUserName = self.eNB1UserName
|
||||
lPassWord = self.eNB1Password
|
||||
lSourcePath = self.eNB1SourceCodePath
|
||||
elif self.testSvrId == '2':
|
||||
lIpAddr = self.eNB2IPAddress
|
||||
lUserName = self.eNB2UserName
|
||||
lPassWord = self.eNB2Password
|
||||
lSourcePath = self.eNB2SourceCodePath
|
||||
if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '':
|
||||
HELP.GenericHelp(CONST.Version)
|
||||
sys.exit('Insufficient Parameter')
|
||||
logging.debug('Pulling images onto server: ' + lIpAddr)
|
||||
mySSH = SSH.SSHConnection()
|
||||
mySSH.open(lIpAddr, lUserName, lPassWord)
|
||||
|
||||
mySSH.command('echo oaicicd | docker login --password-stdin -u oaicicd porcepix.sboai.cs.eurecom.fr', '\$', 5)
|
||||
if re.search('Login Succeeded', mySSH.getBefore()) is None:
|
||||
logging.error('Could not log into local registry')
|
||||
return False
|
||||
|
||||
orgTag = 'develop'
|
||||
if self.ranAllowMerge:
|
||||
orgTag = 'ci-temp'
|
||||
|
||||
for image in self.imageToPull:
|
||||
tagToUse = self.ImageTagToUse(image)
|
||||
mySSH.command(f'docker pull {tagToUse}', '\$', 120)
|
||||
if re.search('Status: Downloaded newer image for |Status: Image is up to date for', mySSH.getBefore()) is None:
|
||||
logging.debug(mySSH.getBefore())
|
||||
logging.error(f'Could not pull {image} from local registry : {tagToUse}')
|
||||
return False
|
||||
|
||||
mySSH.command('docker logout porcepix.sboai.cs.eurecom.fr', '\$', 5)
|
||||
if re.search('Removing login credentials', mySSH.getBefore()) is None:
|
||||
logging.error('Could not log off from local registry')
|
||||
return False
|
||||
|
||||
mySSH.close()
|
||||
return True
|
||||
|
||||
def Clean_Test_Server_Images(self, HTML):
|
||||
if self.testSvrId == '0':
|
||||
lIpAddr = self.eNBIPAddress
|
||||
lUserName = self.eNBUserName
|
||||
lPassWord = self.eNBPassword
|
||||
lSourcePath = self.eNBSourceCodePath
|
||||
elif self.testSvrId == '1':
|
||||
lIpAddr = self.eNB1IPAddress
|
||||
lUserName = self.eNB1UserName
|
||||
lPassWord = self.eNB1Password
|
||||
lSourcePath = self.eNB1SourceCodePath
|
||||
elif self.testSvrId == '2':
|
||||
lIpAddr = self.eNB2IPAddress
|
||||
lUserName = self.eNB2UserName
|
||||
lPassWord = self.eNB2Password
|
||||
lSourcePath = self.eNB2SourceCodePath
|
||||
if lIpAddr == '' or lUserName == '' or lPassWord == '' or lSourcePath == '':
|
||||
HELP.GenericHelp(CONST.Version)
|
||||
sys.exit('Insufficient Parameter')
|
||||
logging.debug('Removing test images from server: ' + lIpAddr)
|
||||
mySSH = SSH.SSHConnection()
|
||||
mySSH.open(lIpAddr, lUserName, lPassWord)
|
||||
|
||||
orgTag = 'develop'
|
||||
if self.ranAllowMerge:
|
||||
orgTag = 'ci-temp'
|
||||
tagToUse = self.ImageTagToUse(self.imageToPull)
|
||||
imageNames = ['oai-enb', 'oai-gnb', 'oai-lte-ue', 'oai-nr-ue', 'oai-lte-ru']
|
||||
for image in imageNames:
|
||||
tagToUse = self.ImageTagToUse(image)
|
||||
mySSH.command(f'docker rmi {tagToUse} || true', '\$', 5)
|
||||
|
||||
mySSH.close()
|
||||
return True
|
||||
|
||||
def DeployObject(self, HTML, EPC):
|
||||
if self.eNB_serverId[self.eNB_instance] == '0':
|
||||
lIpAddr = self.eNBIPAddress
|
||||
|
||||
@@ -35,11 +35,6 @@ import re
|
||||
import subprocess
|
||||
import sshconnection
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
format="[%(asctime)s] %(name)s:%(levelname)s: %(message)s"
|
||||
)
|
||||
|
||||
class Log_Mgt:
|
||||
|
||||
def __init__(self,Username, IPAddress,Password,Path):
|
||||
|
||||
@@ -102,9 +102,9 @@ class HTMLManagement():
|
||||
|
||||
def CreateHtmlHeader(self, ADBIPAddress):
|
||||
if (not self.htmlHeaderCreated):
|
||||
logging.debug('\u001B[1m----------------------------------------\u001B[0m')
|
||||
logging.debug('\u001B[1m Creating HTML header \u001B[0m')
|
||||
logging.debug('\u001B[1m----------------------------------------\u001B[0m')
|
||||
logging.info('\u001B[1m----------------------------------------\u001B[0m')
|
||||
logging.info('\u001B[1m Creating HTML header \u001B[0m')
|
||||
logging.info('\u001B[1m----------------------------------------\u001B[0m')
|
||||
self.htmlFile = open('test_results.html', 'w')
|
||||
self.htmlFile.write('<!DOCTYPE html>\n')
|
||||
self.htmlFile.write('<html class="no-js" lang="en-US">\n')
|
||||
|
||||
@@ -44,10 +44,6 @@ import datetime
|
||||
import signal
|
||||
import statistics as stat
|
||||
from multiprocessing import Process, Lock, SimpleQueue
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
format="[%(asctime)s] %(name)s:%(levelname)s: %(message)s"
|
||||
)
|
||||
|
||||
#import our libs
|
||||
import helpreadme as HELP
|
||||
@@ -3937,7 +3933,7 @@ class OaiCiTest():
|
||||
sys.exit(1)
|
||||
|
||||
def ShowTestID(self):
|
||||
logging.debug('\u001B[1m----------------------------------------\u001B[0m')
|
||||
logging.debug('\u001B[1mTest ID:' + self.testCase_id + '\u001B[0m')
|
||||
logging.debug('\u001B[1m' + self.desc + '\u001B[0m')
|
||||
logging.debug('\u001B[1m----------------------------------------\u001B[0m')
|
||||
logging.info('\u001B[1m----------------------------------------\u001B[0m')
|
||||
logging.info('\u001B[1mTest ID:' + self.testCase_id + '\u001B[0m')
|
||||
logging.info('\u001B[1m' + self.desc + '\u001B[0m')
|
||||
logging.info('\u001B[1m----------------------------------------\u001B[0m')
|
||||
|
||||
+55
-22
@@ -70,7 +70,7 @@ import subprocess
|
||||
from multiprocessing import Process, Lock, SimpleQueue
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
format="[%(asctime)s] %(name)s:%(levelname)s: %(message)s"
|
||||
format="[%(asctime)s] %(levelname)8s: %(message)s"
|
||||
)
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ logging.basicConfig(
|
||||
|
||||
def CheckClassValidity(xml_class_list,action,id):
|
||||
if action not in xml_class_list:
|
||||
logging.debug('ERROR: test-case ' + id + ' has unlisted class ' + action + ' ##CHECK xml_class_list.yml')
|
||||
logging.error('test-case ' + id + ' has unlisted class ' + action + ' ##CHECK xml_class_list.yml')
|
||||
resp=False
|
||||
else:
|
||||
resp=True
|
||||
@@ -328,14 +328,14 @@ def GetParametersFromXML(action):
|
||||
CiTestObj.iperf_profile = 'balanced'
|
||||
else:
|
||||
if CiTestObj.iperf_profile != 'balanced' and CiTestObj.iperf_profile != 'unbalanced' and CiTestObj.iperf_profile != 'single-ue':
|
||||
logging.debug('ERROR: test-case has wrong profile ' + CiTestObj.iperf_profile)
|
||||
logging.error('test-case has wrong profile ' + CiTestObj.iperf_profile)
|
||||
CiTestObj.iperf_profile = 'balanced'
|
||||
CiTestObj.iperf_options = test.findtext('iperf_options')
|
||||
if (CiTestObj.iperf_options is None):
|
||||
CiTestObj.iperf_options = 'check'
|
||||
else:
|
||||
if CiTestObj.iperf_options != 'check' and CiTestObj.iperf_options != 'sink':
|
||||
logging.debug('ERROR: test-case has wrong option ' + CiTestObj.iperf_options)
|
||||
logging.error('test-case has wrong option ' + CiTestObj.iperf_options)
|
||||
CiTestObj.iperf_options = 'check'
|
||||
|
||||
elif action == 'IdleSleep':
|
||||
@@ -464,8 +464,27 @@ def GetParametersFromXML(action):
|
||||
elif action == 'Cppcheck_Analysis':
|
||||
pass
|
||||
|
||||
elif action == 'Push_Local_Registry':
|
||||
string_field = test.findtext('registry_svr_id')
|
||||
if (string_field is not None):
|
||||
CONTAINERS.registrySvrId = string_field
|
||||
|
||||
elif action == 'Pull_Local_Registry':
|
||||
string_field = test.findtext('test_svr_id')
|
||||
if (string_field is not None):
|
||||
CONTAINERS.testSvrId = string_field
|
||||
for image in test.findall('image_to_pull'):
|
||||
string_field = image.findtext('image_name')
|
||||
if (string_field is not None):
|
||||
CONTAINERS.imageToPull.append(string_field)
|
||||
|
||||
elif action == 'Clean_Test_Server_Images':
|
||||
string_field = test.findtext('test_svr_id')
|
||||
if (string_field is not None):
|
||||
CONTAINERS.testSvrId = string_field
|
||||
|
||||
else:
|
||||
logging.error(f"unknown action {action}")
|
||||
logging.warning(f"unknown action {action} from option-parsing point-of-view")
|
||||
|
||||
|
||||
#check if given test is in list
|
||||
@@ -617,7 +636,7 @@ elif re.match('^LogCollecteNB$', mode, re.IGNORECASE):
|
||||
sys.exit('Insufficient Parameter')
|
||||
if RAN.eNBIPAddress == 'none':
|
||||
cmd = 'zip -r enb.log.' + RAN.BuildId + '.zip cmake_targets/log'
|
||||
logging.debug(cmd)
|
||||
logging.info(cmd)
|
||||
zipStatus = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True, timeout=60)
|
||||
sys.exit(0)
|
||||
RAN.LogCollecteNB()
|
||||
@@ -683,17 +702,17 @@ elif re.match('^InitiateHtml$', mode, re.IGNORECASE):
|
||||
HTML.htmlNb_CATM_Modules=len(CiTestObj.CatMDevices)
|
||||
HTML.CreateHtmlHeader(CiTestObj.ADBIPAddress)
|
||||
elif re.match('^FinalizeHtml$', mode, re.IGNORECASE):
|
||||
logging.debug('\u001B[1m----------------------------------------\u001B[0m')
|
||||
logging.debug('\u001B[1m Creating HTML footer \u001B[0m')
|
||||
logging.debug('\u001B[1m----------------------------------------\u001B[0m')
|
||||
logging.info('\u001B[1m----------------------------------------\u001B[0m')
|
||||
logging.info('\u001B[1m Creating HTML footer \u001B[0m')
|
||||
logging.info('\u001B[1m----------------------------------------\u001B[0m')
|
||||
|
||||
CiTestObj.RetrieveSystemVersion('eNB',HTML,RAN)
|
||||
CiTestObj.RetrieveSystemVersion('UE',HTML,RAN)
|
||||
HTML.CreateHtmlFooter(CiTestObj.finalStatus)
|
||||
elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re.IGNORECASE):
|
||||
logging.debug('\u001B[1m----------------------------------------\u001B[0m')
|
||||
logging.debug('\u001B[1m Starting Scenario: ' + CiTestObj.testXMLfiles[0] + '\u001B[0m')
|
||||
logging.debug('\u001B[1m----------------------------------------\u001B[0m')
|
||||
logging.info('\u001B[1m----------------------------------------\u001B[0m')
|
||||
logging.info('\u001B[1m Starting Scenario: ' + CiTestObj.testXMLfiles[0] + '\u001B[0m')
|
||||
logging.info('\u001B[1m----------------------------------------\u001B[0m')
|
||||
if re.match('^TesteNB$', mode, re.IGNORECASE):
|
||||
if RAN.eNBIPAddress == '' or RAN.ranRepository == '' or RAN.ranBranch == '' or RAN.eNBUserName == '' or RAN.eNBPassword == '' or RAN.eNBSourceCodePath == '' or EPC.IPAddress == '' or EPC.UserName == '' or EPC.Password == '' or EPC.Type == '' or EPC.SourceCodePath == '' or CiTestObj.ADBIPAddress == '' or CiTestObj.ADBUserName == '' or CiTestObj.ADBPassword == '':
|
||||
HELP.GenericHelp(CONST.Version)
|
||||
@@ -736,7 +755,7 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
|
||||
HTML.testUnstable = True
|
||||
CiTestObj.testMinStableId = xmlRoot.findtext('TestMinId',default='999999')
|
||||
HTML.testMinStableId = CiTestObj.testMinStableId
|
||||
logging.debug('Test is tagged as Unstable -- starting from TestID ' + str(CiTestObj.testMinStableId))
|
||||
logging.warning('Test is tagged as Unstable -- starting from TestID ' + str(CiTestObj.testMinStableId))
|
||||
all_tests=xmlRoot.findall('testCase')
|
||||
|
||||
exclusion_tests=exclusion_tests.split()
|
||||
@@ -747,10 +766,10 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
|
||||
for test in exclusion_tests:
|
||||
if (not re.match('^[0-9]{6}$', test) and
|
||||
not re.match('^[0-9]{1,5}\+$', test)):
|
||||
logging.debug('ERROR: exclusion test is invalidly formatted: ' + test)
|
||||
logging.error('exclusion test is invalidly formatted: ' + test)
|
||||
sys.exit(1)
|
||||
else:
|
||||
logging.debug(test)
|
||||
logging.info(test)
|
||||
|
||||
#check that requested tests are well formatted
|
||||
#(6 digits or less than 6 digits followed by +)
|
||||
@@ -758,9 +777,9 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
|
||||
for test in requested_tests:
|
||||
if (re.match('^[0-9]{6}$', test) or
|
||||
re.match('^[0-9]{1,5}\+$', test)):
|
||||
logging.debug('INFO: test group/case requested: ' + test)
|
||||
logging.info('test group/case requested: ' + test)
|
||||
else:
|
||||
logging.debug('ERROR: requested test is invalidly formatted: ' + test)
|
||||
logging.error('requested test is invalidly formatted: ' + test)
|
||||
sys.exit(1)
|
||||
if (EPC.IPAddress != '') and (EPC.IPAddress != 'none'):
|
||||
CiTestObj.CheckFlexranCtrlInstallation(RAN,EPC,CONTAINERS)
|
||||
@@ -771,9 +790,9 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
|
||||
todo_tests=[]
|
||||
for test in requested_tests:
|
||||
if (test_in_list(test, exclusion_tests)):
|
||||
logging.debug('INFO: test will be skipped: ' + test)
|
||||
logging.info('test will be skipped: ' + test)
|
||||
else:
|
||||
#logging.debug('INFO: test will be run: ' + test)
|
||||
#logging.info('test will be run: ' + test)
|
||||
todo_tests.append(test)
|
||||
|
||||
signal.signal(signal.SIGUSR1, receive_signal)
|
||||
@@ -941,6 +960,18 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
|
||||
success = CONTAINERS.Copy_Image_to_Test_Server(HTML)
|
||||
if not success:
|
||||
RAN.prematureExit = True
|
||||
elif action == 'Push_Local_Registry':
|
||||
success = CONTAINERS.Push_Image_to_Local_Registry(HTML)
|
||||
if not success:
|
||||
RAN.prematureExit = True
|
||||
elif action == 'Pull_Local_Registry':
|
||||
success = CONTAINERS.Pull_Image_from_Local_Registry(HTML)
|
||||
if not success:
|
||||
RAN.prematureExit = True
|
||||
elif action == 'Clean_Test_Server_Images':
|
||||
success = CONTAINERS.Clean_Test_Server_Images(HTML)
|
||||
if not success:
|
||||
RAN.prematureExit = True
|
||||
elif action == 'Deploy_Object':
|
||||
CONTAINERS.DeployObject(HTML, EPC)
|
||||
if CONTAINERS.exitStatus==1:
|
||||
@@ -973,19 +1004,21 @@ elif re.match('^TesteNB$', mode, re.IGNORECASE) or re.match('^TestUE$', mode, re
|
||||
RAN.prematureExit = True
|
||||
elif action == 'StatsFromGenObject':
|
||||
CONTAINERS.StatsFromGenObject(HTML)
|
||||
elif action == 'Push_Images_To_Test_Servers':
|
||||
logging.debug('To be implemented')
|
||||
else:
|
||||
sys.exit('Invalid class (action) from xml')
|
||||
if RAN.prematureExit:
|
||||
if CiTestObj.testCase_id == CiTestObj.testMinStableId:
|
||||
logging.debug('Scenario has reached minimal stability point')
|
||||
logging.warning('Scenario has reached minimal stability point')
|
||||
CiTestObj.testStabilityPointReached = True
|
||||
HTML.testStabilityPointReached = True
|
||||
CiTestObj.FailReportCnt += 1
|
||||
if CiTestObj.FailReportCnt == CiTestObj.repeatCounts[0] and RAN.prematureExit:
|
||||
logging.debug('Scenario failed ' + str(CiTestObj.FailReportCnt) + ' time(s)')
|
||||
logging.error('Scenario failed ' + str(CiTestObj.FailReportCnt) + ' time(s)')
|
||||
HTML.CreateHtmlTabFooter(False)
|
||||
if CiTestObj.testUnstable and (CiTestObj.testStabilityPointReached or CiTestObj.testMinStableId == '999999'):
|
||||
logging.debug('Scenario has reached minimal stability point -- Not a Failure')
|
||||
logging.warning('Scenario has reached minimal stability point -- Not a Failure')
|
||||
else:
|
||||
sys.exit('Failed Scenario')
|
||||
else:
|
||||
|
||||
+26
-26
@@ -74,7 +74,7 @@ class SSHConnection():
|
||||
count = 10
|
||||
connect_status = True
|
||||
else:
|
||||
logging.debug('self.sshresponse = ' + str(self.sshresponse))
|
||||
logging.warning('self.sshresponse = ' + str(self.sshresponse))
|
||||
elif self.sshresponse == 1:
|
||||
self.ssh.sendline(password)
|
||||
self.sshresponse = self.ssh.expect([prompt, 'Permission denied', 'password:', pexpect.EOF, pexpect.TIMEOUT])
|
||||
@@ -82,7 +82,7 @@ class SSHConnection():
|
||||
count = 10
|
||||
connect_status = True
|
||||
else:
|
||||
logging.debug('self.sshresponse = ' + str(self.sshresponse))
|
||||
logging.warning('self.sshresponse = ' + str(self.sshresponse))
|
||||
elif self.sshresponse == 2:
|
||||
# We directly ended up on the remote server because of pubkey auth
|
||||
count = 10
|
||||
@@ -91,8 +91,8 @@ class SSHConnection():
|
||||
self.sshresponse = self.ssh.expect([prompt])
|
||||
else:
|
||||
# debug output
|
||||
logging.debug(str(self.ssh.before))
|
||||
logging.debug('self.sshresponse = ' + str(self.sshresponse))
|
||||
logging.warning(str(self.ssh.before))
|
||||
logging.warning('self.sshresponse = ' + str(self.sshresponse))
|
||||
# adding a tempo when failure
|
||||
if not connect_status:
|
||||
time.sleep(1)
|
||||
@@ -108,7 +108,7 @@ class SSHConnection():
|
||||
|
||||
|
||||
def cde_check_value(self, commandline, expected, timeout):
|
||||
logging.debug(commandline)
|
||||
logging.info(commandline)
|
||||
self.ssh.timeout = timeout
|
||||
self.ssh.sendline(commandline)
|
||||
expected.append(pexpect.EOF)
|
||||
@@ -118,7 +118,7 @@ class SSHConnection():
|
||||
|
||||
def command(self, commandline, expectedline, timeout, silent=False, resync=False):
|
||||
if not silent:
|
||||
logging.debug(commandline)
|
||||
logging.info(commandline)
|
||||
self.ssh.timeout = timeout
|
||||
# Nasty patch when pexpect output is out of sync.
|
||||
# Much pronounced when running back-to-back-back oc commands
|
||||
@@ -133,27 +133,27 @@ class SSHConnection():
|
||||
if self.sshresponse == 0:
|
||||
return 0
|
||||
elif self.sshresponse == 1:
|
||||
logging.debug('\u001B[1;37;41m Unexpected EOF \u001B[0m')
|
||||
logging.debug('Expected Line : ' + expectedline)
|
||||
logging.debug(str(self.ssh.before))
|
||||
logging.error('\u001B[1;37;41m Unexpected EOF \u001B[0m')
|
||||
logging.error('Expected Line : ' + expectedline)
|
||||
logging.error(str(self.ssh.before))
|
||||
sys.exit(self.sshresponse)
|
||||
elif self.sshresponse == 2:
|
||||
logging.debug('\u001B[1;37;41m Unexpected TIMEOUT \u001B[0m')
|
||||
logging.debug('Expected Line : ' + expectedline)
|
||||
logging.error('\u001B[1;37;41m Unexpected TIMEOUT \u001B[0m')
|
||||
logging.error('Expected Line : ' + expectedline)
|
||||
result = re.search('ping |iperf |picocom', str(commandline))
|
||||
if result is None:
|
||||
logging.debug(str(self.ssh.before))
|
||||
logging.warning(str(self.ssh.before))
|
||||
sys.exit(self.sshresponse)
|
||||
else:
|
||||
return -1
|
||||
else:
|
||||
logging.debug('\u001B[1;37;41m Unexpected Others \u001B[0m')
|
||||
logging.debug('Expected Line : ' + expectedline)
|
||||
logging.error('\u001B[1;37;41m Unexpected Others \u001B[0m')
|
||||
logging.error('Expected Line : ' + expectedline)
|
||||
sys.exit(self.sshresponse)
|
||||
|
||||
def command2(self, commandline, timeout, silent=False):
|
||||
if not silent:
|
||||
logging.debug(commandline)
|
||||
logging.info(commandline)
|
||||
self.cmd2Results = ''
|
||||
noHistoryCmd = 'unset HISTFILE; ' + commandline
|
||||
myHost = self.username + '@' + self.ipaddress
|
||||
@@ -165,7 +165,7 @@ class SSHConnection():
|
||||
|
||||
def command3(self, commandline, timeout, silent=False):
|
||||
if not silent:
|
||||
logging.debug(commandline)
|
||||
logging.info(commandline)
|
||||
self.cmd2Results = ''
|
||||
noHistoryCmd = 'unset HISTFILE; ' + commandline
|
||||
myHost = self.username + '@' + self.ipaddress
|
||||
@@ -186,14 +186,14 @@ class SSHConnection():
|
||||
pass
|
||||
elif self.sshresponse == 1:
|
||||
if not self.picocom_closure:
|
||||
logging.debug('\u001B[1;37;41m Unexpected TIMEOUT during closing\u001B[0m')
|
||||
logging.warning('\u001B[1;37;41m Unexpected TIMEOUT during closing\u001B[0m')
|
||||
else:
|
||||
logging.debug('\u001B[1;37;41m Unexpected Others during closing\u001B[0m')
|
||||
logging.warning('\u001B[1;37;41m Unexpected Others during closing\u001B[0m')
|
||||
|
||||
def copyin(self, ipaddress, username, password, source, destination):
|
||||
count = 0
|
||||
copy_status = False
|
||||
logging.debug('scp -r '+ username + '@' + ipaddress + ':' + source + ' ' + destination)
|
||||
logging.info('scp -r '+ username + '@' + ipaddress + ':' + source + ' ' + destination)
|
||||
while count < 10:
|
||||
scp_spawn = pexpect.spawn('scp -r '+ username + '@' + ipaddress + ':' + source + ' ' + destination, timeout = 100)
|
||||
scp_response = scp_spawn.expect(['Are you sure you want to continue connecting (yes/no)?', 'password:', pexpect.EOF, pexpect.TIMEOUT])
|
||||
@@ -206,7 +206,7 @@ class SSHConnection():
|
||||
count = 10
|
||||
copy_status = True
|
||||
else:
|
||||
logging.debug('1 - scp_response = ' + str(scp_response))
|
||||
logging.warning('1 - scp_response = ' + str(scp_response))
|
||||
elif scp_response == 1:
|
||||
scp_spawn.sendline(password)
|
||||
scp_response = scp_spawn.expect(['\$', 'Permission denied', 'password:', pexpect.EOF, pexpect.TIMEOUT])
|
||||
@@ -214,12 +214,12 @@ class SSHConnection():
|
||||
count = 10
|
||||
copy_status = True
|
||||
else:
|
||||
logging.debug('2 - scp_response = ' + str(scp_response))
|
||||
logging.warning('2 - scp_response = ' + str(scp_response))
|
||||
elif scp_response == 2:
|
||||
count = 10
|
||||
copy_status = True
|
||||
else:
|
||||
logging.debug('3 - scp_response = ' + str(scp_response))
|
||||
logging.warning('3 - scp_response = ' + str(scp_response))
|
||||
# adding a tempo when failure
|
||||
if not copy_status:
|
||||
time.sleep(1)
|
||||
@@ -232,7 +232,7 @@ class SSHConnection():
|
||||
def copyout(self, ipaddress, username, password, source, destination):
|
||||
count = 0
|
||||
copy_status = False
|
||||
logging.debug('scp -r ' + source + ' ' + username + '@' + ipaddress + ':' + destination)
|
||||
logging.info('scp -r ' + source + ' ' + username + '@' + ipaddress + ':' + destination)
|
||||
while count < 4:
|
||||
scp_spawn = pexpect.spawn('scp -r ' + source + ' ' + username + '@' + ipaddress + ':' + destination, timeout = 100)
|
||||
scp_response = scp_spawn.expect(['Are you sure you want to continue connecting (yes/no)?', 'password:', pexpect.EOF, pexpect.TIMEOUT])
|
||||
@@ -245,7 +245,7 @@ class SSHConnection():
|
||||
count = 10
|
||||
copy_status = True
|
||||
else:
|
||||
logging.debug('1 - scp_response = ' + str(scp_response))
|
||||
logging.warning('1 - scp_response = ' + str(scp_response))
|
||||
elif scp_response == 1:
|
||||
scp_spawn.sendline(password)
|
||||
scp_response = scp_spawn.expect(['\$', 'Permission denied', 'password:', pexpect.EOF, pexpect.TIMEOUT])
|
||||
@@ -253,12 +253,12 @@ class SSHConnection():
|
||||
count = 10
|
||||
copy_status = True
|
||||
else:
|
||||
logging.debug('2 - scp_response = ' + str(scp_response))
|
||||
logging.warning('2 - scp_response = ' + str(scp_response))
|
||||
elif scp_response == 2:
|
||||
count = 10
|
||||
copy_status = True
|
||||
else:
|
||||
logging.debug('3 - scp_response = ' + str(scp_response))
|
||||
logging.warning('3 - scp_response = ' + str(scp_response))
|
||||
# adding a tempo when failure
|
||||
if not copy_status:
|
||||
time.sleep(1)
|
||||
|
||||
@@ -51,3 +51,6 @@
|
||||
- IperfFromContainer
|
||||
- StatsFromGenObject
|
||||
- LicenceAndFormattingCheck
|
||||
- Push_Local_Registry
|
||||
- Pull_Local_Registry
|
||||
- Clean_Test_Server_Images
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
<htmlTabIcon>wrench</htmlTabIcon>
|
||||
<TestCaseRequestedList>
|
||||
000001
|
||||
000010
|
||||
</TestCaseRequestedList>
|
||||
<TestCaseExclusionList></TestCaseExclusionList>
|
||||
|
||||
@@ -38,4 +39,10 @@
|
||||
<forced_workspace_cleanup>True</forced_workspace_cleanup>
|
||||
</testCase>
|
||||
|
||||
<testCase id="000010">
|
||||
<class>Push_Local_Registry</class>
|
||||
<desc>Push Images to Local Registry</desc>
|
||||
<registry_svr_id>0</registry_svr_id>
|
||||
</testCase>
|
||||
|
||||
</testCaseList>
|
||||
|
||||
Reference in New Issue
Block a user