Commit 6199f199 authored by Raphael Defosseux's avatar Raphael Defosseux
Browse files

feat(ci): adding gnbsim to sanity check deployment. Currenly failing


Signed-off-by: Raphael Defosseux's avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 65075fb1
......@@ -20,6 +20,7 @@ For more information about the OpenAirInterface (OAI) Software Alliance:
"""
import argparse
import glob
import logging
import os
import re
......@@ -89,11 +90,6 @@ def _parse_args() -> argparse.Namespace:
def deployObject(service, tag, compose_file):
logging.info ('Deploying ' + service)
if service == 'gnbsim-vpp':
logging.info ('Not available for the moment')
time.sleep(10)
return
if not os.path.isdir('./archives'):
subprocess_run_w_echo('mkdir -p ./archives')
......@@ -139,10 +135,16 @@ def deployObject(service, tag, compose_file):
subprocess_run_w_echo('sed -i -e "s#oai-amf:latest#oai-amf:develop#" -e "s#oai-smf:latest#oai-smf:develop#" ./ci-' + compose_file)
subprocess_run_w_echo('docker-compose -p vpp-sanity -f ./ci-' + compose_file + ' up -d ' + service)
expect_healthy = 5
if service == 'gnbsim-vpp':
subprocess_run_w_echo('echo "GNBSIM_TAG: gnbsim:latest" > ../archives/gnbsim_image_info.log')
subprocess_run_w_echo('docker image inspect --format="Size = {{.Size}} bytes" gnbsim:latest >> ../archives/gnbsim_image_info.log')
subprocess_run_w_echo('docker image inspect --format="Date = {{.Created}}" gnbsim:latest >> ../archives/gnbsim_image_info.log')
subprocess_run_w_echo('docker-compose -p vpp-sanity -f ./ci-' + compose_file + ' up -d ' + service)
expect_healthy = 1
# Counting the number of healthy containers
cmd = 'docker-compose -p vpp-sanity -f ./ci-' + compose_file + ' ps -a'
while (nb_healthy != expect_healthy) or (cnt > 50):
while (nb_healthy != expect_healthy) and (cnt < 15):
time.sleep(5)
cnt += 1
res = subprocess.check_output(cmd, shell=True, universal_newlines=True)
......@@ -151,29 +153,26 @@ def deployObject(service, tag, compose_file):
result = re.search('Up.*healthy', line)
if result is not None:
nb_healthy += 1
if nb_healthy == expect_healthy:
logging.info('OK')
# Adding a tempo for VPP-UPF to be fully ready
if service == 'vpp-upf':
time.sleep(10)
elif cnt > 50:
elif cnt == 15:
logging.error('KO')
sys.exit(-1)
def undeployObject(service, compose_file):
logging.info ('Un-Deploying ' + service)
if service == 'gnbsim-vpp':
logging.info ('Not available for the moment')
return
os.chdir('docker-compose')
if os.path.exists('./ci-' + compose_file):
subprocess_run_w_echo('docker-compose -p vpp-sanity -f ./ci-' + compose_file + ' down')
subprocess_run_w_echo('docker-compose -p vpp-sanity -f ./ci-' + compose_file + ' down || true')
else:
subprocess_run_w_echo('docker-compose -p vpp-sanity -f ./' + compose_file + ' down')
subprocess_run_w_echo('docker-compose -p vpp-sanity -f ./' + compose_file + ' down || true')
if os.path.exists('/tmp/ci-upf-vpp-sanity.pcap'):
if os.path.exists('/tmp/ci-upf-vpp-sanity.pcap') and service == 'all':
subprocess_run_w_echo('sudo rm -f /tmp/ci-upf-vpp-sanity.pcap')
def checkDeployment(service, compose_file):
......@@ -203,19 +202,24 @@ def checkDeployment(service, compose_file):
logging.error('PCFP association b/w SMF and UPF failed')
os.chdir('docker-compose')
# we should at least have the default ci-docker-compose.yml
if not os.path.exists('./ci-' + compose_file):
return
cmd = 'docker-compose -p vpp-sanity -f ./ci-' + compose_file + ' ps -a'
res = subprocess.check_output(cmd, shell=True, universal_newlines=True)
healthy_cnt = 0
for line in res.split('\n'):
result = re.search('Up.*healthy', line)
if result is not None:
subprocess_run_w_echo('docker logs ' + line.split(' ')[0] + ' > ../archives/' + line.split(' ')[0] + '.log 2>&1')
healthy_cnt += 1
if upf_register and (healthy_cnt == 5):
for yml_file in glob.glob('./ci-docker-compose*.y*ml'):
cmd = 'docker-compose -p vpp-sanity -f ' + yml_file + ' ps -a'
res = subprocess.check_output(cmd, shell=True, universal_newlines=True)
healthy_cnt = 0
for line in res.split('\n'):
result = re.search('Up.*healthy', line)
if result is not None:
subprocess_run_w_echo('docker logs ' + line.split(' ')[0] + ' > ../archives/' + line.split(' ')[0] + '.log 2>&1')
healthy_cnt += 1
result = re.search('Exit 2', line)
if result is not None:
subprocess_run_w_echo('docker logs ' + line.split(' ')[0] + ' > ../archives/' + line.split(' ')[0] + '.log 2>&1')
if upf_register and pfcp_association and (healthy_cnt == 6):
subprocess_run_w_echo('echo "SANITY-CHECK-DEPLOYMENT: OK" > ../archives/deployment_status.log')
else:
subprocess_run_w_echo('echo "SANITY-CHECK-DEPLOYMENT: KO" > ../archives/deployment_status.log')
......
version: '3.8'
services:
gnbsim-vpp:
container_name: gnbsim-vpp
container_name: "gnbsim-vpp"
image: gnbsim:latest
privileged: true
environment:
......
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