blob: 2684bf7052083740b8cd64683e34e14600fbce0f [file] [log] [blame]
Pau Espin Pedrolbc1ed882018-05-17 16:59:58 +02001#!/usr/bin/env python3
2import os
3from mako.template import Template
4
5from osmo_gsm_tester.testenv import *
6
7hlr_dummy = suite.hlr()
8mgw_dummy = suite.mgw()
9stp_dummy = suite.stp()
10msc_dummy = suite.msc(hlr_dummy, mgw_dummy, stp_dummy)
11ggsn_dummy = suite.ggsn()
12sgsn_dummy = suite.sgsn(hlr_dummy, ggsn_dummy)
13bsc = suite.bsc(msc_dummy, mgw_dummy, stp_dummy)
14bts = suite.bts()
15osmocon = suite.osmocon()
16
17bts.set_num_trx(1)
18bts.set_trx_phy_channel(0, 0, 'CCCH+SDCCH4')
19bts.set_trx_phy_channel(0, 1, 'TCH/F')
20bts.set_trx_phy_channel(0, 2, 'TCH/F')
21bts.set_trx_phy_channel(0, 3, 'TCH/F_PDCH')
22bts.set_trx_phy_channel(0, 4, 'TCH/F_TCH/H_PDCH')
23bts.set_trx_phy_channel(0, 5, 'TCH/H')
24bts.set_trx_phy_channel(0, 6, 'SDCCH8')
25bts.set_trx_phy_channel(0, 7, 'PDCH')
26
27print('Starting CNI')
28hlr_dummy.start()
29stp_dummy.start()
30msc_dummy.start()
31mgw_dummy.start()
32
Pau Espin Pedrola5285562018-10-15 17:20:50 +020033nat_rsl_ip = suite.ip_address().get('addr')
34bsc.set_rsl_ip(nat_rsl_ip)
Pau Espin Pedrolbc1ed882018-05-17 16:59:58 +020035bsc.bts_add(bts)
36sgsn_dummy.bts_add(bts)
37
38bsc.start()
39bts.start(keepalive=True)
40
41print('Starting osmocon')
42osmocon.start()
43
44own_dir = os.path.dirname(os.path.realpath(__file__))
45script_file = os.path.join(own_dir, 'scripts', 'run_ttcn3_docker.sh')
46bts_tmpl_file = os.path.join(own_dir, 'scripts', 'BTS_Tests.cfg.tmpl')
47script_run_dir = test.get_run_dir().new_dir('ttcn3')
48bts_cfg_file = os.path.join(str(script_run_dir), 'BTS_Tests.cfg')
49junit_ttcn3_dst_file = os.path.join(str(suite.trial.get_run_dir()), 'trial-') + suite.name() + '.xml'
Pau Espin Pedrolf6166142018-10-11 17:49:34 +020050if bts.bts_type() == 'osmo-bts-trx':
51 pcu_available = True
52 pcu_sk = bts.pcu_socket_path()
53else: # PCU unix socket not available locally
54 pcu_available = False
55 pcu_sk = ''
Pau Espin Pedrola5285562018-10-15 17:20:50 +020056docker_cmd = (script_file, str(script_run_dir), junit_ttcn3_dst_file, nat_rsl_ip, osmocon.l2_socket_path(), pcu_sk)
Pau Espin Pedrolbc1ed882018-05-17 16:59:58 +020057
58print('Creating template')
59mytemplate = Template(filename=bts_tmpl_file)
Pau Espin Pedrolf6166142018-10-11 17:49:34 +020060r = mytemplate.render(btsvty_ctrl_hostname=bts.remote_addr(), pcu_available=pcu_available)
Pau Espin Pedrolbc1ed882018-05-17 16:59:58 +020061with open(bts_cfg_file, 'w') as f:
62 f.write(r)
63
64
65print('Starting TTCN3 tests')
66proc = process.Process('ttcn3', script_run_dir, docker_cmd)
67try:
68 proc.launch()
69 print('Starting TTCN3 launched, waiting until it finishes')
70 proc.wait(timeout=3600)
71except Exception as e:
72 proc.terminate()
73 raise e
74
75if proc.result != 0:
76 raise RuntimeError("run_ttcn3_docker.sh exited with error code %d" % proc.result)
77
78print('Done')