Commit 68c247b8 authored by Raphael Defosseux's avatar Raphael Defosseux

Merge branch 'add-rhel8-build-ci' into 'develop'

[CI] adding rhel build

See merge request oai/cn5g/oai-cn5g-smf!55
parents 80ce0285 726cd246
...@@ -39,7 +39,7 @@ case "$OS_DISTRO" in ...@@ -39,7 +39,7 @@ case "$OS_DISTRO" in
ubuntu) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;; ubuntu) OS_BASEDISTRO="debian"; INSTALLER="apt-get"; CMAKE="cmake" ;;
esac esac
IS_CONTAINER=`egrep -c "docker|kubepods|podman" /proc/self/cgroup` IS_CONTAINER=`egrep -c "docker|kubepods|podman|buildah|libpod" /proc/self/cgroup || true`
if [ $IS_CONTAINER -eq 0 ] if [ $IS_CONTAINER -eq 0 ]
then then
......
...@@ -28,15 +28,24 @@ def cn_ci_host = params.Host_CN_CI_Server ...@@ -28,15 +28,24 @@ def cn_ci_host = params.Host_CN_CI_Server
// for lock // for lock
def cn_ci_resource = params.DockerContainers def cn_ci_resource = params.DockerContainers
// Location of the 2nd CN executor // Location of the Remote Ubuntu18 CN executor
def new_host_flag = false def rem_u18_host_flag = false
def new_host = "" def rem_u18_host = ""
def new_host_user = "" def rem_u18_host_user = ""
// Location of the Remote RHEL CN executor
def rem_rhel_host_flag = false
def rem_rhel_host = ""
def rem_rhel_host_user = ""
def rem_rhel8_resource = params.PodmanContainers
// Tags/Branches to use // Tags/Branches to use
def smf_tag = "develop" def smf_tag = "develop"
def smf_branch = "develop" def smf_branch = "develop"
// Merge Request Link
def gitlabMergeRequestLink
// We are using a base image to speed up CI build. // We are using a base image to speed up CI build.
// This base image is potentially subject to changes over time. // This base image is potentially subject to changes over time.
def SMF_BASE_IMAGE_TAG = params.SmfBaseImageTag def SMF_BASE_IMAGE_TAG = params.SmfBaseImageTag
...@@ -54,7 +63,8 @@ pipeline { ...@@ -54,7 +63,8 @@ pipeline {
lock(cn_ci_resource) lock(cn_ci_resource)
gitLabConnection('OAI GitLab') gitLabConnection('OAI GitLab')
gitlabBuilds(builds: [ gitlabBuilds(builds: [
"Build SMF Image", "Build U18 SMF Image",
"Build RHEL8 SMF Image",
"Static Code Analysis", "Static Code Analysis",
"Code Formatting Checker", "Code Formatting Checker",
"Test with DsTester" "Test with DsTester"
...@@ -72,14 +82,14 @@ pipeline { ...@@ -72,14 +82,14 @@ pipeline {
JOB_TIMESTAMP = JOB_TIMESTAMP.trim() JOB_TIMESTAMP = JOB_TIMESTAMP.trim()
if (params.Host_CN_CI_2nd_Server_Flag != null) { if (params.Host_CN_CI_2nd_Server_Flag != null) {
new_host_flag = params.Host_CN_CI_2nd_Server_Flag rem_u18_host_flag = params.Host_CN_CI_2nd_Server_Flag
if (new_host_flag) { if (rem_u18_host_flag) {
new_host = params.Host_CN_CI_2nd_Server rem_u18_host = params.Host_CN_CI_2nd_Server
new_host_user = params.Host_CN_CI_2nd_Server_Login rem_u18_host_user = params.Host_CN_CI_2nd_Server_Login
echo "1st Node is ${NODE_NAME}" echo "1st Node is ${NODE_NAME}"
echo "2nd Node is ${new_host}" echo "2nd Node is ${rem_u18_host}"
} else { } else {
echo "Node is ${NODE_NAME}" echo "U18 Node is ${NODE_NAME}"
} }
} else { } else {
echo "Node is ${NODE_NAME}" echo "Node is ${NODE_NAME}"
...@@ -88,7 +98,7 @@ pipeline { ...@@ -88,7 +98,7 @@ pipeline {
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
try { try {
myShCmd('docker image inspect --format=\'Size = {{.Size}} bytes\' oai-smf-base:' + SMF_BASE_IMAGE_TAG, new_host_flag, new_host_user, new_host) myShCmd('docker image inspect --format=\'Size = {{.Size}} bytes\' oai-smf-base:' + SMF_BASE_IMAGE_TAG, rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} catch (Exception e) { } catch (Exception e) {
currentBuild.result = 'FAILURE' currentBuild.result = 'FAILURE'
echo '\u26D4 \u001B[31mBase Image does not exist\u001B[0m' echo '\u26D4 \u001B[31mBase Image does not exist\u001B[0m'
...@@ -103,12 +113,23 @@ pipeline { ...@@ -103,12 +113,23 @@ pipeline {
script { script {
sh "git clean -x -d -f > /dev/null 2>&1" sh "git clean -x -d -f > /dev/null 2>&1"
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
gitlabMergeRequestLink = sh "curl --silent \"https://gitlab.eurecom.fr/api/v4/projects/oai%2Fcn5g%2Foai-cn5g-smf/merge_requests/${env.gitlabMergeRequestIid}\" | jq .web_url | sed 's#\"##g'"
echo "========= THIS IS A MERGE REQUEST =========="
echo "MR ID is ${env.gitlabMergeRequestIid}"
echo "MR LINK is ${gitlabMergeRequestLink}"
echo "MR TITLE is ${env.gitlabMergeRequestTitle}"
gitCommitAuthorEmailAddr = env.gitlabUserEmail gitCommitAuthorEmailAddr = env.gitlabUserEmail
echo "GitLab Usermail is ${gitCommitAuthorEmailAddr}" echo "GitLab Usermail is ${gitCommitAuthorEmailAddr}"
sh "git fetch --prune --unshallow"
shortenShaOne = sh returnStdout: true, script: 'git log -1 --pretty=format:"%h" ' + env.gitlabMergeRequestLastCommit
shortenShaOne = shortenShaOne.trim()
sh "./ci-scripts/doGitLabMerge.sh --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}" sh "./ci-scripts/doGitLabMerge.sh --src-branch ${env.gitlabSourceBranch} --src-commit ${env.gitlabMergeRequestLastCommit} --target-branch ${env.gitlabTargetBranch} --target-commit ${GIT_COMMIT}"
sh "sleep 10"
smf_tag = "ci-tmp" smf_tag = "ci-tmp"
rhel_smf_tag = 'ci-tmp-pr-' + env.gitlabMergeRequestIid + '-' + shortenShaOne
smf_branch = env.gitlabSourceBranch smf_branch = env.gitlabSourceBranch
} else { } else {
echo "======== THIS IS A PUSH REQUEST ========"
echo "Git Branch is ${GIT_BRANCH}" echo "Git Branch is ${GIT_BRANCH}"
echo "Git Commit is ${GIT_COMMIT}" echo "Git Commit is ${GIT_COMMIT}"
gitCommitAuthorEmailAddr = sh returnStdout: true, script: 'git log -n1 --pretty=format:%ae ${GIT_COMMIT}' gitCommitAuthorEmailAddr = sh returnStdout: true, script: 'git log -n1 --pretty=format:%ae ${GIT_COMMIT}'
...@@ -118,11 +139,9 @@ pipeline { ...@@ -118,11 +139,9 @@ pipeline {
} }
sh "tar -cjhf /tmp/openair-smf.tar.bz2 ." sh "tar -cjhf /tmp/openair-smf.tar.bz2 ."
sh "mv /tmp/openair-smf.tar.bz2 ." sh "mv /tmp/openair-smf.tar.bz2 ."
copyTo2ndServer('openair-smf.tar.bz2', new_host_flag, new_host_user, new_host) copyTo2ndServer('openair-smf.tar.bz2', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
sh "mkdir -p archives" copyTo2ndServer('openair-smf.tar.bz2', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
if (new_host_flag) { sh "mkdir -p archives/oai-smf-cfg"
sh "mkdir -p archives/oai-smf-cfg"
}
} }
} }
post { post {
...@@ -137,43 +156,43 @@ pipeline { ...@@ -137,43 +156,43 @@ pipeline {
} }
stage('Build Core Network Function') { stage('Build Core Network Function') {
parallel { parallel {
stage ('Build SMF Image') { stage ('Build U18 SMF Image') {
steps { steps {
script { script {
gitlabCommitStatus(name: "Build SMF Image") { gitlabCommitStatus(name: "Build U18 SMF Image") {
myShCmd('docker image prune --force', new_host_flag, new_host_user, new_host) myShCmd('docker image prune --force', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
if ("PUSH".equals(env.gitlabActionType)) { if ("PUSH".equals(env.gitlabActionType)) {
// Currently this pipeline only runs for pushes to `develop` branch // Currently this pipeline only runs for pushes to `develop` branch
// First clean image registry // First clean image registry
try { try {
myShCmd('docker image rm oai-smf:develop', new_host_flag, new_host_user, new_host) myShCmd('docker image rm oai-smf:develop', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} catch (Exception e) { } catch (Exception e) {
echo "Maybe a previous build went wrong" echo "Maybe a previous build went wrong"
} }
// In case of push to `develop` branch we build from scratch // In case of push to `develop` branch we build from scratch
myShCmd('docker build --no-cache --target oai-smf --tag oai-smf:' + smf_tag + ' --file docker/Dockerfile.ubuntu18.04 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > archives/smf_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host) myShCmd('docker build --no-cache --target oai-smf --tag oai-smf:' + smf_tag + ' --file docker/Dockerfile.ubuntu18.04 --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > archives/smf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
try { try {
// Checking if the CI Base image is still there. // Checking if the CI Base image is still there.
// If the inspect command fails, it's not there. If it passes, let remove tag. // If the inspect command fails, it's not there. If it passes, let remove tag.
myShCmd('docker image inspect oai-smf-base:latest > /dev/null 2>&1', new_host_flag, new_host_user, new_host) myShCmd('docker image inspect oai-smf-base:latest > /dev/null 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker rmi oai-smf-base:latest', new_host_flag, new_host_user, new_host) myShCmd('docker rmi oai-smf-base:latest', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} catch (Exception e) { } catch (Exception e) {
echo 'No need to remove the CI base image' echo 'No need to remove the CI base image'
} }
// "latest" is the tag used in the docker file. // "latest" is the tag used in the docker file.
myShCmd('docker image tag oai-smf-base:' +SMF_BASE_IMAGE_TAG + ' oai-smf-base:latest', new_host_flag, new_host_user, new_host) myShCmd('docker image tag oai-smf-base:' +SMF_BASE_IMAGE_TAG + ' oai-smf-base:latest', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker build --no-cache --target oai-smf --tag oai-smf:' + smf_tag + ' --file ci-scripts/docker/Dockerfile.ci.ubuntu.18.04 . > archives/smf_docker_image_build.log 2>&1', new_host_flag, new_host_user, new_host) myShCmd('docker build --no-cache --target oai-smf --tag oai-smf:' + smf_tag + ' --file ci-scripts/docker/Dockerfile.ci.ubuntu.18.04 . > archives/smf_docker_image_build.log 2>&1', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
myShCmd('docker image ls >> archives/smf_docker_image_build.log', new_host_flag, new_host_user, new_host) myShCmd('docker image ls >> archives/smf_docker_image_build.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
} }
} }
post { post {
always { always {
script { script {
copyFrom2ndServer('archives/smf_docker_image_build.log', 'archives', new_host_flag, new_host_user, new_host) copyFrom2ndServer('archives/smf_docker_image_build.log', 'archives', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
} }
success { success {
...@@ -184,32 +203,76 @@ pipeline { ...@@ -184,32 +203,76 @@ pipeline {
} }
} }
} }
stage ('Build RHEL8 SMF Image') {
when { expression {rem_rhel_host_flag} }
steps {
lock (rem_rhel8_resource) {
script {
if ("PUSH".equals(env.gitlabActionType)) {
// Currently this pipeline only runs for pushes to `develop` branch
// First clean image registry
try {
myShCmd('sudo podman image rm oai-smf:develop || true', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
} catch (Exception e) {
echo "Maybe a previous build went wrong"
}
} else {
// In case we forgot during a previous run
myShCmd('sudo podman image rm oai-smf:' + smf_tag + ' || true', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
}
myShCmd('sudo podman image prune --force', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
// Copy the RHEL Host certificates for building
myShCmd('mkdir -p tmp/ca tmp/entitlement', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('cp /etc/pki/entitlement/*pem tmp/entitlement', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo cp /etc/rhsm/ca/redhat-uep.pem tmp/ca', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo podman build --no-cache --target oai-smf --tag oai-smf:' + smf_tag + ' --file docker/Dockerfile.smf.rhel8.2 --build-arg EURECOM_PROXY="http://proxy.eurecom.fr:8080" . > archives/smf_podman_image_build.log 2>&1', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
myShCmd('sudo podman image ls >> archives/smf_podman_image_build.log', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('sudo podman image tag oai-smf:' + smf_tag + ' oai-smf:' + rhel_smf_tag, rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
}
}
}
}
post {
always {
script {
copyFrom2ndServer('archives/smf_podman_image_build.log', 'archives', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
}
}
success {
sh "echo 'OAI-SMF PODMAN RHEL8 IMAGE BUILD: OK' >> archives/smf_podman_image_build.log"
}
unsuccessful {
sh "echo 'OAI-SMF PODMAN RHEL8 IMAGE BUILD: KO' >> archives/smf_podman_image_build.log"
}
}
}
// Running CPPCHECK in parallel to gain time // Running CPPCHECK in parallel to gain time
stage ('Static Code Analysis') { stage ('Static Code Analysis') {
steps { steps {
script { script {
gitlabCommitStatus(name: "Static Code Analysis") { gitlabCommitStatus(name: "Static Code Analysis") {
// Running on xenial to have 1.72 version of cppcheck // Running on xenial to have 1.72 version of cppcheck
myShCmd('docker run --name ci-cn-cppcheck -d ubuntu:xenial /bin/bash -c "sleep infinity"', new_host_flag, new_host_user, new_host) myShCmd('docker run --name ci-cn-cppcheck -d ubuntu:xenial /bin/bash -c "sleep infinity"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "apt-get update && apt-get upgrade --yes" > archives/cppcheck_install.log', new_host_flag, new_host_user, new_host) myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "apt-get update && apt-get upgrade --yes" > archives/cppcheck_install.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "apt-get install --yes cppcheck bzip2" >> archives/cppcheck_install.log', new_host_flag, new_host_user, new_host) myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "apt-get install --yes cppcheck bzip2" >> archives/cppcheck_install.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker cp ./openair-smf.tar.bz2 ci-cn-cppcheck:/home', new_host_flag, new_host_user, new_host) myShCmd('docker cp ./openair-smf.tar.bz2 ci-cn-cppcheck:/home', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "cd /home && tar -xjf openair-smf.tar.bz2"', new_host_flag, new_host_user, new_host) myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "cd /home && tar -xjf openair-smf.tar.bz2"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "rm -f /home/openair-smf.tar.bz2"', new_host_flag, new_host_user, new_host) myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "rm -f /home/openair-smf.tar.bz2"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "cd /home && cppcheck --enable=warning --force --xml --xml-version=2 --suppressions-list=ci-scripts/cppcheck_suppressions.list src 2> cppcheck.xml 1> cppcheck_build.log"', new_host_flag, new_host_user, new_host) myShCmd('docker exec ci-cn-cppcheck /bin/bash -c "cd /home && cppcheck --enable=warning --force --xml --xml-version=2 --suppressions-list=ci-scripts/cppcheck_suppressions.list src 2> cppcheck.xml 1> cppcheck_build.log"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
} }
} }
post { post {
always { always {
script { script {
myShCmd('docker cp ci-cn-cppcheck:/home/cppcheck.xml archives', new_host_flag, new_host_user, new_host) myShCmd('docker cp ci-cn-cppcheck:/home/cppcheck.xml archives', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker cp ci-cn-cppcheck:/home/cppcheck_build.log archives', new_host_flag, new_host_user, new_host) myShCmd('docker cp ci-cn-cppcheck:/home/cppcheck_build.log archives', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
copyFrom2ndServer('archives/cppcheck*.*', 'archives', new_host_flag, new_host_user, new_host) copyFrom2ndServer('archives/cppcheck*.*', 'archives', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
// no need to keep the cppcheck container // no need to keep the cppcheck container
myShCmd('docker rm -f ci-cn-cppcheck', new_host_flag, new_host_user, new_host) myShCmd('docker rm -f ci-cn-cppcheck', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
} }
success { success {
...@@ -225,20 +288,20 @@ pipeline { ...@@ -225,20 +288,20 @@ pipeline {
steps { steps {
script { script {
gitlabCommitStatus(name: "Code Formatting Checker") { gitlabCommitStatus(name: "Code Formatting Checker") {
myShCmd('docker run --name ci-cn-clang-formatter -d ubuntu:bionic /bin/bash -c "sleep infinity"', new_host_flag, new_host_user, new_host) myShCmd('docker run --name ci-cn-clang-formatter -d ubuntu:bionic /bin/bash -c "sleep infinity"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "apt-get update && apt-get upgrade --yes" > archives/clang_format_install.log', new_host_flag, new_host_user, new_host) myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "apt-get update && apt-get upgrade --yes" > archives/clang_format_install.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "apt-get install --yes git tree bzip2" >> archives/clang_format_install.log', new_host_flag, new_host_user, new_host) myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "apt-get install --yes git tree bzip2" >> archives/clang_format_install.log', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker cp ./openair-smf.tar.bz2 ci-cn-clang-formatter:/home', new_host_flag, new_host_user, new_host) myShCmd('docker cp ./openair-smf.tar.bz2 ci-cn-clang-formatter:/home', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "cd /home && tar -xjf openair-smf.tar.bz2"', new_host_flag, new_host_user, new_host) myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "cd /home && tar -xjf openair-smf.tar.bz2"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "rm -f /home/openair-smf.tar.bz2"', new_host_flag, new_host_user, new_host) myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "rm -f /home/openair-smf.tar.bz2"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
// We install a dedicated version (installed on our CI server). // We install a dedicated version (installed on our CI server).
myShCmd('docker cp /opt/clang-format/9.0.0/bin/clang-format ci-cn-clang-formatter:/usr/local/bin', new_host_flag, new_host_user, new_host) myShCmd('docker cp /opt/clang-format/9.0.0/bin/clang-format ci-cn-clang-formatter:/usr/local/bin', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "cd /home && ./ci-scripts/checkCodingFormattingRules.sh --src-branch ' + env.gitlabSourceBranch +' --target-branch ' + env.gitlabTargetBranch + '"', new_host_flag, new_host_user, new_host) myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "cd /home && ./ci-scripts/checkCodingFormattingRules.sh --src-branch ' + env.gitlabSourceBranch +' --target-branch ' + env.gitlabTargetBranch + '"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} else { } else {
myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "cd /home && ./ci-scripts/checkCodingFormattingRules.sh"', new_host_flag, new_host_user, new_host) myShCmd('docker exec ci-cn-clang-formatter /bin/bash -c "cd /home && ./ci-scripts/checkCodingFormattingRules.sh"', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
} }
} }
...@@ -246,17 +309,17 @@ pipeline { ...@@ -246,17 +309,17 @@ pipeline {
post { post {
always { always {
script { script {
myShCmd('docker cp ci-cn-clang-formatter:/home/src/oai_rules_result.txt src', new_host_flag, new_host_user, new_host) myShCmd('docker cp ci-cn-clang-formatter:/home/src/oai_rules_result.txt src', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
// May not have been generated // May not have been generated
try { try {
myShCmd('docker cp ci-cn-clang-formatter:/home/src/oai_rules_result_list.txt src', new_host_flag, new_host_user, new_host) myShCmd('docker cp ci-cn-clang-formatter:/home/src/oai_rules_result_list.txt src', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} catch (Exception e) { } catch (Exception e) {
echo "Failed to copy src/oai_rules_result_list.txt! It may not have been generated. That's OK!" echo "Failed to copy src/oai_rules_result_list.txt! It may not have been generated. That's OK!"
} }
copyFrom2ndServer('archives/clang_format*.*', 'archives', new_host_flag, new_host_user, new_host) copyFrom2ndServer('archives/clang_format*.*', 'archives', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
copyFrom2ndServer('src/oai_rules*.*', 'src', new_host_flag, new_host_user, new_host) copyFrom2ndServer('src/oai_rules*.*', 'src', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
// no need to keep the clang-formatter container // no need to keep the clang-formatter container
myShCmd('docker rm -f ci-cn-clang-formatter', new_host_flag, new_host_user, new_host) myShCmd('docker rm -f ci-cn-clang-formatter', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
} }
} }
...@@ -317,21 +380,35 @@ pipeline { ...@@ -317,21 +380,35 @@ pipeline {
script { script {
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
// Remove CI Base image tag // Remove CI Base image tag
myShCmd('docker rmi oai-smf-base:latest', new_host_flag, new_host_user, new_host) myShCmd('docker rmi oai-smf-base:latest', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
// Removing temporary / intermediate images // Removing temporary / intermediate images
try { try {
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('docker image rm --force oai-smf:ci-tmp', new_host_flag, new_host_user, new_host) myShCmd('docker image rm --force oai-smf:ci-tmp', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} }
} catch (Exception e) { } catch (Exception e) {
echo "We failed to delete the OAI-SMF temp image" echo "We failed to delete the OAI-SMF temp image"
} }
try { try {
myShCmd('docker image prune --force', new_host_flag, new_host_user, new_host) if ("MERGE".equals(env.gitlabActionType)) {
myShCmd('sudo podman image rm oai-smf:ci-tmp', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
}
} catch (Exception e) {
echo "We failed to delete the OAI-SMF temp image"
}
try {
myShCmd('docker image prune --force', rem_u18_host_flag, rem_u18_host_user, rem_u18_host)
} catch (Exception e) { } catch (Exception e) {
echo "We failed to prune all unneeded intermediate images" echo "We failed to prune all unneeded intermediate images"
} }
if (rem_rhel_host_flag) {
try {
myShCmd('sudo podman image prune --force', rem_rhel_host_flag, rem_rhel_host_user, rem_rhel_host)
} catch (Exception e) {
echo "We failed to prune all unneeded intermediate images"
}
}
// Zipping all archived log files // Zipping all archived log files
sh "zip -r -qq docker_logs.zip archives" sh "zip -r -qq docker_logs.zip archives"
...@@ -342,11 +419,20 @@ pipeline { ...@@ -342,11 +419,20 @@ pipeline {
// Generating the HTML report // Generating the HTML report
if ("MERGE".equals(env.gitlabActionType)) { if ("MERGE".equals(env.gitlabActionType)) {
sh "python3 ci-scripts/generateHtmlReport.py --job_name=${JOB_NAME} --job_id=${BUILD_ID} --job_url=${BUILD_URL} --git_url=${GIT_URL} --git_src_branch=${env.gitlabSourceBranch} --git_src_commit=${env.gitlabMergeRequestLastCommit} --git_pull_request=True --git_target_branch=${env.gitlabTargetBranch} --git_target_commit=${GIT_COMMIT}" sh "python3 ci-scripts/generateHtmlReport.py --job_name=${JOB_NAME} --job_id=${BUILD_ID} --job_url=${BUILD_URL} --git_url=${GIT_URL} --git_src_branch=${env.gitlabSourceBranch} --git_src_commit=${env.gitlabMergeRequestLastCommit} --git_pull_request=True --git_target_branch=${env.gitlabTargetBranch} --git_target_commit=${GIT_COMMIT}"
if (fileExists('test_results_oai_smf.html')) {
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${gitlabMergeRequestLink}#g' test_results_oai_smf.html"
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_TEMPLATE#${env.gitlabMergeRequestTitle}#' test_results_oai_smf.html"
}
if (fileExists('test_results_oai_cn5g.html')) {
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_LINK#${gitlabMergeRequestLink}#g' *_results_oai_cn5g.html"
sh "sed -i -e 's#TEMPLATE_MERGE_REQUEST_TEMPLATE#${env.gitlabMergeRequestTitle}#' *_results_oai_cn5g.html"
}
} else { } else {
sh "python3 ci-scripts/generateHtmlReport.py --job_name=${JOB_NAME} --job_id=${BUILD_ID} --job_url=${BUILD_URL} --git_url=${GIT_URL} --git_src_branch=${GIT_BRANCH} --git_src_commit=${GIT_COMMIT}" sh "python3 ci-scripts/generateHtmlReport.py --job_name=${JOB_NAME} --job_id=${BUILD_ID} --job_url=${BUILD_URL} --git_url=${GIT_URL} --git_src_branch=${GIT_BRANCH} --git_src_commit=${GIT_COMMIT}"
} }
sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' test_results_oai_smf.html" sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' test_results_oai_smf.html"
if (fileExists('test_results_oai_smf.html')) { if (fileExists('test_results_oai_smf.html')) {
sh "sed -i -e 's#TEMPLATE_TIME#${JOB_TIMESTAMP}#' test_results_oai_smf.html"
archiveArtifacts artifacts: 'test_results_oai_smf.html' archiveArtifacts artifacts: 'test_results_oai_smf.html'
} }
if (fileExists('test_results_oai_cn5g.html')) { if (fileExists('test_results_oai_cn5g.html')) {
...@@ -385,8 +471,8 @@ def copyTo2ndServer(filename, flag, user, host) { ...@@ -385,8 +471,8 @@ def copyTo2ndServer(filename, flag, user, host) {
sh "scp ${filename} ${user}@${host}:/tmp/CI-CN-SMF" sh "scp ${filename} ${user}@${host}:/tmp/CI-CN-SMF"
if ("openair-smf.tar.bz2".equals(filename)) { if ("openair-smf.tar.bz2".equals(filename)) {
sh "ssh ${user}@${host} 'cd /tmp/CI-CN-SMF && tar -xjf ${filename}'" sh "ssh ${user}@${host} 'cd /tmp/CI-CN-SMF && tar -xjf ${filename}'"
sh "ssh ${user}@${host} 'mkdir -p /tmp/CI-CN-SMF/archives'"
sh "ssh ${user}@${host} 'mkdir -p /tmp/CI-CN-SMF/archives/oai-smf-cfg'" sh "ssh ${user}@${host} 'mkdir -p /tmp/CI-CN-SMF/archives/oai-smf-cfg'"
sh "ssh ${user}@${host} 'rm -Rf /tmp/CI-CN-SMF/${filename}'"
} }
} }
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
# */ # */
#--------------------------------------------------------------------- #---------------------------------------------------------------------
import glob
import os import os
import re import re
import sys import sys
...@@ -112,6 +113,15 @@ class HtmlReport(): ...@@ -112,6 +113,15 @@ class HtmlReport():
buildSummary += ' <td><a href="' + self.git_url + '">' + self.git_url + '</a></td>\n' buildSummary += ' <td><a href="' + self.git_url + '">' + self.git_url + '</a></td>\n'
buildSummary += ' </tr>\n' buildSummary += ' </tr>\n'
if self.git_pull_request: if self.git_pull_request:
buildSummary += ' <tr>\n'
buildSummary += ' <td bgcolor="lightcyan" > <span class="glyphicon glyphicon-log-out"></span> Source Branch</td>\n'
buildSummary += ' <td><a href="TEMPLATE_MERGE_REQUEST_LINK">TEMPLATE_MERGE_REQUEST_LINK</a></td>\n'
buildSummary += ' </tr>\n'
buildSummary += ' <tr>\n'
buildSummary += ' <td bgcolor="lightcyan" > <span class="glyphicon glyphicon-header"></span> Merge Request Title</td>\n'
buildSummary += ' <td>TEMPLATE_MERGE_REQUEST_TEMPLATE</td>\n'
buildSummary += ' </tr>\n'
buildSummary += ' <tr>\n'
buildSummary += ' <td bgcolor="lightcyan" > <span class="glyphicon glyphicon-log-out"></span> Source Branch</td>\n' buildSummary += ' <td bgcolor="lightcyan" > <span class="glyphicon glyphicon-log-out"></span> Source Branch</td>\n'
buildSummary += ' <td>' + self.git_src_branch + '</td>\n' buildSummary += ' <td>' + self.git_src_branch + '</td>\n'
buildSummary += ' </tr>\n' buildSummary += ' </tr>\n'
...@@ -151,23 +161,10 @@ class HtmlReport(): ...@@ -151,23 +161,10 @@ class HtmlReport():
self.file.write(buildSummary) self.file.write(buildSummary)
cwd = os.getcwd() cwd = os.getcwd()
if os.path.isfile(cwd + '/ds_tester_results_oai_cn5g.html'): for reportFile in glob.glob('./*results_oai_cn5g.html'):
newEpcReport = open(cwd + '/ds_tester_results_oai_cn5g_new.html', 'w') newEpcReport = open(cwd + '/' + str(reportFile) + '.new', 'w')
buildSummaryDone = True buildSummaryDone = True
with open(cwd + '/ds_tester_results_oai_cn5g.html', 'r') as originalEpcReport: with open(cwd + '/' + str(reportFile), 'r') as originalEpcReport:
for line in originalEpcReport:
result = re.search('DS Tester Summary', line)
if (result is not None) and buildSummaryDone:
newEpcReport.write(buildSummary)
buildSummaryDone = False
newEpcReport.write(line)
originalEpcReport.close()
newEpcReport.close()
os.rename(cwd + '/ds_tester_results_oai_cn5g_new.html', cwd + '/ds_tester_results_oai_cn5g.html')
if os.path.isfile(cwd + '/deploy_results_oai_cn5g.html'):
newEpcReport = open(cwd + '/deploy_results_oai_cn5g_new.html', 'w')
buildSummaryDone = True
with open(cwd + '/deploy_results_oai_cn5g.html', 'r') as originalEpcReport:
for line in originalEpcReport: for line in originalEpcReport:
result = re.search('Deployment Summary', line) result = re.search('Deployment Summary', line)
if (result is not None) and buildSummaryDone: if (result is not None) and buildSummaryDone:
...@@ -176,7 +173,7 @@ class HtmlReport(): ...@@ -176,7 +173,7 @@ class HtmlReport():
newEpcReport.write(line) newEpcReport.write(line)
originalEpcReport.close() originalEpcReport.close()
newEpcReport.close() newEpcReport.close()
os.rename(cwd + '/deploy_results_oai_cn5g_new.html', cwd + '/deploy_results_oai_cn5g.html') os.rename(cwd + '/' + str(reportFile) + '.new', cwd + '/' + str(reportFile))
def generateFooter(self): def generateFooter(self):
self.file.write(' <div class="well well-lg">End of Build Report -- Copyright <span class="glyphicon glyphicon-copyright-mark"></span> 2020 <a href="http://www.openairinterface.org/">OpenAirInterface</a>. All Rights Reserved.</div>\n') self.file.write(' <div class="well well-lg">End of Build Report -- Copyright <span class="glyphicon glyphicon-copyright-mark"></span> 2020 <a href="http://www.openairinterface.org/">OpenAirInterface</a>. All Rights Reserved.</div>\n')
...@@ -369,12 +366,13 @@ class HtmlReport(): ...@@ -369,12 +366,13 @@ class HtmlReport():
self.file.write(' </div>\n') self.file.write(' </div>\n')
def buildSummaryHeader(self): def buildSummaryHeader(self):
self.file.write(' <h2>Docker Image Build Summary</h2>\n') self.file.write(' <h2>Docker / Podman Image Build Summary</h2>\n')
self.file.write(' <table class="table-bordered" width = "100%" align = "center" border = "1">\n') self.file.write(' <table class="table-bordered" width = "100%" align = "center" border = "1">\n')
self.file.write(' <tr bgcolor="#33CCFF" >\n') self.file.write(' <tr bgcolor="#33CCFF" >\n')
self.file.write(' <th>Stage Name</th>\n') self.file.write(' <th>Stage Name</th>\n')
self.file.write(' <th>Image Kind</th>\n') self.file.write(' <th>Image Kind</th>\n')
self.file.write(' <th>OAI SMF cNF</th>\n') self.file.write(' <th>OAI AMF <font color="Gold">Ubuntu18</font> Image</th>\n')
self.file.write(' <th>OAI AMF <font color="Gold">RHEL8</font> Image</th>\n')
self.file.write(' </tr>\n') self.file.write(' </tr>\n')
def buildSummaryFooter(self): def buildSummaryFooter(self):
...@@ -418,42 +416,44 @@ class HtmlReport(): ...@@ -418,42 +416,44 @@ class HtmlReport():
def analyze_docker_build_git_part(self, nfType): def analyze_docker_build_git_part(self, nfType):
if nfType != 'SMF': if nfType != 'SMF':
self.file.write(' <td>N/A</td>\n') self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n') self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return return
logFileName = 'smf_docker_image_build.log'
self.file.write(' <td>Builder Image</td>\n') self.file.write(' <td>Builder Image</td>\n')
cwd = os.getcwd() cwd = os.getcwd()
if os.path.isfile(cwd + '/archives/' + logFileName): variants = ['docker', 'podman']
status = False for variant in variants:
section_start_pattern = 'git config --global http' logFileName = 'smf_' + variant + '_image_build.log'
section_end_pattern = 'WORKDIR /openair-smf/build/scripts' if os.path.isfile(cwd + '/archives/' + logFileName):
section_status = False status = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile: section_start_pattern = 'git config --global http'
for line in logfile: section_end_pattern = 'WORKDIR /openair-smf/build/scripts'
result = re.search(section_start_pattern, line) section_status = False
if result is not None: with open(cwd + '/archives/' + logFileName, 'r') as logfile:
section_status = True for line in logfile:
result = re.search(section_end_pattern, line) result = re.search(section_start_pattern, line)
if result is not None: if result is not None:
section_status = False section_status = True
status = True result = re.search(section_end_pattern, line)
logfile.close() if result is not None:
section_status = False
status = True
logfile.close()
if status: if status:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>' cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>'
cell_msg += 'OK:\n' cell_msg += 'OK:\n'
cell_msg += ' -- All Git Operations went successfully</b></pre></td>\n' cell_msg += ' -- All Git Operations went successfully</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO::\n'
cell_msg += ' -- Some Git Operations went WRONG</b></pre></td>\n'
else: else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>' cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO::\n' cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
cell_msg += ' -- Some Git Operations went WRONG</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
self.file.write(cell_msg) self.file.write(cell_msg)
def installLibsPackagesRow(self): def installLibsPackagesRow(self):
self.file.write(' <tr>\n') self.file.write(' <tr>\n')
...@@ -464,108 +464,129 @@ class HtmlReport(): ...@@ -464,108 +464,129 @@ class HtmlReport():
def analyze_install_log(self, nfType): def analyze_install_log(self, nfType):
if nfType != 'SMF': if nfType != 'SMF':
self.file.write(' <td>N/A</td>\n') self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n') self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return return
logFileName = 'smf_docker_image_build.log'
self.file.write(' <td>Builder Image</td>\n') self.file.write(' <td>Builder Image</td>\n')
cwd = os.getcwd() cwd = os.getcwd()
if os.path.isfile(cwd + '/archives/' + logFileName): variants = ['docker', 'podman']
status = False for variant in variants:
section_start_pattern = 'build_smf --install-deps --force' logFileName = 'smf_' + variant + '_image_build.log'
section_end_pattern = 'build_smf --clean --Verbose --build-type Release --jobs' if os.path.isfile(cwd + '/archives/' + logFileName):
section_status = False status = False
package_install = False section_start_pattern = 'build_smf --install-deps --force'
fmt_build_start = False section_end_pattern = 'build_smf --clean --Verbose --build-type Release --jobs'
fmt_build_status = False section_status = False
folly_build_start = False package_install = False
folly_build_status = False fmt_build_start = False
spdlog_build_start = False fmt_build_status = False
spdlog_build_status = False folly_build_start = False
pistache_build_start = False folly_build_status = False
pistache_build_status = False spdlog_build_start = False
json_build_start = False spdlog_build_status = False
json_build_status = False pistache_build_start = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile: pistache_build_status = False
for line in logfile: json_build_start = False
result = re.search(section_start_pattern, line) json_build_status = False
if result is not None: base_image = False
section_status = True with open(cwd + '/archives/' + logFileName, 'r') as logfile:
result = re.search(section_end_pattern, line) for line in logfile:
if result is not None: result = re.search('FROM oai-smf-base', line)
section_status = False
if section_status:
result = re.search('SMF deps installation successful', line)
if result is not None:
status = True
result = re.search('Install fmt from source', line)
if result is not None:
package_install = True
fmt_build_start = True
result = re.search('Installing: /usr/local/lib/pkgconfig/fmt.pc', line)
if result is not None:
fmt_build_status = True
result = re.search('Cloning into \'folly\'', line)
if result is not None:
folly_build_start = True
result = re.search('Installing: /usr/local/lib/libfollybenchmark.a', line)
if result is not None: if result is not None:
folly_build_status = True base_image = True
result = re.search('Install spdlog from', line) result = re.search(section_start_pattern, line)
if result is not None: if result is not None:
spdlog_build_start = True section_status = True
result = re.search('Install Pistache from', line) result = re.search(section_end_pattern, line)
if result is not None: if result is not None:
spdlog_build_status = True section_status = False
pistache_build_start = True if section_status:
result = re.search('Installing: /usr/local/lib/libpistache.a', line) result = re.search('SMF deps installation successful', line)
if result is not None: if result is not None:
pistache_build_status = True status = True
result = re.search('Install Nlohmann Json', line) result = re.search('Install fmt from source', line)
if result is not None: if result is not None:
json_build_status = True package_install = True
result = re.search('Installing: /usr/local/lib/cmake/nlohmann_json/nlohmann_jsonTargets.cmake', line) fmt_build_start = True
if result is not None: result = re.search('Installing: /usr/local/lib/pkgconfig/fmt.pc', line)
json_build_status = True if result is not None:
logfile.close() fmt_build_status = True
if status: result = re.search('Cloning into \'folly\'', line)
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>' if result is not None:
cell_msg += 'OK:\n' folly_build_start = True
result = re.search('Installing: /usr/local/lib/libfollybenchmark.a', line)
if result is not None:
folly_build_status = True
result = re.search('Install spdlog from', line)
if result is not None:
spdlog_build_start = True
result = re.search('Install Pistache from', line)
if result is not None:
spdlog_build_status = True
pistache_build_start = True
result = re.search('Installing: /usr/local/lib/libpistache.a', line)
if result is not None:
pistache_build_status = True
result = re.search('Install Nlohmann Json', line)
if result is not None:
json_build_status = True
result = re.search('Installing: /usr/local/lib/cmake/nlohmann_json/nlohmann_jsonTargets.cmake', line)
if result is not None:
json_build_status = True
logfile.close()
if base_image:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>'
cell_msg += 'N/A:\n'
elif status:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>'
cell_msg += 'OK:\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO:\n'
cell_msg += ' -- build_smf --install-deps --force\n'
if base_image:
cell_msg += ' ** Packages Installation: N/A\n'
elif package_install:
cell_msg += ' ** Packages Installation: OK\n'
else:
cell_msg += ' ** Packages Installation: KO\n'
if base_image:
cell_msg += ' ** fmt Installation: N/A\n'
elif fmt_build_status:
cell_msg += ' ** fmt Installation: OK\n'
else:
cell_msg += ' ** fmt Installation: KO\n'
if base_image:
cell_msg += ' ** folly Installation: N/A\n'
elif folly_build_status:
cell_msg += ' ** folly Installation: OK\n'
else:
cell_msg += ' ** folly Installation: KO\n'
if base_image:
cell_msg += ' ** spdlog Installation: N/A\n'
elif spdlog_build_status:
cell_msg += ' ** spdlog Installation: OK\n'
else:
cell_msg += ' ** spdlog Installation: KO\n'
if base_image:
cell_msg += ' ** pistache Installation: N/A\n'
elif pistache_build_status:
cell_msg += ' ** pistache Installation: OK\n'
else:
cell_msg += ' ** pistache Installation: KO\n'
if base_image:
cell_msg += ' ** Nlohmann Json Installation: N/A\n'
elif json_build_status:
cell_msg += ' ** Nlohmann Json Installation: OK\n'
else:
cell_msg += ' ** Nlohmann Json Installation: KO\n'
cell_msg += '</b></pre></td>\n'
else: else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>' cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO:\n' cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
cell_msg += ' -- build_smf --install-deps --force\n'
if package_install:
cell_msg += ' ** Packages Installation: OK\n'
else:
cell_msg += ' ** Packages Installation: KO\n'
if fmt_build_status:
cell_msg += ' ** fmt Installation: OK\n'
else:
cell_msg += ' ** fmt Installation: KO\n'
if folly_build_status:
cell_msg += ' ** folly Installation: OK\n'
else:
cell_msg += ' ** folly Installation: KO\n'
if spdlog_build_status:
cell_msg += ' ** spdlog Installation: OK\n'
else:
cell_msg += ' ** spdlog Installation: KO\n'
if pistache_build_status:
cell_msg += ' ** pistache Installation: OK\n'
else:
cell_msg += ' ** pistache Installation: KO\n'
if json_build_status:
cell_msg += ' ** Nlohmann Json Installation: OK\n'
else:
cell_msg += ' ** Nlohmann Json Installation: KO\n'
cell_msg += '</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
self.file.write(cell_msg) self.file.write(cell_msg)
def buildCompileRows(self): def buildCompileRows(self):
self.file.write(' <tr>\n') self.file.write(' <tr>\n')
...@@ -577,151 +598,115 @@ class HtmlReport(): ...@@ -577,151 +598,115 @@ class HtmlReport():
self.file.write(' </tr>\n') self.file.write(' </tr>\n')
def analyze_build_log(self, nfType, imageKind): def analyze_build_log(self, nfType, imageKind):
if nfType != 'SMF' and nfType != 'AMF-Server' and nfType != 'AMF-Client' and nfType != 'UDM-Server': if nfType != 'SMF':
if imageKind: if imageKind:
self.file.write(' <td>N/A</td>\n') self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n') self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return return
if nfType == 'SMF':
logFileName = 'smf_docker_image_build.log'
if nfType == 'AMF-Server':
logFileName = 'amf_server_docker_image_build.log'
if nfType == 'AMF-Client':
logFileName = 'amf_client_docker_image_build.log'
if nfType == 'UDM-Server':
logFileName = 'udm_server_docker_image_build.log'
if imageKind: if imageKind:
self.file.write(' <td>Builder Image</td>\n') self.file.write(' <td>Builder Image</td>\n')
cwd = os.getcwd() cwd = os.getcwd()
if os.path.isfile(cwd + '/archives/' + logFileName): variants = ['docker', 'podman']
status = False for variant in variants:
if nfType == 'SMF': logFileName = 'smf_' + variant + '_image_build.log'
section_start_pattern = 'build_smf --clean --Verbose --build-type Release --jobs'
section_end_pattern = 'FROM ubuntu:bionic as oai-smf$' if os.path.isfile(cwd + '/archives/' + logFileName):
pass_pattern = 'smf installed' status = False
if nfType == 'AMF-Server': if nfType == 'SMF':
section_start_pattern = 'mkdir build && cd build && cmake .. && make' section_start_pattern = 'build_smf --clean --Verbose --build-type Release --jobs'
section_end_pattern = 'FROM ubuntu:bionic as test-amf-server$' section_end_pattern = 'FROM ubuntu:bionic as oai-smf$'
pass_pattern = 'Built target amf-server' pass_pattern = 'smf installed'
path_pattern = 'src/test/amf' section_status = False
if nfType == 'AMF-Client': with open(cwd + '/archives/' + logFileName, 'r') as logfile:
section_start_pattern = 'mkdir build && cd build && cmake .. && make' for line in logfile:
section_end_pattern = 'FROM ubuntu:bionic as test-amf-client$' result = re.search(section_start_pattern, line)
pass_pattern = 'Built target amf-client'
path_pattern = 'src/test/amf_client'
if nfType == 'UDM-Server':
section_start_pattern = 'mkdir build && cd build && cmake .. && make'
section_end_pattern = 'FROM ubuntu:bionic as test-udm-server$'
pass_pattern = 'Built target udm-server'
path_pattern = 'src/test/udm'
section_status = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
for line in logfile:
result = re.search(section_start_pattern, line)
if result is not None:
section_status = True
result = re.search(section_end_pattern, line)
if result is not None:
section_status = False
if section_status:
result = re.search(pass_pattern, line)
if result is not None: if result is not None:
status = True section_status = True
logfile.close() result = re.search(section_end_pattern, line)
if status: if result is not None:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>' section_status = False
cell_msg += 'OK:\n' if section_status:
result = re.search(pass_pattern, line)
if result is not None:
status = True
logfile.close()
if status:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>'
cell_msg += 'OK:\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO:\n'
if nfType != 'SMF':
cell_msg += ' -- cd ' + path_pattern + '\n'
cell_msg += ' -- ' + section_start_pattern + '</b></pre></td>\n'
else: else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>' cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO:\n' cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
if nfType != 'SMF':
cell_msg += ' -- cd ' + path_pattern + '\n'
cell_msg += ' -- ' + section_start_pattern + '</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
self.file.write(cell_msg) self.file.write(cell_msg)
def analyze_compile_log(self, nfType, imageKind): def analyze_compile_log(self, nfType, imageKind):
if nfType != 'SMF' and nfType != 'AMF-Server' and nfType != 'AMF-Client' and nfType != 'UDM-Server': if nfType != 'SMF':
if imageKind: if imageKind:
self.file.write(' <td>N/A</td>\n') self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n') self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return return
if nfType == 'SMF':
logFileName = 'smf_docker_image_build.log'
if nfType == 'AMF-Server':
logFileName = 'amf_server_docker_image_build.log'
if nfType == 'AMF-Client':
logFileName = 'amf_client_docker_image_build.log'
if nfType == 'UDM-Server':
logFileName = 'udm_server_docker_image_build.log'
if imageKind: if imageKind:
self.file.write(' <td>Builder Image</td>\n') self.file.write(' <td>Builder Image</td>\n')
cwd = os.getcwd() cwd = os.getcwd()
nb_errors = 0 variants = ['docker', 'podman']
nb_warnings = 0 for variant in variants:
logFileName = 'smf_' + variant + '_image_build.log'
if os.path.isfile(cwd + '/archives/' + logFileName): nb_errors = 0
if nfType == 'SMF': nb_warnings = 0
section_start_pattern = 'build_smf --clean --Verbose --build-type Release --jobs' if os.path.isfile(cwd + '/archives/' + logFileName):
section_end_pattern = 'FROM ubuntu:bionic as oai-smf$' if nfType == 'SMF':
if nfType == 'AMF-Server': section_start_pattern = 'build_smf --clean --Verbose --build-type Release --jobs'
section_start_pattern = 'mkdir build && cd build && cmake .. && make' section_end_pattern = 'FROM ubuntu:bionic as oai-smf$'
section_end_pattern = 'FROM ubuntu:bionic as test-amf-server$' section_status = False
if nfType == 'AMF-Client': with open(cwd + '/archives/' + logFileName, 'r') as logfile:
section_start_pattern = 'mkdir build && cd build && cmake .. && make' for line in logfile:
section_end_pattern = 'FROM ubuntu:bionic as test-amf-client$' result = re.search(section_start_pattern, line)
if nfType == 'UDM-Server':
section_start_pattern = 'mkdir build && cd build && cmake .. && make'
section_end_pattern = 'FROM ubuntu:bionic as test-udm-server$'
section_status = False
with open(cwd + '/archives/' + logFileName, 'r') as logfile:
for line in logfile:
result = re.search(section_start_pattern, line)
if result is not None:
section_status = True
result = re.search(section_end_pattern, line)
if result is not None:
section_status = False
if section_status:
result = re.search('error:', line)
if result is not None: if result is not None:
nb_errors += 1 section_status = True
result = re.search('warning:', line) result = re.search(section_end_pattern, line)
if result is not None: if result is not None:
nb_warnings += 1 section_status = False
if nfType == 'SMF': if section_status:
correctLine = re.sub("^.*/openair-smf","/openair-smf",line.strip()) result = re.search('error:', line)
wordsList = correctLine.split(None,2) if result is not None:
filename = re.sub(":[0-9]*:[0-9]*:","", wordsList[0]) nb_errors += 1
linenumber = re.sub(filename + ':',"", wordsList[0]) result = re.search('warning:', line)
linenumber = re.sub(':[0-9]*:',"", linenumber) if result is not None:
error_warning_status = re.sub(':',"", wordsList[1]) nb_warnings += 1
error_warning_msg = re.sub('^.*' + error_warning_status + ':', '', correctLine) if nfType == 'SMF':
self.warning_rows += '<tr><td>' + filename + '</td><td>' + linenumber + '</td><td>' + error_warning_status + '</td><td>' + error_warning_msg + '</td></tr>\n' correctLine = re.sub("^.*/openair-smf","/openair-smf",line.strip())
logfile.close() wordsList = correctLine.split(None,2)
if nb_warnings == 0 and nb_errors == 0: filename = re.sub(":[0-9]*:[0-9]*:","", wordsList[0])
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>' linenumber = re.sub(filename + ':',"", wordsList[0])
elif nb_warnings < 20 and nb_errors == 0: linenumber = re.sub(':[0-9]*:',"", linenumber)
cell_msg = ' <td bgcolor="Orange"><pre style="border:none; background-color:Orange"><b>' error_warning_status = re.sub(':',"", wordsList[1])
error_warning_msg = re.sub('^.*' + error_warning_status + ':', '', correctLine)
self.warning_rows += '<tr><td>' + filename + '</td><td>' + linenumber + '</td><td>' + error_warning_status + '</td><td>' + error_warning_msg + '</td></tr>\n'
logfile.close()
if nb_warnings == 0 and nb_errors == 0:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>'
elif nb_warnings < 20 and nb_errors == 0:
cell_msg = ' <td bgcolor="Orange"><pre style="border:none; background-color:Orange"><b>'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
if nb_errors > 0:
cell_msg += str(nb_errors) + ' errors found in compile log\n'
cell_msg += str(nb_warnings) + ' warnings found in compile log</b></pre></td>\n'
if nfType == 'SMF':
self.nb_warnings = nb_warnings
else: else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>' cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
if nb_errors > 0: cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
cell_msg += str(nb_errors) + ' errors found in compile log\n'
cell_msg += str(nb_warnings) + ' warnings found in compile log</b></pre></td>\n'
if nfType == 'SMF':
self.nb_warnings = nb_warnings
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
self.file.write(cell_msg) self.file.write(cell_msg)
def copyToTargetImage(self): def copyToTargetImage(self):
self.file.write(' <tr>\n') self.file.write(' <tr>\n')
...@@ -732,40 +717,42 @@ class HtmlReport(): ...@@ -732,40 +717,42 @@ class HtmlReport():
def analyze_copy_log(self, nfType): def analyze_copy_log(self, nfType):
if nfType != 'SMF': if nfType != 'SMF':
self.file.write(' <td>N/A</td>\n') self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n') self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return return
logFileName = 'smf_docker_image_build.log'
self.file.write(' <td>Target Image</td>\n') self.file.write(' <td>Target Image</td>\n')
cwd = os.getcwd() cwd = os.getcwd()
if os.path.isfile(cwd + '/archives/' + logFileName): variants = ['docker', 'podman']
section_start_pattern = 'FROM ubuntu:bionic as oai-smf$' for variant in variants:
section_end_pattern = 'WORKDIR /openair-smf/etc' logFileName = 'smf_' + variant + '_image_build.log'
section_status = False if os.path.isfile(cwd + '/archives/' + logFileName):
status = False section_start_pattern = 'FROM ubuntu:bionic as oai-smf$'
with open(cwd + '/archives/' + logFileName, 'r') as logfile: section_end_pattern = 'WORKDIR /openair-smf/etc'
for line in logfile: section_status = False
result = re.search(section_start_pattern, line) status = False
if result is not None: with open(cwd + '/archives/' + logFileName, 'r') as logfile:
section_status = True for line in logfile:
result = re.search(section_end_pattern, line) result = re.search(section_start_pattern, line)
if result is not None: if result is not None:
section_status = False section_status = True
status = True result = re.search(section_end_pattern, line)
logfile.close() if result is not None:
if status: section_status = False
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>' status = True
cell_msg += 'OK:\n' logfile.close()
if status:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>'
cell_msg += 'OK:\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO:\n'
cell_msg += '</b></pre></td>\n'
else: else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>' cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO:\n' cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
cell_msg += '</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
self.file.write(cell_msg) self.file.write(cell_msg)
def copyConfToolsToTargetImage(self): def copyConfToolsToTargetImage(self):
self.file.write(' <tr>\n') self.file.write(' <tr>\n')
...@@ -776,40 +763,42 @@ class HtmlReport(): ...@@ -776,40 +763,42 @@ class HtmlReport():
def analyze_copy_conf_tool_log(self, nfType): def analyze_copy_conf_tool_log(self, nfType):
if nfType != 'SMF': if nfType != 'SMF':
self.file.write(' <td>N/A</td>\n') self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n') self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return return
logFileName = 'smf_docker_image_build.log'
self.file.write(' <td>Target Image</td>\n') self.file.write(' <td>Target Image</td>\n')
cwd = os.getcwd() cwd = os.getcwd()
if os.path.isfile(cwd + '/archives/' + logFileName): variants = ['docker', 'podman']
section_start_pattern = 'WORKDIR /openair-smf/etc' for variant in variants:
section_end_pattern = 'Successfully tagged oai-smf' logFileName = 'smf_' + variant + '_image_build.log'
section_status = False if os.path.isfile(cwd + '/archives/' + logFileName):
status = False section_start_pattern = 'WORKDIR /openair-smf/etc'
with open(cwd + '/archives/' + logFileName, 'r') as logfile: section_end_pattern = 'Successfully tagged oai-smf'
for line in logfile: section_status = False
result = re.search(section_start_pattern, line) status = False
if result is not None: with open(cwd + '/archives/' + logFileName, 'r') as logfile:
section_status = True for line in logfile:
result = re.search(section_end_pattern, line) result = re.search(section_start_pattern, line)
if result is not None: if result is not None:
section_status = False section_status = True
status = True result = re.search(section_end_pattern, line)
logfile.close() if result is not None:
if status: section_status = False
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>' status = True
cell_msg += 'OK:\n' logfile.close()
if status:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>'
cell_msg += 'OK:\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO:\n'
cell_msg += '</b></pre></td>\n'
else: else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>' cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO:\n' cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
cell_msg += '</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
self.file.write(cell_msg) self.file.write(cell_msg)
def imageSizeRow(self): def imageSizeRow(self):
self.file.write(' <tr>\n') self.file.write(' <tr>\n')
...@@ -818,77 +807,61 @@ class HtmlReport(): ...@@ -818,77 +807,61 @@ class HtmlReport():
self.file.write(' </tr>\n') self.file.write(' </tr>\n')
def analyze_image_size_log(self, nfType, imageKind): def analyze_image_size_log(self, nfType, imageKind):
if nfType != 'SMF' and nfType != 'AMF-Server' and nfType != 'AMF-Client' and nfType != 'UDM-Server': if nfType != 'SMF':
if imageKind: if imageKind:
self.file.write(' <td>N/A</td>\n') self.file.write(' <td>N/A</td>\n')
self.file.write(' <td>Wrong NF Type for this Report</td>\n') self.file.write(' <td colspan="2">Wrong NF Type for this Report</td>\n')
return return
if nfType == 'SMF':
logFileName = 'smf_docker_image_build.log'
if nfType == 'AMF-Server':
logFileName = 'amf_server_docker_image_build.log'
if nfType == 'AMF-Client':
logFileName = 'amf_client_docker_image_build.log'
if nfType == 'UDM-Server':
logFileName = 'udm_server_docker_image_build.log'
if imageKind: if imageKind:
self.file.write(' <td>Target Image</td>\n') self.file.write(' <td>Target Image</td>\n')
cwd = os.getcwd() cwd = os.getcwd()
if os.path.isfile(cwd + '/archives/' + logFileName): variants = ['docker', 'podman']
if nfType == 'SMF': for variant in variants:
section_start_pattern = 'Successfully tagged oai-smf' logFileName = 'smf_' + variant + '_image_build.log'
section_end_pattern = 'OAI-SMF DOCKER IMAGE BUILD' if os.path.isfile(cwd + '/archives/' + logFileName):
if nfType == 'AMF-Server': if nfType == 'SMF':
section_start_pattern = 'Successfully tagged test-amf-server' if variant == 'docker':
section_end_pattern = 'TEST-AMF-SERVER DOCKER IMAGE BUILD' section_start_pattern = 'Successfully tagged oai-smf'
if nfType == 'AMF-Client': section_end_pattern = 'OAI-SMF DOCKER IMAGE BUILD'
section_start_pattern = 'Successfully tagged test-amf-client' else:
section_end_pattern = 'TEST-AMF-CLIENT DOCKER IMAGE BUILD' section_start_pattern = 'COMMIT oai-smf:'
if nfType == 'UDM-Server': section_end_pattern = 'OAI-SMF PODMAN RHEL8 IMAGE BUILD'
section_start_pattern = 'Successfully tagged test-udm-server' section_status = False
section_end_pattern = 'TEST-UDM-SERVER DOCKER IMAGE BUILD' status = False
section_status = False with open(cwd + '/archives/' + logFileName, 'r') as logfile:
status = False for line in logfile:
with open(cwd + '/archives/' + logFileName, 'r') as logfile: result = re.search(section_start_pattern, line)
for line in logfile:
result = re.search(section_start_pattern, line)
if result is not None:
section_status = True
result = re.search(section_end_pattern, line)
if result is not None:
section_status = False
if section_status:
if nfType == 'SMF':
if self.git_pull_request:
result = re.search('oai-smf *ci-tmp', line)
else:
result = re.search('oai-smf *develop', line)
if nfType == 'AMF-Server':
result = re.search('test-amf-server *test-deploy', line)
if nfType == 'AMF-Client':
result = re.search('test-amf-client *test-deploy', line)
if nfType == 'UDM-Server':
result = re.search('test-udm-server *test-deploy', line)
if result is not None: if result is not None:
result = re.search('ago *([0-9A-Z]+)', line) section_status = True
result = re.search(section_end_pattern, line)
if result is not None:
section_status = False
if section_status:
if nfType == 'SMF':
if self.git_pull_request:
result = re.search('oai-smf *ci-tmp', line)
else:
result = re.search('oai-smf *develop', line)
if result is not None: if result is not None:
size = result.group(1) result = re.search('ago *([0-9A-Z]+)', line)
status = True if result is not None:
logfile.close() size = result.group(1)
if status: status = True
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>' logfile.close()
cell_msg += 'OK: ' + size + '\n' if status:
cell_msg = ' <td bgcolor="LimeGreen"><pre style="border:none; background-color:LimeGreen"><b>'
cell_msg += 'OK: ' + size + '\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO:\n'
cell_msg += '</b></pre></td>\n'
else: else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>' cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO:\n' cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
cell_msg += '</b></pre></td>\n'
else:
cell_msg = ' <td bgcolor="Tomato"><pre style="border:none; background-color:Tomato"><b>'
cell_msg += 'KO: logfile (' + logFileName + ') not found</b></pre></td>\n'
self.file.write(cell_msg) self.file.write(cell_msg)
def testBuildCompileRows(self): def testBuildCompileRows(self):
self.file.write(' <tr>\n') self.file.write(' <tr>\n')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment