Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error handling and improve validation checks in pipeline scripts #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions gnbsim.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pipeline {
credentialsId: 'AKIA6OOX34YQ5DJLY5GJ',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
sh """
set -e
aws --region us-west-2 ec2 start-instances --instance-ids i-000f1f7e33fe5a86e
aws --region us-west-2 ec2 modify-instance-attribute --no-source-dest-check \
--instance-id i-000f1f7e33fe5a86e
Expand All @@ -29,20 +30,21 @@ pipeline {
}
}
}

stage('Configure OnRamp') {
steps {
withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID',
credentialsId: 'AKIA6OOX34YQ5DJLY5GJ', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
sh """
set -e
NEWIP=\$(aws --region us-west-2 ec2 describe-instances \
--instance-ids i-000f1f7e33fe5a86e \
--query 'Reservations[0].Instances[0].PrivateIpAddress')
echo \$NEWIP
WORKERIP=\$(echo \$NEWIP | tr -d '"')
echo \$WORKERIP
cd $WORKSPACE
git clone --recursive https://github.com/opennetworkinglab/aether-onramp.git
git clone --recursive https://github.com/opennetworkinglab/aether-onramp.git
cd aether-onramp
# Determine Local IP
MYIP=\$(hostname -I | awk '{print \$1}')
Expand Down Expand Up @@ -85,14 +87,15 @@ EOF
grep -rl "ens18" . | xargs sed -i "s/ens18/\$MYIFC/g"
sudo sed -i "s/10.76.28.113/\$MYIP/" vars/main.yml
make aether-pingall
"""
"""
}
}
}

stage('Install Aether') {
steps {
sh """
set -e
cd $WORKSPACE/aether-onramp
make aether-k8s-install
make aether-5gc-install
Expand All @@ -101,10 +104,11 @@ EOF
"""
}
}

stage("Run gNBsim"){
steps {
sh """
set -e
cd $WORKSPACE/aether-onramp
NODE2_IP=\$(grep ansible_host hosts.ini | grep node2 | awk -F" |=" '{print \$3}')
sleep 60
Expand All @@ -117,28 +121,31 @@ EOF
"""
}
}

stage("Validate Results"){
steps {
catchError(message:'Gnbsim Validation is failed', buildResult:'FAILURE',
stageResult:'FAILURE') {
sh """
cd $WORKSPACE/aether-onramp
NODE2_IP=\$(grep ansible_host hosts.ini | grep node2 | awk -F" |=" '{print \$3}')
cd /home/ubuntu
catchError(message: 'Gnbsim Validation failed. Please check logs for details.',
buildResult: 'FAILURE',
stageResult: 'FAILURE') {
sh """
set -e
cd $WORKSPACE/aether-onramp
NODE2_IP=\$(grep ansible_host hosts.ini | grep node2 | awk -F" |=" '{print \$3}')
cd /home/ubuntu
# weaker validation test
ssh -i "aether-qa.pem" -o StrictHostKeyChecking=no ubuntu@\$NODE2_IP \
"docker exec gnbsim-1 cat summary.log" | grep "Ue's Passed" | grep -v "Passed: 0"
ssh -i "aether-qa.pem" -o StrictHostKeyChecking=no ubuntu@\$NODE2_IP \
"docker exec gnbsim-2 cat summary.log" | grep "Ue's Passed" | grep -v "Passed: 0"
"""
ssh -i "aether-qa.pem" -o StrictHostKeyChecking=no ubuntu@\$NODE2_IP \
"docker exec gnbsim-1 cat summary.log" | grep "Ue's Passed" | grep -v "Passed: 0"
ssh -i "aether-qa.pem" -o StrictHostKeyChecking=no ubuntu@\$NODE2_IP \
"docker exec gnbsim-2 cat summary.log" | grep "Ue's Passed" | grep -v "Passed: 0"
"""
}
}
}

stage("Retrieve Logs") {
steps {
sh """
set -e
mkdir $WORKSPACE/logs
cd $WORKSPACE/aether-onramp
NODE2_IP=\$(grep ansible_host hosts.ini | grep node2 | awk -F" |=" '{print \$3}')
Expand Down Expand Up @@ -193,6 +200,7 @@ EOF
withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID',
credentialsId: 'AKIA6OOX34YQ5DJLY5GJ', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
sh """
set -e
cd $WORKSPACE/aether-onramp
make gnbsim-uninstall
make 5gc-uninstall
Expand Down
22 changes: 16 additions & 6 deletions oai.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ pipeline {
}

agent {
label "${AgentLabel}"
label "${AgentLabel}"
}

stages{

stage('Configure OnRamp') {
steps {
sh """
set -e
cd $WORKSPACE
git clone --recursive https://github.com/opennetworkinglab/aether-onramp.git
cd aether-onramp
Expand Down Expand Up @@ -46,6 +47,7 @@ EOF
stage('Install Aether') {
steps {
sh """
set -e
cd $WORKSPACE/aether-onramp
make k8s-install
make 5gc-install
Expand All @@ -59,6 +61,7 @@ EOF
steps {
retry(2) {
sh """
set -e
cd $WORKSPACE/aether-onramp
sleep 60
make oai-uesim-start
Expand All @@ -70,20 +73,26 @@ EOF

stage ('Validate Results'){
steps {
catchError(message:'UEsim Validation fails', buildResult:'FAILURE', stageResult:'FAILURE')
{
catchError(message: 'UEsim Validation fails: Check UEsim.log for details', buildResult: 'FAILURE', stageResult: 'FAILURE') {
sh """
set -e
cd $WORKSPACE
docker exec rfsim5g-oai-nr-ue ping -c 2 -I oaitun_ue1 192.168.250.1 > UEsim.log
grep "0% packet loss" UEsim.log
if grep "0% packet loss" UEsim.log; then
echo "Validation successful: No packet loss"
else
echo "Validation failed: Packet loss detected"
exit 1
fi
"""
}
}
}
}

stage ('Retrieve Logs'){
steps {
sh '''
set -e
cd $WORKSPACE
mkdir logs
cp UEsim.log logs
Expand Down Expand Up @@ -121,6 +130,7 @@ EOF
post {
always {
sh """
set -e
cd $WORKSPACE/aether-onramp
make oai-uesim-stop
make oai-gnb-uninstall
Expand Down
28 changes: 18 additions & 10 deletions quickstart.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ pipeline {
agent {
label "${AgentLabel}"
}

stages{

stage('Configure OnRamp') {
steps {
sh """
set -e
cd $WORKSPACE
git clone --recursive https://github.com/opennetworkinglab/aether-onramp.git
cd aether-onramp
Expand Down Expand Up @@ -42,10 +43,11 @@ EOF
"""
}
}

stage('Install Aether') {
steps {
sh """
set -e
cd $WORKSPACE/aether-onramp
make aether-k8s-install
make aether-5gc-install
Expand All @@ -60,6 +62,7 @@ EOF
steps {
retry(2) {
sh """
set -e
cd $WORKSPACE/aether-onramp
sleep 60
make aether-gnbsim-run
Expand All @@ -71,19 +74,23 @@ EOF

stage ('Validate Results'){
steps {
catchError(message:'gNBsim Validation fails', buildResult:'FAILURE', stageResult:'FAILURE')
{
sh """
# weaker validation test
docker exec gnbsim-1 cat summary.log | grep "Ue's Passed" | grep -v "Passed: 0"
"""
}
catchError(message: 'gNBsim Validation failed: Check logs for details', buildResult: 'FAILURE', stageResult: 'FAILURE') {
script {
def result = sh(script: "docker exec gnbsim-1 cat summary.log | grep 'Ue\\'s Passed' | grep -v 'Passed: 0'", returnStatus: true)
if (result != 0) {
echo "Validation failed: Check summary.log"
sh "docker exec gnbsim-1 cat summary.log"
error("gNBsim validation failed")
}
}
}
}
}

stage ('Retrieve Logs'){
steps {
sh '''
set -e
mkdir $WORKSPACE/logs
cd $WORKSPACE/logs
logfile=\$(docker exec gnbsim-1 ls | grep "gnbsim1-.*.log")
Expand Down Expand Up @@ -122,6 +129,7 @@ EOF
post {
always {
sh """
set -e
cd $WORKSPACE/aether-onramp
make gnbsim-uninstall
make 5gc-uninstall
Expand Down
27 changes: 18 additions & 9 deletions quickstart_amp.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pipeline {
stage('Configure OnRamp') {
steps {
sh """
set -e
cd $WORKSPACE
git clone --recursive https://github.com/opennetworkinglab/aether-onramp.git
cd aether-onramp
Expand Down Expand Up @@ -47,8 +48,9 @@ EOF
stage('Install Aether') {
steps {
sh """
set -e
cd $WORKSPACE/aether-onramp
make aether-k8s-install
make aether-k8s-install
make aether-amp-install
make aether-5gc-install
make aether-gnbsim-install
Expand All @@ -62,6 +64,7 @@ EOF
steps {
retry(2) {
sh """
set -e
cd $WORKSPACE/aether-onramp
sleep 60
make aether-gnbsim-run
Expand All @@ -72,20 +75,25 @@ EOF
}

stage ('Validate Results'){
steps {
catchError(message:'gNBsim Validation fails', buildResult:'FAILURE', stageResult:'FAILURE')
{
sh """
# weaker validation test
docker exec gnbsim-1 cat summary.log | grep "Ue's Passed" | grep -v "Passed: 0"
"""
}
steps {
catchError(message: 'gNBsim Validation failed: Check logs for details', buildResult: 'FAILURE', stageResult: 'FAILURE') {
script {
def result = sh(script: "docker exec gnbsim-1 cat summary.log | grep 'Ue\\'s Passed' | grep -v 'Passed: 0'", returnStatus: true)
if (result != 0) {
echo "Validation failed: Check summary.log"
sh "docker exec gnbsim-1 cat summary.log" // Print the log to console for debugging
error("gNBsim validation failed") // Explicit failure message
}
}
}
}
}


stage ('Retrieve Logs'){
steps {
sh '''
set -e
mkdir $WORKSPACE/logs
cd $WORKSPACE/logs
logfile=\$(docker exec gnbsim-1 ls | grep "gnbsim1-.*.log")
Expand Down Expand Up @@ -124,6 +132,7 @@ EOF
post {
always {
sh """
set -e
cd $WORKSPACE/aether-onramp
make gnbsim-uninstall
make 5gc-uninstall
Expand Down
Loading