Implement CreateWorkspace() through script, print dir in HTML

Use a script, which can be tested independently of CI code (by running
it on the host on which it will be used), and print the directory that
has been prepared in the HTML.  Also, in the description, use the
infinitive/imperative(?) of the verb to harmonize with other steps.
This commit is contained in:
Robert Schmidt
2024-09-28 12:58:06 +02:00
parent e541aee49e
commit 60b9649e00
58 changed files with 94 additions and 93 deletions
+11 -34
View File
@@ -60,41 +60,21 @@ import cls_oaicitest
#-----------------------------------------------------------
IMAGES = ['oai-enb', 'oai-lte-ru', 'oai-lte-ue', 'oai-gnb', 'oai-nr-cuup', 'oai-gnb-aw2s', 'oai-nr-ue', 'oai-gnb-asan', 'oai-nr-ue-asan', 'oai-nr-cuup-asan', 'oai-gnb-aerial', 'oai-gnb-fhi72']
def CreateWorkspace(sshSession, sourcePath, ranRepository, ranCommitID, ranTargetBranch, ranAllowMerge):
def CreateWorkspace(host, sourcePath, ranRepository, ranCommitID, ranTargetBranch, ranAllowMerge):
if ranCommitID == '':
logging.error('need ranCommitID in CreateWorkspace()')
sys.exit('Insufficient Parameter in CreateWorkspace()')
raise ValueError('Insufficient Parameter in CreateWorkspace(): need ranCommitID')
sshSession.command(f'rm -rf {sourcePath}', '\$', 10)
sshSession.command('mkdir -p ' + sourcePath, '\$', 5)
(sshSession.cd(sourcePath) if isinstance(sshSession, cls_cmd.Cmd) else sshSession.command('cd ' + sourcePath, '\$', 5))
# Recent version of git (>2.20?) should handle missing .git extension # without problems
if ranTargetBranch == 'null':
ranTargetBranch = 'develop'
baseBranch = re.sub('origin/', '', ranTargetBranch)
sshSession.command(f'git clone --filter=blob:none -n -b {baseBranch} {ranRepository} .', '\$', 60)
if sshSession.getBefore().count('error') > 0 or sshSession.getBefore().count('error') > 0:
sys.exit('error during clone')
sshSession.command('git config user.email "jenkins@openairinterface.org"', '\$', 5)
sshSession.command('git config user.name "OAI Jenkins"', '\$', 5)
sshSession.command('mkdir -p cmake_targets/log', '\$', 5)
# if the commit ID is provided use it to point to it
sshSession.command(f'git checkout -f {ranCommitID}', '\$', 30)
if sshSession.getBefore().count(f'HEAD is now at {ranCommitID[:6]}') != 1:
sshSession.command('git log --oneline | head -n5', '\$', 5)
logging.error(f'problems during checkout, is at: {sshSession.getBefore()}')
return False
else:
logging.debug('successful checkout')
# if the branch is not develop, then it is a merge request and we need to do
# the potential merge. Note that merge conflicts should already been checked earlier
script = "scripts/create_workspace.sh"
options = f"{sourcePath} {ranRepository} {ranCommitID}"
if ranAllowMerge:
if ranTargetBranch == '':
ranTargetBranch = 'develop'
logging.debug(f'Merging with the target branch: {ranTargetBranch}')
sshSession.command(f'git merge --ff origin/{ranTargetBranch} -m "Temporary merge for CI"', '\$', 30)
return True
options += f" {ranTargetBranch}"
logging.info(f'execute "{script}" with options "{options}" on node {host}')
ret = cls_cmd.runScript(host, script, 90, options)
logging.debug(f'"{script}" finished with code {ret.returncode}, output:\n{ret.stdout}')
return ret.returncode == 0
def CreateTag(ranCommitID, ranBranch, ranAllowMerge):
shortCommit = ranCommitID[0:8]
@@ -1000,12 +980,9 @@ class Containerize():
HELP.GenericHelp(CONST.Version)
sys.exit('Insufficient Parameter')
logging.info(f"Running on server {lIpAddr}")
sshSession = cls_cmd.getConnection(lIpAddr)
success = CreateWorkspace(sshSession, lSourcePath, self.ranRepository, self.ranCommitID, self.ranTargetBranch, self.ranAllowMerge)
success = CreateWorkspace(lIpAddr, lSourcePath, self.ranRepository, self.ranCommitID, self.ranTargetBranch, self.ranAllowMerge)
if success:
HTML.CreateHtmlTestRow('N/A', 'OK', CONST.ALL_PROCESSES_OK)
HTML.CreateHtmlTestRowQueue('N/A', 'OK', [f"created workspace {lSourcePath}"])
else:
HTML.CreateHtmlTestRowQueue('N/A', 'KO', ["cannot create workspace"])
return success
-1
View File
@@ -45,7 +45,6 @@ from multiprocessing import Process, Lock, SimpleQueue
import helpreadme as HELP
import constants as CONST
import cls_cmd
from cls_containerize import CreateWorkspace
#-----------------------------------------------------------
# Class Declaration
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
function die() {
echo $@
exit 1
}
[ $# -ge 3 -a $# -le 4 ] || die "usage: $0 <directory> <repository> <ref> [<merge-ref>]"
set -ex
dir=$1
repo=$2
ref=$3
merge=$4
rm -rf ${dir}
git clone --filter=blob:none -n -b develop ${repo} ${dir}
cd ${dir}
git config user.email "jenkins@openairinterface.org"
git config user.name "OAI Jenkins"
git config advice.detachedHead false
mkdir -p cmake_targets/log
git checkout -f ${ref}
[ -n "${merge}" ] && git merge --ff ${merge} -m "Temporary merge for CI"
+1 -1
View File
@@ -31,7 +31,7 @@
<TestCaseExclusionList></TestCaseExclusionList>
<testCase id="000002">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
</testCase>
<testCase id="000001">
<class>Build_Cluster_Image</class>
@@ -31,7 +31,7 @@
<TestCaseExclusionList></TestCaseExclusionList>
<testCase id="100001">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>1</eNB_instance>
<eNB_serverId>1</eNB_serverId>
</testCase>
@@ -49,7 +49,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -45,7 +45,7 @@
<TestCaseExclusionList></TestCaseExclusionList>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -48,7 +48,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -52,7 +52,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -52,7 +52,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -45,7 +45,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -45,7 +45,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -52,7 +52,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -45,7 +45,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -47,7 +47,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -47,7 +47,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -47,7 +47,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
+1 -1
View File
@@ -62,7 +62,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -47,7 +47,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -47,7 +47,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -44,7 +44,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -54,7 +54,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -45,7 +45,7 @@
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -47,7 +47,7 @@
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -45,7 +45,7 @@
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -53,7 +53,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -47,7 +47,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -33,7 +33,7 @@
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -31,7 +31,7 @@
<TestCaseExclusionList></TestCaseExclusionList>
<testCase id="100001">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -32,7 +32,7 @@
<testCase id="100001">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>1</eNB_instance>
<eNB_serverId>1</eNB_serverId>
</testCase>
@@ -68,7 +68,7 @@ Replaces xml_files/enb_usrp210_band7_test_05mhz_tm1.xml
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -67,7 +67,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -60,7 +60,7 @@ Replaces xml_files/enb_usrp210_band7_test_05mhz_tm1_rrc_inactivity_no_flexran.xm
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -62,7 +62,7 @@ Replaces xml_files/enb_usrp210_band7_test_10mhz_tm1.xml
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -61,7 +61,7 @@ Replaces xml_files/enb_usrp210_band7_test_10mhz_tm1.xml
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -86,7 +86,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -99,7 +99,7 @@
</testCase>
<testCase id="800814">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 1</desc>
<desc>Create new Workspace for server 1</desc>
<eNB_instance>1</eNB_instance>
<eNB_serverId>1</eNB_serverId>
</testCase>
@@ -61,7 +61,7 @@ Replaces xml_files/enb_usrp210_band7_test_10mhz_tm1.xml
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -69,7 +69,7 @@ Replaces xml_files/enb_usrp210_band40_test_05mhz_tm1.xml
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -67,7 +67,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -59,7 +59,7 @@ Replaces xml_files/enb_usrp210_band40_test_05mhz_tm2.xml
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -60,7 +60,7 @@ Replaces xml_files/enb_usrp210_band40_test_10mhz_tm1.xml
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -60,7 +60,7 @@ Replaces xml_files/enb_usrp210_band40_test_20mhz_tm1.xml
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -61,7 +61,7 @@ Replaces xml_files/enb_usrp210_band40_test_20mhz_tm1_default_scheduler.xml
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -67,7 +67,7 @@
</testCase>
<testCase id="800833">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -67,7 +67,7 @@
</testCase>
<testCase id="800833">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -126,7 +126,7 @@
</testCase>
<testCase id="800833">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -139,7 +139,7 @@
</testCase>
<testCase id="800834">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>1</eNB_instance>
<eNB_serverId>1</eNB_serverId>
</testCase>
@@ -49,7 +49,7 @@
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -68,7 +68,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -100,7 +100,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -84,7 +84,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -83,7 +83,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -60,7 +60,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace for server 0</desc>
<desc>Create new Workspace for server 0</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -79,7 +79,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -79,7 +79,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -70,7 +70,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
@@ -83,7 +83,7 @@
</testCase>
<testCase id="800814">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>1</eNB_instance>
<eNB_serverId>1</eNB_serverId>
</testCase>
@@ -94,7 +94,7 @@
</testCase>
<testCase id="800813">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
</testCase>
+1 -1
View File
@@ -31,7 +31,7 @@
<TestCaseExclusionList></TestCaseExclusionList>
<testCase id="000002">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
</testCase>
<testCase id="000001">
<class>Cppcheck_Analysis</class>
+1 -1
View File
@@ -33,7 +33,7 @@
<testCase id="000000">
<class>Create_Workspace</class>
<desc>Creating new Workspace</desc>
<desc>Create new Workspace</desc>
</testCase>
<testCase id="010101">