Skip to content

Commit

Permalink
CORTX-33964: Improvement in code coverage job (Seagate#2099)
Browse files Browse the repository at this point in the history
Problem:
With the previous job if one of the test failed then
rest of the jobs were not executed.

Solution:
Running tests individually instead of a group.
Ignoring any failures that occur.

Signed-off-by: Rinku Kothiya <rinku.kothiya@seagate.com>
  • Loading branch information
rkothiya authored and kiwionly2 committed Aug 30, 2022
1 parent 053ce9d commit 45a118c
Showing 1 changed file with 44 additions and 33 deletions.
77 changes: 44 additions & 33 deletions scripts/jenkins/code-coverage.groovy
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
pipeline {
pipeline {

agent {
label "jenkins-client-for-cortx-motr"
label "code-coverage"
}

parameters {
string(name: 'NODE_HOST', defaultValue: '', description: 'Node 1 Host FQDN', trim: true)
string(name: 'NODE_USER', defaultValue: '', description: 'Host machine root user', trim: true)
string(name: 'NODE_PASS', defaultValue: '', description: 'Host machine root user password', trim: true)
string(name: 'BRANCH', defaultValue: '', description: 'Branch name', trim: true)
string(name: 'OPTIONS', defaultValue: '', description: 'Build options', trim: true)
booleanParam(name: 'UT', defaultValue: true, description: 'Run UT')
Expand All @@ -17,58 +14,72 @@ pipeline {
options {
timeout(time: 180, unit: 'MINUTES')
timestamps()
ansiColor('xterm')
ansiColor('xterm')
buildDiscarder(logRotator(numToKeepStr: "30"))
}

environment {
NODE_PASS = "${NODE_PASS.isEmpty() ? NODE_DEFAULT_SSH_CRED_PSW : NODE_PASS}"
TestList = "/tmp/list-of-unit-tests.txt"
}

stages {
stage('Checkout') {
steps {
checkout([$class: 'GitSCM', branches: [[name: "main"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'PathRestriction', excludedRegions: '', includedRegions: 'scripts/third-party-rpm/.*']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'cortx-admin-github', url: "https://github.com/Seagate/cortx-motr"]]])
}
}
stage ('Compile, execute test and report code coverage') {
steps {
script { build_stage = env.STAGE_NAME }
sh label: 'Clean up and build motr and run ut for code coverage', script: '''
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} hostname
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "yum install -y httpd lcov"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "systemctl start httpd.service"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "rm -rf /root/cortx-motr"
sh label: 'Clean up, build motr, run ut/st and generate code coverage report', script: '''
hostname
pwd
yum install -y httpd lcov
systemctl start httpd.service
make uninstall || true
make clean || true
rm -rf cortx-motr
OLD_BUILD_NUMBER=$(echo "$BUILD_NUMBER - 10" | bc)
echo "Old build number is : $OLD_BUILD_NUMBER"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "rm -rf /var/www/html/$OLD_BUILD_NUMBER || true"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/ ; git clone --recursive -b ${BRANCH} https://github.com/Seagate/cortx-motr"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; sudo ./scripts/install-build-deps"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; ./autogen.sh"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; ./configure --enable-coverage --enable-debug ${OPTIONS}"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; make -j6"
rm -rf /var/www/html/$OLD_BUILD_NUMBER || true
git clone --recursive -b ${BRANCH} https://github.com/Seagate/cortx-motr cortx-motr
cd cortx-motr
sudo ./scripts/install-build-deps
./autogen.sh
./configure --enable-coverage --enable-debug ${OPTIONS}
make -j6
if [ ${UT} == true ]
then
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; sudo ./scripts/m0 run-ut"
./scripts/m0 run-ut -l > "$TestList"
set +o errexit
while read Test
do
echo "Executing: $Test"
timeout --preserve-status -k 600s 600s ./scripts/m0 run-ut -t $Test
echo "Test $Test Executed and exited with return code $?"
done < "$TestList"
fi
if [ ${ST} == true ]
then
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; sudo ./scripts/m0 run-st"
./scripts/m0 run-ut -l > "$TestList"
set +o errexit
while read Test
do
echo "Executing: $Test"
timeout --preserve-status -k 600s 600s ./scripts/m0 run-st -t $Test
echo "Test $Test Executed and exited with return code $?"
done < "$TestList"
fi
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cd /root/cortx-motr ; ./scripts/coverage/gcov-gen-html user ./ ./"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "mkdir -p /var/www/html/$BUILD_NUMBER"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "cp -r /root/cortx-motr/* /var/www/html/$BUILD_NUMBER/"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "systemctl start firewalld.service"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "firewall-cmd --permanent --add-port=80/tcp"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "firewall-cmd --permanent --add-port=443/tcp"
sshpass -p ${NODE_PASS} ssh -o StrictHostKeyChecking=no ${NODE_USER}@${NODE_HOST} "firewall-cmd --reload"
echo "http://${NODE_HOST}/${BUILD_NUMBER}/"
./scripts/coverage/gcov-gen-html user ./ ./
mkdir -p /var/www/html/$BUILD_NUMBER
cp -r * /var/www/html/$BUILD_NUMBER/
systemctl start firewalld.service
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --reload
echo "http://$(hostname)/${BUILD_NUMBER}/"
'''
}
}
}
}

0 comments on commit 45a118c

Please sign in to comment.