-
Notifications
You must be signed in to change notification settings - Fork 0
/
gnbsim.groovy
211 lines (194 loc) · 8.62 KB
/
gnbsim.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// SPDX-FileCopyrightText: 2021 Open Networking Foundation <[email protected]>
// SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
pipeline {
options {
timeout(time: 1, unit: 'HOURS')
}
agent {
label "${AgentLabel}"
}
stages{
stage('Verify AWS Accessible') {
steps {
withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID',
credentialsId: 'AKIA6OOX34YQ5DJLY5GJ',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
sh """
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
aws --region us-west-2 ec2 describe-instances --instance-ids i-000f1f7e33fe5a86e
sleep 300
aws --region us-west-2 ec2 describe-instances --instance-ids i-000f1f7e33fe5a86e \
--query 'Reservations[0].Instances[0].PrivateIpAddress'
"""
}
}
}
stage('Configure OnRamp') {
steps {
withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID',
credentialsId: 'AKIA6OOX34YQ5DJLY5GJ', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
sh """
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
cd aether-onramp
# Determine Local IP
MYIP=\$(hostname -I | awk '{print \$1}')
echo "MY IP is: " \$MYIP
which curl
which wget
MYID=\$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
echo "MYID is " \$MYID
aws --region us-west-2 ec2 modify-instance-attribute --no-source-dest-check \
--instance-id \$MYID
echo "WORKER SourceDestCheck"
aws --region us-west-2 ec2 describe-instances --instance-ids i-000f1f7e33fe5a86e \
--query 'Reservations[0].Instances[0].NetworkInterfaces[0].SourceDestCheck'
echo "MAIN SourceDestCheck"
aws --region us-west-2 ec2 describe-instances --instance-ids \$MYID \
--query 'Reservations[0].Instances[0].NetworkInterfaces[0].SourceDestCheck'
# Determine active network interface (8.8.8.8 is Google)
MYIFC=\$(ip route get 8.8.8.8| awk '{print \$5}'|awk /./)
echo "MY IFC is: " \$MYIFC
# Create appropriate hosts.ini file
cat > hosts.ini << EOF
[all]
node1 ansible_host=\$MYIP ansible_user=ubuntu ansible_ssh_private_key_file=/home/ubuntu/aether-qa.pem ansible_sudo_pass=ubuntu
node2 ansible_host=\$WORKERIP ansible_user=ubuntu ansible_ssh_private_key_file=/home/ubuntu/aether-qa.pem ansible_sudo_pass=ubuntu
[master_nodes]
node1
[worker_nodes]
#node2
[gnbsim_nodes]
node2
EOF
cat hosts.ini
NODE2_IP=\$(grep ansible_host hosts.ini | grep node2 | awk -F" |=" '{print \$3}')
echo "NODE2_IP is " \$NODE2_IP
sleep 120
sudo cp vars/main-gnbsim.yml vars/main.yml
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 """
cd $WORKSPACE/aether-onramp
make aether-k8s-install
make aether-5gc-install
make aether-gnbsim-install
kubectl get pods -n omec
"""
}
}
stage("Run gNBsim"){
steps {
sh """
cd $WORKSPACE/aether-onramp
NODE2_IP=\$(grep ansible_host hosts.ini | grep node2 | awk -F" |=" '{print \$3}')
sleep 60
kubectl get pods -n omec
make aether-gnbsim-run
cd /home/ubuntu
ssh -i "aether-qa.pem" -o StrictHostKeyChecking=no ubuntu@\$NODE2_IP \
"docker exec gnbsim-1 cat summary.log"
ssh -i "aether-qa.pem" -o StrictHostKeyChecking=no ubuntu@\$NODE2_IP \
"docker exec gnbsim-2 cat summary.log"
"""
}
}
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
ssh -i "aether-qa.pem" -o StrictHostKeyChecking=no ubuntu@\$NODE2_IP \
"docker exec gnbsim-1 cat summary.log" | grep "Profile Status: PASS"
ssh -i "aether-qa.pem" -o StrictHostKeyChecking=no ubuntu@\$NODE2_IP \
"docker exec gnbsim-2 cat summary.log" | grep "Profile Status: PASS"
"""
}
}
}
stage("Retrieve Logs") {
steps {
sh """
mkdir $WORKSPACE/logs
cd $WORKSPACE/aether-onramp
NODE2_IP=\$(grep ansible_host hosts.ini | grep node2 | awk -F" |=" '{print \$3}')
cd /home/ubuntu
LOGFILE=\$(ssh -i "aether-qa.pem" -o StrictHostKeyChecking=no ubuntu@\$NODE2_IP \
"docker exec gnbsim-1 ls " | grep "gnbsim1-.*.log") || true
echo \$LOGFILE
ssh -i "aether-qa.pem" -o StrictHostKeyChecking=no ubuntu@\$NODE2_IP \
"docker cp gnbsim-1:/gnbsim/bin/\$LOGFILE /home/ubuntu/\$LOGFILE"
scp -i "aether-qa.pem" -o StrictHostKeyChecking=no \
ubuntu@\$NODE2_IP:\$LOGFILE $WORKSPACE/logs
LOGFILE=\$(ssh -i "aether-qa.pem" -o StrictHostKeyChecking=no ubuntu@\$NODE2_IP \
"docker exec gnbsim-2 ls " | grep "gnbsim2-.*.log") || true
echo \$LOGFILE
ssh -i "aether-qa.pem" -o StrictHostKeyChecking=no ubuntu@\$NODE2_IP \
"docker cp gnbsim-2:/gnbsim/bin/\$LOGFILE /home/ubuntu/\$LOGFILE"
scp -i "aether-qa.pem" -o StrictHostKeyChecking=no \
ubuntu@\$NODE2_IP:\$LOGFILE $WORKSPACE/logs
cd $WORKSPACE/logs
AMF_POD_NAME=\$(kubectl get pods -n omec | grep amf | awk 'NR==1{print \$1}')
echo \$AMF_POD_NAME
kubectl logs \$AMF_POD_NAME -n omec > gnbsim_amf.log
WEBUI_POD_NAME=\$(kubectl get pods -n omec | grep webui | awk 'NR==1{print \$1}')
echo \$WEBUI_POD_NAME
kubectl logs \$WEBUI_POD_NAME -n omec > gnbsim_webui.log
UDR_POD_NAME=\$(kubectl get pods -n omec | grep udr | awk 'NR==1{print \$1}')
echo \$UDR_POD_NAME
kubectl logs \$UDR_POD_NAME -n omec > gnbsim_udr.log
UDM_POD_NAME=\$(kubectl get pods -n omec | grep udm | awk 'NR==1{print \$1}')
echo \$UDM_POD_NAME
kubectl logs \$UDM_POD_NAME -n omec > gnbsim_udm.log
AUSF_POD_NAME=\$(kubectl get pods -n omec | grep ausf | awk 'NR==1{print \$1}')
echo \$AUSF_POD_NAME
kubectl logs \$AUSF_POD_NAME -n omec > gnbsim_ausf.log
SMF_POD_NAME=\$(kubectl get pods -n omec | grep smf | awk 'NR==1{print \$1}')
echo \$SMF_POD_NAME
kubectl logs \$SMF_POD_NAME -n omec > gnbsim_smf.log
"""
}
}
stage("Archive Artifacts"){
steps {
archiveArtifacts allowEmptyArchive: true, artifacts: "**/logs/*.log", followSymlinks: false
}
}
}
post {
always {
withCredentials([aws(accessKeyVariable: 'AWS_ACCESS_KEY_ID',
credentialsId: 'AKIA6OOX34YQ5DJLY5GJ', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY')]) {
sh """
cd $WORKSPACE/aether-onramp
make gnbsim-uninstall
make 5gc-uninstall
make k8s-uninstall
aws --region us-west-2 ec2 stop-instances --instance-ids i-000f1f7e33fe5a86e
"""
}
}
// triggered when red sign
failure {
slackSend color: "danger", message: "FAILED ${env.JOB_NAME} ${env.BUILD_NUMBER} ${env.BUILD_URL}"
}
}
}