blob: 4839052a54d3d00e7f27860a2855cc74a66af88e [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
Pau Espin Pedrolceb7ea62020-02-06 15:59:48 +01007ttcn3_test_execute="BTS_Tests.control"
8
Pau Espin Pedrolbc1ed882018-05-17 16:59:58 +02009hlr_dummy = suite.hlr()
10mgw_dummy = suite.mgw()
11stp_dummy = suite.stp()
12msc_dummy = suite.msc(hlr_dummy, mgw_dummy, stp_dummy)
13ggsn_dummy = suite.ggsn()
14sgsn_dummy = suite.sgsn(hlr_dummy, ggsn_dummy)
15bsc = suite.bsc(msc_dummy, mgw_dummy, stp_dummy)
16bts = suite.bts()
17osmocon = suite.osmocon()
18
19bts.set_num_trx(1)
20bts.set_trx_phy_channel(0, 0, 'CCCH+SDCCH4')
21bts.set_trx_phy_channel(0, 1, 'TCH/F')
22bts.set_trx_phy_channel(0, 2, 'TCH/F')
23bts.set_trx_phy_channel(0, 3, 'TCH/F_PDCH')
24bts.set_trx_phy_channel(0, 4, 'TCH/F_TCH/H_PDCH')
25bts.set_trx_phy_channel(0, 5, 'TCH/H')
26bts.set_trx_phy_channel(0, 6, 'SDCCH8')
27bts.set_trx_phy_channel(0, 7, 'PDCH')
28
29print('Starting CNI')
30hlr_dummy.start()
31stp_dummy.start()
32msc_dummy.start()
33mgw_dummy.start()
34
Pau Espin Pedrola5285562018-10-15 17:20:50 +020035nat_rsl_ip = suite.ip_address().get('addr')
36bsc.set_rsl_ip(nat_rsl_ip)
Pau Espin Pedrolbc1ed882018-05-17 16:59:58 +020037bsc.bts_add(bts)
38sgsn_dummy.bts_add(bts)
39
40bsc.start()
41bts.start(keepalive=True)
42
43print('Starting osmocon')
44osmocon.start()
45
46own_dir = os.path.dirname(os.path.realpath(__file__))
47script_file = os.path.join(own_dir, 'scripts', 'run_ttcn3_docker.sh')
48bts_tmpl_file = os.path.join(own_dir, 'scripts', 'BTS_Tests.cfg.tmpl')
49script_run_dir = test.get_run_dir().new_dir('ttcn3')
50bts_cfg_file = os.path.join(str(script_run_dir), 'BTS_Tests.cfg')
51junit_ttcn3_dst_file = os.path.join(str(suite.trial.get_run_dir()), 'trial-') + suite.name() + '.xml'
Pau Espin Pedrolf6166142018-10-11 17:49:34 +020052if bts.bts_type() == 'osmo-bts-trx':
53 pcu_available = True
54 pcu_sk = bts.pcu_socket_path()
55else: # PCU unix socket not available locally
56 pcu_available = False
57 pcu_sk = ''
Pau Espin Pedrola5285562018-10-15 17:20:50 +020058docker_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 +020059
60print('Creating template')
61mytemplate = Template(filename=bts_tmpl_file)
Pau Espin Pedrolceb7ea62020-02-06 15:59:48 +010062r = mytemplate.render(btsvty_ctrl_hostname=bts.remote_addr(), pcu_available=pcu_available, ttcn3_test_execute=ttcn3_test_execute)
Pau Espin Pedrolbc1ed882018-05-17 16:59:58 +020063with open(bts_cfg_file, 'w') as f:
64 f.write(r)
65
66
67print('Starting TTCN3 tests')
68proc = process.Process('ttcn3', script_run_dir, docker_cmd)
69try:
70 proc.launch()
71 print('Starting TTCN3 launched, waiting until it finishes')
72 proc.wait(timeout=3600)
73except Exception as e:
74 proc.terminate()
75 raise e
76
77if proc.result != 0:
78 raise RuntimeError("run_ttcn3_docker.sh exited with error code %d" % proc.result)
79
80print('Done')